From 45011042480936aa954dad19772d80cf67cdc447 Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov Date: Tue, 24 Jun 2025 16:12:38 +0400 Subject: [PATCH 1/6] PLUGINS-6154 returned files for block definition --- js/gutenberg/buynow.jsx | 146 +++++++++++++++ js/gutenberg/cart-page.jsx | 97 ++++++++++ js/gutenberg/categories.jsx | 86 +++++++++ js/gutenberg/category-page.jsx | 207 +++++++++++++++++++++ js/gutenberg/filters-page.jsx | 171 +++++++++++++++++ js/gutenberg/minicart.jsx | 108 +++++++++++ js/gutenberg/product-page.jsx | 180 ++++++++++++++++++ js/gutenberg/product.jsx | 190 +++++++++++++++++++ js/gutenberg/search.jsx | 66 +++++++ js/gutenberg/store.jsx | 327 +++++++++++++++++++++++++++++++++ 10 files changed, 1578 insertions(+) create mode 100644 js/gutenberg/buynow.jsx create mode 100644 js/gutenberg/cart-page.jsx create mode 100644 js/gutenberg/categories.jsx create mode 100644 js/gutenberg/category-page.jsx create mode 100644 js/gutenberg/filters-page.jsx create mode 100644 js/gutenberg/minicart.jsx create mode 100644 js/gutenberg/product-page.jsx create mode 100644 js/gutenberg/product.jsx create mode 100644 js/gutenberg/search.jsx create mode 100644 js/gutenberg/store.jsx diff --git a/js/gutenberg/buynow.jsx b/js/gutenberg/buynow.jsx new file mode 100644 index 00000000..a7815004 --- /dev/null +++ b/js/gutenberg/buynow.jsx @@ -0,0 +1,146 @@ +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; + + +if ( !EcwidGutenbergParams.isDemoStore ) { + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const { + BlockControls, + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + ToggleControl, +} = wp.components; + +const { withState } = wp.compose; + +const { + Fragment +} = wp.element; + +registerBlockType( 'ec-store/buynow', { + title: __( 'Buy Now Button', 'ecwid-shopping-cart' ), + icon: EcwidIcons.button, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: { + id: {type: 'integer'}, + show_price_on_button: {type: 'boolean', default: true}, + center_align: {type: 'boolean', default: true} + }, + description: __( 'Display a buy button', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + align: true, + alignWide: false, + isPrivate: !EcwidGutenbergParams.isApiAvailable + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const saveCallback = function( params ) { + + const attributes = { + 'id': params.newProps.id + }; + + EcwidGutenbergParams.products[params.newProps.id] = { + name: params.newProps.product.name, + imageUrl: params.newProps.product.thumb + }; + + params.originalProps.setAttributes(attributes); + }; + + const editor =
+ { !attributes.id && +
+
+
+ +
+ +
+
+ } + + { attributes.id && +
+
+ } +
; + + function buildToggle(props, name, label) { + return props.setAttributes( { [name]: ! props.attributes[name] } ) } + /> + } + + function openEcwidProductPopup( props ) { + ecwid_open_product_popup( { 'saveCallback': saveCallback, 'props': props } ); + } + + return ([ + editor, + + {attributes.id && +
+
+ +
+ +
+ + { EcwidGutenbergParams.products && EcwidGutenbergParams.products[attributes.id] && + + } + + +
+
+ } + {!attributes.id && +
+ +
+ } + +
+ + { buildToggle( props, 'show_price_on_button', __( 'Show price inside the «Buy now» button', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'center_align', __( 'Center align on a page', 'ecwid-shopping-cart' ) ) } + +
+ ]); + }, + + save: function( props ) { + return false; + }, + +} ); + +} \ No newline at end of file diff --git a/js/gutenberg/cart-page.jsx b/js/gutenberg/cart-page.jsx new file mode 100644 index 00000000..85fd2d2e --- /dev/null +++ b/js/gutenberg/cart-page.jsx @@ -0,0 +1,97 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; +import { EcwidControls, EcwidProductBrowserBlock, EcwidImage } from '../includes/controls.js'; + +const { __, _x } = wp.i18n; + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + PanelRow, + ToggleControl, + ButtonGroup, + Button, + BaseControl, + Toolbar, + ColorPalette, + ColorIndicator +} = wp.components; + +const { withState } = wp.compose; + +const blockName = 'ec-store/cart-page'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/cart-page', { + title: __( 'Cart and Checkout', 'ecwid-shopping-cart' ), // Block title. + icon: EcwidIcons.cartPage, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: blockParams.attributes, + description: __( 'Display shopping cart and checkout page', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + multiple: false + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + + const editor = + + + ; + + function buildDangerousHTMLMessageWithTitle( title, message ) { + return
; + } + + return ([ + editor + ]); + }, + + save: function( props ) { + return null; + } +} ); diff --git a/js/gutenberg/categories.jsx b/js/gutenberg/categories.jsx new file mode 100644 index 00000000..47e57dee --- /dev/null +++ b/js/gutenberg/categories.jsx @@ -0,0 +1,86 @@ +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; + +if ( !EcwidGutenbergParams.isDemoStore ) { + +const { + InspectorControls +} = wp.editor; + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const { + registerBlockType, +} = wp.blocks; + +const blockName = 'ec-store/categories'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; + +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/categories', { + title: __( 'Store Categories Menu', 'ecwid-shopping-cart' ), + icon: EcwidIcons.categories, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + description: __( 'Display categories navigation bar', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + isPrivate: !EcwidGutenbergParams.isApiAvailable + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const editor =
+
+ { EcwidIcons.categories } + { __( 'Categories', 'ecwid-shopping-cart' ) } +
+
; + + const message = __( 'The block is hidden because you don\'t have categories in your store. Add categories.', 'ecwid-shopping-cart' ); + + return ([ + editor, + +
+ + { !blockParams.has_categories && +
+ } + + ]); + }, + + save: function( props ) { + return false; + }, + +} ); + +} \ No newline at end of file diff --git a/js/gutenberg/category-page.jsx b/js/gutenberg/category-page.jsx new file mode 100644 index 00000000..db43aaaf --- /dev/null +++ b/js/gutenberg/category-page.jsx @@ -0,0 +1,207 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; +import { EcwidControls, EcwidInspectorSubheader, EcwidProductBrowserBlock } from '../includes/controls.js'; + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const ecwidIcons = EcwidIcons; + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + BaseControl, +} = wp.components; + +const blockName = 'ec-store/category-page'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; + + +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ + +registerBlockType( 'ec-store/category-page', { + title: __( 'Store Category Page', 'ecwid-shopping-cart' ), // Block title. + icon: EcwidIcons.category, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: EcwidGutenbergStoreBlockParams.attributes, + description: __( 'Display category page', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + multiple: false + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + // legacy reset + props.setAttributes({widgets:''}); + + const editor = + +
+
+
+
+
+
+
+
+
+
+
; + + function buildDangerousHTMLMessageWithTitle( title, message ) { + return
; + } + + const productMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your store and manage your storefront appearance here, please enable the “Next-gen look and feel of the product list on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const cartIconMessage = buildDangerousHTMLMessageWithTitle( + __( 'Display cart icon', 'ecwid-shopping-cart' ), + blockParams.customizeMinicartText + ); + + const isNewProductList = blockParams.isNewProductList; + const isNewDetailsPage = blockParams.isNewDetailsPage; + + const controls = EcwidControls(blockParams.attributes, props); + + return ([ + editor, + +
+ { !EcwidGutenbergParams.hasCategories && + + } + { EcwidGutenbergParams.hasCategories && + [ + !props.attributes.default_category_id && + controls.select( 'default_category_id', __( 'Select category', 'ecwid-shopping-cart' ) ), + props.attributes.default_category_id && + controls.select( 'default_category_id', __( 'Selected category', 'ecwid-shopping-cart' ) ) + ] + } + + { isNewProductList && + [ + controls.select('product_list_category_title_behavior'), + attributes.product_list_category_title_behavior !== 'SHOW_TEXT_ONLY' && + [ + controls.buttonGroup('product_list_category_image_size'), + controls.toolbar('product_list_category_image_aspect_ratio'), + ] + ] + } + { !isNewProductList && productMigrationWarning } + + + + { isNewProductList && + [ + controls.toggle( 'product_list_show_product_images' ), + attributes.product_list_show_product_images && [ + controls.buttonGroup( 'product_list_image_size' ), + controls.toolbar( 'product_list_image_aspect_ratio' ) + ], + controls.toolbar( 'product_list_product_info_layout' ), + controls.select( 'product_list_title_behavior' ), + controls.select( 'product_list_price_behavior' ), + controls.select( 'product_list_sku_behavior' ), + controls.select( 'product_list_buybutton_behavior' ), + controls.toggle( 'product_list_show_additional_image_on_hover' ), + controls.toggle( 'product_list_show_frame' ) + ] + } + { !isNewProductList && productMigrationWarning } + + + + { isNewDetailsPage && + [ + controls.select('product_details_layout'), + ( attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT' + || attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_LEFT' ) && + controls.toggle('show_description_under_image'), + controls.toolbar('product_details_gallery_layout'), + EcwidInspectorSubheader( __('Product sidebar content', 'ecwid-shopping-cart') ), + controls.toggle('product_details_show_product_name'), + controls.toggle('product_details_show_breadcrumbs'), + controls.toggle('product_details_show_product_sku'), + controls.toggle('product_details_show_product_price'), + controls.toggle('product_details_show_qty'), + controls.toggle('product_details_show_number_of_items_in_stock'), + controls.toggle('product_details_show_in_stock_label'), + controls.toggle('product_details_show_wholesale_prices'), + controls.toggle('product_details_show_share_buttons'), + ] + } + { !isNewDetailsPage && productDetailsMigrationWarning } + + + { controls.toggle( 'show_categories') } + { controls.toggle( 'show_search') } + { controls.toggle( 'show_breadcrumbs') } + { isNewProductList && controls.toggle( 'show_footer_menu' ) } + { controls.toggle( 'show_signin_link') } + { controls.toggle( 'product_list_show_sort_viewas_options') } + { cartIconMessage } + + + { controls.color( 'chameleon_color_button' ) } + { controls.color( 'chameleon_color_foreground' ) } + { controls.color( 'chameleon_color_price' ) } + { controls.color( 'chameleon_color_link' ) } + { controls.color( 'chameleon_color_background' ) } + +
+ ]); + }, + + save: function( props ) { + return null; + }, +} ); diff --git a/js/gutenberg/filters-page.jsx b/js/gutenberg/filters-page.jsx new file mode 100644 index 00000000..83767df1 --- /dev/null +++ b/js/gutenberg/filters-page.jsx @@ -0,0 +1,171 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; +import { EcwidControls, EcwidProductBrowserBlock, EcwidImage } from '../includes/controls.js'; + +const { __, _x } = wp.i18n; + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + PanelRow, + ToggleControl, + ButtonGroup, + Button, + BaseControl, + Toolbar, + ColorPalette, + ColorIndicator +} = wp.components; + +const { withState } = wp.compose; + +const blockName = 'ec-store/filters-page'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/filters-page', { + title: __( 'Product Search and filters', 'ecwid-shopping-cart' ), // Block title. + icon: EcwidIcons.filters, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: blockParams.attributes, + description: __( 'Display search page with filters on a side', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + multiple: false + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const editor = + + + ; + /* const editor = +
+
+ { EcwidIcons.filters } + { __( 'Filters Page', 'ecwid-shopping-cart' ) } +
+
+
+ { blockParams.isDemoStore && + + } +
+ ;*/ + + function buildDangerousHTMLMessageWithTitle( title, message ) { + return
; + } + + const filtersDisabledMessage = buildDangerousHTMLMessageWithTitle( + '', + __( 'You can enable filters in the store settings: (“Settings → Product Filters”).', 'ecwid-shopping-cart' ) + ); + + const productMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your store and manage your storefront appearance here, please enable the “Next-gen look and feel of the product list on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const isNewProductList = blockParams.isNewProductList; + + const controls = EcwidControls(blockParams.attributes, props); + + return ([ + editor, + + + { !blockParams.filtersEnabled && filtersDisabledMessage } + { blockParams.filtersEnabled && + [ + controls.select( 'product_filters_position_search_page' ) + ] + } + + + + { isNewProductList && + [ + controls.toggle( 'product_list_show_product_images' ), + attributes.product_list_show_product_images && [ + controls.buttonGroup( 'product_list_image_size' ), + controls.toolbar( 'product_list_image_aspect_ratio' ) + ], + controls.toolbar( 'product_list_product_info_layout' ), + controls.select( 'product_list_title_behavior' ), + controls.select( 'product_list_price_behavior' ), + controls.select( 'product_list_sku_behavior' ), + controls.select( 'product_list_buybutton_behavior' ), + controls.toggle( 'product_list_show_additional_image_on_hover' ), + controls.toggle( 'product_list_show_frame' ) + ] + } + { !isNewProductList && productMigrationWarning } + + + + { controls.toggle( 'show_categories') } + { controls.toggle( 'show_breadcrumbs') } + { isNewProductList && controls.toggle( 'show_footer_menu' ) } + { controls.toggle( 'show_signin_link') } + { controls.toggle( 'product_list_show_sort_viewas_options') } + + + + { controls.color( 'chameleon_color_button' ) } + { controls.color( 'chameleon_color_foreground' ) } + { controls.color( 'chameleon_color_price' ) } + { controls.color( 'chameleon_color_link' ) } + { controls.color( 'chameleon_color_background' ) } + + + ]); + }, + + save: function( props ) { + return null; + } +} ); diff --git a/js/gutenberg/minicart.jsx b/js/gutenberg/minicart.jsx new file mode 100644 index 00000000..993ade96 --- /dev/null +++ b/js/gutenberg/minicart.jsx @@ -0,0 +1,108 @@ +// Import CSS. +import './style.scss'; +import './editor.scss'; + +import {EcwidIcons} from '../icons.js'; + +if ( !EcwidGutenbergParams.isDemoStore ) { + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const { + InspectorControls +} = wp.editor; + +const { + PanelBody, + BaseControl, +} = wp.components; + +const { + registerBlockType, +} = wp.blocks; + +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/minicart', { + title: __( 'Shopping Cart Icon', 'ecwid-shopping-cart' ), + icon: EcwidIcons.cart, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + description: __( 'Display shopping bag link and summary', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + isPrivate: !EcwidGutenbergParams.isApiAvailable, + align: true, + alignWide: false + }, + attributes: EcwidGutenbergParams.minicartAttributes, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + function buildSelect(props, name, label, items) { + return + + ; + } + + function buildItem(props, name, type) { + + const item = EcwidGutenbergParams.minicartAttributes[name]; + + if ( typeof type === 'undefined' ) { + type = item.type; + } + + return buildSelect( props, item.name, item.title, item.values ); + } + + const editor =
+
+
+
; + + return ([ + editor, + + + { buildItem(props, 'layout', 'select' ) } + { buildItem(props, 'icon', 'select' ) } + { buildItem(props, 'fixed_shape', 'select' ) } + + + ]); + }, + + save: function( props ) { + return false; + }, + +} ); + +} \ No newline at end of file diff --git a/js/gutenberg/product-page.jsx b/js/gutenberg/product-page.jsx new file mode 100644 index 00000000..1b29f69e --- /dev/null +++ b/js/gutenberg/product-page.jsx @@ -0,0 +1,180 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; +import { EcwidControls, EcwidInspectorSubheader, EcwidProductBrowserBlock, EcwidImage } from '../includes/controls.js'; + +const { __, _x } = wp.i18n; + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + BaseControl +} = wp.components; + +const { withState } = wp.compose; + +const blockName = 'ec-store/product-page'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/product-page', { + title: __( 'Product Card Large', 'ecwid-shopping-cart' ), + icon: EcwidIcons.product, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: blockParams.attributes, + description: __( 'Display product page with description and a buy button', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + multiple: false + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const saveCallback = function( params ) { + + const attributes = { + 'default_product_id': params.newProps.product.id + }; + + EcwidGutenbergParams.products[params.newProps.product.id] = { + name: params.newProps.product.name, + imageUrl: params.newProps.product.thumb + }; + + params.originalProps.setAttributes(attributes); + }; + + function openEcwidProductPopup( props ) { + ecwid_open_product_popup( { 'saveCallback': saveCallback, 'props': props } ); + } + + const editor = + + + { !attributes.default_product_id && + +
+ +
+ } +
; + + function buildDangerousHTMLMessageWithTitle( title, message ) { + return
; + } + + const productMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your store and manage your storefront appearance here, please enable the “Next-gen look and feel of the product list on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const productDetailsMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your product page and manage your its appearance here, please enable the “Next-gen look and feel of the product page on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const isNewDetailsPage = blockParams.isNewDetailsPage; + + const controls = EcwidControls(blockParams.attributes, props); + + return ([ + editor, + + {attributes.default_product_id > 0 && +
+
+ +
+ +
+ + { EcwidGutenbergParams.products && EcwidGutenbergParams.products[attributes.default_product_id] && + + } + + +
+
+ } + {!attributes.default_product_id && +
+ +
+ } + + + { isNewDetailsPage && + [ + controls.select('product_details_layout'), + ( attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT' + || attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_LEFT' ) && + controls.toggle('show_description_under_image'), + controls.toolbar('product_details_gallery_layout'), + EcwidInspectorSubheader( __('Product sidebar content', 'ecwid-shopping-cart') ), + controls.toggle('product_details_show_product_name'), + controls.toggle('product_details_show_breadcrumbs'), + controls.toggle('product_details_show_product_sku'), + controls.toggle('product_details_show_product_price'), + controls.toggle('product_details_show_qty'), + controls.toggle('product_details_show_number_of_items_in_stock'), + controls.toggle('product_details_show_in_stock_label'), + controls.toggle('product_details_show_wholesale_prices'), + controls.toggle('product_details_show_share_buttons'), + ] + } + { !isNewDetailsPage && productMigrationWarning } + + + { controls.color( 'chameleon_color_button' ) } + { controls.color( 'chameleon_color_foreground' ) } + { controls.color( 'chameleon_color_price' ) } + { controls.color( 'chameleon_color_link' ) } + { controls.color( 'chameleon_color_background' ) } + +
+ ]); + }, + + save: function( props ) { + return null; + } +} ); diff --git a/js/gutenberg/product.jsx b/js/gutenberg/product.jsx new file mode 100644 index 00000000..6638e4d8 --- /dev/null +++ b/js/gutenberg/product.jsx @@ -0,0 +1,190 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; + +if ( !EcwidGutenbergParams.isDemoStore ) { + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + ToggleControl, +} = wp.components; + +const { withState } = wp.compose; + +const { + Fragment +} = wp.element; + + +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ecwid/product-block', { + title: __( 'Product Card Small', 'ecwid-shopping-cart' ), // Block title. + icon: EcwidIcons.product, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: { + id: {type: 'integer'}, + show_picture: {type: 'boolean', default: true}, + show_title: {type: 'boolean', default: true}, + show_price: {type: 'boolean', default: true}, + show_options: {type: 'boolean', default: true}, + show_qty: {type: 'boolean', default: false}, + show_addtobag: {type: 'boolean', default: true}, + show_price_on_button: {type: 'boolean', default: true}, + show_border: {type: 'boolean', default: true}, + center_align: {type: 'boolean', default: true} + }, + description: __( 'Display product with a buy button', 'ecwid-shopping-cart' ), + alignWide: false, + supports: { + customClassName: false, + className: false, + html: false, + align: true, + isPrivate: !EcwidGutenbergParams.isApiAvailable + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const saveCallback = function( params ) { + + const attributes = { + 'id': params.newProps.product.id + }; + + EcwidGutenbergParams.products[params.newProps.product.id] = { + name: params.newProps.product.name, + imageUrl: params.newProps.product.thumb + }; + + params.originalProps.setAttributes(attributes); + } + + const editor =
+ { EcwidGutenbergParams.products && attributes.id && EcwidGutenbergParams.products[attributes.id] && +
+ +
+ } + + { EcwidGutenbergParams.products && attributes.id && EcwidGutenbergParams.products[attributes.id] && +
+ { EcwidGutenbergParams.products[attributes.id].name } +
+ } + + { !attributes.id && +
+ { EcwidIcons.productPreview } +
+ } + + { !attributes.id && +
+ +
+ } + +
; + + function buildToggle(props, name, label) { + return props.setAttributes( { [name]: ! props.attributes[name] } ) } + /> + } + + function openEcwidProductPopup( props ) { + ecwid_open_product_popup( { 'saveCallback': saveCallback, 'props': props } ); + } + + return ([ + editor, + + + { attributes.id && +
+
+ +
+
+ + { EcwidGutenbergParams.products && EcwidGutenbergParams.products[attributes.id] && + + } + + +
+
+ } + {!attributes.id && +
+ +
+ } + + { buildToggle( props, 'show_picture', __( 'Picture', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_title', __( 'Title', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_price', __( 'Price', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_options', __( 'Options', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_qty', __( 'Quantity', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_addtobag', __( '«Buy now» button', 'ecwid-shopping-cart' ) ) } + + + + { buildToggle( props, 'show_price_on_button', __( 'Show price inside the «Buy now» button', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'show_border', __( 'Add border', 'ecwid-shopping-cart' ) ) } + { buildToggle( props, 'center_align', __( 'Center align on a page', 'ecwid-shopping-cart' ) ) } + +
+ ]); + }, + + save: function( props ) { + return false; + }, + +} ); + +} \ No newline at end of file diff --git a/js/gutenberg/search.jsx b/js/gutenberg/search.jsx new file mode 100644 index 00000000..21ed1edd --- /dev/null +++ b/js/gutenberg/search.jsx @@ -0,0 +1,66 @@ +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; + +if ( !EcwidGutenbergParams.isDemoStore ) { + +const { __, _x } = wp.i18n; // Import __() from wp.i18n + +const { + registerBlockType, +} = wp.blocks; + +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ec-store/search', { + title: __( 'Product Search Box', 'ecwid-shopping-cart' ), + icon: EcwidIcons.search, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + description: __( 'Display search box', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + isPrivate: !EcwidGutenbergParams.isApiAvailable + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + const editor =
+
+
; + + return ([ + editor + ]); + }, + + save: function( props ) { + return false; + }, + +} ); + +} \ No newline at end of file diff --git a/js/gutenberg/store.jsx b/js/gutenberg/store.jsx new file mode 100644 index 00000000..1c63ec42 --- /dev/null +++ b/js/gutenberg/store.jsx @@ -0,0 +1,327 @@ +/** + * BLOCK: my-block + * + * Registering a basic block with Gutenberg. + * Simple block, renders and saves the same content without any interactivity. + */ + +// Import CSS. +import './style.scss'; +import './editor.scss'; +import {EcwidIcons} from '../icons.js'; +import { EcwidControls, EcwidInspectorSubheader, EcwidProductBrowserBlock } from '../includes/controls.js'; + +const { __, _x } = wp.i18n; + +const { + registerBlockType, +} = wp.blocks; + +const { + InspectorControls, +} = wp.editor; + +const { + PanelBody, + PanelRow, + ToggleControl, + ButtonGroup, + Button, + BaseControl, + Toolbar, + ColorPalette, + ColorIndicator +} = wp.components; + +const { withState } = wp.compose; + +const blockName = 'ecwid/store-block'; + +const blockParams = EcwidGutenbergParams.blockParams[blockName]; +/** + * Register: aa Gutenberg Block. + * + * Registers a new block provided a unique name and an object defining its + * behavior. Once registered, the block is made editor as an option to any + * editor interface where blocks are implemented. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/ + * @param {string} name Block name. + * @param {Object} settings Block settings. + * @return {?WPBlock} The block, if it has been successfully + * registered; otherwise `undefined`. + */ +registerBlockType( 'ecwid/store-block', { + title: __( 'Store Home Page', 'ecwid-shopping-cart' ), // Block title. + icon: EcwidIcons.store, + category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. + attributes: blockParams.attributes, + description: __( 'Add storefront (product listing)', 'ecwid-shopping-cart' ), + supports: { + customClassName: false, + className: false, + html: false, + multiple: false + }, + + /** + * The edit function describes the structure of your block in the context of the editor. + * This represents what the editor will render when the block is used. + * + * The "edit" property must be a valid function. + * + * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ + */ + edit: function( props ) { + + const { attributes } = props; + + // legacy reset + props.setAttributes({widgets:''}); + + const editor = + +
+
+
+
+
+
+
+
+
+
+
; + + function buildDangerousHTMLMessageWithTitle( title, message ) { + return
; + } + + const productMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your store and manage your storefront appearance here, please enable the “Next-gen look and feel of the product list on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const cartIconMessage = buildDangerousHTMLMessageWithTitle( + __( 'Display cart icon', 'ecwid-shopping-cart' ), + blockParams.customizeMinicartText + ); + + const productDetailsMigrationWarning = buildDangerousHTMLMessageWithTitle( + '', + __( 'To improve the look and feel of your product page and manage its appearance here, please enable the “Next-gen look and feel of the product page on the storefront” option in your store dashboard (“Settings → What’s New”).', 'ecwid-shopping-cart' ) + ); + + const isNewProductList = blockParams.isNewProductList; + const isNewDetailsPage = blockParams.isNewDetailsPage; + + const hasCategories = blockParams.attributes.default_category_id && blockParams.attributes.default_category_id.values && blockParams.attributes.default_category_id.values.length > 0; + + const controls = EcwidControls(blockParams.attributes, props); + + return ([ + editor, + + { hasCategories && + + { isNewProductList && + [ + controls.select('product_list_category_title_behavior'), + attributes.product_list_category_title_behavior !== 'SHOW_TEXT_ONLY' && + [ + controls.buttonGroup('product_list_category_image_size'), + controls.toolbar('product_list_category_image_aspect_ratio'), + ] + ] + } + { !isNewProductList && productMigrationWarning } + + } + + + { isNewProductList && + [ + controls.toggle( 'product_list_show_product_images' ), + attributes.product_list_show_product_images && [ + controls.buttonGroup( 'product_list_image_size' ), + controls.toolbar( 'product_list_image_aspect_ratio' ) + ], + controls.toolbar( 'product_list_product_info_layout' ), + controls.select( 'product_list_title_behavior' ), + controls.select( 'product_list_price_behavior' ), + controls.select( 'product_list_sku_behavior' ), + controls.select( 'product_list_buybutton_behavior' ), + controls.toggle( 'product_list_show_additional_image_on_hover' ), + controls.toggle( 'product_list_show_frame' ) + ] + } + { !isNewProductList && productMigrationWarning } + + + + { isNewDetailsPage && + [ + controls.select('product_details_layout'), + ( attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT' + || attributes.product_details_layout === 'TWO_COLUMNS_SIDEBAR_ON_THE_LEFT' ) && + controls.toggle('show_description_under_image'), + controls.toolbar('product_details_gallery_layout'), + EcwidInspectorSubheader( __('Product sidebar content', 'ecwid-shopping-cart') ), + controls.toggle('product_details_show_product_name'), + controls.toggle('product_details_show_breadcrumbs'), + controls.toggle('product_details_show_product_sku'), + controls.toggle('product_details_show_product_price'), + controls.toggle('product_details_show_qty'), + controls.toggle('product_details_show_number_of_items_in_stock'), + controls.toggle('product_details_show_in_stock_label'), + controls.toggle('product_details_show_wholesale_prices'), + controls.toggle('product_details_show_share_buttons'), + ] + } + { !isNewDetailsPage && productMigrationWarning } + + + { hasCategories && + + + { controls.defaultCategoryId( 'default_category_id' ) } + + + } + + { controls.toggle( 'show_categories') } + { controls.toggle( 'show_search') } + { controls.toggle( 'show_breadcrumbs') } + { isNewProductList && controls.toggle( 'show_footer_menu' ) } + { controls.toggle( 'show_signin_link') } + { controls.toggle( 'product_list_show_sort_viewas_options') } + { cartIconMessage } + + + { controls.color( 'chameleon_color_button' ) } + { controls.color( 'chameleon_color_foreground' ) } + { controls.color( 'chameleon_color_price' ) } + { controls.color( 'chameleon_color_link' ) } + { controls.color( 'chameleon_color_background' ) } + + + ]); + }, + + save: function( props ) { + + var widgets = ['productbrowser']; + if ( props.attributes.show_categories ) { + widgets[widgets.length] = 'categories'; + } + if ( props.attributes.show_search ) { + widgets[widgets.length] = 'search'; + } + const shortcodeAttributes = { + 'widgets': widgets.join(' '), + 'default_category_id': typeof props.attributes.default_category_id !== 'undefined' ? props.attributes.default_category_id : 0 + }; + + const shortcode = new wp.shortcode({ + 'tag': blockParams.shortcodeName, + 'attrs': shortcodeAttributes, + 'type': 'single' + }); + + return shortcode.string(); + }, + + deprecated: [ + { + attributes: { + widgets: { type: 'string' }, + categories_per_row: { type: 'integer' }, + grid: { type: 'string' }, + list: { type: 'integer' }, + table: { type: 'integer' }, + default_category_id: { type: 'integer' }, + default_product_id: { type: 'integer' }, + category_view: { type: 'string' }, + search_view: { type: 'string' }, + minicart_layout: {type: 'string' } + }, + + save: function( props ) { + return null; + }, + }, { + attributes: { + widgets: { type: 'string', default: 'productbrowser' }, + default_category_id: { type: 'integer', default: 0 } + }, + + migrate: function ( attributes ) { + return { + 'widgets': attributes.widgets, + 'default_category_id': attributes.default_category_id + } + }, + + save: function( props ) { + var shortcodeAttributes = {}; + const attrs = ['widgets', 'default_category_id']; + for ( var i = 0; i < attrs.length; i++ ) { + shortcodeAttributes[attrs[i]] = props.attributes[attrs[i]]; + } + shortcodeAttributes.default_product_id = 0; + + var shortcode = new wp.shortcode({ + 'tag': blockParams.shortcodeName, + 'attrs': shortcodeAttributes, + 'type': 'single' + }); + + return shortcode.string(); + }, + }, + { + save: function( props ) { + return '[ecwid]'; + }, + }, + { + save: function( props ) { + return '[ecwid widgets="productbrowser" default_category_id="0" default_product_id="0"]'; + }, + }, + { + save: function( props ) { + return '[ecwid widgets="productbrowser" default_category_id="0"]'; + }, + }, + ], + + transforms: { + from: [{ + type: 'shortcode', + tag: ['ecwid', 'ec_store'], + attributes: { + default_category_id: { + type: 'integer', + shortcode: function(named) { + return named.default_category_id + } + }, + show_categories: { + type: 'boolean', + shortcode: function(attributes) { + return attributes.named.widgets.indexOf('categories') !== -1 + } + }, + show_search: { + type: 'boolean', + shortcode: function(attributes) { + return attributes.named.widgets.indexOf('search') !== -1 + } + } + }, + priority: 10 + }] + }, + +} ); From 9c7f52325588990da4b2913ab73451d8f73d4b69 Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov Date: Fri, 27 Jun 2025 15:21:12 +0400 Subject: [PATCH 2/6] Updated broken links on the plugin page --- README.md | 12 ++++++------ ecwid-shopping-cart.php | 2 +- readme.txt | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 06369c91..336965d3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ With Ecwid, you can include your ecommerce shop on multiple websites, blogs, soc ### Mobile Responsive Design -Ecwid works great on any Wordpress site, especially those running on mobile-optimized themes. Your online store looks perfect on smartphones and automatically adapts to your customer’s screen size: laptops, tablets, smart TVs or smart watches. Check out this [demo](https://ecwid.to/ecwid-demo-store) +Ecwid works great on any Wordpress site, especially those running on mobile-optimized themes. Your online store looks perfect on smartphones and automatically adapts to your customer’s screen size: laptops, tablets, smart TVs or smart watches. Check out this [demo](https://go.lightspeedhq.com/ecwid-demo-store) ### Hundreds of extensions and powerful API @@ -45,17 +45,17 @@ There is a lot of in-house and third party extensions built on the Ecwid Ecommer ### Plans start at just $5/mo -Start selling ealisy with no big investment. As your online shop grows, Ecwid grows with you. When the time is right, consider upgrading your store to one of our premium plans to get more robust features and preferred support. See also: [Ecwid plan and pricing](https://ecwid.to/ecwid-pricing) +Start selling ealisy with no big investment. As your online shop grows, Ecwid grows with you. When the time is right, consider upgrading your store to one of our premium plans to get more robust features and preferred support. See also: [Ecwid plan and pricing](https://go.lightspeedhq.com/ecwid-pricing) ### See Ecwid In Action -* [Demo Store](https://ecwid.to/ecwid-demo-store "Ecwid demo") -* [Ecwid Ecommerce Control panel](https://ecwid.to/ecwid-store-control-panel "Ecwid Control Panel") (you will be able to create an Ecwid account) -* [Showcase](https://ecwid.to/ecwid-wp-site) +* [Demo Store](https://go.lightspeedhq.com/ecwid-demo-store "Ecwid demo") +* [Ecwid Ecommerce Control panel](https://go.lightspeedhq.com/ecwid-store-control-panel "Ecwid Control Panel") (you will be able to create an Ecwid account) +* [Showcase](https://go.lightspeedhq.com/ecwid-wp-site) ### Ecwid Site -* [www.ecwid.com](https://ecwid.to/ecwid-wp-site "Ecwid site") +* [www.ecwid.com](https://go.lightspeedhq.com/ecwid-wp-site "Ecwid site") ## Installation diff --git a/ecwid-shopping-cart.php b/ecwid-shopping-cart.php index 4164ec58..fd4f806e 100644 --- a/ecwid-shopping-cart.php +++ b/ecwid-shopping-cart.php @@ -6,7 +6,7 @@ Text Domain: ecwid-shopping-cart Author: Ecwid Ecommerce Version: 7.0.3 -Author URI: https://ecwid.to/ecwid-site +Author URI: https://go.lightspeedhq.com/ecwid-site License: GPLv2 or later */ diff --git a/readme.txt b/readme.txt index 1fc58360..2bda9867 100644 --- a/readme.txt +++ b/readme.txt @@ -56,16 +56,16 @@ There is a lot of in-house and third party extensions built on the Ecwid Ecommer ### Plans start at just $5/mo -Start selling ealisy with no big investment. As your online shop grows, Ecwid grows with you. When the time is right, consider upgrading your store to one of our premium plans to get more robust features and preferred support. See also: [Ecwid plan and pricing](https://ecwid.to/ecwid-pricing) +Start selling ealisy with no big investment. As your online shop grows, Ecwid grows with you. When the time is right, consider upgrading your store to one of our premium plans to get more robust features and preferred support. See also: [Ecwid plan and pricing](https://go.lightspeedhq.com/ecwid-pricing) ### See Ecwid In Action -* [Ecwid Ecommerce Control panel](https://ecwid.to/ecwid-store-control-panel "Ecwid Control Panel") (you will be able to create an Ecwid account) -* [Showcase](https://ecwid.to/ecwid-wp-site) +* [Ecwid Ecommerce Control panel](https://go.lightspeedhq.com/ecwid-store-control-panel "Ecwid Control Panel") (you will be able to create an Ecwid account) +* [Showcase](https://go.lightspeedhq.com/ecwid-wp-site) ### Ecwid Site -* [www.ecwid.com](https://ecwid.to/ecwid-wp-site "Ecwid site") +* [www.ecwid.com](https://go.lightspeedhq.com/ecwid-wp-site "Ecwid site") ### Terms of usage @@ -123,7 +123,7 @@ Ecwid is PCI DSS Level 1 certified shopping cart plugin – the gold standard fo = How much does Ecwid cost? = -Ecwid shopping cart plans vary by number of products, types of ecommerce functionality, and level of support. Learn more: [https://ecwid.to/ecwid-pricing](https://ecwid.to/ecwid-pricing). +Ecwid shopping cart plans vary by number of products, types of ecommerce functionality, and level of support. Learn more: [https://go.lightspeedhq.com/ecwid-pricing](https://go.lightspeedhq.com/ecwid-pricing). = How can I manage my online shop from a mobile device? = From a7cefe89b950aa96b8c4ffa565c380be4e5d44c1 Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov Date: Tue, 8 Jul 2025 12:54:16 +0400 Subject: [PATCH 3/6] Added data-cfasync="false" data-no-optimize="1" for some script tags --- includes/class-ecwid-ajax-defer-renderer.php | 4 ++-- includes/class-ecwid-floating-minicart.php | 2 +- includes/gutenberg/class-ecwid-gutenberg-block-cart-page.php | 2 +- .../gutenberg/class-ecwid-gutenberg-block-filters-page.php | 2 +- includes/gutenberg/class-ecwid-gutenberg-block-minicart.php | 2 +- includes/shortcodes/class-ecwid-shortcode-productbrowser.php | 2 +- includes/widgets/nsf-minicart.tpl.php | 2 +- templates/debug.php | 2 +- templates/help.php | 2 +- templates/product.php | 2 +- templates/store-popup.php | 2 +- templates/sync.php | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/includes/class-ecwid-ajax-defer-renderer.php b/includes/class-ecwid-ajax-defer-renderer.php index d29a0fbd..9fe9a64d 100644 --- a/includes/class-ecwid-ajax-defer-renderer.php +++ b/includes/class-ecwid-ajax-defer-renderer.php @@ -94,7 +94,7 @@ public function render_shortcode( $shortcode ) { public function add_shortcodes( $content ) { $ecwid_store_id = get_ecwid_store_id(); - $before = ''; + $before = ''; $scriptjs_domain = esc_attr( Ecwid_Config::get_scriptjs_domain() ); @@ -104,7 +104,7 @@ public function add_shortcodes( $content ) { $script_src = "https://$scriptjs_domain/script.js?$ecwid_store_id&data_platform=wporg&lang=$lang"; ob_start(); ?> - "; +$content = ""; echo ecwid_wrap_shortcode_content( $content, 'product', array() ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped diff --git a/templates/store-popup.php b/templates/store-popup.php index e803fce5..82ca7b2a 100644 --- a/templates/store-popup.php +++ b/templates/store-popup.php @@ -299,7 +299,7 @@ class="number"
- diff --git a/templates/sync.php b/templates/sync.php index 77b2d767..15c1daf6 100644 --- a/templates/sync.php +++ b/templates/sync.php @@ -5,7 +5,7 @@ $api = new Ecwid_Api_V3( get_ecwid_store_id() ); ?> -'; //phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + $code .= ''; //phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript } $code .= ecwid_sso(); - $code .= ''; + $code .= ''; return apply_filters( 'ecwid_scriptjs_code', $code ); } From 1cdf96dfb8f919cbc1543417e8fcbfad2afcdc3b Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov Date: Tue, 8 Jul 2025 15:57:34 +0400 Subject: [PATCH 5/6] PLUGINS-6307 fixed warning message --- lib/ecwid_catalog_entry.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/ecwid_catalog_entry.php b/lib/ecwid_catalog_entry.php index 76a6cc32..c93b53e4 100644 --- a/lib/ecwid_catalog_entry.php +++ b/lib/ecwid_catalog_entry.php @@ -93,13 +93,11 @@ public function get_seo_link( $baseUrl = '' ) { $url .= '/'; } - preg_match( '!([^\/]+-[p|c][0-9]+)$!', $this->_data->url, $slug ); - - if( ! empty( $slug[1] ) ) { - $url .= $slug[1]; - } else { - $url .= $this->_linkify( $this->_data->name ) . '-' . $this->_link_prefix . $this->_data->id; - } + if ( ! empty( $this->_data->url ) && preg_match( '!([^\/]+-[p|c][0-9]+)$!', $this->_data->url, $slug)) { + $url .= $slug[1]; + } else { + $url .= $this->_linkify($this->_data->name) . '-' . $this->_link_prefix . $this->_data->id; + } if ( ! empty( $query ) ) { $url .= '/?' . $query; From 129c3289c9f86af2c119a9901598d18f18861c85 Mon Sep 17 00:00:00 2001 From: Ilnur Basyrov Date: Mon, 14 Jul 2025 18:54:01 +0400 Subject: [PATCH 6/6] ver 7.0.4 --- CHANGELOG.txt | 4 ++++ ecwid-shopping-cart.php | 2 +- lib/ecwid_catalog_entry.php | 15 +++++++-------- readme.txt | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0d8b84ef..360ba459 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,8 @@ == Changelog == += 7.0.4 - Jul 15, 2025 = +- Improved compatibility with the Jetpack plugin to ensure storefront scripts load correctly when 'Defer Non-Essential JavaScript' is enabled. +- Applied minor fixes and general improvements for better performance and stability. + = 7.0.3 - Jun 24, 2025 = - Internal improvements and minor fixes for Gutenberg ecommerce blocks. diff --git a/ecwid-shopping-cart.php b/ecwid-shopping-cart.php index f89dba83..cff8e69c 100644 --- a/ecwid-shopping-cart.php +++ b/ecwid-shopping-cart.php @@ -5,7 +5,7 @@ Description: Ecwid by Lightspeed is a 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: 7.0.3 +Version: 7.0.4 Author URI: https://go.lightspeedhq.com/ecwid-site License: GPLv2 or later */ diff --git a/lib/ecwid_catalog_entry.php b/lib/ecwid_catalog_entry.php index c93b53e4..4869c168 100644 --- a/lib/ecwid_catalog_entry.php +++ b/lib/ecwid_catalog_entry.php @@ -12,7 +12,7 @@ protected function __construct() { public function __get( $name ) { - if ( $name == 'link' ) { + if ( $name === 'link' ) { return $this->get_link(); } @@ -25,7 +25,7 @@ public function __get( $name ) { public function __isset( $name ) { - if ( $name == 'link' ) { + if ( $name === 'link' ) { $link = $this->get_link(); return (bool) $link; } @@ -73,7 +73,6 @@ public function get_link( $baseUrl = false ) { public function get_seo_link( $baseUrl = '' ) { if ( $this->_data->id && isset( $this->_data->name ) ) { - if ( ! $baseUrl ) { if ( Ecwid_Store_Page::is_store_page() ) { $baseUrl = get_permalink(); @@ -93,11 +92,11 @@ public function get_seo_link( $baseUrl = '' ) { $url .= '/'; } - if ( ! empty( $this->_data->url ) && preg_match( '!([^\/]+-[p|c][0-9]+)$!', $this->_data->url, $slug)) { - $url .= $slug[1]; - } else { - $url .= $this->_linkify($this->_data->name) . '-' . $this->_link_prefix . $this->_data->id; - } + if ( ! empty( $this->_data->url ) && preg_match( '!([^\/]+-[p|c][0-9]+)$!', $this->_data->url, $slug ) ) { + $url .= $slug[1]; + } else { + $url .= $this->_linkify( $this->_data->name ) . '-' . $this->_link_prefix . $this->_data->id; + } if ( ! empty( $query ) ) { $url .= '/?' . $query; diff --git a/readme.txt b/readme.txt index 2bda9867..4e9e7281 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.8 -Stable tag: 7.0.3 +Stable tag: 7.0.4 Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. @@ -152,6 +152,10 @@ 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 == += 7.0.4 - Jul 15, 2025 = +- Improved compatibility with the Jetpack plugin to ensure storefront scripts load correctly when 'Defer Non-Essential JavaScript' is enabled. +- Applied minor fixes and general improvements for better performance and stability. + = 7.0.3 - Jun 24, 2025 = - Internal improvements and minor fixes for Gutenberg ecommerce blocks.