Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 324
Sam Avatar asked Mar 28 '15 05:03

Sam


1 Answers

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 );
like image 189
m3esma Avatar answered Nov 16 '22 02:11

m3esma