• Resolved mtz

    (@mtzwald)


    Hello,

    At customer invoice pdf,
    Is it possible to hide any product that falls into a specified product category?

    <Example case>
    I created a product called “Pizza-A” price:$20 category “food”
    Using smart bundle plugin, I added the following 3 products to “Pizza-A” as a package
    – “tomato” category “ingredient” x 500 qty price: 0
    – “cheese” category “ingredient” x 100 qty price: 0

    At shop page and checkout page,
    customer will see only “Pizza-A” $20 was ordered

    At backend, ingredient manager would be able to see that he need to prepare 500 units of tomato and 100 units of cheese.

    At customer invoice. To avoid confusion,
    Customer would need to see that he ordered “Pizza-A” only!. and not the ingredients.

    Therefore, I would like to hide any product that has category of “ingredient”

    <Question>
    Is it possible to add some snippet or do some modification to exclude any product from a specified category (ID) from showing on invoices ?

    Alternatively, is it possible to hide any product that has price = 0 ?
    because all my ingredients were shown as price = 0 on the generated invoice

    Best regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @mtzwald,

    Depending on which product bundle plugin you are using each bundled item might already have an extra CSS class which you can target. Can you let us know which plugin you are using to create your product bundles?

    Thread Starter mtz

    (@mtzwald)

    Thank you for your quick reply

    I’m using a free version of this plugin

    “WPC Product Bundles for WooCommerce”
    https://www.ads-software.com/plugins/woo-product-bundle/

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @mtzwald

    Try this:

    add_action( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_remove_ingredients', 10, 3 );
    function wpo_wcpdf_remove_ingredients ( $data_list, $order, $type ) {
    	
    	$order_items = $order->get_items();
    	foreach( $order_items as $key => $item ) {
    		$product = wc_get_product($item['product_id']);
    		$categories = $product->get_category_ids();
    
    		$category_slugs = array();
    		foreach( $categories as $category ) {
    			$category_slugs[] = get_term( $category )->slug;
    		}
    
    		if( in_array('ingredient', $category_slugs) ) {  // change the category slug accordingly
    			unset($data_list[$key]);
    		}
    	}
    
    	return $data_list;
    }

    If you never worked with filters/actions please read this documentation.

    • This reply was modified 4 years, 10 months ago by alexmigf.
    Thread Starter mtz

    (@mtzwald)

    Thank you very much!!
    Best support ever : )

    Plugin Contributor alexmigf

    (@alexmigf)

    You’re welcome ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘hide product of a certain category from the generated invoice’ is closed to new replies.