• Resolved Eiman

    (@eimanam)


    hi

    Is there a way that I can only activate the add to cart button for the products I want? I mean that all the products have prices, but only the products that I choose have an add to cart button. Is there a plugin or code that can do this? There are many products, I have to select only certain products to activate the purchase option. thanks in advanced

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jonayed (woo-hc)

    (@jonayedhosen)

    Hi @eimanam ,

    I understand you’re looking to show the “Add to Cart” button for some specific products. While this is possible, it requires either custom code or a plugin to achieve.

    One option is the Hide Price & Add to Cart Button plugin, which provides an easy way to control the visibility of the “Add to Cart” button.

    WooCommerce offers a 30-day refund policy, so you can test the extensions and make sure they meet your needs. If you have any questions before purchasing, you can reach out to us at WooCommerce.com → My Account → Support (you’ll just need to create an account if you don’t already have one).

    If you’d prefer not to use a plugin, custom code can be implemented to achieve this. However, since this involves modifying default functionality, it falls outside the scope of support we can provide here. We recommend working with a local developer or exploring resources like Codeable or a Certified WooExpert for assistance with advanced customizations.

    You’re also welcome to review our Support Policy for more details on what’s covered.

    I hope this helps point you in the right direction.

    Hi,

    You may try this (to add to functions.php of you theme).

    function purchasable_products( $is_purchasable, $object ){

    // array of purchasable products ID's
    $purchasable = [100, 101...etx ]; // Replace 100, 101 ...etc by the actual product_id's.

    if( !in_array( $object->get_id(), $purchasable ) ){
    return false;
    } else {
    return $is_purchasable;
    }

    }
    add_filter( 'woocommerce_is_purchasable', 'purchasable_products', 10, 2 );

    Adapted from this source.

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