woocommerce_loop_add_to_cart_link

The WooCommerce woocommerce loop add to cart link hook.

Description

apply_filters( 'woocommerce_loop_add_to_cart_link', (unknown) $quantity, (unknown) $product ); 

Parameters (2)

0. $quantity — Optional. (unknown) => sprintf( '%s', esc_url( $product->add_to_cart_url() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), esc_attr( $product->get_id() ), esc_attr( $product->get_sku() ), esc_attr( isset( $class ) ? $class : 'button' ), esc_html( $product->add_to_cart_text() ) )
The sprintf.
1. $product (unknown)
The product.

Usage

To run the hook, copy the example below.
  1. $quantity = apply_filters( 'woocommerce_loop_add_to_cart_link', $quantity, $product ); 
  2.  
  3. if ( !empty( $quantity ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_loop_add_to_cart_link callback 
  2. function filter_woocommerce_loop_add_to_cart_link( $quantity, $product ) { 
  3. // make filter magic happen here... 
  4. return $quantity
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_loop_add_to_cart_link', 'filter_woocommerce_loop_add_to_cart_link', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_loop_add_to_cart_link', 'filter_woocommerce_loop_add_to_cart_link', 10, 2 ); 

Defined (1)

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

/templates/loop/add-to-cart.php  
  1. echo apply_filters( 'woocommerce_loop_add_to_cart_link',