Local_Ghost

woocommerce_get_template_loop_add_to_cart

Apr 10th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. if ( ! function_exists( 'woocommerce_get_template_loop_add_to_cart' ) ) {
  2.  
  3.     /**
  4.      * Get the add to cart template for the loop.
  5.      *
  6.      * @subpackage  Loop
  7.      */
  8.     function woocommerce_get_template_loop_add_to_cart( $args = array() ) {
  9.         global $product;
  10.  
  11.         if ( $product ) {
  12.             $defaults = array(
  13.                 'quantity' => 1,
  14.                 'class'    => implode( ' ', array_filter( array(
  15.                         'button',
  16.                         'product_type_' . $product->product_type,
  17.                         $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
  18.                         $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : ''
  19.                 ) ) )
  20.             );
  21.  
  22.             $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product );
  23.  
  24.             return wc_get_template_html( 'loop/add-to-cart.php', $args );
  25.         }
  26.                
  27.                 return false;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment