From 2857a4aea13cf486f6e2dac149f60218ae85d9ef Mon Sep 17 00:00:00 2001 From: meteor Date: Wed, 17 Jul 2024 18:53:17 +0400 Subject: [PATCH 1/8] PLUGINS-6916 --- lib/ecwid_api_v3.php | 66 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/lib/ecwid_api_v3.php b/lib/ecwid_api_v3.php index 37675d6e..40b3fbd8 100644 --- a/lib/ecwid_api_v3.php +++ b/lib/ecwid_api_v3.php @@ -188,6 +188,10 @@ public function get_categories( $input_params ) { $result = EcwidPlatform::get_from_categories_cache( $url ); if ( ! $result ) { + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( $result['code'] != '200' ) { @@ -262,6 +266,10 @@ public function get_category( $category_id ) { $result = EcwidPlatform::get_from_categories_cache( $url ); if ( ! $result ) { + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( $result['code'] != '200' ) { @@ -316,6 +324,10 @@ public function get_product( $product_id ) { $result = EcwidPlatform::get_from_products_cache( $url ); if ( ! $result ) { + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( $result['code'] != '200' ) { @@ -364,7 +376,12 @@ public function search_products( $input_params ) { $result = EcwidPlatform::get_from_products_cache( $url ); if ( ! $result ) { + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); + if ( $result['code'] != '200' ) { return false; } @@ -410,6 +427,10 @@ public function get_deleted_products( $input_params ) { $params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( $result['code'] != '200' ) { @@ -444,6 +465,10 @@ public function get_products( $input_params ) { $params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( $result['code'] != '200' ) { @@ -478,6 +503,14 @@ protected static function _load_token() { return $token; } + public static function get_public_token() { + if ( ecwid_is_demo_store() ) { + return ecwid_get_demo_store_public_key(); + } + + return get_option( 'ecwid_public_token', false ); + } + public static function get_token() { if ( ecwid_is_demo_store() ) { return ecwid_get_demo_store_public_key(); @@ -568,6 +601,10 @@ public function get_store_update_stats( $additional_params = false ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $url, $params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( ! isset( $result['data'] ) ) { @@ -607,6 +644,10 @@ public function get_store_profile( $disable_cache = false ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_profile_api_url, $params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( @$result['code'] == '403' ) { @@ -821,11 +862,18 @@ protected function build_request_url( $url, $input_params ) { } protected function build_request_headers() { - $headers = array( - 'headers' => array( - 'Authorization' => 'Bearer ' . self::get_token(), - ), - ); + $headers = array(); + $token = self::get_token(); + + if ( empty( $token ) ) { + $token = self::get_public_token(); + } + + if ( ! empty( $token ) ) { + $headers['headers'] = array( + 'Authorization' => 'Bearer ' . $token, + ); + } return $headers; } @@ -988,6 +1036,10 @@ public function get_starter_site_info() { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_starter_site_api_url, $request_params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( ! isset( $result['data'] ) ) { @@ -1102,6 +1154,10 @@ public function get_batch_status( $ticket ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_batch_requests_api_url, $params ); + if ( empty( $options['Authorization'] ) ) { + return false; + } + $result = EcwidPlatform::fetch_url( $url, $options ); if ( @$result['code'] != '200' ) { From 80da6a9be9631bbdf1a06ca18f69cfeb4d131d86 Mon Sep 17 00:00:00 2001 From: meteor Date: Wed, 17 Jul 2024 19:04:53 +0400 Subject: [PATCH 2/8] PLUGINS-6916 --- lib/ecwid_api_v3.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/ecwid_api_v3.php b/lib/ecwid_api_v3.php index 40b3fbd8..fc6b9b08 100644 --- a/lib/ecwid_api_v3.php +++ b/lib/ecwid_api_v3.php @@ -865,10 +865,6 @@ protected function build_request_headers() { $headers = array(); $token = self::get_token(); - if ( empty( $token ) ) { - $token = self::get_public_token(); - } - if ( ! empty( $token ) ) { $headers['headers'] = array( 'Authorization' => 'Bearer ' . $token, From 86491c7d1161330f5bec85ff4ff96d44cfacb7e8 Mon Sep 17 00:00:00 2001 From: meteor Date: Wed, 17 Jul 2024 19:06:17 +0400 Subject: [PATCH 3/8] PLUGINS-6916 --- lib/ecwid_api_v3.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/ecwid_api_v3.php b/lib/ecwid_api_v3.php index fc6b9b08..87614dd8 100644 --- a/lib/ecwid_api_v3.php +++ b/lib/ecwid_api_v3.php @@ -503,14 +503,6 @@ protected static function _load_token() { return $token; } - public static function get_public_token() { - if ( ecwid_is_demo_store() ) { - return ecwid_get_demo_store_public_key(); - } - - return get_option( 'ecwid_public_token', false ); - } - public static function get_token() { if ( ecwid_is_demo_store() ) { return ecwid_get_demo_store_public_key(); From 0ec87d8e63233e096bc53a8ea3a55e25cbbaded2 Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov <47570955+meteor-ec@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:40:16 +0400 Subject: [PATCH 4/8] Create build-zip.yml --- .github/workflows/build-zip.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/build-zip.yml diff --git a/.github/workflows/build-zip.yml b/.github/workflows/build-zip.yml new file mode 100644 index 00000000..206bda73 --- /dev/null +++ b/.github/workflows/build-zip.yml @@ -0,0 +1,20 @@ +name: Build release zip + +on: + workflow_dispatch + +jobs: + build: + name: Build release zip + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Generate zip + uses: 10up/action-wordpress-plugin-build-zip@stable + env: + SLUG: ecwid-shopping-cart + + - name: Output artifact URL + run: echo 'Artifact URL is ${{ steps.upload-plugin-artifact.outputs.artifact-url }}' From de53c0d706536d68c82116ce23117a409e1b29be Mon Sep 17 00:00:00 2001 From: meteor Date: Wed, 24 Jul 2024 23:51:00 +0400 Subject: [PATCH 5/8] PLUGINS-6918 Updated static page js sdk --- js/static-page.js | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/js/static-page.js b/js/static-page.js index 746301d3..f7db8168 100644 --- a/js/static-page.js +++ b/js/static-page.js @@ -9,6 +9,7 @@ var invisibleDynamicContainerStyle = "display: block !important; height: 0 !important; max-height: 0 !important; min-height: 0 !important; overflow-y: auto !important; margin: 0 !important; padding: 0 !important;"; var mainCategoryId = 0; var initialCategoryOffset = 0; + var pageAlreadyLoaded = false; function find(selector) { return document.querySelector(selector); @@ -228,7 +229,9 @@ // if we've already switched to dynamic, we don't need to dispatch this event anymore return; } - var storeClosed = window.ecwid_initial_data.data.storeClosed; + var storeClosed = window.ecwid_initial_data !== undefined + ? window.ecwid_initial_data.data.storeClosed // Storefront v2 + : false; // Storefront v3 var storeClosedWrapper = document.querySelectorAll('.ecwid-maintenance-wrapper'); var storeNotClosedAndWrapperExists = !storeClosed && storeClosedWrapper.length > 0; @@ -269,7 +272,8 @@ return; } - if (!ecwidPageOpened + if (!hasEcwidMessages() + && !ecwidPageOpened && openedPage.type === "CATEGORY" && openedPage.categoryId === mainCategoryId && openedPage.offset === initialCategoryOffset) { @@ -359,8 +363,8 @@ } } - addClickHandlers('#' + staticId + ' .ec-breadcrumbs a', function (element) { - var categoryId = element.getAttribute('categoryId'); + addClickHandlers('#' + staticId + ' .breadcrumbs__link', function (element) { + var categoryId = element.getAttribute('data-category-id'); if (categoryId !== mainCategoryId) { addStaticClickEvent(element, openEcwidPage('category', { 'id': categoryId })); } @@ -408,9 +412,15 @@ addStaticClickEvent(element, openEcwidPage('category', { 'id': categoryId })); }) - addClickHandlers('#' + staticId + ' .grid-product__buy-now', function (element) { - var productId = element.getAttribute('data-product-id'); - addStaticClickEvent(element, openEcwidPage('product', { 'id': productId })); + addClickHandlers('#' + staticId + ' .grid-product__buy-now .form-control', function (element) { + const productId = element.getAttribute('data-product-id'); + const isGermanStore = element.getAttribute('data-country-code') === 'DE'; + const updatedBuyButtonsFeature = element.getAttribute('data-updated-buy-buttons') != null; + const params = { 'id': productId }; + if (updatedBuyButtonsFeature && !isGermanStore) { + params['buyNow'] = ''; + } + addStaticClickEvent(element, openEcwidPage('product', params, true)); }); addClickHandlers('#' + staticId + ' .footer__link--gift-card', function (element) { @@ -500,8 +510,11 @@ }); } - function openEcwidPage(page, params) { + function openEcwidPage(page, params, stopPropagation = false) { return function (e) { + if (stopPropagation) { + e.stopPropagation(); + } if (isCtrlClickOnProductEvent(page, e)) { // In case product element in grid was clicked with ctrl/meta key, do not invoke e.preventDefault() // and do nothing. Event will be handled and processed by default ctrl/meta + click handler on @@ -537,6 +550,12 @@ } function addOnPageLoadedCallback(callback, attempt) { + const isModernStorefront = window.Ecwid && window.Ecwid.isStorefrontV3 && window.Ecwid.isStorefrontV3(); + if (isModernStorefront && pageAlreadyLoaded) { + callback(); + return; + } + // let's wait for the Ecwid environment to be loaded for up to 2000 milliseconds if (attempt >= 40) { if (!!console) { @@ -546,7 +565,10 @@ } if (typeof (Ecwid) == 'object' && typeof (Ecwid.OnPageLoaded) == 'object') { - Ecwid.OnPageLoaded.add(callback); + Ecwid.OnPageLoaded.add(function (page) { + pageAlreadyLoaded = true; + callback(page); + }); } else { setTimeout(function () { addOnPageLoadedCallback(callback, attempt + 1); From 0ac9ff199cea84476d5ab443033d7ff21e36d701 Mon Sep 17 00:00:00 2001 From: meteor Date: Fri, 2 Aug 2024 16:24:00 +0400 Subject: [PATCH 6/8] v 6.12.17 changelog --- CHANGELOG.txt | 3 +++ ecwid-shopping-cart.php | 2 +- readme.txt | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d82fb414..d1050075 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,7 @@ == Changelog == += 6.12.17 - Aug 5, 2024 = +- Internal improvements and optimization of the loading of the admin pages of the plugin. + = 6.12.16 - Jul 16, 2024 = - Resolved an issue with the store sometimes failing to connect to a plugin. - Additionally, we've fixed a problem that in some cases caused direct category links to display a 404 Not Found page. diff --git a/ecwid-shopping-cart.php b/ecwid-shopping-cart.php index 8f56114f..f1b66842 100644 --- a/ecwid-shopping-cart.php +++ b/ecwid-shopping-cart.php @@ -5,7 +5,7 @@ Description: Ecwid by Lightspeed is a free full-featured shopping cart. It can be easily integrated with any Wordpress blog and takes less than 5 minutes to set up. Text Domain: ecwid-shopping-cart Author: Ecwid Ecommerce -Version: 6.12.16 +Version: 6.12.17 Author URI: https://ecwid.to/ecwid-site License: GPLv2 or later */ diff --git a/readme.txt b/readme.txt index 70788be9..d0f48186 100644 --- a/readme.txt +++ b/readme.txt @@ -153,6 +153,9 @@ You can use Ecwid’s built-in import tools to copy your store products from any * [Ecwid Help Center](http://help.ecwid.com "Ecwid Help") == Changelog == += 6.12.17 - Aug 5, 2024 = +- Internal improvements and optimization of the loading of the admin pages of the plugin. + = 6.12.16 - Jul 16, 2024 = - Resolved an issue with the store sometimes failing to connect to a plugin. - Additionally, we've fixed a problem that in some cases caused direct category links to display a 404 Not Found page. From af156ae8cb03937ad680782e182c05c2b75fce10 Mon Sep 17 00:00:00 2001 From: meteor Date: Tue, 6 Aug 2024 00:55:06 +0400 Subject: [PATCH 7/8] PLUGINS-6916 Prerealese fixes --- lib/ecwid_api_v3.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ecwid_api_v3.php b/lib/ecwid_api_v3.php index 87614dd8..df8e82d2 100644 --- a/lib/ecwid_api_v3.php +++ b/lib/ecwid_api_v3.php @@ -188,7 +188,7 @@ public function get_categories( $input_params ) { $result = EcwidPlatform::get_from_categories_cache( $url ); if ( ! $result ) { - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -266,7 +266,7 @@ public function get_category( $category_id ) { $result = EcwidPlatform::get_from_categories_cache( $url ); if ( ! $result ) { - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -324,7 +324,7 @@ public function get_product( $product_id ) { $result = EcwidPlatform::get_from_products_cache( $url ); if ( ! $result ) { - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -376,7 +376,7 @@ public function search_products( $input_params ) { $result = EcwidPlatform::get_from_products_cache( $url ); if ( ! $result ) { - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -427,7 +427,7 @@ public function get_deleted_products( $input_params ) { $params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -465,7 +465,7 @@ public function get_products( $input_params ) { $params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -593,7 +593,7 @@ public function get_store_update_stats( $additional_params = false ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $url, $params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -636,7 +636,7 @@ public function get_store_profile( $disable_cache = false ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_profile_api_url, $params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -1024,7 +1024,7 @@ public function get_starter_site_info() { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_starter_site_api_url, $request_params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } @@ -1142,7 +1142,7 @@ public function get_batch_status( $ticket ) { $options = $this->build_request_headers(); $url = $this->build_request_url( $this->_batch_requests_api_url, $params ); - if ( empty( $options['Authorization'] ) ) { + if ( empty( $options ) ) { return false; } From 4a26e5edd89ebdd7fb77b21c971883f234813698 Mon Sep 17 00:00:00 2001 From: meteor Date: Tue, 6 Aug 2024 01:00:07 +0400 Subject: [PATCH 8/8] switch to v 6.12.17 --- CHANGELOG.txt | 2 +- readme.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d1050075..cc56708b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,6 @@ == Changelog == = 6.12.17 - Aug 5, 2024 = -- Internal improvements and optimization of the loading of the admin pages of the plugin. +- Internal improvements and optimizations. = 6.12.16 - Jul 16, 2024 = - Resolved an issue with the store sometimes failing to connect to a plugin. diff --git a/readme.txt b/readme.txt index d0f48186..12b73275 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Requires at least: 4.4 Tested up to: 6.6 -Stable tag: 6.12.16 +Stable tag: 6.12.17 Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available. @@ -154,7 +154,7 @@ You can use Ecwid’s built-in import tools to copy your store products from any == Changelog == = 6.12.17 - Aug 5, 2024 = -- Internal improvements and optimization of the loading of the admin pages of the plugin. +- Internal improvements and optimizations. = 6.12.16 - Jul 16, 2024 = - Resolved an issue with the store sometimes failing to connect to a plugin.