WC_Cart::remove_cart_item() public WC 2.3.0
Remove a cart item.
{} Это метод класса: WC_Cart{}
Хуки из метода
Возвращает
true/false.
Использование
$WC_Cart = new WC_Cart(); $WC_Cart->remove_cart_item( $cart_item_key );
- $cart_item_key(строка) (обязательный)
- Cart item key to remove from the cart.
Список изменений
С версии 2.3.0 | Введена. |
Код WC_Cart::remove_cart_item() WC Cart::remove cart item WC 5.0.0
public function remove_cart_item( $cart_item_key ) {
if ( isset( $this->cart_contents[ $cart_item_key ] ) ) {
$this->removed_cart_contents[ $cart_item_key ] = $this->cart_contents[ $cart_item_key ];
unset( $this->removed_cart_contents[ $cart_item_key ]['data'] );
do_action( 'woocommerce_remove_cart_item', $cart_item_key, $this );
unset( $this->cart_contents[ $cart_item_key ] );
do_action( 'woocommerce_cart_item_removed', $cart_item_key, $this );
return true;
}
return false;
}