Jump to content


Photo
- - - - -

Достучаться до item в getItems


Best Answer CB9TOIIIA , 02 April 2016 - 16:39

Вроде так:


$cartItems = $order->getItems();
foreach ($cartItems as $cartItem) {
    $itemPrice = $order->val($cartItem->get('total'))->convert($setCurrency);

    jbdump($cartItem->get('item_name'),0,'Товары заказа');
}

Go to the full post


  • This topic is locked This topic is locked
2 replies to this topic

#1 CB9TOIIIA

CB9TOIIIA
  • Administrators
  • User rate: 230.6
  • posts: 3680
  • topics: 235

Posted 02 April 2016 - 16:00

Делаю спец. вывод.

 

Возник вопрос - как достучаться до item?

$zakaz = $this->_order->getItems(); // получили сумму за все товары (без доставки и прочего)
jbdump($zakaz,0,'Товары заказа');
020011.png
 
Внутри item'ы все с разными ID
 
В итоге такой вид надо получить:
Название: Мясная 40, Количество: 1, Цена: 525, Скидка (%): , Сумма: ;
Название: Филадельфия, Количество: 3, Цена: 179, Скидка (%): , Сумма: ;

Поэтому важно достучаться до полей :)


Edited by CB9TOIIIA, 02 April 2016 - 16:04.

  • 0

#2 CB9TOIIIA

CB9TOIIIA
  • Topic Starter
  • Administrators
  • User rate: 230.6
  • posts: 3680
  • topics: 235

Posted 02 April 2016 - 16:39   Best Answer

Вроде так:


$cartItems = $order->getItems();
foreach ($cartItems as $cartItem) {
    $itemPrice = $order->val($cartItem->get('total'))->convert($setCurrency);

    jbdump($cartItem->get('item_name'),0,'Товары заказа');
}


  • 3

#3 SmetDenis

SmetDenis
  • Administrators
  • User rate: 139.4
  • posts: 16232
  • topics: 200

Posted 04 April 2016 - 09:09

Вроде похоже на правду.

 

PS На выходных не заходил на форум.


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.





Click to return to top of page in style!