|
@@ 109-120 (lines=12) @@
|
| 106 |
|
* @param string $cart_item_key |
| 107 |
|
* @return bool |
| 108 |
|
*/ |
| 109 |
|
public function remove_item( $cart_item_key ) { |
| 110 |
|
if ( isset( $this->items[ $cart_item_key ] ) ) { |
| 111 |
|
do_action( 'woocommerce_remove_cart_item', $cart_item_key, WC()->cart ); |
| 112 |
|
|
| 113 |
|
$this->removed_items[ $cart_item_key ] = $this->items[ $cart_item_key ]; |
| 114 |
|
unset( $this->items[ $cart_item_key ] ); |
| 115 |
|
|
| 116 |
|
do_action( 'woocommerce_cart_item_removed', $cart_item_key, WC()->cart ); |
| 117 |
|
return true; |
| 118 |
|
} |
| 119 |
|
return false; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
/** |
| 123 |
|
* Restore a cart item. |
|
@@ 127-138 (lines=12) @@
|
| 124 |
|
* @param string $cart_item_key |
| 125 |
|
* @return bool |
| 126 |
|
*/ |
| 127 |
|
public function restore_item( $cart_item_key ) { |
| 128 |
|
if ( isset( $this->removed_items[ $cart_item_key ] ) ) { |
| 129 |
|
do_action( 'woocommerce_restore_cart_item', $cart_item_key, WC()->cart ); |
| 130 |
|
|
| 131 |
|
$this->items[ $cart_item_key ] = new WC_Item_Product( $this->removed_items[ $cart_item_key ] ); |
| 132 |
|
unset( $this->removed_items[ $cart_item_key ] ); |
| 133 |
|
|
| 134 |
|
do_action( 'woocommerce_cart_item_restored', $cart_item_key, WC()->cart ); |
| 135 |
|
return true; |
| 136 |
|
} |
| 137 |
|
return false; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
/** |
| 141 |
|
* Filter items needing shipping callback. |