Sam
Sam

Reputation: 123

how to disable cart functionality from woocommerce?

How to disable cart functionality from woocommerce store. I want user can only see products available.customer can not purchase from store.

Upvotes: 10

Views: 23241

Answers (3)

m3esma
m3esma

Reputation: 277

If you need conditions, you can use the following code:

function m3wc_woocommerce_is_purchasable( $is_purchasable, $product ) {
    // Conditions here.

    return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'm3wc_woocommerce_is_purchasable', 10, 2 );

For example, if you need to check users:

// Disable purchase for non-logged-in users.
function m3wc_woocommerce_is_purchasable( $is_purchasable, $product ) {
    if ( ! is_user_logged_in() ) {
        return false;
    }

    return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'm3wc_woocommerce_is_purchasable', 10, 2 );

Upvotes: 1

kirillrocks
kirillrocks

Reputation: 223

To fully disable woocommerce purchase functionality:

add_filter( 'woocommerce_is_purchasable', '__return_false'); // DISABLING PURCHASE FUNCTIONALITY AND REMOVING ADD TO CART BUTTON FROM NORMAL PRODUCTS

remove_action('woocommerce_single_variation', 'woocommerce_single_variation', 10); // REMOVING PRICE FROM VARIATIONS

remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20); // REMOVING ADD TO CART BUTTON FROM VARIATIONS

More option you can find here: https://react2wp.com/remove-hide-add-to-cart-button-in-woocommerce-while-disabling-keeping-purchase-functionality/

Upvotes: 5

Reigel Gallarde
Reigel Gallarde

Reputation: 65264

the easiest way is make the products not purchasable..

add_filter( 'woocommerce_is_purchasable','__return_false',10,2);

Upvotes: 15

Related Questions