• pat

    (@paloma-ti)


    Hello!
    I would like just to allow to add one product on the cart page, so I tried with a code on my funtions.php and it worked for one week, but suddenly is not working and I don’t know why.
    That’s my code:
    //Just one item in cart at a time

    add_filter( ‘woocommerce_add_cart_item_data’, ‘woo_custom_add_to_cart’ );

    function woo_custom_add_to_cart( $cart_item_data ) {

    global $woocommerce;
    $woocommerce->cart->empty_cart();

    // Do nothing with the data and return
    return $cart_item_data;
    }

    Maybe there’s something wrong with my code or you can provide me a different one
    Thank you

    https://www.ads-software.com/plugins/woocommerce/

  • The topic ‘Add one product on the cart’ is closed to new replies.