I need to do extra step in the backend when a product is add to cart.
I need to get the product ID juste after it’s add to the cart.
I use the woocommerce hook woocommerce_add_to_cart
add_action('woocommerce_add_to_cart', 'attach_item');
function attach_item() {
// I need to have the product id here.
}
I tried many way to get the ID but nothing work.
Any idea …
Today I also get the same problem but I got the solution.
At the time of writing this, the hook is actually called from WooCommerce like so: (source)
Add your custom method like so: