Cart_Recovery::handle_request()
Summary
No summary available.Return
(string)
Source
File: src/BigCommerce/Cart/Cart_Recovery.php
public function handle_request( ) { $token = filter_input( INPUT_GET, 't', FILTER_SANITIZE_STRING ); if ( empty( $token ) ) { wp_die( esc_html( __( 'Bad Request', 'bigcommerce' ) ), esc_html( __( 'Bad Request', 'bigcommerce' ) ), 400 ); exit(); } $cart_page_id = 0; if ( get_option( CartSettings::OPTION_ENABLE_CART, true ) ) { $cart_page_id = get_option( \BigCommerce\Pages\Cart_Page::NAME, 0 ); } try { $abandoned_cart = $this->api->recoverCart( $token )->getData()->getCartId(); } catch ( ApiException $e ) { $error = new \WP_Error( 'api_error', $e->getMessage() ); if ( $cart_page_id ) { $destination = get_permalink( $cart_page_id ); } else { $destination = get_post_type_archive_link( Product::NAME ); } do_action( 'bigcommerce/form/error', $error, $_POST, $destination ); } if ( empty( $abandoned_cart ) ) { $this->redirect_to_cart( $cart_page_id ); } else { $this->set_abandoned_cart_cookie( $abandoned_cart ); } $this->redirect_to_cart( $cart_page_id ); }