Hooks before and after adding to cart
I want to limit the purchase of a product to N amount per day.
I have found these 3 hooks:
add_filter('woocommerce_add_to_cart_validation', 'filter_add_to_cart_validation', 10, 3); add_filter('woocommerce_add_to_cart_quantity', 'filter_add_to_cart_validation', 10, 3); add_action('woocommerce_add_to_cart', 'action_woocommerce_add_to_cart', 10, 6);
Should I just have all the logic in
Check that the product in the cart doesn’t contain more than N minus whatever he already bought and delete or reduce the quantity accordingly?
Or should I separate stuff into each hook?
woocommerce_add_to_cart_validationto check if he can buy more.
woocommerce_add_to_cart_quantityto check he’s not adding more than N minus what he’s already bought today.
woocommerce_add_to_cartin this case would be just to double check?
I’m not sure what the pros and cons are on each case.