Woocommerce: how to create a custom add-to-cart link for a variation with attribute instead of variation ID?

Question

So I have a product with ID 25529. And its two variation based on attribute “color”: “black”(25530) and “white”(25531).

http://example.com/?add-to-cart=25529&variation_id=25530
http://example.com/?add-to-cart=25531

The above add to cart URLs both work. But I’d like to construct the URL by attribute, such as

http://example.com/?add-to-cart=25529&attribute_color=black

I read some articles but still am not very sure if that is possible or not.

0
shenkwen 1 year 2022-01-12T17:34:34-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse