I have product category called “the-collection” with many products inside. All of that products is variable products with variations inside. I have variation with Size: “Simple Pot” and Finish: “Chalky Interior Matt” inside. I want to add custom button, that will auto add this varialtion into cart. For that i added this function into functions.php file:

function cmk_additional_button()
  echo '<a href="#" button type="submit" class="button alt">Sample 


That add me a button. I also followed this manual how to create varaible link, but variation ID is not exact for all products. I also want to show that button only for “The Collection” product category. How to do that?

Read more here: How to add WooCommerce variation automatically when press on button?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: