title: Add Custom attributes from a variable product to cart in WooCommerce
body: <p>I am trying to redirect my custom shop page to cart page after user select custom attributes (liability and hours) and then clicks the purchase button.</p>
  
  <p>I have written custom JS code which retrieves the variation_id and attributes value and append it to the URL so that it automatically gets added to cart and get's redirected to cart page.</p>
  
  <pre><code>href="yourdomain.com/?add-to-cart=47&amp;variation_id=88&amp;quantity=3&amp;attribute_pa_colour=blue&amp;attribute_pa_size=m"
  </code></pre>
  
  <p>This is the URL format which I have found in a blog: <code>(https://businessbloomer.com/woocommerce-custom-add-cart-urls-ultimate-guide/)</code> and I made my link in this format.</p>
  
  <p>My link is:</p>
  
  <pre><code>localhost/wordpress/cart/?add-to-cart=1185&amp;variation_id=1641&amp;quantity=1&amp;attribute_pa_liability=2_million&amp;attribute_pa_hours=500_hours
  </code></pre>
  
  <p>Where liability and hours is my custom attribute which has values as 1 million, 2 million and 500 hours, 750 hours respectively.</p>
  
  <p>But when it get's redirected to cart page woocommerce give me an error and shows it's alert box which shows the error message as "liability and hours are required fields".</p>
  
  <p>I think woocommerce is unable to get the attribute values through my URL.</p>
  
  <p>Can anyone explain why is this happening and what is the error if there is any?</p>