• mariodts

    (@mariodts)


    Hi we use this code sippet

    // remove old items in cart when new items added
        add_filter('woocommerce_add_to_cart_validation', 'remove_cart_item_before_add_to_cart', 1, 3);
        function remove_cart_item_before_add_to_cart($passed, $product_id, $quantity) {
            if (!WC()->cart->is_empty()) {
                WC()->cart->empty_cart();
            }
            
            return $passed;
        }

    to remove old products from the cart when someone adds to the cart a new product. This works ok.

    We work with your plugin and added 3 virtual products to checkout with Upsell funnel (to sell them as extra services). When we click on one of these products it returns us an error message that the session expired.

    We modifies our code to this

    add_filter('woocommerce_add_to_cart_validation', 'remove_cart_item_before_add_to_cart', 1, 3);
    function remove_cart_item_before_add_to_cart($passed, $product_id, $quantity) {
        if (!is_checkout() && !WC()->cart->is_empty()) {
            WC()->cart->empty_cart();
        }
        
        return $passed;
    }
    

    so when is checkout page exclude the code but still do the same.

    How does your plugin add products to the cart? Is possible to make this work somehow?

    Thanks

    • This topic was modified 2 years ago by mariodts.
Viewing 1 replies (of 1 total)
  • villasupport

    (@villasupport)

    Hi,

    Thank you for contacting VillaTheme.

    I’m sorry to inform you that we do not offer support for custom codes or modifications made to our plugin. However, we’re always here to help with any bugs or problems that you may encounter with the original functionality of our plugin. Please feel free to report any issues to our support team. Thank you for understanding.

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘How your plugin works?’ is closed to new replies.