• Resolved yourinieuw

    (@yourinieuw)


    Hello,

    We are a biological Store with a webshop.
    On the invoice must stand BIO-NL01, unless one of the articles.
    Is that possible? To set it on or off with like a button because its different with every invoice.

    Kind Regards,
    Youri

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @yourinieuw,

    On the invoice must stand BIO-NL01, unless one of the articles.

    Sorry if I don’t understand. Where do you need to put BIO-NL01: 1) In a specific place on the invoice, regardless of the products; 2) Next to the products’ name?

    To set it on or off with like a button because its different with every invoice.

    Do you mean that you’ll use the orders/products with BIO-NL01 to disable/enable the invoice? Please note that after the invoice is generated, an invoice number is created, so previewing the document to check if it stands BIO-NL01, it’s not a good approach. In other words, the best way to automatically disabling the invoice is using this value. This will require a code snippet, but I can write it for you, if this is not beyond the free support.

    Thread Starter yourinieuw

    (@yourinieuw)

    @yordansoares Ho sorry, unless one of the articles isnt biological. Then Everything on the invoice must be the same, but there cant stand NL-Bio01. So the only change is that on almost every invoice must stand Bio-NL01 but if there is a not biological product, i can delete that

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing more details, @yourinieuw!

    Ho sorry, unless one of the articles isnt biological. Then Everything on the invoice must be the same, but there cant stand NL-Bio01.

    Where in the invoice you need to display this? Is it just the NL-Bio01 text, with some styling (maybe a heading?), or is this an image seal or something similar?

    the only change is that on almost every invoice must stand Bio-NL01 but if there is a not biological product, i can delete that

    How can you determine if an order have a product of this type? Does the products have a custom field with this info, it’s in the product name, it’s a category…?

    Thread Starter yourinieuw

    (@yourinieuw)

    Well @yordansoares, i can’t share a picture but it must stand under the business information. Its text like:

    Business name: …
    Adress: …
    delivery date: ….
    NL- Bio01

    And well, i can remove it manually but then it must be a button or something to remove it by only that peticular invoice, Because out of the 100 invoices, there will most likely only be 2 or 3 without the NL-Bio01. But it is illegal to show it on the invoice when its incorrect so i need to remove it then. But yeah it is a product attribute in WordPress.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    You don’t need to do this manually: I can write a code snippet to add this automatically based on the product attribute you mentioned. Please give me the product attribute name, and I’ll start writing the code snippet for you.

    Thread Starter yourinieuw

    (@yourinieuw)

    The product attribute name = Biologisch
    So when the product does have this attribute its all good,
    But when only one product of the whole invoice doesnt have it, then there cant be NL-Bio01 on the invoice. Can you write that?

    Thread Starter yourinieuw

    (@yourinieuw)

    @yordansoares Sorry i forgot the Tag

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing those details, @yourinieuw!

    Try adding this code snippet to your site, to display ‘NL-Bio01’ after the billing address, if all the products has the ‘Biologisch’ attribute:

    /**
     * WooCommerce PDF Invoices & Packing Slips
     * Print 'NL-Bio01' after billing address if all the products has the 'Biologisch'
     */
    add_action( 'wpo_wcpdf_after_billing_address', function( $document_type, $order ) {
    	if( $document_type == 'invoice' ) {
    		foreach ( $order->get_items() as $item_id => $item ) {
    			if ( ( $product = $item->get_product() ) && is_callable( array( $product, 'get_attribute' ) ) ) {
    				if ( empty( $product->get_attribute( 'Biologisch' ) ) ) {
    					return;
    				}
    			}
    		}
    		echo '<div>NL-Bio01</div>';
    	}
    }, 10, 3 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Thread Starter yourinieuw

    (@yourinieuw)

    @yordansoares Thanks!

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m happy to help: Let me know if it worked! ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Button On/Off Invoice Information’ is closed to new replies.