• Resolved danekhoo

    (@danekhoo)


    Hi there,

    I’ve been using your plugin for many years and we’re very happy with it so far as it’s given us zero issues.

    Lately, we’ve implemented a new product inventory system called ATUM and it’s basically allow us to have Build of Materials (BOM) for our unique ordering configurator.

    How can we disable the BOM list from being printed on the invoice? Below are the sample image.

    BOM list on Order Details – https://imgur.com/p9eW5fY
    PDF details – https://imgur.com/vmzu41F

    Your assistance is much appreciated. Thank you and stay safe!

    • This topic was modified 6 years ago by danekhoo.
    • This topic was modified 6 years ago by danekhoo.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danekhoo

    First you have to discover what custom field that plugin is giving to the order items. Read this about Finding WooCommerce custom fields.

    Then you just need to paste that custom field name (‘custom_meta_name’) on this snippet and should do the trick:

    add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_hide_products_invoice', 10, 3 );
    function wpo_wcpdf_hide_products_invoice( $items, $order )
    {
    
        if ($order->get_document() == 'invoice') {
    
    		$items = $order->get_items();
    
    		foreach( $items as $key => $item ) {
    			if( wc_get_order_item_meta( $item->get_id(), 'custom_meta_name', true ) ) {
    				unset($items[$key]);
    			}
    		}
    
        }
    
        return $items;
    }

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

    • This reply was modified 5 years, 12 months ago by alexmigf.
    • This reply was modified 5 years, 12 months ago by alexmigf.
    • This reply was modified 5 years, 12 months ago by alexmigf.
    Thread Starter danekhoo

    (@danekhoo)

    Hi Alex,

    Thanks for the feedback. I’ve identified the ‘custom_meta_name’ which is

    But got hit by this fatal Error when generating the invoice:-

    Fatal error: Call to undefined method Automattic\WooCommerce\Admin\Overrides\Order::get_document()
    #0 /home/sabertri/public_html/wp-includes/class-wp-hook.php(287): wpo_wcpdf_hide_products_invoice(Array, Object(Automattic\WooCommerce\Admin\Overrides\Order), ‘invoice’)
    #1 /home/sabertri/public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array)
    #2 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php(590): apply_filters(‘wpo_wcpdf_order…’, Array, Object(Automattic\WooCommerce\Admin\Overrides\Order), ‘invoice’)
    #3 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/templates/Simple/invoice.php(94): WPO\WC\PDF_Invoices\Documents\Order_Document_Methods->get_order_items()
    #4 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(742): include(‘/home/sabertri/…’)
    #5 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(646): WPO\WC\PDF_Invoices\Documents\Order_Document->render_template(‘/home/sabertri/…’, Array)
    #6 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(628): WPO\WC\PDF_Invoices\Documents\Order_Document->get_html()
    #7 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document.php(664): WPO\WC\PDF_Invoices\Documents\Order_Document->get_pdf()
    #8 /home/sabertri/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/class-wcpdf-main.php(337): WPO\WC\PDF_Invoices\Documents\Order_Document->output_pdf(‘inline’)
    #9 /home/sabertri/public_html/wp-includes/class-wp-hook.php(287): WPO\WC\PDF_Invoices\Main->generate_pdf_ajax(”)
    #10 /home/sabertri/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array)
    #11 /home/sabertri/public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #12 /home/sabertri/public_html/wp-admin/admin-ajax.php(175): do_action(‘wp_ajax_generat…’)
    #13 {main}

    Could I be using the wrong meta name?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danekhoo

    My mistake, sorry. Please update with this one:

    add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_hide_products_invoice', 10, 3 );
    function wpo_wcpdf_hide_products_invoice( $items, $order )
    {
    
        if ( wcpdf_get_document( 'invoice', $order, true ) ) {
    
    		$items = $order->get_items();
    
    		foreach( $items as $key => $item ) {
    			if( wc_get_order_item_meta( $item->get_id(), 'custom_meta_name', true ) ) {
    				unset($items[$key]);
    			}
    		}
    
        }
    
        return $items;
    }

    Let me know.

    • This reply was modified 5 years, 12 months ago by alexmigf.
    • This reply was modified 5 years, 12 months ago by alexmigf.
    Thread Starter danekhoo

    (@danekhoo)

    Hi Alex,

    The new code does not give an error anymore, however I can’t seemed to selectively remove the ones in circle. When I use ‘custom_meta_name’, all of the product items is missing from the invoice.

    Items required to be remove: https://imgur.com/vmzu41F

    This is the custom fields – https://imgur.com/mpOxc8A

    Is it possible to find a way to specifically remove them?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danekhoo

    Looking at your order meta i can’t see how to hide those products. Could you tell me if there’s some specific meta on that products? You can share the screenshot of that meta?

    • This reply was modified 5 years, 12 months ago by alexmigf.
    • This reply was modified 5 years, 12 months ago by alexmigf.
    Thread Starter danekhoo

    (@danekhoo)

    Hi Alex,

    This is an example of one of the products I want to hide.
    https://imgur.com/WRIlepO

    It seemed to share the same meta of the products that I do not want to hide…

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danekhoo

    That’s from the order items, i mean from the product itself: WordPress Dashboard > Products

    Let me know.

    Thread Starter danekhoo

    (@danekhoo)

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @danekhoo

    I suggest you to contact support from the ATUM inventory manager plugin and ask how to detect a BOM element product. With that information we can then incorporate that into the code.

    Let me know.

    Thread Starter danekhoo

    (@danekhoo)

    Hi Alex,

    This is their reply:-

    If they are asking what method we use to get any product’s linked BOM, it’s this one:

    BOMModel::get_linked_bom()

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @danekhoo

    You can drop us an email, we will try to help you the best we can.

    Thread Starter danekhoo

    (@danekhoo)

    Hi Alex, email sent. Thanks again.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Remove details in invoice’ is closed to new replies.