• Resolved befla.net

    (@beflanet)


    Hi. Very nice plugin.

    I′m using shopmagic example plugin for to get custom placeholders which works for me.
    Now I′m looking for a solution to get the quantity of each item ordered. I′ve tried it with return $this->is_order_provided() ? $this->get_order()->get_item_count() : ''; but I′m just getting the total of quantities. Finaly I want the {{ order.details }} without prices and maybe with the product image.

    Someone can give me a snippet? Thanks a lot.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Bartek

    (@bartj)

    Hi!

    At first you just have to get WC_Order, what you already did by running $this->get_order(). From now on you need some variable to hold items with quantities. Something like that:

    
    $order_items = $this->get_order()->get_items();
    $items_with_quantity = array();
    foreach ( $order_items as $item ) {
     if ( $item instanceof \WC_Order_Item_Product ) {
        $item_with_quantity = array();
        $item_with_quantity[] = $item->get_name();
        $item_with_quantity[] = $item->get_quantity();
        $items_with_quantity[] = implode(': ', $item_with_quantity);
      }
    }
    
    return implode(', ', $items_with_quantity);
    
Viewing 1 replies (of 1 total)
  • The topic ‘Order item quantity / Order details without prices’ is closed to new replies.