WC_Cart_Session::clean_up_removed_cart_contents
Removes items from the removed cart contents on next user initiated request.
Method of the class: WC_Cart_Session{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Cart_Session = new WC_Cart_Session(); $WC_Cart_Session->clean_up_removed_cart_contents();
WC_Cart_Session::clean_up_removed_cart_contents() WC Cart Session::clean up removed cart contents code WC 10.5.0
public function clean_up_removed_cart_contents() {
// Limit to page requests initiated by the user.
$is_page = is_singular() || is_archive() || is_search();
if ( is_404() || ! $is_page ) {
return;
}
// Don't cleanup if user just removed an item (undo link is being displayed).
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['removed_item'] ) ) {
return;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['undo_item'] ) ) {
return;
}
WC()->session->set( 'removed_cart_contents', null );
$this->cart->set_removed_cart_contents( array() );
}