All of the functionality is built into WooCommerce already. This would
allow us to simply piggyback on that for custom sorting our other
taxonomies. Pretty please. :)
This is the only notification type that can't be hooked before starting
to compile the message.
One good reason for hooking there is to switch e-mail languages
according to a stored order language. Other people might find other
uses for these hooks, but, bottom line is, no hook exists in this case.
This is a rough proposal - basically food for thought. The supplied
code has NOT been tested.
In some cases, we may need to do the checking part on multiple products
before giving permission to actually add them all to the cart. The
reason is that if any product check fails (e.g., out of stock), then no
product should be added to the cart and a product-specific error
message should be returned, like so: "Product X: The product is out of
stock", instead of a vague "The product is out of stock". This is esp
useful for Product Bundles, which at the moment handles this by reusing
parts of existing code.
Things would be more elegant if an add_to_cart_check function existed.
I am not sure if the add_to_cart_check call should exist within
add_to_cart, or if there should be 2 separate calls, one for
add_to_cart_check and one for add_to_cart, throughout the core codebase.
The supplied woocommerce_add_to_cart_error_message filters would be
useful for manipulating the messages to include product-specific info.
Finally, the woocommerce_add_to_cart_…_halt filters would be useful in
cases where these checks should not return false. I can image some
cases, esp related to bundling.
Note - This is not required for 'Product Bundles' to work, but it's
always a good idea to make the core code a bit more flexible.