public function CommerceCartProviderSession::cartDelete in Commerce Core 7
Deletes either all order IDs or a specific order ID from a carts array.
Parameters
$order_id: The order ID to remove from the array or NULL to delete the variable.
$completed: Boolean indicating whether or not the operation should delete from the completed orders array instead of the active cart orders array.
Overrides CommerceCartProviderInterface::cartDelete
File
- modules/
cart/ plugins/ cart_provider/ CommerceCartProviderSession.class.php, line 14
Class
- CommerceCartProviderSession
- Defines a session array based cart provider.
Code
public function cartDelete($order_id = NULL, $completed = FALSE) {
$key = $completed ? self::COMPLETED : self::CART;
if (!empty($_SESSION[$key])) {
if (!empty($order_id)) {
$_SESSION[$key] = array_diff($_SESSION[$key], array(
$order_id,
));
}
else {
unset($_SESSION[$key]);
}
}
}