I tried to search some articles on the google but they mentioned to variation products and I don't know what they are. I'm only want to add product to cart with product attribute (or multi attribute) and quantity. I tried this url
<?php echo home_url('/cart/?add-to-cart='.$product->id.'&attribute_mau-sac=#425f70'); ?> for "a" element but attribute_mau-sac doesn't add to cart width product. My products are simple products. Please help me!
Best How To :
See my writeup here on how variations work.
First off, you want to select “Variable Product” from the “Product Data” dropdown. Simple product is the default output.
From there, you need to go to the attributes menu. This allows you to have both global attributes than be applied to a product (set in the Products > Attributes menu on the left admin sidebar if you want to set globals) or on a per-product basis. You can see I’ve added one for pant pattern. If you want to give the customer the option of selecting it and it appearing as part of their selection in their order, make sure “Used for variations” is checked.
Once checked, make sure you click the “Save attributes” button. Then you can go to the Variations tab.
You can see now that I’ve added variations. This is done by choosing an option (see highlighted area in red), in this case the pant pattern. I did this because the pants affect the price. If they didn’t I could have had it set to “Any Pant Type…” You just need to make sure you have at least one (even if it is "Any" across the board). You can bulk edit the fields available with the “Choose a field to bulk edit…” dropdown. You will need at least one variation to set the Price and shipping (even if it doesn’t matter what variations the customer chooses).
On the front-end, you will see that no “Add to cart” appears without selecting attributes and the variation.
When you make your value selection, the price and “Add to cart” buttons appear.
When the attribute for pant type is changed the price adjusts accordingly as well.