Store_Settings::run()
Summary
No summary available.Source
File: src/BigCommerce/Import/Processors/Store_Settings.php
public function run() { $status = new Status(); $status->set_status( Status::FETCHING_STORE ); try { do_action( 'bigcommerce/log', Error_Log::DEBUG, __( 'Requesting store settings', 'bigcommerce' ), [] ); $store = $this->store_api->getStore(); if ( empty( $store ) ) { // v2 api client doesn't throw proper errors throw new ApiException( __( 'Unable to retrieve store information', 'bigcommerce' ) ); } $settings = [ self::DOMAIN => $store->domain, Settings\Sections\Currency::CURRENCY_CODE => $store->currency, Settings\Sections\Currency::CURRENCY_SYMBOL => $store->currency_symbol, Settings\Sections\Currency::CURRENCY_SYMBOL_POSITION => $this->sanitize_currency_symbol_position( $store->currency_symbol_location ), Settings\Sections\Currency::DECIMAL_UNITS => absint( $store->decimal_places ), Settings\Sections\Currency::INTEGER_UNITS => $this->get_max_integer_units(), Settings\Sections\Units::MASS => $this->sanitize_mass_unit( $store->weight_units ), Settings\Sections\Units::LENGTH => $this->sanitize_length_unit( $store->dimension_units ), Settings\Sections\Wishlists::ENABLED => isset( $store->features->wishlists_enabled ) ? (int) $store->features->wishlists_enabled : 0, ]; if ( get_option( Settings\Sections\Analytics::SYNC_ANALYTICS, 1 ) ) { $analytics = $this->store_api->get_analytics_settings(); $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); } do_action( 'bigcommerce/log', Error_Log::DEBUG, __( 'Retrieved store settings', 'bigcommerce' ), [ 'settings' => $settings, ] ); foreach ( $settings as $key => $value ) { if ( $value !== false ) { update_option( $key, $value ); } } do_action( 'bigcommerce/import/fetched_currency', $settings[ Settings\Sections\Currency::CURRENCY_CODE ] ); do_action( 'bigcommerce/import/fetched_store_settings', $settings ); } catch ( \Exception $e ) { // if anything fails here, leave it be and let the user configure currency settings do_action( 'bigcommerce/import/could_not_fetch_store_settings' ); } $status->set_status( Status::FETCHED_STORE ); }