In the woocommerce cart, when the user presses the REMOVE ITEM button on the cart I am trying to retrieve some post meta from an item in the cart. Something like:
$removed_stock = get_post_meta( $product_id, 'more_info_data', 'x' );
To do that I am adding an action:
function ss_cart_updated( $item_id ) {
print "<pre>";
print_r (WC()->cart->get_cart());
print "</pre>";
exit;
};
// add the action
add_action( 'woocommerce_cart_item_removed', 'ss_cart_updated' );
Unfortunately this only list all the products in the cart that have been not removed. The item that has not been removed it is not listed anymore.
I tried "woocommerce_get_remove_url" and "woocommerce_cart_item_remove_link" they dont seem to do anything for me.
Thanks so much!
I think you need to use the
woocommerce_remove_cart_item
which runs just before the item is actual unset from the cart contents array.woocommerce_cart_item_removed
happens after the item is removed, so as you have found out there's no way to get any information about the product. Untested, but try this: