1
1
13ffingers2021-01-22 16:05:41
WooCommerce
13ffingers, 2021-01-22 16:05:41

Question on woocommerce, on crosssale, how to immediately add it to the cart?

How to add a function to the crosssale so that it is immediately added to the cart. Or when adding any product, it automatically added the product as in the second screen. 600acd5dc40f6334369661.jpeg- Klass-food.ru
600acd6822855403376638.jpeg - Butcher.rf

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2021-01-22
@wppanda5 WooCommerce

This is how the product is added to the cart.
WC()->cart->add_to_cart( $product_id );
How to check if a product is in the cart

$product_cart_id = WC()->cart->generate_cart_id( $product_id );
 $in_cart = WC()->cart->find_product_in_cart( $product_cart_id );

This hook is triggered when adding a product to the cart
'woocommerce_add_to_cart' It
remains only to collect it in a function ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question