سؤال

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>
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top