woocommerce_variable_add_to_cart

Output the variable product add to cart area.

Description

woocommerce_variable_add_to_cart(); 

Usage

  1. if ( !function_exists( 'woocommerce_variable_add_to_cart' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = woocommerce_variable_add_to_cart(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function woocommerce_variable_add_to_cart() { 
  2. global $product; 
  3.  
  4. // Enqueue variation scripts 
  5. wp_enqueue_script( 'wc-add-to-cart-variation' ); 
  6.  
  7. // Get Available variations? 
  8. $get_variations = sizeof( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product ); 
  9.  
  10. // Load the template 
  11. wc_get_template( 'single-product/add-to-cart/variable.php', array( 
  12. 'available_variations' => $get_variations ? $product->get_available_variations() : false,  
  13. 'attributes' => $product->get_variation_attributes(),  
  14. 'selected_attributes' => $product->get_default_attributes(),  
  15. ) );