| @@ -17,18 +17,15 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | public function find( \WP_REST_Request $request ) { |
| 19 | 19 | return rest_ensure_response( |
| 20 | 20 | [ |
| 21 | - 'object' => 'settings', | |
| 22 | - 'api_token' => ApiToken::get(), | |
| 23 | - 'uninstall' => (bool) get_option( 'sc_uninstall', false ), | |
| 24 | - 'stripe_payment_element' => (bool) get_option( 'sc_stripe_payment_element', true ), | |
| 25 | - 'auto_sync_user_to_customer' => (bool) get_option( 'surecart_auto_sync_user_to_customer', false ), | |
| 26 | - 'checkout_show_login_prompt' => (bool) get_option( 'surecart_checkout_show_login_prompt', false ), | |
| 27 | - 'use_esm_loader' => (bool) get_option( 'surecart_use_esm_loader', false ), | |
| 28 | - 'slide_out_cart_disabled' => (bool) get_option( 'sc_slide_out_cart_disabled', false ), | |
| 29 | - 'load_block_assets_on_demand' => (bool) get_option( 'surecart_load_block_assets_on_demand', false ), | |
| 30 | - 'modern_order_bump' => get_option( 'surecart_order_bump_design', 'modern' ) === 'modern', | |
| 21 | + 'object' => 'settings', | |
| 22 | + 'api_token' => ApiToken::get(), | |
| 23 | + 'uninstall' => (bool) get_option( 'sc_uninstall', false ), | |
| 24 | + 'stripe_payment_element' => (bool) get_option( 'sc_stripe_payment_element', false ), | |
| 25 | + 'auto_sync_user_to_customer' => (bool) get_option( 'surecart_auto_sync_user_to_customer', false ), | |
| 26 | + 'use_esm_loader' => (bool) get_option( 'surecart_use_esm_loader', false ), | |
| 27 | + 'slide_out_cart_disabled' => (bool) get_option( 'sc_slide_out_cart_disabled', false ), | |
| 31 | 28 | ] |
| 32 | 29 | ); |
| 33 | 30 | } |
| 34 | 31 | |
| @@ -47,14 +44,9 @@ | ||
| 47 | 44 | if ( is_wp_error( $validate ) ) { |
| 48 | 45 | return $validate; |
| 49 | 46 | } |
| 50 | 47 | } |
| 51 | - | |
| 52 | - // Update the API token. | |
| 53 | 48 | ApiToken::save( $request['api_token'] ); |
| 54 | - | |
| 55 | - // Clear the account cache. | |
| 56 | - \SureCart::account()->clearCache(); | |
| 57 | 49 | } |
| 58 | 50 | |
| 59 | 51 | // update uninstall option. |
| 60 | 52 | if ( isset( $request['uninstall'] ) ) { |
| @@ -60,11 +52,11 @@ | ||
| 60 | 52 | if ( isset( $request['uninstall'] ) ) { |
| 61 | 53 | update_option( 'sc_uninstall', $request->get_param( 'uninstall' ) ); |
| 62 | 54 | } |
| 63 | 55 | |
| 64 | - // update stripe payment_element option - used to enable the stripe's legacy card element. | |
| 56 | + // update uninstall option. | |
| 65 | 57 | if ( isset( $request['stripe_payment_element'] ) ) { |
| 66 | - update_option( 'sc_stripe_payment_element', $request->get_param( 'stripe_payment_element' ) === false ? 0 : 1 ); | |
| 58 | + update_option( 'sc_stripe_payment_element', $request->get_param( 'stripe_payment_element' ) ); | |
| 67 | 59 | } |
| 68 | 60 | |
| 69 | 61 | // update performance option. |
| 70 | 62 | if ( isset( $request['use_esm_loader'] ) ) { |
| @@ -77,22 +69,8 @@ | ||
| 77 | 69 | } |
| 78 | 70 | |
| 79 | 71 | if ( isset( $request['auto_sync_user_to_customer'] ) ) { |
| 80 | 72 | update_option( 'surecart_auto_sync_user_to_customer', (bool) $request->get_param( 'auto_sync_user_to_customer' ) ); |
| 81 | - } | |
| 82 | - | |
| 83 | - if ( isset( $request['checkout_show_login_prompt'] ) ) { | |
| 84 | - update_option( 'surecart_checkout_show_login_prompt', (bool) $request->get_param( 'checkout_show_login_prompt' ) ); | |
| 85 | - } | |
| 86 | - | |
| 87 | - // update load block styles on demand option. | |
| 88 | - if ( isset( $request['load_block_assets_on_demand'] ) ) { | |
| 89 | - update_option( 'surecart_load_block_assets_on_demand', $request->get_param( 'load_block_assets_on_demand' ) ); | |
| 90 | - } | |
| 91 | - | |
| 92 | - // update order bump design option. | |
| 93 | - if ( isset( $request['modern_order_bump'] ) ) { | |
| 94 | - update_option( 'surecart_order_bump_design', (bool) $request->get_param( 'modern_order_bump' ) ? 'modern' : 'classic' ); | |
| 95 | 73 | } |
| 96 | 74 | |
| 97 | 75 | return rest_ensure_response( $this->find( $request ) ); |
| 98 | 76 | } |