• Resolved henningwhatawatchdk

    (@henningwhatawatchdk)


    Hi there.
    Can I make af custom field on a specific product, that only is visible on the invoice?
    I sell both second-hand and new products and according to Danish law, I have to write a specific “VAT-sentence” (Profit margin scheme – used items – buyer can not deduct VAT) on invoices, when I sell second-hand products, as there is no VAT on second-hand products. So when a customer buys a new product from me, the sentence will not show on the invoice and when they buy a second-hand product, the “VAT-sentence” will show beneath the second-hand product on the invoice.
    I hope it makes sense;-)

    Kind regards

    Henning

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

    (@kluver)

    Hi @henningwhatawatchdk,

    Yes, that is certainly possible. With our Premium Templates extension you can add product custom fields to your product column with the following placeholder:

    {{product_custom_field::your_field_name}}

    You can add this placeholder in the text field of a product block in the customizer:

    Schermafbeelding-2020-02-25-om-13-49-07

    Simply replace “your_field_name” with the field name of your specific custom field.

    Thread Starter henningwhatawatchdk

    (@henningwhatawatchdk)

    Thanks for your reply @kluver:-)
    I don’t think I quite can understand how, without having bought the Premium Templates Extension, but if you can garanty me, that the custom field only will show on the invoice on “ProductXX”, and NOT will show in the product description for “ProductXX” inside my webshop, then I will buy your extension right away;-)

    Plugin Contributor kluver

    (@kluver)

    Hi @henningwhatawatchdk,

    Just to be sure we are on the same page. You would like to create a product custom field for your second hand products like this:

    Schermafbeelding-2020-02-25-om-17-12-31

    If so, you can add it to your invoice via the Customizer like this:

    Schermafbeelding-2020-02-25-om-17-20-37

    I’ve added the <small> tag in this example so the text will be a bit smaller than your product title on the invoice. It will then look like this on your invoice:

    Schermafbeelding-2020-02-25-om-17-21-00

    Let me know if I understood correctly. ??

    Thread Starter henningwhatawatchdk

    (@henningwhatawatchdk)

    Yeah maybe it’s a bit difficult to understand;-)
    In my webshop I sell second-hand watches and new watch straps, -new watch tools and so on. I would like, that when a customer for instance buys a second hand watch and a new watch strap, the invoice shows a row with the second hand watch and the sentence: “profit margin sceme…” below, like you have shown in your post above.
    On the next row on the invoice, is the new watch strap and there is no “profit-margin-sentence” beneath that, because, there is VAT on that product.
    S? can I setup my invoices, so the sentence only shows up on the invoices, when a customer buys a second hand watch from my “second-hand-watch-category”?
    I don’t want the “profit-margin-sentence” to show in my webshop under each second hand watch. I only want the sentence shown on my invoices, when a second hand watch is bought.

    Plugin Contributor kluver

    (@kluver)

    Hi @henningwhatawatchdk,

    I see. If you want to add the sentence for specific categories you will have to use a small code snippet:

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_add_VAT_sentence_for_second_hand_products', 10, 3 );
    function wpo_wcpdf_add_VAT_sentence_for_second_hand_products ( $template_type, $item, $order ) {
    	if ( $template_type == 'invoice' ) {
    		$vat_sentence = false;
    		// Add your second hand categories here (comma separated)
    		$second_hand_categories = array( 'Second hand', 'Second hand watch' );
    
    		// Get the category (list of categories)
    		$category = strip_tags( wc_get_product_category_list( $item['product_id'] ) );
    	
    		foreach ( $second_hand_categories as $second_hand_category ) {
    			if ( strpos( $category, $second_hand_category ) !== false ) $vat_sentence = true;
    		}
    
    		echo $vat_sentence === true ? '<p><small>Profit margin scheme – used items – buyer can not deduct VAT</small></p>' : '';
    	}
    }

    You can add your categories in the $second_hand_categories array (comma separated). This will add the VAT sentence to products on your invoice only that fall within one or more of these categories.

    This code snippets should be added to the functions.php of your child theme or with a plugin like Code Snippets. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

    Thread Starter henningwhatawatchdk

    (@henningwhatawatchdk)

    Thanks alot @kluver.
    I bought the premium package, installed it and added the code snippet above and it works perfect?? I’m all new to this website-stuff, but it only took me a few minutes to get it up and running????

    Plugin Contributor Ewout

    (@pomegranate)

    Fantastic, very glad to hear that Henning! If you need any further help with any of the paid extensions, please send an email to [email protected] as www.ads-software.com does not allow us to utilize these forums for supporting these.

    Happy selling!

    @pomegranate does custom fields also work with Premium Templates extension you refer to, with the free version of WooCommerce PDF Invoices & Packing Slips ?

    Plugin Contributor kluver

    (@kluver)

    Hi @bsp4750,

    The Premium Templates extension is an extension for the WooCommerce PDF Invoices & Packing Slips plugin.

    It gives you access to the customizer that will let you add order custom fields and product custom fields as described above.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Field only on invoice’ is closed to new replies.