• Resolved clickingclients

    (@clickingclients)


    I’d like to be able to display a SUMMARY of items ordered in the WC admin area when viewing an individual order. And tallied items.
    e.g. if someone have product A in their cart, and a Combo product which also contains product A, product B and product C… Product A will be listed twice as well as the Combo product itself.
    Currently: product A, Combo product, product A, product B, product C
    This is annoying when packing as it slows down the packer.

    IDEAL: product A x2, product B, product C, Combo product

    I’d like to know how to obtain the Ordered items in a list and then create the summary of them (not just the list which may double up items).

    I realise there is Print Invoice, or Packing Slip… but that’s doesn’t give the summary and tallied items.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter clickingclients

    (@clickingclients)

    This is the php snippet I came up with.
    Is there any way to make it faster/smoother or better in a WC way?

    add_action( 'woocommerce_admin_order_data_after_shipping_address', 'additional_admin_order_data_block_after_shipping_address', 100 );
    
    function additional_admin_order_data_block_after_shipping_address(){
    
        echo '</div><div class="order_data_column order_packing_column">
        <h3>' . esc_html__( 'Packing Items', 'woocommerce' ) . '</h3>';
    
        // here goes your code and content
    	//custom array to list products:
    	$products_array = array();
    	$product_tally = 0;
    
    	 global $post; // <=== Alway at the beginning
    
        // Get an instance of the WC_Order Object
        $order = wc_get_order( $post->ID );
    
    	// let's decide what order item types we would like to get
    	$types = array( 'line_item'); 
    	// defaults to line_item which allows to get products from order
    
    	foreach( $order->get_items( $types ) as $item_id => $item ) {
    
    		// order ID
    		$item_order_id = $item->get_order_id();
    
    		// product only and no bundle 'summary' item
    		if( empty( $item['woosb_ids']) && $item->is_type( 'line_item' ) ) {
    
    			// order item name (product title, name of a shipping method or coupon code)
    			$item_name = $item->get_name();
    
    			if ( array_key_exists($item_name, $products_array)) {
    				$products_array[$item_name] += $item['qty'];
    			} else {
    				$products_array[$item_name] = $item['qty'];
    			}
    			$product_tally = $product_tally + $item->get_quantity();
    		}
    	}
    	arsort($products_array);
    echo '<div class="woocommerce_order_items" id="packing-table">
    			<div class="thead">
    				<div class="tr">
    					<div class="item sortable">Product</div>
    					<div class="quantity sortable">Qty</div>
    				</div>
    			</div>
    			<div class="tbody" id="order_line_items">';
    		
    	//display list:
    	foreach ($products_array as $title => $quantity) {
    		echo '<div class="lineitem">
    					<div class="item">';
    			echo $title.'</div>
    					<div class="quantity">'.$quantity.'</div>
    				</div>';
    
    	}
    	echo '<div class="lineitem tally">
    				<div class="item">Tally of Items</div>
    				<div class="quantity">'.$product_tally.'</div>
    		  </div>';
    	echo '</div>
    		</div>';
    	
    	
    }

    Hi @clickingclients

    Thanks for reaching out!

    I understand that you want to display a summary of all the ordered items on your site.

    What you want to achieve is a bit complex and would require customization to do it. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    We have our WooCommerce Developer Resources Portal that can help you get going.

    You can also visit the WooCommerce Community Forum, the WooCommerce FB group, or the #developers channel of our Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Another option is to check our customizations page to hire an expert that can create a custom solution for you: https://woocommerce.com/experts/

    Meanwhile, you could check the WooCommerce Print Invoices and Packing Lists plugin allows you to easily print documents for orders straight from the Orders page (individually and in bulk), while editing orders, and allows customer to view invoices from the “My Account” page.

    If you want to try our products, please note we have a 30-day refund policy.

    If the product doesn’t work the way you need it or you think another product would work better, we are more than happy to offer a full refund. [You can read more about our refund policy on our website here](https://woocommerce.com/refund-policy/).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display a packing summary on “Edit Order” admin page’ is closed to new replies.