• Resolved gwlshop

    (@gwlshop)


    Hi,

    we want to sell print on demand products in our shop. we have a cooperation with a print partner and therefore want to hide all print on demand products from our packing slip since the packing slip is created by the print partner. we need the shipping address and also shipping fee to be calculated in our shop so setting the products to virtual does not work for us. I have already tried some solutions posted here in the forum for hiding specific products on the invoice but it does not seem to work for packing slips… it would be also fine with us to hide specific products on packing slips via product ID.

    Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @gwlshop

    Please add the code snippet below to your functions.php file:

    add_action( 'wpo_wcpdf_before_order_data', 'wpo_wcpdf_hide_products', 10, 2 );
    function wpo_wcpdf_hide_products ( $document_type, $order )
    {
        $products_to_hide_ids = array(16, 23); // add product ID's here
    
        if ( !empty($order) && $document_type == 'packing-slip' ) {
            echo '<style type="text/css">';
            foreach( $order->get_items() as $item_id => $item ) {
                $product_id = $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'];
                if( in_array($product_id, $products_to_hide_ids) ) {
                    echo 'table.order-details tr.'.$item_id.' {display: none !important;}';
                }
            }
            echo '</style>';
        }
    }

    Don’t forget to add the product IDs like indicating in the comment.

    If you never worked with actions/filters please read this documentation page: How to use filters

    Thread Starter gwlshop

    (@gwlshop)

    Thanks for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide specific category from packing slip’ is closed to new replies.