Ecwid Ecommerce Shopping Cart - Version 6.8.2

Version Description

  • Jun 14, 2019 =
  • Fixed an error that happened under certain site configurations
Download this release

Release Info

Developer Ecwid
Plugin Icon 128x128 Ecwid Ecommerce Shopping Cart
Version 6.8.2
Comparing to
See all releases

Code changes from version 6.8.1 to 6.8.2

ecwid-shopping-cart.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.ecwid.com?source=wporg
5
  Description: Ecwid 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.
6
  Text Domain: ecwid-shopping-cart
7
  Author: Ecwid Ecommerce
8
- Version: 6.8.1
9
  Author URI: https://ecwid.to/ecwid-site
10
  */
11
 
@@ -192,8 +192,7 @@ function ecwid_init_integrations()
192
  'polylang/polylang.php' => 'polylang',
193
  );
194
 
195
-
196
- if (version_compare( phpversion(), '5.4', '>=' ) ) {
197
  $integrations['gutenberg/gutenberg.php'] = 'gutenberg';
198
  }
199
 
5
  Description: Ecwid 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.
6
  Text Domain: ecwid-shopping-cart
7
  Author: Ecwid Ecommerce
8
+ Version: 6.8.2
9
  Author URI: https://ecwid.to/ecwid-site
10
  */
11
 
192
  'polylang/polylang.php' => 'polylang',
193
  );
194
 
195
+ if (version_compare( phpversion(), '5.4', '>=' ) && version_compare( get_bloginfo('version'), '5.0' ) < 0 ) {
 
196
  $integrations['gutenberg/gutenberg.php'] = 'gutenberg';
197
  }
198
 
includes/integrations/class-ecwid-integration-gutenberg.php ADDED
@@ -0,0 +1,498 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-product-browser.php';
4
+
5
+ class Ecwid_Integration_Gutenberg {
6
+
7
+ const STORE_BLOCK = 'ecwid/store-block';
8
+ const PRODUCT_BLOCK = 'ecwid/product-block';
9
+
10
+ public function __construct() {
11
+
12
+ if ( isset( $_GET['classic-editor'] ) ) return;
13
+
14
+ add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
15
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
16
+
17
+ add_action( "rest_insert_post", array( $this, 'on_save_post' ), 10, 3 );
18
+ add_action( "rest_insert_page", array( $this, 'on_save_post' ), 10, 3 );
19
+
20
+ register_block_type(self::STORE_BLOCK, array(
21
+ 'editor_script' => 'ecwid-gutenberg-store',
22
+ 'render_callback' => array( $this, 'render_callback' ),
23
+ ));
24
+
25
+ register_block_type(self::PRODUCT_BLOCK, array(
26
+ 'editor_script' => 'ecwid-gutenberg-store',
27
+ 'render_callback' => array( $this, 'product_render_callback' ),
28
+ ));
29
+
30
+ add_filter( 'block_categories', array( $this, 'block_categories' ) );
31
+ }
32
+
33
+ public function admin_enqueue_scripts()
34
+ {
35
+ wp_enqueue_script( 'gutenberg-store' );
36
+ EcwidPlatform::enqueue_style( 'store-popup' );
37
+ }
38
+
39
+ public function block_categories( $categories ) {
40
+ return array_merge(
41
+ $categories,
42
+ array(
43
+ array(
44
+ 'slug' => 'ec-store',
45
+ 'title' => sprintf( __( '%s', 'ecwid-shopping-cart' ), Ecwid_Config::get_brand() ),
46
+ 'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="#555d66" d="' . $this->_get_store_icon_path() . '"/><path d="M19 13H5v-2h14v2z" /></svg>'
47
+ ),
48
+ )
49
+ );
50
+ }
51
+
52
+ public function on_save_post( $post, $request, $creating ) {
53
+ if (strpos( $post->post_content, '<!-- wp:' . self::STORE_BLOCK ) !== false ) {
54
+ Ecwid_Store_Page::add_store_page( $post->ID );
55
+ }
56
+ }
57
+
58
+ public function enqueue_block_editor_assets() {
59
+
60
+ wp_enqueue_script( 'ecwid-gutenberg-store', ECWID_PLUGIN_URL . 'js/gutenberg/blocks.build.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) );
61
+ wp_enqueue_style( 'ecwid-gutenberg-block', ECWID_PLUGIN_URL . 'css/gutenberg/blocks.editor.build.css' );
62
+
63
+ $locale_data = '';
64
+ if ( function_exists( 'gutenberg_get_jed_locale_data' ) ) {
65
+ $locale_data = gutenberg_get_jed_locale_data( 'ecwid-shopping-cart' );
66
+ } else if ( function_exists( 'wp_get_jed_locale_data' ) ) {
67
+ $locale_data = wp_get_jed_locale_data( 'ecwid-shopping-cart' );
68
+ }
69
+
70
+
71
+ if ( $locale_data ) {
72
+ wp_add_inline_script(
73
+ 'ecwid-gutenberg-store',
74
+ 'wp.i18n.setLocaleData( ' . json_encode( $locale_data ) . ', "ecwid-shopping-cart"' . ');',
75
+ 'before'
76
+ );
77
+ }
78
+
79
+ $api = new Ecwid_Api_V3();
80
+ wp_localize_script( 'ecwid-gutenberg-store', 'EcwidGutenbergStoreBlockParams',
81
+ array(
82
+ 'attributes' => $this->_get_attributes_for_editor(),
83
+ 'is_new_product_list' => $this->_is_new_product_list(),
84
+ 'is_new_details_page' => $this->_is_new_details_page(),
85
+ 'storeBlockTitle' => _x( 'Store', 'gutenberg-store-block-stub', 'ecwid-shopping-cart' )
86
+ )
87
+ );
88
+
89
+ $is_demo_store = ecwid_is_demo_store();
90
+ wp_localize_script( 'ecwid-gutenberg-store', 'EcwidGutenbergParams',
91
+ array(
92
+ 'ecwid_pb_defaults' => ecwid_get_default_pb_size(),
93
+ 'storeImageUrl' => site_url('?file=ecwid_store_svg.svg'),
94
+ 'storeBlockTitle' => sprintf( __( '%s Store', 'ecwid-shopping-cart' ), Ecwid_Config::get_brand() ),
95
+ 'storeShortcodeName' => Ecwid_Shortcode_Base::get_current_store_shortcode_name(),
96
+ 'storeBlock' => self::STORE_BLOCK,
97
+ 'productBlockTitle' => sprintf( __( '%s product', 'ecwid-shopping-cart'), Ecwid_Config::get_brand() ),
98
+ 'productShortcodeName' => Ecwid_Shortcode_Product::get_shortcode_name(),
99
+ 'productBlock' => self::PRODUCT_BLOCK,
100
+ 'storeId' => get_ecwid_store_id(),
101
+ 'chooseProduct' => __( 'Choose product', 'ecwid-shopping-cart' ),
102
+ 'editAppearance' => __( 'Edit Appearance', 'ecwid-shopping-cart' ),
103
+ 'yourStoreWill' => __( 'Your store will be shown here', 'ecwid-shopping-cart' ),
104
+ 'storeIdLabel' => __( 'Store ID', 'ecwid-shopping-cart' ),
105
+ 'yourProductLabel' => __( 'Your product', 'ecwid-shopping-cart' ),
106
+ 'storeIcon' => $this->_get_store_icon_path(),
107
+ 'productIcon' => $this->_get_product_icon_path(),
108
+ 'isDemoStore' => $is_demo_store,
109
+ 'isApiAvailable' => Ecwid_Api_V3::is_available(),
110
+ 'products' => $this->_get_products_data(),
111
+ 'customizeMinicartText' =>
112
+ sprintf(
113
+ __(
114
+ 'You can enable an extra shopping bag icon widget that will appear on your site pages. Open “<a href="%1$s">Appearance → Customize → %2$s</a>” menu to enable it.',
115
+ 'ecwid-shopping-cart'
116
+ ),
117
+ 'customize.php?autofocus[section]=' . Ecwid_Customizer::SECTION_MINICART . '&return=' . urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) )
118
+ ),
119
+ Ecwid_Config::get_brand()
120
+ )
121
+ )
122
+ );
123
+
124
+ }
125
+
126
+ protected function _get_products_data() {
127
+
128
+ $blocks = self::get_blocks_on_page();
129
+
130
+ $productIds = array();
131
+ foreach ( $blocks as $block ) {
132
+ if ( $block['blockName'] == self::PRODUCT_BLOCK ) {
133
+ $productIds[] = $block['attrs']['id'];
134
+ }
135
+ }
136
+
137
+ if ( empty( $productIds ) ) {
138
+ return array();
139
+ }
140
+
141
+ $result = array();
142
+ foreach ( $productIds as $id ) {
143
+ $product = Ecwid_Product::get_by_id( $id );
144
+
145
+ $result[$id] = array(
146
+ 'name' => $product->name,
147
+ 'imageUrl' => $product->thumbnailUrl
148
+ );
149
+ }
150
+
151
+ return $result;
152
+ }
153
+
154
+ protected function _is_new_product_list() {
155
+ $api = new Ecwid_Api_V3();
156
+
157
+ return ecwid_is_demo_store() || !Ecwid_Api_V3::is_available() || $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_NEW_PRODUCT_LIST );
158
+ }
159
+
160
+ protected function _is_new_details_page() {
161
+ $api = new Ecwid_Api_V3();
162
+
163
+ return ecwid_is_demo_store() || !Ecwid_Api_V3::is_available() || $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_NEW_DETAILS_PAGE );
164
+ }
165
+
166
+ public function product_render_callback( $params ) {
167
+
168
+ if ( !@$params['id'] ) return '';
169
+
170
+ $params = wp_parse_args(
171
+ $params,
172
+ array(
173
+ 'id' => 0,
174
+ 'show_picture' => true,
175
+ 'show_title' => true,
176
+ 'show_price' => true,
177
+ 'show_options' => true,
178
+ 'show_addtobag' => true,
179
+ 'show_border' => true,
180
+ 'center_align' => true,
181
+ 'show_price_on_button' => true
182
+ )
183
+ );
184
+
185
+ $display = array(
186
+ 'picture', 'title', 'price', 'options', 'qty', 'addtobag'
187
+ );
188
+
189
+ $params['display'] = '';
190
+ $display_string = '';
191
+ foreach ( $display as $name ) {
192
+ if ( @$params['show_' . $name] ) {
193
+ $params['display'] .= ' ' . $name;
194
+ }
195
+ }
196
+
197
+ $params['version'] = 2;
198
+
199
+ $shortcode = new Ecwid_Shortcode_Product( $params );
200
+
201
+ return $shortcode->render();
202
+ }
203
+
204
+ public function render_callback( $params ) {
205
+
206
+ if ( $_SERVER['REQUEST_METHOD'] != 'GET' ) {
207
+ return '';
208
+ }
209
+
210
+ $result = "[ecwid";
211
+
212
+ $params['widgets'] = 'productbrowser';
213
+ if ( @$params['show_categories'] ) {
214
+ $params['widgets'] .= ' categories';
215
+ }
216
+ if ( @$params['show_search'] ) {
217
+ $params['widgets'] .= ' search';
218
+ }
219
+
220
+ foreach ($params as $key => $value) {
221
+ $result .= " $key='$value'";
222
+ }
223
+
224
+ $result .= ']';
225
+
226
+ $result .= <<<HTML
227
+ <script type="text/javascript">
228
+ window.ec = window.ec || Object();
229
+ window.ec.storefront = window.ec.storefront || Object();
230
+ HTML;
231
+
232
+ $attributes = $this->_get_attributes_for_editor();
233
+
234
+ $store_page_data = array();
235
+
236
+ foreach ( $attributes as $key => $attribute ) {
237
+
238
+ $name = $attribute['name'];
239
+ // we do not print defaults
240
+ if ( !isset( $params[$name] ) ) {
241
+ $store_page_data[$name] = $attribute['default'];
242
+ continue;
243
+ }
244
+
245
+ $value = $params[$name];
246
+
247
+ if ( $name == 'show_description_under_image' ) {
248
+ $attribute['is_storefront_api'] = true;
249
+ $value = !@$params[$name];
250
+
251
+ $layout = @$params['product_details_layout'];
252
+ if ( is_null( $layout ) ) {
253
+ $layout = $attributes['product_details_layout']['default'];
254
+ }
255
+
256
+ if ( $layout == 'TWO_COLUMNS_SIDEBAR_ON_THE_LEFT' ) {
257
+ $name = 'product_details_two_columns_with_left_sidebar_show_product_description_on_sidebar';
258
+ } else if ( $layout == 'TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT' ) {
259
+ $name = 'product_details_two_columns_with_right_sidebar_show_product_description_on_sidebar';
260
+ } else {
261
+ unset( $attribute['is_storefront_api'] );
262
+ }
263
+ }
264
+
265
+ if ( @$attribute['is_storefront_api'] ) {
266
+
267
+ if ( @$attribute['type'] == 'boolean') {
268
+ $result .= 'window.ec.storefront.' . $name . "=" . ( $value ? 'true' : 'false' ) . ";" . PHP_EOL;
269
+ } else {
270
+ $result .= 'window.ec.storefront.' . $name . "='" . $value . "';" . PHP_EOL;
271
+ }
272
+ $store_page_data[$name] = $value;
273
+ }
274
+ }
275
+
276
+ $colors = array();
277
+ foreach ( array( 'foreground', 'background', 'link', 'price', 'button' ) as $kind ) {
278
+ $color = @$params['chameleon_color_' . $kind];
279
+ if ( $color ) {
280
+ $colors['color-' . $kind] = $color;
281
+ } else {
282
+ //$colors['color-' . $kind] = 'auto';
283
+ }
284
+ }
285
+
286
+ if ( empty( $colors ) ) {
287
+ $colors = 'auto';
288
+ }
289
+
290
+ $colors = json_encode($colors);
291
+
292
+ $chameleon = apply_filters( 'ecwid_chameleon_settings', array( 'colors' => $colors ) );
293
+
294
+ if ( !is_array($chameleon ) ) {
295
+ $chameleon = array(
296
+ 'colors' => $colors,
297
+ );
298
+ }
299
+
300
+ if ( !isset( $chameleon['colors'] ) ) {
301
+ $chameleon['colors'] = json_encode($colors);
302
+ }
303
+
304
+ $store_page_data['chameleon-colors'] = $chameleon['colors'];
305
+
306
+ Ecwid_Store_Page::save_store_page_params( $store_page_data );
307
+
308
+ if ( $chameleon['colors'] != 'auto' ) {
309
+ $result .= <<<JS
310
+ window.ec.config.chameleon = window.ec.config.chameleon || Object();
311
+ window.ec.config.chameleon.colors = $chameleon[colors];
312
+ JS;
313
+ }
314
+ $result .= "
315
+ Ecwid.OnAPILoaded.add(function() {
316
+ Ecwid.refreshConfig();
317
+ });
318
+ </script>";
319
+
320
+ return $result;
321
+ }
322
+
323
+ public static function get_block_names() {
324
+ return array(
325
+ self::STORE_BLOCK,
326
+ self::PRODUCT_BLOCK
327
+ );
328
+ }
329
+
330
+ /**
331
+ * @param $post
332
+ *
333
+ * @return array
334
+ */
335
+ public static function get_blocks_on_page() {
336
+ $post = get_post();
337
+
338
+ if ( !$post ) return array();
339
+
340
+ if ( function_exists( 'gutenberg_parse_blocks' ) ) {
341
+ $blocks = gutenberg_parse_blocks( $post->post_content );
342
+ } else {
343
+ $blocks = parse_blocks( $post->post_content );
344
+ }
345
+
346
+ if ( empty( $blocks ) ) {
347
+ return array();
348
+ }
349
+
350
+ $result = array();
351
+
352
+ $ecwid_blocks = self::get_block_names();
353
+ foreach ( $blocks as $block ) {
354
+ if ( in_array( $block['blockName'], $ecwid_blocks ) ) {
355
+ $result[$block['blockName']] = $block;
356
+ }
357
+ }
358
+
359
+ return $result;
360
+ }
361
+
362
+ protected function _get_version_for_assets( $asset_file_path )
363
+ {
364
+ if ( $_SERVER['HTTP_HOST'] == 'localhost' ) {
365
+ return filemtime( ECWID_PLUGIN_DIR . '/' . $asset_file_path );
366
+ }
367
+
368
+ return get_option( 'ecwid_plugin_version' );
369
+ }
370
+
371
+ protected function _get_attributes_for_editor() {
372
+ $api = new Ecwid_Api_V3();
373
+
374
+ if ( $api->is_available() && $api->get_store_profile() ) {
375
+ $settings = $api->get_store_profile()->designSettings;
376
+ } else {
377
+ $settings = new stdClass();
378
+ }
379
+
380
+ $attributes = Ecwid_Product_Browser::get_attributes();
381
+ $to_remove = array(
382
+ 'product_details_two_columns_with_left_sidebar_show_product_description_on_sidebar',
383
+ 'product_details_two_columns_with_right_sidebar_show_product_description_on_sidebar'
384
+ );
385
+ foreach ( $to_remove as $name ) {
386
+ unset( $attributes[ $name ] );
387
+ }
388
+
389
+ $attributes['show_description_under_image'] = array(
390
+ 'name' => 'show_description_under_image',
391
+ 'title' => __( 'Show description under the image', 'ecwid-shopping-cart' ),
392
+ 'default' => false,
393
+ 'type' => 'boolean'
394
+ );
395
+
396
+ foreach ( $attributes as $key => $attribute ) {
397
+ $name = $attribute['name'];
398
+
399
+ $default = null;
400
+ if ( property_exists( $settings, $name ) ) {
401
+ $default = $settings->$name;
402
+ }
403
+
404
+ $prop_to_default_exceptions = array(
405
+ 'product_list_category_image_aspect_ratio' => 'product_list_image_aspect_ratio',
406
+ 'product_list_category_image_size' => 'product_list_image_size'
407
+ );
408
+
409
+ if ( array_key_exists( $name, $prop_to_default_exceptions ) ) {
410
+ $another_name = $prop_to_default_exceptions[ $name ];
411
+ if ( property_exists( $settings, $another_name ) ) {
412
+ $default = $settings->$another_name;
413
+ }
414
+ }
415
+
416
+ if ( $default !== null ) {
417
+ $attributes[ $key ]['default'] = $default;
418
+ }
419
+ }
420
+
421
+ $categories = ecwid_get_categories_for_selector();
422
+
423
+ if ( $categories ) {
424
+ $attributes['default_category_id']['values'] = array(
425
+ array(
426
+ 'value' => '',
427
+ 'title' => __( 'Store root category', 'ecwid-shopping-cart' )
428
+ )
429
+ );
430
+ foreach ( $categories as $category ) {
431
+ $attributes['default_category_id']['values'][] = array(
432
+ 'value' => $category->id,
433
+ 'title' => $category->name
434
+ );
435
+ }
436
+ } else {
437
+ $api = new Ecwid_Api_V3();
438
+ $cats = $api->get_categories( array() );
439
+
440
+ if ( $cats && $cats->total == 0 ) {
441
+ unset( $attributes['default_category_id'] );
442
+ }
443
+ }
444
+
445
+ $attributes['widgets'] = array( 'type' => 'string', 'default' => '', 'name' => 'widgets' );
446
+
447
+ return $attributes;
448
+ }
449
+
450
+ public static function get_store_block_data_from_current_page() {
451
+
452
+ $blocks = self::get_blocks_on_page();
453
+
454
+ $store_block = null;
455
+ foreach ( $blocks as $block ) {
456
+ if ( $block['blockName'] == self::STORE_BLOCK ) {
457
+ $store_block = $block;
458
+ break;
459
+ }
460
+ }
461
+
462
+ if ( !$store_block ) return array();
463
+
464
+ return $store_block['atts'];
465
+ }
466
+
467
+ protected function _get_store_icon_path()
468
+ {
469
+ return 'M15.32,15.58c-0.37,0-0.66,0.3-0.66,0.67c0,0.37,0.3,0.67,0.66,0.67c0.37,0,0.67-0.3,0.67-0.67
470
+ C15.98,15.88,15.69,15.58,15.32,15.58z M15.45,0H4.55C2.04,0,0,2.04,0,4.55v10.91C0,17.97,2.04,20,4.55,20h10.91c2.51,0,4.55-2.04,4.55-4.55V4.55
471
+ C20,2.04,17.96,0,15.45,0z M12.97,4.94C13.54,4.94,14,5.4,14,5.96s-0.46,1.03-1.03,1.03c-0.57,0-1.03-0.46-1.03-1.03
472
+ C11.95,5.4,12.41,4.94,12.97,4.94z M12.97,8.02c0.57,0,1.03,0.46,1.03,1.03c0,0.57-0.46,1.03-1.03,1.03c-0.57,0-1.03-0.46-1.03-1.03
473
+ C11.95,8.48,12.41,8.02,12.97,8.02z M9.98,4.94c0.57,0,1.03,0.46,1.03,1.03s-0.46,1.03-1.03,1.03c-0.57,0-1.03-0.46-1.03-1.03
474
+ C8.95,5.4,9.41,4.94,9.98,4.94z M9.98,8.02c0.57,0,1.03,0.46,1.03,1.03s-0.46,1.03-1.03,1.03c-0.57,0-1.03-0.46-1.03-1.03
475
+ C8.95,8.48,9.41,8.02,9.98,8.02z M7.03,4.94c0.57,0,1.03,0.46,1.03,1.03S7.6,6.99,7.03,6.99C6.46,6.99,6,6.53,6,5.96
476
+ C6,5.4,6.46,4.94,7.03,4.94z M7.03,8.02c0.57,0,1.03,0.46,1.03,1.03s-0.46,1.03-1.03,1.03C6.46,10.08,6,9.62,6,9.05
477
+ C6,8.48,6.46,8.02,7.03,8.02z M4.6,18.02c-1.02,0-1.86-0.83-1.86-1.86c0-1.03,0.83-1.86,1.86-1.86c1.03,0,1.86,0.83,1.86,1.86
478
+ C6.45,17.19,5.62,18.02,4.6,18.02z M15.32,18.1c-1.02,0-1.86-0.83-1.86-1.86c0-1.03,0.83-1.86,1.86-1.86c1.03,0,1.86,0.83,1.86,1.86
479
+ C17.17,17.27,16.34,18.1,15.32,18.1z M18.48,2.79l-1.92,7.14c-0.51,1.91-2.03,3.1-4,3.1H7.2c-1.91,0-3.26-1.09-3.84-2.91L1.73,5
480
+ C1.7,4.9,1.72,4.79,1.78,4.71c0.06-0.09,0.16-0.14,0.27-0.14l0.31,0c0.75,0,1.41,0.49,1.64,1.2l1.2,3.76
481
+ c0.32,1.02,1.26,1.7,2.33,1.7h4.81c1.1,0,2.08-0.74,2.36-1.81l1.55-5.78c0.2-0.75,0.89-1.28,1.67-1.28h0.24
482
+ c0.1,0,0.2,0.05,0.26,0.13C18.48,2.58,18.5,2.68,18.48,2.79z M4.6,15.5c-0.37,0-0.66,0.3-0.66,0.67c0,0.37,0.3,0.67,0.66,0.67c0.37,0,0.67-0.3,0.67-0.67
483
+ S4.96,15.5,4.6,15.5z';
484
+ }
485
+
486
+ protected function _get_product_icon_path()
487
+ {
488
+ return 'M16.43,5.12c-0.13-1.19-0.15-1.19-1.35-1.33c-0.21-0.02-0.21-0.02-0.43-0.05c-0.01,0.06,0.06,0.78,0.14,1.13
489
+ c0.57,0.37,0.87,0.98,0.87,1.71c0,1.14-0.93,2.07-2.07,2.07s-2.07-0.93-2.07-2.07c0-0.54,0.09-0.97,0.55-1.4
490
+ c-0.06-0.61-0.19-1.54-0.18-1.64C10.14,3.46,8.72,3.46,8.58,3.6l-8.17,8.13c-0.56,0.55-0.56,1.43,0,1.97l5.54,5.93
491
+ c0.56,0.55,1.46,0.55,2.01,0l8.67-8.14C17.04,11.09,16.68,7.14,16.43,5.12z M16.06,0.04c-1.91,0-3.46,1.53-3.46,3.41c0,0.74,0.4,3.09,0.44,3.28c0.07,0.34,0.52,0.56,0.86,0.49
492
+ C14,7.19,14.07,7.15,14.12,7.1c0.24-0.11,0.32-0.39,0.25-0.68c-0.09-0.45-0.39-2.44-0.39-2.94c0-1.16,0.94-2.09,2.11-2.09
493
+ c1.24,0,2.11,0.96,2.11,2.34c0,2.43-0.31,4.23-0.32,4.26c-0.1,0.17-0.1,0.38-0.03,0.55c0.03,0.17,0.13,0.31,0.28,0.4
494
+ c0.1,0.06,0.22,0.09,0.33,0.09c0.21,0,0.42-0.1,0.54-0.3c0.06-0.09,0.52-2.17,0.52-5.03C19.52,1.61,18.04,0.04,16.06,0.04z';
495
+ }
496
+ }
497
+
498
+ $ecwid_gutenberg = new Ecwid_Integration_Gutenberg();
js/gutenberg/minicart.jsx ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Import CSS.
2
+ import './style.scss';
3
+ import './editor.scss';
4
+
5
+ import {EcwidIcons} from '../icons.js';
6
+
7
+ if ( !EcwidGutenbergParams.isDemoStore ) {
8
+
9
+ const { __, _x } = wp.i18n; // Import __() from wp.i18n
10
+
11
+ const {
12
+ InspectorControls
13
+ } = wp.editor;
14
+
15
+ const {
16
+ PanelBody,
17
+ BaseControl,
18
+ } = wp.components;
19
+
20
+ const {
21
+ registerBlockType,
22
+ } = wp.blocks;
23
+
24
+ /**
25
+ * Register: aa Gutenberg Block.
26
+ *
27
+ * Registers a new block provided a unique name and an object defining its
28
+ * behavior. Once registered, the block is made editor as an option to any
29
+ * editor interface where blocks are implemented.
30
+ *
31
+ * @link https://wordpress.org/gutenberg/handbook/block-api/
32
+ * @param {string} name Block name.
33
+ * @param {Object} settings Block settings.
34
+ * @return {?WPBlock} The block, if it has been successfully
35
+ * registered; otherwise `undefined`.
36
+ */
37
+ registerBlockType( 'ec-store/minicart', {
38
+ title: __( 'Shopping Cart Icon', 'ecwid-shopping-cart' ),
39
+ icon: EcwidIcons.cart,
40
+ category: 'ec-store', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
41
+ description: __( 'Display shopping bag link and summary', 'ecwid-shopping-cart' ),
42
+ supports: {
43
+ customClassName: false,
44
+ className: false,
45
+ html: false,
46
+ isPrivate: !EcwidGutenbergParams.isApiAvailable,
47
+ align: true,
48
+ alignWide: false
49
+ },
50
+ attributes: EcwidGutenbergParams.minicartAttributes,
51
+
52
+ /**
53
+ * The edit function describes the structure of your block in the context of the editor.
54
+ * This represents what the editor will render when the block is used.
55
+ *
56
+ * The "edit" property must be a valid function.
57
+ *
58
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
59
+ */
60
+ edit: function( props ) {
61
+
62
+ const { attributes } = props;
63
+
64
+ function buildSelect(props, name, label, items) {
65
+ return <BaseControl label={ label }>
66
+ <select className="ec-store-inspector-select" onChange={ (event) => { props.setAttributes( { [name]:event.target.value } ) } }>
67
+ { items.map( function(item) {
68
+ return <option value={item.value} selected={ props.attributes[name] == item.value }>{item.title}</option>
69
+ })}
70
+ </select>
71
+ </BaseControl>;
72
+ }
73
+
74
+ function buildItem(props, name, type) {
75
+
76
+ const item = EcwidGutenbergParams.minicartAttributes[name];
77
+
78
+ if ( typeof type === 'undefined' ) {
79
+ type = item.type;
80
+ }
81
+
82
+ return buildSelect( props, item.name, item.title, item.values );
83
+ }
84
+
85
+ const editor = <div className="ec-store-block ec-store-block-minicart">
86
+ <div className="image">
87
+ </div>
88
+ </div>;
89
+
90
+ return ([
91
+ editor,
92
+ <InspectorControls>
93
+ <PanelBody title={ __('Appearance', 'ecwid-shopping-cart') } initialOpen={true}>
94
+ { buildItem(props, 'layout', 'select' ) }
95
+ { buildItem(props, 'icon', 'select' ) }
96
+ { buildItem(props, 'fixed_shape', 'select' ) }
97
+ </PanelBody>
98
+ </InspectorControls>
99
+ ]);
100
+ },
101
+
102
+ save: function( props ) {
103
+ return false;
104
+ },
105
+
106
+ } );
107
+
108
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Ecwid
3
  Tags: ecommerce, e-commerce, storefront, online store, sell
4
  Requires at least: 3.7
5
  Tested up to: 5.2
6
- Stable tag: 6.8.1
7
 
8
  Powerful, easy to use ecommerce shopping cart. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.
9
 
@@ -153,6 +153,9 @@ You can use Ecwid’s built-in import tools to copy your store products from any
153
  * [Ecwid eCommerce Forums](https://www.ecwid.com/forums/forumdisplay.php?f=19)
154
 
155
  == Changelog ==
 
 
 
156
  = 6.8.1 - Jun 13, 2019 =
157
  - **Enabled the “Cache and speed up the store page” feature for the old Ecwid accounts**. The feature appeared in the previously released version (6.8), but it was disabled for the part of old Ecwid accounts. It’s now available for everyone. You can turn it on on the “Ecwid/Advanced” page in your WordPress admin backend.
158
 
3
  Tags: ecommerce, e-commerce, storefront, online store, sell
4
  Requires at least: 3.7
5
  Tested up to: 5.2
6
+ Stable tag: 6.8.2
7
 
8
  Powerful, easy to use ecommerce shopping cart. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.
9
 
153
  * [Ecwid eCommerce Forums](https://www.ecwid.com/forums/forumdisplay.php?f=19)
154
 
155
  == Changelog ==
156
+ = 6.8.2 - Jun 14, 2019 =
157
+ - Fixed an error that happened under certain site configurations
158
+
159
  = 6.8.1 - Jun 13, 2019 =
160
  - **Enabled the “Cache and speed up the store page” feature for the old Ecwid accounts**. The feature appeared in the previously released version (6.8), but it was disabled for the part of old Ecwid accounts. It’s now available for everyone. You can turn it on on the “Ecwid/Advanced” page in your WordPress admin backend.
161