Woocommerce Add Variation Product to Cart from custom link [closed]

i currently work on a woocommerce v2.1.12 shop and it seems they chaged that behavior.

my ajax url to add items to the cart has to look like this:

?add-to-cart=[PRODUCT-ID]&variation_id=[VARIATION-ID]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG]

example:

http://example.com/store/category/product/?add-to-cart=239&variation_id=240&attribute_pa_size=48-2&attribute_pa_color=gold

this adds a specific product to the cart and also sets the variation attributes in the cart.
you can even set the quantity by simply adding &quantity=[VALUE]

in the end this comes in handy since all these values are set inside the submit form / select fields, you just have to look those up..

Leave a Comment