Changeset 2887672
- Timestamp:
- 03/27/2023 02:41:16 PM (3 years ago)
- Location:
- bigcommerce
- Files:
-
- 50 edited
- 1 copied
-
tags/5.0.2 (copied) (copied from bigcommerce/trunk)
-
tags/5.0.2/CHANGELOG.md (modified) (2 diffs)
-
tags/5.0.2/bigcommerce.php (modified) (1 diff)
-
tags/5.0.2/build-timestamp.php (modified) (1 diff)
-
tags/5.0.2/readme.txt (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Api/Store_Api.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Container/Import.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Container/Settings.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Customizer/Sections/Product_Single.php (modified) (2 diffs)
-
tags/5.0.2/src/BigCommerce/Editor/Editor_Dialog_Template.php (modified) (2 diffs)
-
tags/5.0.2/src/BigCommerce/Import/Processors/Store_Settings.php (modified) (4 diffs)
-
tags/5.0.2/src/BigCommerce/Import/Task_Manager.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Plugin.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Rest/Products_Controller.php (modified) (6 diffs)
-
tags/5.0.2/src/BigCommerce/Rest/Rest_Controller.php (modified) (2 diffs)
-
tags/5.0.2/src/BigCommerce/Settings/Import_Status.php (modified) (2 diffs)
-
tags/5.0.2/src/BigCommerce/Settings/Sections/Analytics.php (modified) (4 diffs)
-
tags/5.0.2/src/BigCommerce/Templates/Product_Gallery.php (modified) (2 diffs)
-
tags/5.0.2/src/BigCommerce/Templates/Product_Options.php (modified) (1 diff)
-
tags/5.0.2/src/BigCommerce/Templates/Product_Sku.php (modified) (1 diff)
-
tags/5.0.2/templates/admin/query-builder.php (modified) (2 diffs)
-
tags/5.0.2/vendor/autoload.php (modified) (1 diff)
-
tags/5.0.2/vendor/composer/autoload_real.php (modified) (5 diffs)
-
tags/5.0.2/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/5.0.2/vendor/composer/installed.json (modified) (2 diffs)
-
tags/5.0.2/vendor/moderntribe/bigcommerce-api-php-v3/src/Api/SettingsApi.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (2 diffs)
-
trunk/bigcommerce.php (modified) (1 diff)
-
trunk/build-timestamp.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/src/BigCommerce/Api/Store_Api.php (modified) (1 diff)
-
trunk/src/BigCommerce/Container/Import.php (modified) (1 diff)
-
trunk/src/BigCommerce/Container/Settings.php (modified) (1 diff)
-
trunk/src/BigCommerce/Customizer/Sections/Product_Single.php (modified) (2 diffs)
-
trunk/src/BigCommerce/Editor/Editor_Dialog_Template.php (modified) (2 diffs)
-
trunk/src/BigCommerce/Import/Processors/Store_Settings.php (modified) (4 diffs)
-
trunk/src/BigCommerce/Import/Task_Manager.php (modified) (1 diff)
-
trunk/src/BigCommerce/Plugin.php (modified) (1 diff)
-
trunk/src/BigCommerce/Rest/Products_Controller.php (modified) (6 diffs)
-
trunk/src/BigCommerce/Rest/Rest_Controller.php (modified) (2 diffs)
-
trunk/src/BigCommerce/Settings/Import_Status.php (modified) (2 diffs)
-
trunk/src/BigCommerce/Settings/Sections/Analytics.php (modified) (4 diffs)
-
trunk/src/BigCommerce/Templates/Product_Gallery.php (modified) (2 diffs)
-
trunk/src/BigCommerce/Templates/Product_Options.php (modified) (1 diff)
-
trunk/src/BigCommerce/Templates/Product_Sku.php (modified) (1 diff)
-
trunk/templates/admin/query-builder.php (modified) (2 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (5 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.json (modified) (2 diffs)
-
trunk/vendor/moderntribe/bigcommerce-api-php-v3/src/Api/SettingsApi.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bigcommerce/tags/5.0.2/CHANGELOG.md
r2866539 r2887672 1 1 # Changelog 2 3 ## [5.0.2] 4 5 ### Added 6 - Add ability to use original image proportion on product single page. Go to Apperance → Bigcommerce → Product Single and change image size to original. 7 8 ### Changed 9 - Show variant SKU if product SKU is not added or missing 10 11 ### Fixed 12 - Prevent import fail on Analytics Settings retrieval due to outdated API use 13 - Fix search issue with product widget block while using fast(headless) import. Allow searching by SKU, name 2 14 3 15 ## [5.0.1] … … 1878 1890 1879 1891 1892 [5.0.2]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/5.0.1...5.0.2 1880 1893 [5.0.1]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/5.0.0...5.0.1 1881 1894 [5.0.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.37.0...5.0.0 -
bigcommerce/tags/5.0.2/bigcommerce.php
r2866539 r2887672 4 4 Description: Scale your ecommerce business with WordPress on the front-end and BigCommerce on the back end. Free up server resources from things like catalog management, processing payments, and managing fulfillment logistics. 5 5 Author: BigCommerce 6 Version: 5.0. 16 Version: 5.0.2 7 7 Author URI: https://www.bigcommerce.com/wordpress 8 8 Requires PHP: 7.4.0 -
bigcommerce/tags/5.0.2/build-timestamp.php
r2866539 r2887672 1 1 <?php 2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', ' 4.11.02.16.2023');2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.41.03.24.2023'); -
bigcommerce/tags/5.0.2/readme.txt
r2866539 r2887672 4 4 Requires at least: 5.2 5 5 Tested up to: 6.0.3 6 Stable tag: 5.0. 16 Stable tag: 5.0.2 7 7 Requires PHP: 7.4.0 8 8 License: GPLv2 or later -
bigcommerce/tags/5.0.2/src/BigCommerce/Api/Store_Api.php
r2626896 r2887672 102 102 try { 103 103 $settings = $this->getCollection( '/settings/analytics' ); 104 105 if ( empty( $settings ) ) { 106 return []; 107 } 104 108 $settings = array_map( function ( Resource $resource ) { 105 109 return get_object_vars( $resource->getUpdateFields() ); 106 110 }, $settings ); 107 } catch ( \ Exception$e ) {111 } catch ( \Throwable $e ) { 108 112 $settings = []; 109 113 } -
bigcommerce/tags/5.0.2/src/BigCommerce/Container/Import.php
r2865940 r2887672 235 235 236 236 $container[ self::STORE ] = function ( Container $container ) { 237 return new Processors\Store_Settings( $container[ Api::FACTORY ]->store(), $container[ self::CUSTOMER_DEFAULT_GROUP ], $container[ self::MSF_STOREFRONT_PROCESSOR ] );237 return new Processors\Store_Settings( $container[ Api::FACTORY ]->store(), $container[ self::CUSTOMER_DEFAULT_GROUP ], $container[ self::MSF_STOREFRONT_PROCESSOR ], $container[ Api::FACTORY ]->storefront_settings() ); 238 238 }; 239 239 -
bigcommerce/tags/5.0.2/src/BigCommerce/Container/Settings.php
r2742415 r2887672 441 441 private function analytics( Container $container ) { 442 442 $container[ self::ANALYTICS_SECTION ] = function ( Container $container ) { 443 return new Analytics_Settings( $container[ Api::FACTORY ]->store() );443 return new Analytics_Settings( $container[ Api::FACTORY ]->store(), $container[ Api::FACTORY ]->storefront_settings() ); 444 444 }; 445 445 -
bigcommerce/tags/5.0.2/src/BigCommerce/Customizer/Sections/Product_Single.php
r2826745 r2887672 22 22 const SIZE_DEFAULT = 'default'; 23 23 const SIZE_LARGE = 'large'; 24 const SIZE_ORIGINAL = 'original'; 24 25 const SIZE_CDN_STD = 'standard'; 25 26 const SIZE_CDN_THUMB = 'thumbnail'; … … 96 97 'label' => __( 'Image Gallery Size', 'bigcommerce' ), 97 98 'choices' => [ 98 self::SIZE_DEFAULT => __( 'Default', 'bigcommerce' ), 99 self::SIZE_LARGE => __( 'Large', 'bigcommerce' ), 99 self::SIZE_DEFAULT => __( 'Default', 'bigcommerce' ), 100 self::SIZE_LARGE => __( 'Large', 'bigcommerce' ), 101 self::SIZE_ORIGINAL => __( 'Original', 'bigcommerce' ), 100 102 ], 101 103 ] ); -
bigcommerce/tags/5.0.2/src/BigCommerce/Editor/Editor_Dialog_Template.php
r2108438 r2887672 6 6 use BigCommerce\Customizer\Sections\Product_Archive; 7 7 use BigCommerce\Exceptions\Channel_Not_Found_Exception; 8 use BigCommerce\Import\Import_Type; 8 9 use BigCommerce\Rest\Products_Controller; 9 10 use BigCommerce\Rest\Shortcode_Controller; … … 105 106 return $this->render_template( 'query-builder.php', [ 106 107 'featured' => $featured, 107 'sale' => $sale,108 'sale' => Import_Type::is_traditional_import() && $sale, 108 109 'brands' => $brand_choices, 109 110 'categories' => $category_choices, -
bigcommerce/tags/5.0.2/src/BigCommerce/Import/Processors/Store_Settings.php
r2865940 r2887672 7 7 use Bigcommerce\Api\Client; 8 8 use BigCommerce\Api\Store_Api; 9 use BigCommerce\Api\v3\Api\SettingsApi; 9 10 use BigCommerce\Api\v3\ApiException; 10 11 use BigCommerce\Import\Runner\Status; … … 12 13 use BigCommerce\Post_Types\Product\Product; 13 14 use BigCommerce\Settings; 15 use BigCommerce\Taxonomies\Channel\Channel; 16 use BigCommerce\Taxonomies\Channel\Connections; 14 17 15 18 class Store_Settings implements Import_Processor { … … 40 43 private $storefront_processor; 41 44 42 public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor ) { 45 /** 46 * @var \BigCommerce\Api\v3\Api\SettingsApi 47 */ 48 private $api_v3; 49 50 public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor, SettingsApi $api ) { 43 51 $this->store_api = $store_api; 52 $this->api_v3 = $api; 44 53 $this->default_customer_group = $default_customer_group; 45 54 $this->storefront_processor = $storefront_processor; … … 76 85 77 86 if ( get_option( Settings\Sections\Analytics::SYNC_ANALYTICS, 1 ) ) { 78 $analytics = $this->store_api->get_analytics_settings(); 79 $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); 80 $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); 87 $connections = new Connections(); 88 $channel = $connections->current(); 89 $analytics = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true )); 90 91 if ( ! empty( $analytics->data ) ) { 92 $analytics = json_decode( json_encode( $analytics->data ), true ); 93 $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); 94 $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); 95 } 96 81 97 } 82 98 -
bigcommerce/tags/5.0.2/src/BigCommerce/Import/Task_Manager.php
r2860929 r2887672 101 101 do_action( 'bigcommerce/log', Error_Log::NOTICE, __( 'No handler found for current import state', 'bigcommerce' ), [ 102 102 'state' => $state, 103 'import' => Import_Type::is_traditional_import() ? 'full' : 'headless', 103 104 ] ); 104 105 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [] ); -
bigcommerce/tags/5.0.2/src/BigCommerce/Plugin.php
r2866539 r2887672 5 5 6 6 class Plugin { 7 const VERSION = '5.0. 1';7 const VERSION = '5.0.2'; 8 8 9 9 protected static $_instance; -
bigcommerce/tags/5.0.2/src/BigCommerce/Rest/Products_Controller.php
r2742415 r2887672 70 70 71 71 protected function get_items_headless( $request ) { 72 $container = bigcommerce()->container(); 73 74 if ( ! empty( $request['slug'] ) ) { 75 return $this->get_items_graphql( $container, $request ); 72 $container = bigcommerce()->container(); 73 $request_data = $request->get_params(); 74 75 if ( ! empty( $request_data['slug'] ) ) { 76 return $this->get_items_graphql( $container, $request_data ); 76 77 } 77 78 … … 81 82 try { 82 83 $params = [ 83 'page' => $request['page'],84 'limit' => $request['per_page'],85 'include' => [ 'variants', 'custom_fields', 'images', 'bulk_pricing_rules', 'options', 'modifiers' ],84 'page' => $request_data['page'], 85 'limit' => $request_data['per_page'], 86 'include' => [ 'variants', 'custom_fields', 'images', 'bulk_pricing_rules', 'options', 'modifiers' ], 86 87 ]; 87 88 88 if ( ! empty( $request['bigcommerce_brand'] ) ) { 89 $params['brand_id'] = $request['bigcommerce_brand']; 90 } 91 92 if ( ! empty( $request['bigcommerce_category'] ) ) { 93 $params['categories:in'] = $request['bigcommerce_category']; 94 } 95 96 if ( ! empty( $request['bcid'] ) ) { 97 $params['id'] = $request['bcid']; 89 if ( ! empty( $request_data['bigcommerce_brand'] ) ) { 90 $params['brand_id'] = $this->get_term_bc_id( $request_data['bigcommerce_brand'] ); 91 } 92 93 if ( ! empty( $request_data['bigcommerce_flag'] ) ) { 94 $term_ids = $request_data['bigcommerce_flag']; 95 96 97 foreach ( $term_ids as $id ) { 98 $flag = get_term( $id, Flag::NAME ); 99 100 if ( empty( $flag ) || is_wp_error( $flag ) ) { 101 continue; 102 } 103 104 if ( $flag->name === Flag::FEATURED ) { 105 $params['is_featured'] = 1; 106 } 107 } 108 109 } 110 111 if ( ! empty( $request_data['bigcommerce_category'] ) ) { 112 $params['categories:in'] = $this->get_term_bc_id( $request_data['bigcommerce_category'] ); 113 } 114 115 if ( ! empty( $request_data['bcid'] ) ) { 116 $params['id'] = $request_data['bcid']; 117 } 118 119 if ( ! empty( $request_data['search'] ) ) { 120 $params['keyword'] = $request_data['search']; 98 121 } 99 122 100 123 $response = $catalog->getProducts( $params ); 101 124 102 return $this->parse_result( $response, $client ); 125 $result = $this->parse_result( $response, $client, false ); 126 if ( empty( $result ) ) { 127 return rest_ensure_response( [] ); 128 } 129 130 return $this->convert_to_wp_response( $request, $result ); 103 131 } catch ( ApiException $e ) { 104 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [ 'request' => $request ], 'rest' );132 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [ 'request' => $request_data ], 'rest' ); 105 133 106 134 $error = new \WP_Error( 'api_error', sprintf( … … 111 139 return $error; 112 140 } 141 } 142 143 private function convert_to_wp_response( $request, $result ) { 144 $mapper = new Query_Mapper(); 145 $args = $mapper->map_rest_args_to_query( $request->get_params() ); 146 147 // We don't have required data in WP db. Instead, we will use result from remote 148 if ( ! empty( $args['s'] ) ) { 149 unset( $args['s'] ); 150 } 151 $args['bigcommerce_id__in'] = []; 152 153 array_walk( $result, function ( $item ) use ( &$args ) { 154 if ( empty( $item ) ) { 155 return; 156 } 157 158 $args['bigcommerce_id__in'][] = $item->id; 159 } ); 160 161 $args['post_type'] = Product::NAME; 162 $args['post_status'] = 'publish'; 163 $args['posts_per_page'] = 12; 164 if ( ! empty( $args['bigcommerce_id__in'] ) ) { 165 $args['posts_per_page'] = - 1; 166 } 167 168 $posts_query = new \WP_Query(); 169 $query_result = $posts_query->query( $args ); 170 $posts = []; 171 172 foreach ( $query_result as $post_id ) { 173 $bcid = get_post_meta( $post_id, Product::BIGCOMMERCE_ID, true ); 174 $data = $this->prepare_item_for_response( get_post( $post_id ), $request ); 175 // ensure that we only have one result per BCID, no matter how many channels it's in 176 $posts[ $bcid ] = $this->prepare_response_for_collection( $data ); 177 } 178 179 return $this->retrieve_rest_response( $posts, $request, $args, $posts_query, null, true ); 180 } 181 182 /** 183 * @param $posts 184 * @param $request 185 * @param $query_args 186 * @param $posts_query 187 * @param null $channel_filter 188 * @param bool $always_fetch 189 * 190 * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response 191 */ 192 private function retrieve_rest_response( $posts, $request, $query_args, $posts_query, $channel_filter = null, $always_fetch = false ) { 193 $page = (int) $query_args['paged']; 194 $total_posts = $posts_query->found_posts; 195 196 if ( $total_posts < 1 ) { 197 // Out-of-bounds, run the query again without LIMIT for total count. 198 unset( $query_args['paged'] ); 199 200 $count_query = new \WP_Query(); 201 $count_query->query( $query_args ); 202 $total_posts = $count_query->found_posts; 203 } 204 205 if ( $channel_filter ) { 206 remove_action( 'pre_get_posts', $channel_filter, 9 ); 207 } 208 209 if ( $posts_query->query_vars['posts_per_page'] === - 1 ) { 210 $max_pages = 1; 211 } else { 212 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 213 } 214 215 if ( $page > $max_pages && $total_posts > 0 && ! $always_fetch ) { 216 return new \WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.', 'bigcommerce' ), [ 'status' => 400 ] ); 217 } 218 219 $response = rest_ensure_response( array_values( $posts ) ); 220 221 $response->header( 'X-WP-Total', (int) $total_posts ); 222 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 223 224 $request_params = $request->get_query_params(); 225 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 226 227 if ( $page > 1 ) { 228 $prev_page = $page - 1; 229 230 if ( $prev_page > $max_pages ) { 231 $prev_page = $max_pages; 232 } 233 234 $prev_link = add_query_arg( 'page', $prev_page, $base ); 235 $response->link_header( 'prev', $prev_link ); 236 } 237 if ( $max_pages > $page || $always_fetch ) { 238 $next_page = $page + 1; 239 $next_link = add_query_arg( 'page', $next_page, $base ); 240 241 $response->link_header( 'next', $next_link ); 242 } 243 244 return $response; 113 245 } 114 246 … … 137 269 138 270 if ( ! Import_Type::is_traditional_import() ) { 139 return $this->get_items_headless( $request _data);271 return $this->get_items_headless( $request ); 140 272 } 141 273 $mapper = new Query_Mapper(); … … 171 303 $posts[ $bcid ] = $this->prepare_response_for_collection( $data ); 172 304 } 173 174 $page = (int) $query_args['paged']; 175 $total_posts = $posts_query->found_posts; 176 177 if ( $total_posts < 1 ) { 178 // Out-of-bounds, run the query again without LIMIT for total count. 179 unset( $query_args['paged'] ); 180 181 $count_query = new \WP_Query(); 182 $count_query->query( $query_args ); 183 $total_posts = $count_query->found_posts; 184 } 185 186 remove_action( 'pre_get_posts', $channel_filter, 9 ); 187 188 if ( $posts_query->query_vars['posts_per_page'] === - 1 ) { 189 $max_pages = 1; 190 } else { 191 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 192 } 193 194 if ( $page > $max_pages && $total_posts > 0 ) { 195 return new \WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.', 'bigcommerce' ), [ 'status' => 400 ] ); 196 } 197 198 $response = rest_ensure_response( array_values( $posts ) ); 199 200 $response->header( 'X-WP-Total', (int) $total_posts ); 201 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 202 203 $request_params = $request->get_query_params(); 204 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 205 206 if ( $page > 1 ) { 207 $prev_page = $page - 1; 208 209 if ( $prev_page > $max_pages ) { 210 $prev_page = $max_pages; 211 } 212 213 $prev_link = add_query_arg( 'page', $prev_page, $base ); 214 $response->link_header( 'prev', $prev_link ); 215 } 216 if ( $max_pages > $page ) { 217 $next_page = $page + 1; 218 $next_link = add_query_arg( 'page', $next_page, $base ); 219 220 $response->link_header( 'next', $next_link ); 221 } 222 223 return $response; 305 do_action( 'bigcommerce/log', Error_Log::ERROR, __( 'Product debug', 'bigcommerce' ), [ 306 'args' => $query_args, 307 ] ); 308 309 return $this->retrieve_rest_response( $posts, $request, $query_args, $posts_query, $channel_filter ); 224 310 } 225 311 … … 720 806 } 721 807 808 private function get_term_bc_id( $data ) { 809 $bc_ids = []; 810 foreach ( $data as $id ) { 811 $bc_id = get_term_meta( $id, 'bigcommerce_id', true ); 812 if ( empty( $bc_id ) ) { 813 continue; 814 } 815 816 $bc_ids[] = $bc_id; 817 } 818 819 return $bc_ids; 820 } 821 722 822 } -
bigcommerce/tags/5.0.2/src/BigCommerce/Rest/Rest_Controller.php
r2742415 r2887672 32 32 } 33 33 34 protected function parse_result( $response, $client ) {34 protected function parse_result( $response, $client, $rest_response = true ) { 35 35 $result['data'] = json_decode( '[' . $client->getSerializer()->serializeCollection( $response->getData(), 'multi' ) . ']' ); 36 36 $result['meta'] = json_decode( '[' . $response->getMeta()->__toString() . ']' ); … … 40 40 } 41 41 42 if ( ! $rest_response ) { 43 return $result['data']; 44 } 45 42 46 return rest_ensure_response( $result ); 43 47 } -
bigcommerce/tags/5.0.2/src/BigCommerce/Settings/Import_Status.php
r2742415 r2887672 137 137 } 138 138 139 $current_task = $this->get_current_task( $current['status'] ); 139 try { 140 $current_task = $this->get_current_task( $current['status'] ); 141 } catch ( \Throwable $exception ) { 142 $current_task = null; 143 $import_stuck = true; 144 } 145 146 if ( isset( $import_stuck ) ) { 147 $response_message = esc_attr__( 'Import has been stuck. Please abort current import and try again. Enable plugin logs and check any potential issues there', 'bigcommerce' ); 148 return [ 149 'message' => $response_message, 150 'status' => $current[ 'status' ], 151 'previous' => Status::FAILED, 152 'products' => [ 153 'total' => 0, 154 'completed' => 0, 155 'status' => $response_message, 156 ], 157 'aborted' => true, 158 ]; 159 } 160 140 161 141 162 $total = (int) get_option( self::IMPORT_TOTAL_PRODUCTS, 0 ); … … 230 251 'state' => $state, 231 252 ] ); 232 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [] ); 253 do_action( 'bigcommerce/log', Error_Log::DEBUG, __( 'Could not process the task', 'bigcommerce' ), [ 254 'code' => $e->getCode(), 255 'message' => $e->getMessage(), 256 'trace' => $e->getTraceAsString(), 257 ] ); 233 258 234 259 return null; -
bigcommerce/tags/5.0.2/src/BigCommerce/Settings/Sections/Analytics.php
r2722893 r2887672 6 6 7 7 use BigCommerce\Api\Store_Api; 8 use BigCommerce\Api\v3\Api\SettingsApi; 8 9 use BigCommerce\Settings\Screens\Settings_Screen; 10 use BigCommerce\Taxonomies\Channel\Channel; 11 use BigCommerce\Taxonomies\Channel\Connections; 9 12 10 13 class Analytics extends Settings_Section { … … 26 29 private $api; 27 30 28 public function __construct( Store_Api $api ) { 29 $this->api = $api; 31 /** 32 * @var SettingsApi 33 */ 34 private $api_v3; 35 36 public function __construct( Store_Api $api, SettingsApi $api_v3 ) { 37 $this->api = $api; 38 $this->api_v3 = $api_v3; 30 39 } 31 40 … … 149 158 return; 150 159 } 151 $settings = $this->api->get_analytics_settings(); 160 $connections = new Connections(); 161 $channel = $connections->current(); 162 $settings = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true ) ); 163 164 if ( empty( $settings ) || empty( $settings->data ) ) { 165 return; 166 } 167 168 $settings = json_decode( json_encode( $settings->data ), true ); 169 152 170 foreach ( $settings as &$account ) { 153 171 if ( $account['name'] == self::FACEBOOK_PIXEL_NAME ) { … … 173 191 return; 174 192 } 175 $settings = $this->api->get_analytics_settings(); 193 $connections = new Connections(); 194 $channel = $connections->current(); 195 $settings = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true ) ); 196 197 if ( empty( $settings ) || empty( $settings->data ) ) { 198 return; 199 } 200 201 $settings = json_decode( json_encode( $settings->data ), true ); 202 176 203 foreach ( $settings as &$account ) { 177 204 if ( $account['name'] == self::GOOGLE_ANALYTICS_NAME ) { -
bigcommerce/tags/5.0.2/src/BigCommerce/Templates/Product_Gallery.php
r2742415 r2887672 43 43 $size = Image_Sizes::BC_EXTRA_MEDIUM; 44 44 break; 45 case Customizer::SIZE_ORIGINAL: 46 $size = Image_Sizes::BC_CATEGORY_IMAGE; 47 break; 45 48 case Customizer::SIZE_DEFAULT: 46 49 default: … … 62 65 case Customizer::SIZE_LARGE: 63 66 $size = Image_Sizes::BC_THUMB_LARGE; 67 break; 68 case Customizer::SIZE_ORIGINAL: 69 $size = 'full'; 64 70 break; 65 71 case Customizer::SIZE_DEFAULT: -
bigcommerce/tags/5.0.2/src/BigCommerce/Templates/Product_Options.php
r2785458 r2887672 236 236 $size = Image_Sizes::BC_EXTRA_MEDIUM; 237 237 break; 238 case Customizer::SIZE_ORIGINAL: 239 $size = 'full'; 240 break; 238 241 case Customizer::SIZE_DEFAULT: 239 242 default: -
bigcommerce/tags/5.0.2/src/BigCommerce/Templates/Product_Sku.php
r2141486 r2887672 27 27 return [ 28 28 self::PRODUCT => $product, 29 self::SKU => $ product->sku(),29 self::SKU => $this->get_sku( $product ), 30 30 ]; 31 31 } 32 33 /** 34 * @param \BigCommerce\Post_Types\Product\Product $product 35 * 36 * @return string 37 */ 38 private function get_sku( Product $product ) { 39 $sku = $product->sku(); 40 41 if ( ! empty( $sku ) ) { 42 return $sku; 43 } 44 45 $data = $product->get_source_data(); 46 47 if ( empty( $data->variants ) ) { 48 return ''; 49 } 50 51 return $data->variants[0]->sku ?? ''; 52 } 32 53 } -
bigcommerce/tags/5.0.2/templates/admin/query-builder.php
r2342514 r2887672 12 12 */ 13 13 14 use BigCommerce\Import\Import_Type; 14 15 use BigCommerce\Taxonomies\Brand\Brand; 15 16 use BigCommerce\Taxonomies\Channel\Channel; … … 34 35 35 36 <ul class="bc-shortcode-ui__query-builder-list" data-js="bcqb-list"> 36 <li class="bc-shortcode-ui__query-builder-list-item"> 37 <a 38 href="#" 39 class="bc-shortcode-ui__query-builder-anchor" 40 data-key="recent" 41 data-value="1" 42 data-slug="<?php esc_html_e( 'recent', 'bigcommerce' ); ?>" 43 data-depth="0" 44 ><?php esc_html_e( 'Recent', 'bigcommerce' ); ?></a> 45 </li> 37 <?php if ( Import_Type::is_traditional_import() ) : ?> 38 <li class="bc-shortcode-ui__query-builder-list-item"> 39 <a 40 href="#" 41 class="bc-shortcode-ui__query-builder-anchor" 42 data-key="recent" 43 data-value="1" 44 data-slug="<?php esc_html_e( 'recent', 'bigcommerce' ); ?>" 45 data-depth="0" 46 ><?php esc_html_e( 'Recent', 'bigcommerce' ); ?></a> 47 </li> 48 <?php endif; ?> 46 49 <?php if ( $featured ) { ?> 47 50 <li class="bc-shortcode-ui__query-builder-list-item"> -
bigcommerce/tags/5.0.2/vendor/autoload.php
r2866539 r2887672 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65::getLoader();7 return ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff::getLoader(); -
bigcommerce/tags/5.0.2/vendor/composer/autoload_real.php
r2866539 r2887672 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd655 class ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit9f56a5c2911017136344a43be2570fff::getInitializer($loader)); 31 31 } else { 32 32 $classMap = require __DIR__ . '/autoload_classmap.php'; … … 40 40 41 41 if ($useStaticLoader) { 42 $includeFiles = Composer\Autoload\ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$files;42 $includeFiles = Composer\Autoload\ComposerStaticInit9f56a5c2911017136344a43be2570fff::$files; 43 43 } else { 44 44 $includeFiles = require __DIR__ . '/autoload_files.php'; 45 45 } 46 46 foreach ($includeFiles as $fileIdentifier => $file) { 47 composerRequire 3a8e1eb94f496d635fd89a7cc1cbcd65($fileIdentifier, $file);47 composerRequire9f56a5c2911017136344a43be2570fff($fileIdentifier, $file); 48 48 } 49 49 … … 52 52 } 53 53 54 function composerRequire 3a8e1eb94f496d635fd89a7cc1cbcd65($fileIdentifier, $file)54 function composerRequire9f56a5c2911017136344a43be2570fff($fileIdentifier, $file) 55 55 { 56 56 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
bigcommerce/tags/5.0.2/vendor/composer/autoload_static.php
r2866539 r2887672 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd657 class ComposerStaticInit9f56a5c2911017136344a43be2570fff 8 8 { 9 9 public static $files = array ( … … 1185 1185 { 1186 1186 return \Closure::bind(function () use ($loader) { 1187 $loader->prefixLengthsPsr4 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixLengthsPsr4;1188 $loader->prefixDirsPsr4 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixDirsPsr4;1189 $loader->prefixesPsr0 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixesPsr0;1190 $loader->classMap = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$classMap;1187 $loader->prefixLengthsPsr4 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixLengthsPsr4; 1188 $loader->prefixDirsPsr4 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixDirsPsr4; 1189 $loader->prefixesPsr0 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixesPsr0; 1190 $loader->classMap = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$classMap; 1191 1191 1192 1192 }, null, ClassLoader::class); -
bigcommerce/tags/5.0.2/vendor/composer/installed.json
r2865940 r2887672 121 121 { 122 122 "name": "moderntribe/bigcommerce-api-php-v3", 123 "version": "v2.3. 3",124 "version_normalized": "2.3. 3.0",123 "version": "v2.3.4", 124 "version_normalized": "2.3.4.0", 125 125 "source": { 126 126 "type": "git", 127 127 "url": "git@github.com:moderntribe/bigcommerce-api-php-v3.git", 128 "reference": " 860eb3be09c623dc0c8b53f506abed72a882f399"129 }, 130 "dist": { 131 "type": "zip", 132 "url": "https://api.github.com/repos/moderntribe/bigcommerce-api-php-v3/zipball/ 860eb3be09c623dc0c8b53f506abed72a882f399",133 "reference": " 860eb3be09c623dc0c8b53f506abed72a882f399",128 "reference": "054f0c7bc188560bdcad24c7ace908def11a5c9e" 129 }, 130 "dist": { 131 "type": "zip", 132 "url": "https://api.github.com/repos/moderntribe/bigcommerce-api-php-v3/zipball/054f0c7bc188560bdcad24c7ace908def11a5c9e", 133 "reference": "054f0c7bc188560bdcad24c7ace908def11a5c9e", 134 134 "shasum": "" 135 135 }, … … 145 145 "squizlabs/php_codesniffer": "~2.6" 146 146 }, 147 "time": "202 2-08-17T17:15:47+00:00",147 "time": "2023-03-15T21:18:15+00:00", 148 148 "type": "library", 149 149 "installation-source": "dist", -
bigcommerce/tags/5.0.2/vendor/moderntribe/bigcommerce-api-php-v3/src/Api/SettingsApi.php
r2865940 r2887672 110 110 return $response; 111 111 } 112 113 public function getStoreAnalyticsSettings( $channel_id = 0 ) { 114 list( $response ) = $this->getStorefrontHttpInfo( '/settings/analytics', $channel_id ); 115 116 return $response; 117 } 112 118 113 119 /** -
bigcommerce/trunk/CHANGELOG.md
r2866539 r2887672 1 1 # Changelog 2 3 ## [5.0.2] 4 5 ### Added 6 - Add ability to use original image proportion on product single page. Go to Apperance → Bigcommerce → Product Single and change image size to original. 7 8 ### Changed 9 - Show variant SKU if product SKU is not added or missing 10 11 ### Fixed 12 - Prevent import fail on Analytics Settings retrieval due to outdated API use 13 - Fix search issue with product widget block while using fast(headless) import. Allow searching by SKU, name 2 14 3 15 ## [5.0.1] … … 1878 1890 1879 1891 1892 [5.0.2]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/5.0.1...5.0.2 1880 1893 [5.0.1]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/5.0.0...5.0.1 1881 1894 [5.0.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.37.0...5.0.0 -
bigcommerce/trunk/bigcommerce.php
r2866539 r2887672 4 4 Description: Scale your ecommerce business with WordPress on the front-end and BigCommerce on the back end. Free up server resources from things like catalog management, processing payments, and managing fulfillment logistics. 5 5 Author: BigCommerce 6 Version: 5.0. 16 Version: 5.0.2 7 7 Author URI: https://www.bigcommerce.com/wordpress 8 8 Requires PHP: 7.4.0 -
bigcommerce/trunk/build-timestamp.php
r2866539 r2887672 1 1 <?php 2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', ' 4.11.02.16.2023');2 define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.41.03.24.2023'); -
bigcommerce/trunk/readme.txt
r2866539 r2887672 4 4 Requires at least: 5.2 5 5 Tested up to: 6.0.3 6 Stable tag: 5.0. 16 Stable tag: 5.0.2 7 7 Requires PHP: 7.4.0 8 8 License: GPLv2 or later -
bigcommerce/trunk/src/BigCommerce/Api/Store_Api.php
r2626896 r2887672 102 102 try { 103 103 $settings = $this->getCollection( '/settings/analytics' ); 104 105 if ( empty( $settings ) ) { 106 return []; 107 } 104 108 $settings = array_map( function ( Resource $resource ) { 105 109 return get_object_vars( $resource->getUpdateFields() ); 106 110 }, $settings ); 107 } catch ( \ Exception$e ) {111 } catch ( \Throwable $e ) { 108 112 $settings = []; 109 113 } -
bigcommerce/trunk/src/BigCommerce/Container/Import.php
r2865940 r2887672 235 235 236 236 $container[ self::STORE ] = function ( Container $container ) { 237 return new Processors\Store_Settings( $container[ Api::FACTORY ]->store(), $container[ self::CUSTOMER_DEFAULT_GROUP ], $container[ self::MSF_STOREFRONT_PROCESSOR ] );237 return new Processors\Store_Settings( $container[ Api::FACTORY ]->store(), $container[ self::CUSTOMER_DEFAULT_GROUP ], $container[ self::MSF_STOREFRONT_PROCESSOR ], $container[ Api::FACTORY ]->storefront_settings() ); 238 238 }; 239 239 -
bigcommerce/trunk/src/BigCommerce/Container/Settings.php
r2742415 r2887672 441 441 private function analytics( Container $container ) { 442 442 $container[ self::ANALYTICS_SECTION ] = function ( Container $container ) { 443 return new Analytics_Settings( $container[ Api::FACTORY ]->store() );443 return new Analytics_Settings( $container[ Api::FACTORY ]->store(), $container[ Api::FACTORY ]->storefront_settings() ); 444 444 }; 445 445 -
bigcommerce/trunk/src/BigCommerce/Customizer/Sections/Product_Single.php
r2826745 r2887672 22 22 const SIZE_DEFAULT = 'default'; 23 23 const SIZE_LARGE = 'large'; 24 const SIZE_ORIGINAL = 'original'; 24 25 const SIZE_CDN_STD = 'standard'; 25 26 const SIZE_CDN_THUMB = 'thumbnail'; … … 96 97 'label' => __( 'Image Gallery Size', 'bigcommerce' ), 97 98 'choices' => [ 98 self::SIZE_DEFAULT => __( 'Default', 'bigcommerce' ), 99 self::SIZE_LARGE => __( 'Large', 'bigcommerce' ), 99 self::SIZE_DEFAULT => __( 'Default', 'bigcommerce' ), 100 self::SIZE_LARGE => __( 'Large', 'bigcommerce' ), 101 self::SIZE_ORIGINAL => __( 'Original', 'bigcommerce' ), 100 102 ], 101 103 ] ); -
bigcommerce/trunk/src/BigCommerce/Editor/Editor_Dialog_Template.php
r2108438 r2887672 6 6 use BigCommerce\Customizer\Sections\Product_Archive; 7 7 use BigCommerce\Exceptions\Channel_Not_Found_Exception; 8 use BigCommerce\Import\Import_Type; 8 9 use BigCommerce\Rest\Products_Controller; 9 10 use BigCommerce\Rest\Shortcode_Controller; … … 105 106 return $this->render_template( 'query-builder.php', [ 106 107 'featured' => $featured, 107 'sale' => $sale,108 'sale' => Import_Type::is_traditional_import() && $sale, 108 109 'brands' => $brand_choices, 109 110 'categories' => $category_choices, -
bigcommerce/trunk/src/BigCommerce/Import/Processors/Store_Settings.php
r2865940 r2887672 7 7 use Bigcommerce\Api\Client; 8 8 use BigCommerce\Api\Store_Api; 9 use BigCommerce\Api\v3\Api\SettingsApi; 9 10 use BigCommerce\Api\v3\ApiException; 10 11 use BigCommerce\Import\Runner\Status; … … 12 13 use BigCommerce\Post_Types\Product\Product; 13 14 use BigCommerce\Settings; 15 use BigCommerce\Taxonomies\Channel\Channel; 16 use BigCommerce\Taxonomies\Channel\Connections; 14 17 15 18 class Store_Settings implements Import_Processor { … … 40 43 private $storefront_processor; 41 44 42 public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor ) { 45 /** 46 * @var \BigCommerce\Api\v3\Api\SettingsApi 47 */ 48 private $api_v3; 49 50 public function __construct( Store_Api $store_api, Default_Customer_Group $default_customer_group, Storefront_Processor $storefront_processor, SettingsApi $api ) { 43 51 $this->store_api = $store_api; 52 $this->api_v3 = $api; 44 53 $this->default_customer_group = $default_customer_group; 45 54 $this->storefront_processor = $storefront_processor; … … 76 85 77 86 if ( get_option( Settings\Sections\Analytics::SYNC_ANALYTICS, 1 ) ) { 78 $analytics = $this->store_api->get_analytics_settings(); 79 $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); 80 $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); 87 $connections = new Connections(); 88 $channel = $connections->current(); 89 $analytics = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true )); 90 91 if ( ! empty( $analytics->data ) ) { 92 $analytics = json_decode( json_encode( $analytics->data ), true ); 93 $settings[ Settings\Sections\Analytics::FACEBOOK_PIXEL ] = $this->extract_facebook_pixel_id( $analytics ); 94 $settings[ Settings\Sections\Analytics::GOOGLE_ANALYTICS ] = $this->extract_google_analytics_id( $analytics ); 95 } 96 81 97 } 82 98 -
bigcommerce/trunk/src/BigCommerce/Import/Task_Manager.php
r2860929 r2887672 101 101 do_action( 'bigcommerce/log', Error_Log::NOTICE, __( 'No handler found for current import state', 'bigcommerce' ), [ 102 102 'state' => $state, 103 'import' => Import_Type::is_traditional_import() ? 'full' : 'headless', 103 104 ] ); 104 105 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [] ); -
bigcommerce/trunk/src/BigCommerce/Plugin.php
r2866539 r2887672 5 5 6 6 class Plugin { 7 const VERSION = '5.0. 1';7 const VERSION = '5.0.2'; 8 8 9 9 protected static $_instance; -
bigcommerce/trunk/src/BigCommerce/Rest/Products_Controller.php
r2742415 r2887672 70 70 71 71 protected function get_items_headless( $request ) { 72 $container = bigcommerce()->container(); 73 74 if ( ! empty( $request['slug'] ) ) { 75 return $this->get_items_graphql( $container, $request ); 72 $container = bigcommerce()->container(); 73 $request_data = $request->get_params(); 74 75 if ( ! empty( $request_data['slug'] ) ) { 76 return $this->get_items_graphql( $container, $request_data ); 76 77 } 77 78 … … 81 82 try { 82 83 $params = [ 83 'page' => $request['page'],84 'limit' => $request['per_page'],85 'include' => [ 'variants', 'custom_fields', 'images', 'bulk_pricing_rules', 'options', 'modifiers' ],84 'page' => $request_data['page'], 85 'limit' => $request_data['per_page'], 86 'include' => [ 'variants', 'custom_fields', 'images', 'bulk_pricing_rules', 'options', 'modifiers' ], 86 87 ]; 87 88 88 if ( ! empty( $request['bigcommerce_brand'] ) ) { 89 $params['brand_id'] = $request['bigcommerce_brand']; 90 } 91 92 if ( ! empty( $request['bigcommerce_category'] ) ) { 93 $params['categories:in'] = $request['bigcommerce_category']; 94 } 95 96 if ( ! empty( $request['bcid'] ) ) { 97 $params['id'] = $request['bcid']; 89 if ( ! empty( $request_data['bigcommerce_brand'] ) ) { 90 $params['brand_id'] = $this->get_term_bc_id( $request_data['bigcommerce_brand'] ); 91 } 92 93 if ( ! empty( $request_data['bigcommerce_flag'] ) ) { 94 $term_ids = $request_data['bigcommerce_flag']; 95 96 97 foreach ( $term_ids as $id ) { 98 $flag = get_term( $id, Flag::NAME ); 99 100 if ( empty( $flag ) || is_wp_error( $flag ) ) { 101 continue; 102 } 103 104 if ( $flag->name === Flag::FEATURED ) { 105 $params['is_featured'] = 1; 106 } 107 } 108 109 } 110 111 if ( ! empty( $request_data['bigcommerce_category'] ) ) { 112 $params['categories:in'] = $this->get_term_bc_id( $request_data['bigcommerce_category'] ); 113 } 114 115 if ( ! empty( $request_data['bcid'] ) ) { 116 $params['id'] = $request_data['bcid']; 117 } 118 119 if ( ! empty( $request_data['search'] ) ) { 120 $params['keyword'] = $request_data['search']; 98 121 } 99 122 100 123 $response = $catalog->getProducts( $params ); 101 124 102 return $this->parse_result( $response, $client ); 125 $result = $this->parse_result( $response, $client, false ); 126 if ( empty( $result ) ) { 127 return rest_ensure_response( [] ); 128 } 129 130 return $this->convert_to_wp_response( $request, $result ); 103 131 } catch ( ApiException $e ) { 104 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [ 'request' => $request ], 'rest' );132 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [ 'request' => $request_data ], 'rest' ); 105 133 106 134 $error = new \WP_Error( 'api_error', sprintf( … … 111 139 return $error; 112 140 } 141 } 142 143 private function convert_to_wp_response( $request, $result ) { 144 $mapper = new Query_Mapper(); 145 $args = $mapper->map_rest_args_to_query( $request->get_params() ); 146 147 // We don't have required data in WP db. Instead, we will use result from remote 148 if ( ! empty( $args['s'] ) ) { 149 unset( $args['s'] ); 150 } 151 $args['bigcommerce_id__in'] = []; 152 153 array_walk( $result, function ( $item ) use ( &$args ) { 154 if ( empty( $item ) ) { 155 return; 156 } 157 158 $args['bigcommerce_id__in'][] = $item->id; 159 } ); 160 161 $args['post_type'] = Product::NAME; 162 $args['post_status'] = 'publish'; 163 $args['posts_per_page'] = 12; 164 if ( ! empty( $args['bigcommerce_id__in'] ) ) { 165 $args['posts_per_page'] = - 1; 166 } 167 168 $posts_query = new \WP_Query(); 169 $query_result = $posts_query->query( $args ); 170 $posts = []; 171 172 foreach ( $query_result as $post_id ) { 173 $bcid = get_post_meta( $post_id, Product::BIGCOMMERCE_ID, true ); 174 $data = $this->prepare_item_for_response( get_post( $post_id ), $request ); 175 // ensure that we only have one result per BCID, no matter how many channels it's in 176 $posts[ $bcid ] = $this->prepare_response_for_collection( $data ); 177 } 178 179 return $this->retrieve_rest_response( $posts, $request, $args, $posts_query, null, true ); 180 } 181 182 /** 183 * @param $posts 184 * @param $request 185 * @param $query_args 186 * @param $posts_query 187 * @param null $channel_filter 188 * @param bool $always_fetch 189 * 190 * @return \WP_Error|\WP_HTTP_Response|\WP_REST_Response 191 */ 192 private function retrieve_rest_response( $posts, $request, $query_args, $posts_query, $channel_filter = null, $always_fetch = false ) { 193 $page = (int) $query_args['paged']; 194 $total_posts = $posts_query->found_posts; 195 196 if ( $total_posts < 1 ) { 197 // Out-of-bounds, run the query again without LIMIT for total count. 198 unset( $query_args['paged'] ); 199 200 $count_query = new \WP_Query(); 201 $count_query->query( $query_args ); 202 $total_posts = $count_query->found_posts; 203 } 204 205 if ( $channel_filter ) { 206 remove_action( 'pre_get_posts', $channel_filter, 9 ); 207 } 208 209 if ( $posts_query->query_vars['posts_per_page'] === - 1 ) { 210 $max_pages = 1; 211 } else { 212 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 213 } 214 215 if ( $page > $max_pages && $total_posts > 0 && ! $always_fetch ) { 216 return new \WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.', 'bigcommerce' ), [ 'status' => 400 ] ); 217 } 218 219 $response = rest_ensure_response( array_values( $posts ) ); 220 221 $response->header( 'X-WP-Total', (int) $total_posts ); 222 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 223 224 $request_params = $request->get_query_params(); 225 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 226 227 if ( $page > 1 ) { 228 $prev_page = $page - 1; 229 230 if ( $prev_page > $max_pages ) { 231 $prev_page = $max_pages; 232 } 233 234 $prev_link = add_query_arg( 'page', $prev_page, $base ); 235 $response->link_header( 'prev', $prev_link ); 236 } 237 if ( $max_pages > $page || $always_fetch ) { 238 $next_page = $page + 1; 239 $next_link = add_query_arg( 'page', $next_page, $base ); 240 241 $response->link_header( 'next', $next_link ); 242 } 243 244 return $response; 113 245 } 114 246 … … 137 269 138 270 if ( ! Import_Type::is_traditional_import() ) { 139 return $this->get_items_headless( $request _data);271 return $this->get_items_headless( $request ); 140 272 } 141 273 $mapper = new Query_Mapper(); … … 171 303 $posts[ $bcid ] = $this->prepare_response_for_collection( $data ); 172 304 } 173 174 $page = (int) $query_args['paged']; 175 $total_posts = $posts_query->found_posts; 176 177 if ( $total_posts < 1 ) { 178 // Out-of-bounds, run the query again without LIMIT for total count. 179 unset( $query_args['paged'] ); 180 181 $count_query = new \WP_Query(); 182 $count_query->query( $query_args ); 183 $total_posts = $count_query->found_posts; 184 } 185 186 remove_action( 'pre_get_posts', $channel_filter, 9 ); 187 188 if ( $posts_query->query_vars['posts_per_page'] === - 1 ) { 189 $max_pages = 1; 190 } else { 191 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 192 } 193 194 if ( $page > $max_pages && $total_posts > 0 ) { 195 return new \WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.', 'bigcommerce' ), [ 'status' => 400 ] ); 196 } 197 198 $response = rest_ensure_response( array_values( $posts ) ); 199 200 $response->header( 'X-WP-Total', (int) $total_posts ); 201 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 202 203 $request_params = $request->get_query_params(); 204 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 205 206 if ( $page > 1 ) { 207 $prev_page = $page - 1; 208 209 if ( $prev_page > $max_pages ) { 210 $prev_page = $max_pages; 211 } 212 213 $prev_link = add_query_arg( 'page', $prev_page, $base ); 214 $response->link_header( 'prev', $prev_link ); 215 } 216 if ( $max_pages > $page ) { 217 $next_page = $page + 1; 218 $next_link = add_query_arg( 'page', $next_page, $base ); 219 220 $response->link_header( 'next', $next_link ); 221 } 222 223 return $response; 305 do_action( 'bigcommerce/log', Error_Log::ERROR, __( 'Product debug', 'bigcommerce' ), [ 306 'args' => $query_args, 307 ] ); 308 309 return $this->retrieve_rest_response( $posts, $request, $query_args, $posts_query, $channel_filter ); 224 310 } 225 311 … … 720 806 } 721 807 808 private function get_term_bc_id( $data ) { 809 $bc_ids = []; 810 foreach ( $data as $id ) { 811 $bc_id = get_term_meta( $id, 'bigcommerce_id', true ); 812 if ( empty( $bc_id ) ) { 813 continue; 814 } 815 816 $bc_ids[] = $bc_id; 817 } 818 819 return $bc_ids; 820 } 821 722 822 } -
bigcommerce/trunk/src/BigCommerce/Rest/Rest_Controller.php
r2742415 r2887672 32 32 } 33 33 34 protected function parse_result( $response, $client ) {34 protected function parse_result( $response, $client, $rest_response = true ) { 35 35 $result['data'] = json_decode( '[' . $client->getSerializer()->serializeCollection( $response->getData(), 'multi' ) . ']' ); 36 36 $result['meta'] = json_decode( '[' . $response->getMeta()->__toString() . ']' ); … … 40 40 } 41 41 42 if ( ! $rest_response ) { 43 return $result['data']; 44 } 45 42 46 return rest_ensure_response( $result ); 43 47 } -
bigcommerce/trunk/src/BigCommerce/Settings/Import_Status.php
r2742415 r2887672 137 137 } 138 138 139 $current_task = $this->get_current_task( $current['status'] ); 139 try { 140 $current_task = $this->get_current_task( $current['status'] ); 141 } catch ( \Throwable $exception ) { 142 $current_task = null; 143 $import_stuck = true; 144 } 145 146 if ( isset( $import_stuck ) ) { 147 $response_message = esc_attr__( 'Import has been stuck. Please abort current import and try again. Enable plugin logs and check any potential issues there', 'bigcommerce' ); 148 return [ 149 'message' => $response_message, 150 'status' => $current[ 'status' ], 151 'previous' => Status::FAILED, 152 'products' => [ 153 'total' => 0, 154 'completed' => 0, 155 'status' => $response_message, 156 ], 157 'aborted' => true, 158 ]; 159 } 160 140 161 141 162 $total = (int) get_option( self::IMPORT_TOTAL_PRODUCTS, 0 ); … … 230 251 'state' => $state, 231 252 ] ); 232 do_action( 'bigcommerce/log', Error_Log::DEBUG, $e->getTraceAsString(), [] ); 253 do_action( 'bigcommerce/log', Error_Log::DEBUG, __( 'Could not process the task', 'bigcommerce' ), [ 254 'code' => $e->getCode(), 255 'message' => $e->getMessage(), 256 'trace' => $e->getTraceAsString(), 257 ] ); 233 258 234 259 return null; -
bigcommerce/trunk/src/BigCommerce/Settings/Sections/Analytics.php
r2722893 r2887672 6 6 7 7 use BigCommerce\Api\Store_Api; 8 use BigCommerce\Api\v3\Api\SettingsApi; 8 9 use BigCommerce\Settings\Screens\Settings_Screen; 10 use BigCommerce\Taxonomies\Channel\Channel; 11 use BigCommerce\Taxonomies\Channel\Connections; 9 12 10 13 class Analytics extends Settings_Section { … … 26 29 private $api; 27 30 28 public function __construct( Store_Api $api ) { 29 $this->api = $api; 31 /** 32 * @var SettingsApi 33 */ 34 private $api_v3; 35 36 public function __construct( Store_Api $api, SettingsApi $api_v3 ) { 37 $this->api = $api; 38 $this->api_v3 = $api_v3; 30 39 } 31 40 … … 149 158 return; 150 159 } 151 $settings = $this->api->get_analytics_settings(); 160 $connections = new Connections(); 161 $channel = $connections->current(); 162 $settings = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true ) ); 163 164 if ( empty( $settings ) || empty( $settings->data ) ) { 165 return; 166 } 167 168 $settings = json_decode( json_encode( $settings->data ), true ); 169 152 170 foreach ( $settings as &$account ) { 153 171 if ( $account['name'] == self::FACEBOOK_PIXEL_NAME ) { … … 173 191 return; 174 192 } 175 $settings = $this->api->get_analytics_settings(); 193 $connections = new Connections(); 194 $channel = $connections->current(); 195 $settings = $this->api_v3->getStoreAnalyticsSettings( (int) get_term_meta( $channel->term_id, Channel::CHANNEL_ID, true ) ); 196 197 if ( empty( $settings ) || empty( $settings->data ) ) { 198 return; 199 } 200 201 $settings = json_decode( json_encode( $settings->data ), true ); 202 176 203 foreach ( $settings as &$account ) { 177 204 if ( $account['name'] == self::GOOGLE_ANALYTICS_NAME ) { -
bigcommerce/trunk/src/BigCommerce/Templates/Product_Gallery.php
r2742415 r2887672 43 43 $size = Image_Sizes::BC_EXTRA_MEDIUM; 44 44 break; 45 case Customizer::SIZE_ORIGINAL: 46 $size = Image_Sizes::BC_CATEGORY_IMAGE; 47 break; 45 48 case Customizer::SIZE_DEFAULT: 46 49 default: … … 62 65 case Customizer::SIZE_LARGE: 63 66 $size = Image_Sizes::BC_THUMB_LARGE; 67 break; 68 case Customizer::SIZE_ORIGINAL: 69 $size = 'full'; 64 70 break; 65 71 case Customizer::SIZE_DEFAULT: -
bigcommerce/trunk/src/BigCommerce/Templates/Product_Options.php
r2785458 r2887672 236 236 $size = Image_Sizes::BC_EXTRA_MEDIUM; 237 237 break; 238 case Customizer::SIZE_ORIGINAL: 239 $size = 'full'; 240 break; 238 241 case Customizer::SIZE_DEFAULT: 239 242 default: -
bigcommerce/trunk/src/BigCommerce/Templates/Product_Sku.php
r2141486 r2887672 27 27 return [ 28 28 self::PRODUCT => $product, 29 self::SKU => $ product->sku(),29 self::SKU => $this->get_sku( $product ), 30 30 ]; 31 31 } 32 33 /** 34 * @param \BigCommerce\Post_Types\Product\Product $product 35 * 36 * @return string 37 */ 38 private function get_sku( Product $product ) { 39 $sku = $product->sku(); 40 41 if ( ! empty( $sku ) ) { 42 return $sku; 43 } 44 45 $data = $product->get_source_data(); 46 47 if ( empty( $data->variants ) ) { 48 return ''; 49 } 50 51 return $data->variants[0]->sku ?? ''; 52 } 32 53 } -
bigcommerce/trunk/templates/admin/query-builder.php
r2342514 r2887672 12 12 */ 13 13 14 use BigCommerce\Import\Import_Type; 14 15 use BigCommerce\Taxonomies\Brand\Brand; 15 16 use BigCommerce\Taxonomies\Channel\Channel; … … 34 35 35 36 <ul class="bc-shortcode-ui__query-builder-list" data-js="bcqb-list"> 36 <li class="bc-shortcode-ui__query-builder-list-item"> 37 <a 38 href="#" 39 class="bc-shortcode-ui__query-builder-anchor" 40 data-key="recent" 41 data-value="1" 42 data-slug="<?php esc_html_e( 'recent', 'bigcommerce' ); ?>" 43 data-depth="0" 44 ><?php esc_html_e( 'Recent', 'bigcommerce' ); ?></a> 45 </li> 37 <?php if ( Import_Type::is_traditional_import() ) : ?> 38 <li class="bc-shortcode-ui__query-builder-list-item"> 39 <a 40 href="#" 41 class="bc-shortcode-ui__query-builder-anchor" 42 data-key="recent" 43 data-value="1" 44 data-slug="<?php esc_html_e( 'recent', 'bigcommerce' ); ?>" 45 data-depth="0" 46 ><?php esc_html_e( 'Recent', 'bigcommerce' ); ?></a> 47 </li> 48 <?php endif; ?> 46 49 <?php if ( $featured ) { ?> 47 50 <li class="bc-shortcode-ui__query-builder-list-item"> -
bigcommerce/trunk/vendor/autoload.php
r2866539 r2887672 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65::getLoader();7 return ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff::getLoader(); -
bigcommerce/trunk/vendor/composer/autoload_real.php
r2866539 r2887672 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd655 class ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit 3a8e1eb94f496d635fd89a7cc1cbcd65', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInit9f56a5c2911017136344a43be2570fff', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit9f56a5c2911017136344a43be2570fff::getInitializer($loader)); 31 31 } else { 32 32 $classMap = require __DIR__ . '/autoload_classmap.php'; … … 40 40 41 41 if ($useStaticLoader) { 42 $includeFiles = Composer\Autoload\ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$files;42 $includeFiles = Composer\Autoload\ComposerStaticInit9f56a5c2911017136344a43be2570fff::$files; 43 43 } else { 44 44 $includeFiles = require __DIR__ . '/autoload_files.php'; 45 45 } 46 46 foreach ($includeFiles as $fileIdentifier => $file) { 47 composerRequire 3a8e1eb94f496d635fd89a7cc1cbcd65($fileIdentifier, $file);47 composerRequire9f56a5c2911017136344a43be2570fff($fileIdentifier, $file); 48 48 } 49 49 … … 52 52 } 53 53 54 function composerRequire 3a8e1eb94f496d635fd89a7cc1cbcd65($fileIdentifier, $file)54 function composerRequire9f56a5c2911017136344a43be2570fff($fileIdentifier, $file) 55 55 { 56 56 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
bigcommerce/trunk/vendor/composer/autoload_static.php
r2866539 r2887672 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd657 class ComposerStaticInit9f56a5c2911017136344a43be2570fff 8 8 { 9 9 public static $files = array ( … … 1185 1185 { 1186 1186 return \Closure::bind(function () use ($loader) { 1187 $loader->prefixLengthsPsr4 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixLengthsPsr4;1188 $loader->prefixDirsPsr4 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixDirsPsr4;1189 $loader->prefixesPsr0 = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$prefixesPsr0;1190 $loader->classMap = ComposerStaticInit 3a8e1eb94f496d635fd89a7cc1cbcd65::$classMap;1187 $loader->prefixLengthsPsr4 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixLengthsPsr4; 1188 $loader->prefixDirsPsr4 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixDirsPsr4; 1189 $loader->prefixesPsr0 = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$prefixesPsr0; 1190 $loader->classMap = ComposerStaticInit9f56a5c2911017136344a43be2570fff::$classMap; 1191 1191 1192 1192 }, null, ClassLoader::class); -
bigcommerce/trunk/vendor/composer/installed.json
r2865940 r2887672 121 121 { 122 122 "name": "moderntribe/bigcommerce-api-php-v3", 123 "version": "v2.3. 3",124 "version_normalized": "2.3. 3.0",123 "version": "v2.3.4", 124 "version_normalized": "2.3.4.0", 125 125 "source": { 126 126 "type": "git", 127 127 "url": "git@github.com:moderntribe/bigcommerce-api-php-v3.git", 128 "reference": " 860eb3be09c623dc0c8b53f506abed72a882f399"129 }, 130 "dist": { 131 "type": "zip", 132 "url": "https://api.github.com/repos/moderntribe/bigcommerce-api-php-v3/zipball/ 860eb3be09c623dc0c8b53f506abed72a882f399",133 "reference": " 860eb3be09c623dc0c8b53f506abed72a882f399",128 "reference": "054f0c7bc188560bdcad24c7ace908def11a5c9e" 129 }, 130 "dist": { 131 "type": "zip", 132 "url": "https://api.github.com/repos/moderntribe/bigcommerce-api-php-v3/zipball/054f0c7bc188560bdcad24c7ace908def11a5c9e", 133 "reference": "054f0c7bc188560bdcad24c7ace908def11a5c9e", 134 134 "shasum": "" 135 135 }, … … 145 145 "squizlabs/php_codesniffer": "~2.6" 146 146 }, 147 "time": "202 2-08-17T17:15:47+00:00",147 "time": "2023-03-15T21:18:15+00:00", 148 148 "type": "library", 149 149 "installation-source": "dist", -
bigcommerce/trunk/vendor/moderntribe/bigcommerce-api-php-v3/src/Api/SettingsApi.php
r2865940 r2887672 110 110 return $response; 111 111 } 112 113 public function getStoreAnalyticsSettings( $channel_id = 0 ) { 114 list( $response ) = $this->getStorefrontHttpInfo( '/settings/analytics', $channel_id ); 115 116 return $response; 117 } 112 118 113 119 /**
Note: See TracChangeset
for help on using the changeset viewer.