Variable product add to cart in Woocommerce

I have two variations for a product which is of weight 0.5 kg and 1 kg.
I have defaultly selected 1 kg and when clicking add to cart button then 1 kg product is adding to the cart but i need when i click another button swatch buy i want to add 0.5 kg product defaultly to the cart and redirect it to cart page. Can u help me to solve this as i am new to woocommerce.
I am using this to add the product with id ang slug name. its just redirecting to cart page but not adding to cart

<a href="<?php echo get_site_url(); ?>/index.php/cart?tag_id=103&attribute_pa_weight-gms-per-meter=0-5" class="button">swatch buy</a>

Read more here: Variable product add to cart in Woocommerce

Leave a Reply

Your email address will not be published. Required fields are marked *