I would like to display my add to cart doem in a modal but doing so make a part of becomes missing.
I have variable products and the select field corresponding to the variation options is missing
Here is how i call the Add to cart form in my child theme :
<div id="buyModal" class="modal">
<div class="buyModal-content">
<?php woocommerce_template_single_add_to_cart(); ?>
<a href="javascript:;" class="close_btn_subsciption">X</a>
</div>
</div>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I have replaced woocommerce_template_single_add_to_cart(); by this
global $product;
if( is_a( $product, 'WC_Product_Variable' ) ){
woocommerce_variable_add_to_cart();
} else {
woocommerce_simple_add_to_cart();
}
and it worked as i wanted.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0