Home Forums WoodMart support forum Custom PHP code

Custom PHP code

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #688144

    rmigadde
    Participant

    Hello am trying to hide, add to cart for a particular product but it seems am not geting it right, here is my snippet, please guide:

    // For shop/archive pages
    add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘hide_add_to_cart_link’, 10, 2 );
    function hide_add_to_cart_link( $link, $product ) {
    if ( 2532 == $product->get_id() ) {
    return ”;
    }
    return $link;
    }

    // For single product pages
    add_action( ‘woocommerce_single_product_summary’, ‘hide_single_add_to_cart’, 1 );
    function hide_single_add_to_cart() {
    global $product;
    if ( 2532 == $product->get_id() ) {
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    }
    }

    #688263

    Artem Temos
    Keymaster

    Hello

    Thank you for sharing your code snippet. Unfortunately, we are unable to provide support for custom PHP code modifications as it is beyond the scope of our theme support. We recommend consulting a developer to assist you with this customization.

    Regards

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)