Description
The “tcp_add_to_shopping_cart” filter is used to filter the addition of new products in the shopping cart.
Parameters
- $shopping_cart_item
- ShoppingCartItem ObjectItem to add to the Shopping Cart
Example
<?php
define( 'MAX_WEIGTH', 100 );
function check_adding( $shopping_cart_item ) {
$shoppingcart = TheCartPress::getShoppingCart();
if ( $shoppingcart->getWeight() + $shopping_cart_item->getWeight() < MAX_WEIGTH ) {
return $shopping_cart_item;
} else {
//TODO Notice about the Failure when adding
return false;
}
}
add_filter( 'tcp_add_to_shopping_cart', 'check_adding' ); ?>
Change Log
Since 1.0.8
