0

Редактирую шаблон письма с информацией о заказе. Woocommerce выдает ошибку(она не отображается почему-то, просто error)если я хочу отправить заказ. Если удалить $item->get_price(); то все хорошо работает. Где я допускаю ошибку?введите сюда описание изображения

$order_id = $order->get_id(); // The order_id

// get an instance of the WC_Order object
$order = wc_get_order( $order_id );

// The loop to get the order items which are WC_Order_Item_Product objects since WC 3+
foreach( $order->get_items() as $item_id => $item ){
    //Get the product ID
    $product_id = $item->get_product_id();

    //Get the variation ID
    $product_id = $item->get_variation_id();

    //Get the WC_Product object
    $product = $item->get_product();

    // The quantity
    $product_count = $item->get_quantity();
    $product_price = $item->get_price();
    // The product name
    $product_name = $item->get_name(); // … OR: $product->get_name();

    //Get the product SKU (using WC_Product method)
    $sku = $product->get_sku();
    echo  "<tr><td><p>".$product_name." ".$sku."</p></td>"."<td><p>".$product_count."</p></td>"."<td><p>".$product_price."</p></td>"."</tr>";

}

1 ответ 1

1

Функция get_price есть у товара, а не у order item. Надо использовать

$product->get_price()

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.