How to use add_to_cart () method in WooCommerce?
I am currently adding a product to my cart:
$woocommerce->cart->add_to_cart( $product_id, $quantity );
I noticed that the method add_to_cart()
actually takes 5 parameters. See the following (taken from the WooCommerce docs):
add_to_cart( string $product_id, string $quantity = 1, integer $variation_id = '', array $variation = '', array $cart_item_data = array() )
Can anyone provide an example of what the last 3 parameters will be used for?
-
$variation_id
-
$variation
-
$cart_item_data
There is some description that they are in the documentation for the method, but this is not very explicable:
int $ variant_id
the values ββof the $ value $ array attribute
array $ cart_item_data additional cart item data that we want to pass to the item
Link: http://docs.woothemes.com/wc-apidocs/class-WC_Cart.html#_add_to_cart
+3
source to share
No one has answered this question yet
Check out similar questions: