If Order item belongs to either of these categories, hide from Packing Slip
-
Hi. I’ve created custom packing slip template and this code is WORKING to fetch the Parent product category but I now need to exclude Items (don’t fetch) if the items belong to any of these categories – eg. ‘cat1’, ‘cat2’, ‘cat3’ – How can I do that? I’ve tried has_terms and in_carry… not working. Also how I need to stop products in these categories from being included in my count?
<?php $count = 1; $items = $order->get_items(); if ( sizeof( $items ) > 0 ) : foreach ( $items as $item_id => $item ) : ?> <?php $items_count = count( $order->get_items() ); $product = wc_get_product($item->get_product_id()); $item_sku = $product->get_sku(); $product_terms = wc_get_product_terms( $product->get_id(), 'product_cat' ); ?>
<?php foreach ($product_terms as $product_term) { if ($product_term->parent == 0) { echo $product_term->name; } } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘If Order item belongs to either of these categories, hide from Packing Slip’ is closed to new replies.