• Resolved liborg

    (@liborg)


    Hello,
    How can I hide weight and SKU in simple invoice?
    I tried to put text below into template-functions.php, but no change.

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles' );
    function wpo_wcpdf_custom_styles () {
    	?>
    	.weight, .sku { display: none; }
    	<?php
    }

    Thank you.

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

    (@yordansoares)

    Hi @liborg,

    Your code snippet is fine, but the place in which you’re adding it isn’t: move it from template-functions.php to functions.php (in the root folder of your child theme).

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

    Thread Starter liborg

    (@liborg)

    If I put entire code into functions.php (at the end of code, according to “How to use filters”), the webpage views “Fatal error: Cannot redeclare….”.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Did you try using the Code Snippets plugin?

    Thread Starter liborg

    (@liborg)

    No, I gave code over FTP. I will try it.

    • This reply was modified 3 years, 7 months ago by liborg.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    If I put entire code into functions.php (at the end of code, according to “How to use filters”), the webpage views “Fatal error: Cannot redeclare….”.

    Sorry, I don’t read well the error you was receiving: this is likely because you forgot to remove the code from template-functions.php

    Please remove the code there first, and then try to add it in your functions.php (in the root folder of your child theme) or using the Code Snippets plugin.

    Thread Starter liborg

    (@liborg)

    The same problem. I tried both.
    Code Snippets state:

    “This snippet has been disabled due to an error on line 3:

    Cannot declare wpo_wcpdf_custom_styles function.”

    Plugin Contributor Yordan Soares

    (@yordansoares)

    As the error suggest, you can’t put the same functions in more than one place. Remove the code from the other places, and only save it whether in your functions.php (in the root folder of your child theme) or using the Code Snippets plugin.

    Thread Starter liborg

    (@liborg)

    I have similar code there, isn’t problem in it?

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
    	?>
    	.order-number, .order-date {
    		display: none;}
    	
    	<?php
    }

    I tried to insert new code into my old code:

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
    	?>
    	.order-number, .order-date {
    		display: none;}
            .weight, .sku { display: none; }
    	
    	<?php
    }

    Order number and order date are gone, but weight and sku still are there.

    Thread Starter liborg

    (@liborg)

    Finally it is working. It had collision with another code.
    Thank you very much.

    • This reply was modified 3 years, 7 months ago by liborg.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to know that you managed to solve it ??

    Let us know if you need more help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Hide weight and SKU’ is closed to new replies.