Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we let WooCommerce empty the cart once limits are reached? #59

Open
stevegrunwell opened this issue Feb 4, 2021 · 0 comments
Open
Labels
question Further information is requested

Comments

@stevegrunwell
Copy link
Contributor

WordPress.org user intriguemediaweb raised an interesting question yesterday: how does a shop owner keep WooCommerce from emptying customer carts once the order threshold has been met?

Digging in, WooCommerce runs WC_Cart_Session::get_cart_from_session() on the "wp_loaded" hook, where it loads up the current cart and filters out anything that is no longer available for purchase.

Meanwhile, Limit Orders uses add_filter('woocommerce_is_purchasable', '__return_false'); as one of the components of OrderLimiter::limit_ordering(), as it prevents WooCommerce from showing the "Add to Cart" button.

The side-effect here is that once the threshold has been hit, the limit_ordering() callback goes into effect, which in-turn causes get_cart_from_session() to remove the now "unpurchasable" items.

I've come up with a filter-based work-around to help in the short term, but it's worth considering if there's a better filter we can use to disable the "Add to Cart" buttons without clearing the carts. Perhaps the answer is to not remove the buttons at all, letting users populate carts but not check out?

@stevegrunwell stevegrunwell added the question Further information is requested label Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant