Support » Plugin: WooCommerce » empty cart before add

  • Resolved amila


    Hi, I need to empty cart before add_to_cart,
    If I add “WC_Cart::empty_cart()” to function add_to_cart in includes/class-wc-cart.php it works.

    But if I add the following code in functions.php

    add_filter( ‘woocommerce_add_to_cart_validation’, ‘woo_custom_add_to_cart_before’ );
    function woo_custom_add_to_cart_before( $cart_item_data ) {
    global $woocommerce;
    // Do nothing with the data and return
    return true;

    I get an error in page:
    jquery.js?ver=1.12.4:4 POST 500 (Internal Server Error)

    I do not want to change core source. How to solve it?

    • This topic was modified 9 months, 2 weeks ago by  amila.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘empty cart before add’ is closed to new replies.