Site logo

[Resolved] Apply php code only on single product page.

Home Forums Support [Resolved] Apply php code only on single product page.

Home Forums Support Apply php code only on single product page.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2561352
    Jusung

    Hello. I have added php code, but one code break the cart page.

    I found a function is breaking the cart page. So, I need to apply the function only on single page.

    Is there any way to apply a code to a single page?

    I tried this, but not working

    function asfasdf() {
    if( is_product() ) {
    }
    }

    #2561374
    David
    Staff
    Customer Support

    Hi there,

    try this:

    add_action( 'wp', function(){
        // do stuff on single product
        if ( is_product() ){
            add_action( 'woocommerce_after_quantity_input_field', 'action_woocommerce_single_product_summary', 31, 0 );
        }
    });
    #2561387
    Jusung

    Thank you!!!

    It works well!

    #2561395
    David
    Staff
    Customer Support

    Glad to hear that!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.