wcml_add_to_cart_sold_individually

The WooCommerce Multilingual wcml add to cart sold individually hook.

Description

apply_filters( 'wcml_add_to_cart_sold_individually', (bool) $true, (unknown) $cart_item_data, (unknown) $product_id, (unknown) $quantity ); 

Parameters (4)

0. $true (bool) => true
The true.
1. $cart_item_data (unknown)
The cart item data.
2. $product_id (unknown)
The product id.
3. $quantity (unknown)
The quantity.

Usage

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

Defined (1)

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

/inc/class-wcml-cart.php  
  1. if( apply_filters( 'wcml_add_to_cart_sold_individually', true, $cart_item_data, $product_id, $quantity ) && $current_product_trid == $cart_element_trid && $cart_item[ 'quantity' ] > 0 ) {