Version Description
- Jun 13, 2019 =
- 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. Its now available for everyone. You can turn it on on the Ecwid/Advanced page in your WordPress admin backend.
Download this release
Release Info
Developer | Ecwid |
Plugin | Ecwid Ecommerce Shopping Cart |
Version | 6.8.1 |
Comparing to | |
See all releases |
Code changes from version 6.8 to 6.8.1
- css/gutenberg-product.css +0 -0
- css/gutenberg-store.css +0 -216
- css/gutenberg/blocks.style.css +0 -2
- ecwid-shopping-cart.php +1 -1
- includes/class-ecwid-static-home-page.php +0 -237
- includes/class-ecwid-static-page.php +1 -2
- includes/integrations/class-ecwid-integration-gutenberg.php +0 -498
- js/create_scroller.js +0 -12
- js/gutenberg-product.js +0 -114
- js/gutenberg-store.js +0 -172
- js/static-home-page.js +0 -281
- js/sync.js +0 -15
- js/themes/vantage.js +0 -69
- lib/ecwid_api_v3.php +0 -1
- lib/ecwid_product_api.php +0 -263
- readme.txt +4 -1
css/gutenberg-product.css
DELETED
File without changes
|
css/gutenberg-store.css
DELETED
@@ -1,216 +0,0 @@
|
|
1 |
-
.ecwid-store-block-icon {
|
2 |
-
background: url('../images/wordpress_20x20.svg');
|
3 |
-
background-size: contain;
|
4 |
-
width: 20px;
|
5 |
-
height: 20px;
|
6 |
-
margin-bottom: 3px;
|
7 |
-
}
|
8 |
-
|
9 |
-
.ecwid-store-block {
|
10 |
-
position: relative;
|
11 |
-
}
|
12 |
-
|
13 |
-
.ecwid-store-block-button {
|
14 |
-
font-family: Open Sans, Trebuchet MS, Helvetica, Verdana, sans-serif;
|
15 |
-
position: relative;
|
16 |
-
top:135px;
|
17 |
-
font-size: 14px;
|
18 |
-
}
|
19 |
-
|
20 |
-
.ecwid-product-block-icon {
|
21 |
-
background: url('../images/gutenberg-block-product.svg');
|
22 |
-
background-size: contain;
|
23 |
-
width: 20px;
|
24 |
-
height: 20px;
|
25 |
-
margin-bottom: 3px;
|
26 |
-
}
|
27 |
-
|
28 |
-
.ecwid-block {
|
29 |
-
text-align: center;
|
30 |
-
font-size: 13px;
|
31 |
-
font-family: 'Open Sans';
|
32 |
-
padding: 1em;
|
33 |
-
background-color: #f8f9f9;
|
34 |
-
display: flex;
|
35 |
-
flex-direction: column;
|
36 |
-
justify-content: center;
|
37 |
-
min-height: 220px;
|
38 |
-
}
|
39 |
-
|
40 |
-
.ecwid-block > div {
|
41 |
-
display: flex;
|
42 |
-
justify-content: center;
|
43 |
-
}
|
44 |
-
|
45 |
-
.ecwid-block .ecwid-block-header {
|
46 |
-
font-weight: 600;
|
47 |
-
margin-bottom: 1em;
|
48 |
-
}
|
49 |
-
|
50 |
-
.ecwid-block .ecwid-block-header svg {
|
51 |
-
max-height: 20px;
|
52 |
-
margin-right: 1ch;
|
53 |
-
}
|
54 |
-
|
55 |
-
.ecwid-block .ecwid-store-block-icon,
|
56 |
-
.ecwid-block .ecwid-product-block-icon {
|
57 |
-
margin-right: 10px;
|
58 |
-
}
|
59 |
-
|
60 |
-
.ecwid-block .ecwid-block-image {
|
61 |
-
height: 90px;
|
62 |
-
background-repeat: no-repeat;
|
63 |
-
background-size: contain;
|
64 |
-
background-position: 50% 50%;
|
65 |
-
}
|
66 |
-
|
67 |
-
.ecwid-block .ecwid-block-image img {
|
68 |
-
width: auto;
|
69 |
-
max-height: 100%;
|
70 |
-
-webkit-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
71 |
-
-moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
72 |
-
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
73 |
-
}
|
74 |
-
|
75 |
-
.ecwid-block .ecwid-block-title {
|
76 |
-
margin-top: 11px;
|
77 |
-
margin-bottom: 1em;
|
78 |
-
}
|
79 |
-
|
80 |
-
.ecwid-block .ecwid-block-button {
|
81 |
-
font-weight: 400;
|
82 |
-
}
|
83 |
-
|
84 |
-
/*
|
85 |
-
Popup styles for selected product block
|
86 |
-
*/
|
87 |
-
|
88 |
-
.ecwid-selected-product {
|
89 |
-
font-family: Open Sans, Trebuchet MS, Helvetica, Verdana, sans-serif;
|
90 |
-
}
|
91 |
-
|
92 |
-
.ecwid-selected-product > div {
|
93 |
-
display: table-cell;
|
94 |
-
}
|
95 |
-
|
96 |
-
.ecwid-selected-product .ecwid-selected-product-image img {
|
97 |
-
-webkit-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
98 |
-
-moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
99 |
-
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
100 |
-
}
|
101 |
-
|
102 |
-
.ecwid-selected-product .ecwid-selected-product-image {
|
103 |
-
padding-right: 25px;
|
104 |
-
vertical-align: top;
|
105 |
-
}
|
106 |
-
|
107 |
-
.ecwid-selected-product .ecwid-selected-product-details {
|
108 |
-
vertical-align: middle;
|
109 |
-
}
|
110 |
-
|
111 |
-
.ecwid-selected-product .ecwid-selected-product-name {
|
112 |
-
font-size: 20px;
|
113 |
-
font-weight: 600;
|
114 |
-
margin-bottom: 0.5em;
|
115 |
-
}
|
116 |
-
|
117 |
-
.ecwid-selected-product .ecwid-selected-product-sku {
|
118 |
-
font-size: 16px;
|
119 |
-
margin-bottom: 1em;
|
120 |
-
}
|
121 |
-
|
122 |
-
.media-frame-content.has-selected-product form,
|
123 |
-
.media-frame-content.has-selected-product .products,
|
124 |
-
.media-frame-content.has-selected-product .tablenav
|
125 |
-
{
|
126 |
-
display: none;
|
127 |
-
}
|
128 |
-
|
129 |
-
#ecwid-product-popup-content .media-frame-content.ecwid-selected-product {
|
130 |
-
padding-left: 20px;
|
131 |
-
padding-top: 40px;
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
.ecwid-store-block-icon {
|
136 |
-
background: url('../images/wordpress_20x20.svg');
|
137 |
-
background-size: contain;
|
138 |
-
width: 20px;
|
139 |
-
height: 20px;
|
140 |
-
margin-bottom: 3px;
|
141 |
-
}
|
142 |
-
|
143 |
-
.ecwid-store-block {
|
144 |
-
position: relative;
|
145 |
-
}
|
146 |
-
|
147 |
-
.ecwid-store-block-button {
|
148 |
-
font-family: Open Sans, Trebuchet MS, Helvetica, Verdana, sans-serif;
|
149 |
-
position: relative;
|
150 |
-
top:135px;
|
151 |
-
font-size: 14px;
|
152 |
-
}
|
153 |
-
|
154 |
-
.ecwid-product-block-icon {
|
155 |
-
background: url('../images/gutenberg-block-product.svg');
|
156 |
-
background-size: contain;
|
157 |
-
width: 20px;
|
158 |
-
height: 20px;
|
159 |
-
margin-bottom: 3px;
|
160 |
-
}
|
161 |
-
|
162 |
-
.ec-store-block {
|
163 |
-
text-align: center;
|
164 |
-
font-size: 13px;
|
165 |
-
font-family: 'Open Sans';
|
166 |
-
padding: 1em;
|
167 |
-
background-color: #f8f9f9;
|
168 |
-
display: flex;
|
169 |
-
flex-direction: column;
|
170 |
-
justify-content: center;
|
171 |
-
min-height: 220px;
|
172 |
-
}
|
173 |
-
|
174 |
-
.ec-store-block > div {
|
175 |
-
display: flex;
|
176 |
-
justify-content: center;
|
177 |
-
}
|
178 |
-
|
179 |
-
.ec-store-block .ec-store-block-header {
|
180 |
-
font-weight: 600;
|
181 |
-
margin-bottom: 1em;
|
182 |
-
}
|
183 |
-
|
184 |
-
.ec-store-block .ec-store-block-header svg {
|
185 |
-
max-height: 20px;
|
186 |
-
margin-right: 1ch;
|
187 |
-
}
|
188 |
-
|
189 |
-
.ec-store-block .ec-store-store-block-icon,
|
190 |
-
.ec-store-block .ec-store-product-block-icon {
|
191 |
-
margin-right: 10px;
|
192 |
-
}
|
193 |
-
|
194 |
-
.ec-store-block .ec-store-block-image {
|
195 |
-
height: 90px;
|
196 |
-
background-repeat: no-repeat;
|
197 |
-
background-size: contain;
|
198 |
-
background-position: 50% 50%;
|
199 |
-
}
|
200 |
-
|
201 |
-
.ec-store-block .ec-store-block-image img {
|
202 |
-
width: auto;
|
203 |
-
max-height: 100%;
|
204 |
-
-webkit-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
205 |
-
-moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
206 |
-
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.1);
|
207 |
-
}
|
208 |
-
|
209 |
-
.ec-store-block .ec-store-block-title {
|
210 |
-
margin-top: 11px;
|
211 |
-
margin-bottom: 1em;
|
212 |
-
}
|
213 |
-
|
214 |
-
.ec-store-block .ec-store-block-button {
|
215 |
-
font-weight: 400;
|
216 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/gutenberg/blocks.style.css
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
.wp-block-cgb-block-my-block{background:#ff4500;border:0.2rem solid #292929;color:#292929;margin:0 auto;max-width:740px;padding:2rem}
|
2 |
-
.wp-block-cgb-block-my-block2{background:#ff4500;border:0.2rem solid #292929;color:#292929;margin:0 auto;max-width:740px;padding:2rem}
|
|
|
|
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
|
9 |
Author URI: https://ecwid.to/ecwid-site
|
10 |
*/
|
11 |
|
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 |
|
includes/class-ecwid-static-home-page.php
DELETED
@@ -1,237 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-product-browser.php';
|
4 |
-
|
5 |
-
class Ecwid_Static_Home_Page {
|
6 |
-
|
7 |
-
const OPTION_IS_ENABLED = 'ecwid_static_home_page_enabled';
|
8 |
-
|
9 |
-
const OPTION_VALUE_ENABLED = 'Y';
|
10 |
-
const OPTION_VALUE_DISABLED = 'N';
|
11 |
-
const OPTION_VALUE_AUTO = '';
|
12 |
-
|
13 |
-
const CACHE_DATA = 'static_home_page_data';
|
14 |
-
const PARAM_VALID_FROM = 'static_home_page_valid_from';
|
15 |
-
|
16 |
-
const HANDLE_STATIC_PAGE = 'static-home-page';
|
17 |
-
|
18 |
-
protected $_has_theme_adjustments = false;
|
19 |
-
|
20 |
-
public function __construct() {
|
21 |
-
|
22 |
-
add_option( self::OPTION_IS_ENABLED );
|
23 |
-
|
24 |
-
if ( !is_admin() ) {
|
25 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
26 |
-
add_action( Ecwid_Theme_Base::ACTION_APPLY_THEME, array( $this, 'apply_theme' ) );
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
public function enqueue_scripts()
|
31 |
-
{
|
32 |
-
if ( !self::is_enabled() ) {
|
33 |
-
return null;
|
34 |
-
}
|
35 |
-
|
36 |
-
$data = $this->get_data_for_current_page();
|
37 |
-
|
38 |
-
if ( !$data || !is_array( $data->cssFiles ) || empty ( $data->cssFiles ) ) return;
|
39 |
-
|
40 |
-
EcwidPlatform::enqueue_script( self::HANDLE_STATIC_PAGE, array() );
|
41 |
-
|
42 |
-
foreach ( $data->cssFiles as $ind => $item ) {
|
43 |
-
wp_enqueue_style( 'ecwid-' . self::HANDLE_STATIC_PAGE . '-' . $ind, $item );
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
public function apply_theme( $theme ) {
|
48 |
-
if ( $theme ) {
|
49 |
-
$this->_has_theme_adjustments = true;
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
public static function get_data_for_current_page()
|
54 |
-
{
|
55 |
-
if ( !self::is_enabled() ) {
|
56 |
-
return null;
|
57 |
-
}
|
58 |
-
|
59 |
-
if ( current_user_can( Ecwid_Admin::get_capability() ) ) {
|
60 |
-
EcwidPlatform::force_catalog_cache_reset();
|
61 |
-
}
|
62 |
-
|
63 |
-
|
64 |
-
if ( Ecwid_Seo_Links::is_enabled() && Ecwid_Seo_Links::is_seo_link() ) {
|
65 |
-
return null;
|
66 |
-
}
|
67 |
-
|
68 |
-
$data = self::_maybe_fetch_data();
|
69 |
-
|
70 |
-
if ( $data ) {
|
71 |
-
return $data;
|
72 |
-
}
|
73 |
-
|
74 |
-
return null;
|
75 |
-
}
|
76 |
-
|
77 |
-
protected static function _maybe_fetch_data()
|
78 |
-
{
|
79 |
-
$store_page_params = Ecwid_Store_Page::get_store_page_params();
|
80 |
-
|
81 |
-
if ( isset( $store_page_params['default_category_id'] ) && $store_page_params['default_category_id'] ) {
|
82 |
-
return null;
|
83 |
-
}
|
84 |
-
|
85 |
-
if ( isset( $store_page_params['default_product_id'] ) && $store_page_params['default_product_id'] ) {
|
86 |
-
return null;
|
87 |
-
}
|
88 |
-
|
89 |
-
$params = array();
|
90 |
-
|
91 |
-
if ( Ecwid_Seo_Links::is_enabled() ) {
|
92 |
-
$params['clean_links'] = 'true';
|
93 |
-
$params['base_url'] = get_permalink();
|
94 |
-
}
|
95 |
-
|
96 |
-
foreach ( Ecwid_Product_Browser::get_attributes() as $attribute ) {
|
97 |
-
$name = $attribute['name'];
|
98 |
-
if ( @$attribute['is_storefront_api'] && isset( $store_page_params[$name] ) ) {
|
99 |
-
if ( @$attribute['type'] == 'boolean' ) {
|
100 |
-
$value = $store_page_params[$name] ? 'true' : 'false';
|
101 |
-
} else {
|
102 |
-
$value = $store_page_params[$name];
|
103 |
-
}
|
104 |
-
|
105 |
-
$params['tplvar_ec.storefront.' . $name] = $value;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
$url = 'https://storefront.ecwid.com/home-page/' . get_ecwid_store_id() . '/static-code?';
|
110 |
-
foreach ( $params as $name => $value ) {
|
111 |
-
$url .= $name . '=' . urlencode( $value ) . '&';
|
112 |
-
}
|
113 |
-
|
114 |
-
$accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
115 |
-
$accept_language = apply_filters( 'ecwid_lang', $accept_language );
|
116 |
-
|
117 |
-
$cache_key = $accept_language . "\n" . $url;
|
118 |
-
|
119 |
-
$cached_data = EcwidPlatform::get_from_catalog_cache( $cache_key );
|
120 |
-
|
121 |
-
if ( $cached_data ) {
|
122 |
-
return $cached_data;
|
123 |
-
}
|
124 |
-
|
125 |
-
$fetched_data = null;
|
126 |
-
|
127 |
-
$fetched_data = EcwidPlatform::fetch_url(
|
128 |
-
$url,
|
129 |
-
array(
|
130 |
-
'timeout' => 3,
|
131 |
-
'headers' => array(
|
132 |
-
'ACCEPT-LANGUAGE' => $accept_language
|
133 |
-
)
|
134 |
-
)
|
135 |
-
);
|
136 |
-
|
137 |
-
|
138 |
-
if ( $fetched_data && @$fetched_data['data'] ) {
|
139 |
-
|
140 |
-
$fetched_data = @json_decode( $fetched_data['data'] );
|
141 |
-
|
142 |
-
if ( $fetched_data->jsCode ) {
|
143 |
-
$fetched_data->jsCode .= <<<JS
|
144 |
-
window.ec = window.ec || {};
|
145 |
-
window.ec.config = window.ec.config || {};
|
146 |
-
window.ec.config.interactive = false;
|
147 |
-
JS;
|
148 |
-
}
|
149 |
-
|
150 |
-
EcwidPlatform::store_in_catalog_cache( $cache_key, $fetched_data );
|
151 |
-
|
152 |
-
return $fetched_data;
|
153 |
-
}
|
154 |
-
|
155 |
-
return null;
|
156 |
-
}
|
157 |
-
|
158 |
-
protected static function _get_store_params()
|
159 |
-
{
|
160 |
-
$store_id = get_ecwid_store_id();
|
161 |
-
|
162 |
-
$post = get_post();
|
163 |
-
if ( !$post ) {
|
164 |
-
return null;
|
165 |
-
}
|
166 |
-
$post_modified = strtotime( $post->post_modified_gmt );
|
167 |
-
|
168 |
-
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
169 |
-
$lang = substr( $lang, 0, strpos( $lang, ';' ) );
|
170 |
-
|
171 |
-
$cache_key = "static_post_content $store_id $post->ID $post_modified $lang";
|
172 |
-
|
173 |
-
$store_params = EcwidPlatform::get_from_catalog_cache( $cache_key );
|
174 |
-
|
175 |
-
if ( !$store_params ) {
|
176 |
-
$store_params = Ecwid_Store_Page::get_store_page_params();
|
177 |
-
}
|
178 |
-
|
179 |
-
$non_tplvar_params = array(
|
180 |
-
'default_category_id',
|
181 |
-
'lang'
|
182 |
-
);
|
183 |
-
|
184 |
-
$result = array();
|
185 |
-
|
186 |
-
foreach ( $store_params as $name => $value ) {
|
187 |
-
if ( in_array( $name, $non_tplvar_params ) ) {
|
188 |
-
$result[$name] = $value;
|
189 |
-
} else {
|
190 |
-
$result['tplvar_ec.storefront.' . $name] = $value;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return $result;
|
195 |
-
}
|
196 |
-
|
197 |
-
|
198 |
-
public static function is_enabled()
|
199 |
-
{
|
200 |
-
if ( !EcwidPlatform::is_catalog_cache_trusted() ) {
|
201 |
-
return false;
|
202 |
-
}
|
203 |
-
|
204 |
-
if ( get_option( self::OPTION_IS_ENABLED ) == self::OPTION_VALUE_ENABLED ) {
|
205 |
-
return true;
|
206 |
-
}
|
207 |
-
|
208 |
-
if ( !self::is_feature_available() ) {
|
209 |
-
return false;
|
210 |
-
}
|
211 |
-
|
212 |
-
if ( get_option( self::OPTION_IS_ENABLED ) == self::OPTION_VALUE_DISABLED ) {
|
213 |
-
return false;
|
214 |
-
}
|
215 |
-
|
216 |
-
if ( 0 && get_ecwid_store_id() > 15182050 && get_ecwid_store_id() % 2 == 0 ) {
|
217 |
-
return true;
|
218 |
-
}
|
219 |
-
|
220 |
-
return false;
|
221 |
-
}
|
222 |
-
|
223 |
-
public static function is_feature_available()
|
224 |
-
{
|
225 |
-
$api = new Ecwid_Api_V3();
|
226 |
-
|
227 |
-
return $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_STATIC_HOME_PAGE )
|
228 |
-
&& $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_NEW_PRODUCT_LIST );
|
229 |
-
}
|
230 |
-
|
231 |
-
protected static function _get_page_content_data_key( $url ) {
|
232 |
-
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
233 |
-
}
|
234 |
-
|
235 |
-
}
|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294,7 @@ class Ecwid_Static_Page {
|
|
294 |
public static function is_feature_available() {
|
295 |
$api = new Ecwid_Api_V3();
|
296 |
|
297 |
-
return $api->is_store_feature_enabled( Ecwid_Api_V3::
|
298 |
-
&& $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_NEW_PRODUCT_LIST );
|
299 |
}
|
300 |
|
301 |
}
|
294 |
public static function is_feature_available() {
|
295 |
$api = new Ecwid_Api_V3();
|
296 |
|
297 |
+
return $api->is_store_feature_enabled( Ecwid_Api_V3::FEATURE_NEW_PRODUCT_LIST );
|
|
|
298 |
}
|
299 |
|
300 |
}
|
includes/integrations/class-ecwid-integration-gutenberg.php
DELETED
@@ -1,498 +0,0 @@
|
|
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();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|
2 |
-
if (jQuery('#ecwid_product_browser_scroller').length == 0) {
|
3 |
-
|
4 |
-
var parent = jQuery('div[id^="ecwid-store-"]');
|
5 |
-
|
6 |
-
if (jQuery('.ecwid-shopping-cart-categories').length == 1) {
|
7 |
-
parent = jQuery('.ecwid-shopping-cart-categories');
|
8 |
-
}
|
9 |
-
|
10 |
-
parent.before('<div id="ecwid_product_browser_scroller" class="ecwid-scroller-adjustment"></div>');
|
11 |
-
}
|
12 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/gutenberg-product.js
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
( function( blocks, components, i18n, element, _ ) {
|
2 |
-
var el = element.createElement;
|
3 |
-
|
4 |
-
var saveCallback = function( params ) {
|
5 |
-
|
6 |
-
var attributes = {
|
7 |
-
'id': params.newProps.id
|
8 |
-
};
|
9 |
-
|
10 |
-
for (var i in {center_align:1, show_border:1, show_price_on_button:1}) {
|
11 |
-
attributes[i] = params.newProps[i];
|
12 |
-
}
|
13 |
-
|
14 |
-
for (var i in {picture:1,title:1,price:1,options:1,qty:1,addtobag:1}) {
|
15 |
-
attributes['show_' + i] = params.newProps.display.indexOf(i) != -1;
|
16 |
-
}
|
17 |
-
|
18 |
-
attributes.productName = params.newProps.product.name;
|
19 |
-
attributes.productSKU = params.newProps.product.sku;
|
20 |
-
attributes.productImageURL = params.newProps.product.thumb;
|
21 |
-
|
22 |
-
params.originalProps.setAttributes(attributes);
|
23 |
-
}
|
24 |
-
|
25 |
-
var getIcon = function() {
|
26 |
-
return el("svg", {
|
27 |
-
"aria-hidden": !0,
|
28 |
-
role: "img",
|
29 |
-
focusable: "false",
|
30 |
-
xmlns: "http://www.w3.org/2000/svg",
|
31 |
-
className: "dashicon",
|
32 |
-
width: 20,
|
33 |
-
height: 20,
|
34 |
-
viewBox: "0 0 20 20"
|
35 |
-
}, el("path", {
|
36 |
-
d: EcwidGutenbergParams.productIcon
|
37 |
-
}));
|
38 |
-
}
|
39 |
-
|
40 |
-
var ecwidBlockParams = {
|
41 |
-
title: EcwidGutenbergParams.productBlockTitle,
|
42 |
-
icon: getIcon(),
|
43 |
-
category: 'common',
|
44 |
-
attributes: {
|
45 |
-
id: { type: 'integer' },
|
46 |
-
show_picture: { type: 'boolean' },
|
47 |
-
show_title: { type: 'boolean' },
|
48 |
-
show_price: { type: 'boolean' },
|
49 |
-
show_options: { type: 'boolean' },
|
50 |
-
show_qty: { type: 'boolean' },
|
51 |
-
show_addtobag: { type: 'boolean' },
|
52 |
-
show_price_on_button: { type: 'boolean' },
|
53 |
-
show_border: { type: 'boolean' },
|
54 |
-
center_align: { type: 'boolean' },
|
55 |
-
productName: {type: 'string' },
|
56 |
-
productSKU: {type: 'string' },
|
57 |
-
productImageURL: {type: 'string' }
|
58 |
-
},
|
59 |
-
supports: {
|
60 |
-
customClassName: false,
|
61 |
-
className: false,
|
62 |
-
html: false
|
63 |
-
},
|
64 |
-
|
65 |
-
edit: function( props ) {
|
66 |
-
|
67 |
-
var imageUrl = props.attributes.productImageURL;
|
68 |
-
var productName = props.attributes.productName;
|
69 |
-
|
70 |
-
if ( !props.attributes.id ) {
|
71 |
-
return el( 'div', { className: 'ecwid-block' },
|
72 |
-
el( 'div', { className: 'ecwid-block-header' },
|
73 |
-
getIcon(),
|
74 |
-
EcwidGutenbergParams.yourProductLabel
|
75 |
-
),
|
76 |
-
el( 'div', {},
|
77 |
-
el( 'button', { className: 'button ecwid-block-button', onClick: function() { var params = {'saveCallback':saveCallback, 'props': props}; ecwid_open_product_popup( params ); } }, EcwidGutenbergParams.chooseProduct )
|
78 |
-
)
|
79 |
-
);
|
80 |
-
}
|
81 |
-
|
82 |
-
return el( 'div', {className: 'ecwid-block' },
|
83 |
-
el( 'div', { className: 'ecwid-block-header' },
|
84 |
-
el('div', {className: 'ecwid-product-block-icon'} ),
|
85 |
-
EcwidGutenbergParams.yourProductLabel
|
86 |
-
), el( 'div', { className: 'ecwid-block-image' }, el( 'img', {src: imageUrl } )
|
87 |
-
),
|
88 |
-
el( 'div', { className: 'ecwid-block-title' } , productName ),
|
89 |
-
el( 'div', {},
|
90 |
-
el( 'button', { className: 'button ecwid-block-button', onClick: function() { var params = {'saveCallback':saveCallback, 'props': props}; ecwid_open_product_popup( params ); } }, EcwidGutenbergParams.editAppearance )
|
91 |
-
)
|
92 |
-
);
|
93 |
-
},
|
94 |
-
save: function( props ) {
|
95 |
-
return false;
|
96 |
-
var shortcode = new wp.shortcode({
|
97 |
-
'tag': EcwidGutenbergParams.productShortcodeName,
|
98 |
-
'attrs': props.attributes,
|
99 |
-
'type': 'single'
|
100 |
-
});
|
101 |
-
|
102 |
-
return el( element.RawHTML, null, shortcode.string() );
|
103 |
-
}
|
104 |
-
};
|
105 |
-
blocks.registerBlockType( EcwidGutenbergParams.productBlock, ecwidBlockParams);
|
106 |
-
|
107 |
-
} )(
|
108 |
-
window.wp.blocks,
|
109 |
-
window.wp.components,
|
110 |
-
window.wp.i18n,
|
111 |
-
window.wp.element,
|
112 |
-
window._
|
113 |
-
);
|
114 |
-
ecwid_pb_defaults = EcwidGutenbergParams.ecwid_pb_defaults;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/gutenberg-store.js
DELETED
@@ -1,172 +0,0 @@
|
|
1 |
-
( function( blocks, components, i18n, element, _ ) {
|
2 |
-
var el = element.createElement;
|
3 |
-
|
4 |
-
var getIcon = function() {
|
5 |
-
return el("svg", {
|
6 |
-
"aria-hidden": !0,
|
7 |
-
role: "img",
|
8 |
-
focusable: "false",
|
9 |
-
xmlns: "http://www.w3.org/2000/svg",
|
10 |
-
className: "dashicon",
|
11 |
-
width: 20,
|
12 |
-
height: 20,
|
13 |
-
viewBox: "0 0 20 20"
|
14 |
-
}, el("path", {
|
15 |
-
d: EcwidGutenbergParams.storeIcon
|
16 |
-
}));
|
17 |
-
}
|
18 |
-
|
19 |
-
EcwidGutenbergParams.attributes = {
|
20 |
-
widgets: { type: 'string', default: 'productbrowser' },
|
21 |
-
default_category_id: { type: 'integer', default: 0 },
|
22 |
-
default_product_id: { type: 'integer', default: 0 }
|
23 |
-
};
|
24 |
-
|
25 |
-
// Cuz save knows nothing about the original params object, and I need to know the exact original attributes order
|
26 |
-
// Cuz their validation routine sucks and does not allow a tiny little difference between expected and actual block content
|
27 |
-
EcwidGutenbergParams.ownAttributes = Object.assign({}, EcwidGutenbergParams.attributes);
|
28 |
-
|
29 |
-
var ecwidStoreParams = {
|
30 |
-
title: EcwidGutenbergParams.storeBlockTitle,
|
31 |
-
icon: getIcon(),
|
32 |
-
category: 'common',
|
33 |
-
attributes: EcwidGutenbergParams.attributes,
|
34 |
-
supports: {
|
35 |
-
customClassName: false,
|
36 |
-
className: false,
|
37 |
-
html: false,
|
38 |
-
multiple: false
|
39 |
-
},
|
40 |
-
|
41 |
-
edit: function( props ) {
|
42 |
-
|
43 |
-
return el( 'div', {className: 'ecwid-block' },
|
44 |
-
el( 'div', { className: 'ecwid-block-header' },
|
45 |
-
getIcon(),
|
46 |
-
EcwidGutenbergParams.yourStoreWill
|
47 |
-
),
|
48 |
-
el( 'div', { className: 'ecwid-block-title' } , EcwidGutenbergParams.storeIdLabel + ': ' + EcwidGutenbergParams.storeId ),
|
49 |
-
el( 'div', {},
|
50 |
-
el( 'button', { className: 'button ecwid-block-button', onClick: function() { ecwid_open_store_popup( props ); } }, EcwidGutenbergParams.editAppearance )
|
51 |
-
)
|
52 |
-
);
|
53 |
-
},
|
54 |
-
save: function( props ) {
|
55 |
-
var shortcodeAttributes = {};
|
56 |
-
for ( var i in EcwidGutenbergParams.ownAttributes ) {
|
57 |
-
if ( EcwidGutenbergParams.ownAttributes.hasOwnProperty(i) ) {
|
58 |
-
shortcodeAttributes[i] = props.attributes[i];
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
var shortcode = new wp.shortcode({
|
63 |
-
'tag': EcwidGutenbergParams.storeShortcodeName,
|
64 |
-
'attrs': shortcodeAttributes,
|
65 |
-
'type': 'single'
|
66 |
-
});
|
67 |
-
|
68 |
-
return shortcode.string();
|
69 |
-
},
|
70 |
-
|
71 |
-
deprecated: [
|
72 |
-
{
|
73 |
-
attributes: {
|
74 |
-
widgets: { type: 'string' },
|
75 |
-
categories_per_row: { type: 'integer' },
|
76 |
-
grid: { type: 'string' },
|
77 |
-
list: { type: 'integer' },
|
78 |
-
table: { type: 'integer' },
|
79 |
-
default_category_id: { type: 'integer' },
|
80 |
-
default_product_id: { type: 'integer' },
|
81 |
-
category_view: { type: 'string' },
|
82 |
-
search_view: { type: 'string' },
|
83 |
-
minicart_layout: {type: 'string' }
|
84 |
-
},
|
85 |
-
|
86 |
-
save: function( props ) {
|
87 |
-
return null;
|
88 |
-
},
|
89 |
-
}
|
90 |
-
],
|
91 |
-
|
92 |
-
transforms: {
|
93 |
-
from: [{
|
94 |
-
type: 'shortcode',
|
95 |
-
tag: ['ecwid', 'ec_store'],
|
96 |
-
attributes: {
|
97 |
-
widgets: {
|
98 |
-
type: 'string',
|
99 |
-
shortcode: function(named) {
|
100 |
-
return named.widgets
|
101 |
-
}
|
102 |
-
},
|
103 |
-
categories_per_row: {
|
104 |
-
type: 'integer',
|
105 |
-
shortcode: function(named) {
|
106 |
-
return named.categories_per_row
|
107 |
-
}
|
108 |
-
},
|
109 |
-
grid: {
|
110 |
-
type: 'string',
|
111 |
-
shortcode: function(named) {
|
112 |
-
return named.grid
|
113 |
-
}
|
114 |
-
},
|
115 |
-
list: {
|
116 |
-
type: 'integer',
|
117 |
-
shortcode: function(named) {
|
118 |
-
return named.list
|
119 |
-
}
|
120 |
-
},
|
121 |
-
table: {
|
122 |
-
type: 'integer',
|
123 |
-
shortcode: function(named) {
|
124 |
-
return named.table
|
125 |
-
}
|
126 |
-
},
|
127 |
-
default_category_id: {
|
128 |
-
type: 'integer',
|
129 |
-
shortcode: function(named) {
|
130 |
-
return named.default_category_id
|
131 |
-
}
|
132 |
-
},
|
133 |
-
default_product_id: {
|
134 |
-
type: 'integer',
|
135 |
-
shortcode: function(named) {
|
136 |
-
return named.default_product_id
|
137 |
-
}
|
138 |
-
},
|
139 |
-
category_view: {
|
140 |
-
type: 'string',
|
141 |
-
shortcode: function(named) {
|
142 |
-
return named.category_view
|
143 |
-
}
|
144 |
-
},
|
145 |
-
search_view: {
|
146 |
-
type: 'string',
|
147 |
-
shortcode: function(named) {
|
148 |
-
return named.search_view
|
149 |
-
}
|
150 |
-
},
|
151 |
-
minicart_layout: {
|
152 |
-
type: 'string',
|
153 |
-
shortcode: function(named) {
|
154 |
-
return named.minicart_layout
|
155 |
-
}
|
156 |
-
}
|
157 |
-
},
|
158 |
-
priority: 10
|
159 |
-
}]
|
160 |
-
},
|
161 |
-
};
|
162 |
-
|
163 |
-
blocks.registerBlockType( EcwidGutenbergParams.storeBlock, ecwidStoreParams);
|
164 |
-
|
165 |
-
} )(
|
166 |
-
window.wp.blocks,
|
167 |
-
window.wp.components,
|
168 |
-
window.wp.i18n,
|
169 |
-
window.wp.element,
|
170 |
-
window._
|
171 |
-
);
|
172 |
-
ecwid_pb_defaults = EcwidGutenbergParams.ecwid_pb_defaults;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/static-home-page.js
DELETED
@@ -1,281 +0,0 @@
|
|
1 |
-
var EcwidStaticPageLoader = {
|
2 |
-
isTouchDevice: false,
|
3 |
-
staticId: null,
|
4 |
-
dynamicId: null,
|
5 |
-
defaultCategoryId: null,
|
6 |
-
|
7 |
-
find: function (selector) {
|
8 |
-
return document.querySelector(selector);
|
9 |
-
},
|
10 |
-
|
11 |
-
findAll: function (selector) {
|
12 |
-
return document.querySelectorAll(selector);
|
13 |
-
},
|
14 |
-
|
15 |
-
isVisible: function (elem) {
|
16 |
-
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
|
17 |
-
},
|
18 |
-
|
19 |
-
forEach: function (elements, fn) {
|
20 |
-
return Array.prototype.forEach.call(elements, fn);
|
21 |
-
},
|
22 |
-
|
23 |
-
isRootCaregory: function () {
|
24 |
-
return window.location.hash === '' || window.location.hash.indexOf("#!/c/0/") !== -1;
|
25 |
-
},
|
26 |
-
|
27 |
-
onDocumentReady: function (fn) {
|
28 |
-
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
|
29 |
-
fn();
|
30 |
-
} else {
|
31 |
-
document.addEventListener('DOMContentLoaded', fn);
|
32 |
-
}
|
33 |
-
},
|
34 |
-
|
35 |
-
processStaticHomePage: function (staticId, dynamicId, defaultCategoryId) {
|
36 |
-
this.staticId = staticId;
|
37 |
-
this.dynamicId = dynamicId;
|
38 |
-
this.defaultCategoryId = defaultCategoryId;
|
39 |
-
|
40 |
-
this.onDocumentReady(function () {
|
41 |
-
if (!!('ontouchstart' in window)) {
|
42 |
-
this.isTouchDevice = true;
|
43 |
-
document.body.classList.add('touchable');
|
44 |
-
}
|
45 |
-
|
46 |
-
if (!EcwidStaticPageLoader.isRootCaregory()) {
|
47 |
-
EcwidStaticPageLoader.hideStorefront();
|
48 |
-
EcwidStaticPageLoader.switchToDynamicMode();
|
49 |
-
return;
|
50 |
-
}
|
51 |
-
|
52 |
-
EcwidStaticPageLoader.hideStorefront();
|
53 |
-
EcwidStaticPageLoader.showStaticHtml();
|
54 |
-
EcwidStaticPageLoader.addStaticPageHandlers();
|
55 |
-
|
56 |
-
Ecwid.OnPageLoad.add(function (openedPage) {
|
57 |
-
var staticHtml = EcwidStaticPageLoader.find('#' + EcwidStaticPageLoader.staticId);
|
58 |
-
if (!EcwidStaticPageLoader.isVisible(staticHtml)) {
|
59 |
-
// if we've already switched to dynamic, we don't need to dispatch this event anymore
|
60 |
-
return;
|
61 |
-
}
|
62 |
-
if (openedPage.type == "CART"
|
63 |
-
|| openedPage.type == "ORDERS"
|
64 |
-
|| openedPage.type == "FAVORITES"
|
65 |
-
|| openedPage.type == "SIGN_IN") {
|
66 |
-
// static links from bottom of the page should be processed before page load event finishes,
|
67 |
-
// so that pre-opening scroll didn't make the page jump
|
68 |
-
EcwidStaticPageLoader.switchToDynamicMode();
|
69 |
-
}
|
70 |
-
});
|
71 |
-
|
72 |
-
Ecwid.OnPageLoaded.add(function (openedPage) {
|
73 |
-
var staticHtml = EcwidStaticPageLoader.find('#' + EcwidStaticPageLoader.staticId);
|
74 |
-
if (!EcwidStaticPageLoader.isVisible(staticHtml)) {
|
75 |
-
// if we've already switched to dynamic, we don't need to dispatch this event anymore
|
76 |
-
return;
|
77 |
-
}
|
78 |
-
if (openedPage.type == "CATEGORY"
|
79 |
-
&& openedPage.categoryId == EcwidStaticPageLoader.defaultCategoryId
|
80 |
-
&& openedPage.offset == 0
|
81 |
-
&& openedPage.sort == 'normal') {
|
82 |
-
// we don't need to dispatch root category loading,
|
83 |
-
// since our static contents covers it for the first time
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
// other than that we must show opened page in dynamic view,
|
87 |
-
// because static view contains only root category page
|
88 |
-
EcwidStaticPageLoader.switchToDynamicModeDeferred();
|
89 |
-
});
|
90 |
-
});
|
91 |
-
},
|
92 |
-
|
93 |
-
addStaticPageHandlers: function () {
|
94 |
-
var categoryLinks = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .grid-category__card a');
|
95 |
-
if (categoryLinks.length > 0) {
|
96 |
-
EcwidStaticPageLoader.forEach(categoryLinks, function (element) {
|
97 |
-
var categoryId = element.getAttribute('data-category-id');
|
98 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('category', {'id': categoryId}));
|
99 |
-
});
|
100 |
-
}
|
101 |
-
|
102 |
-
var productLinks = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .grid-product a');
|
103 |
-
if (productLinks.length > 0) {
|
104 |
-
EcwidStaticPageLoader.forEach(productLinks, function (element) {
|
105 |
-
var productId = element.getAttribute('data-product-id');
|
106 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('product', {'id': productId}));
|
107 |
-
});
|
108 |
-
}
|
109 |
-
|
110 |
-
var buyNowLinks = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .grid-product__buy-now');
|
111 |
-
if (buyNowLinks.length > 0) {
|
112 |
-
EcwidStaticPageLoader.forEach(buyNowLinks, function (element) {
|
113 |
-
var productId = element.getAttribute('data-product-id');
|
114 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('product', {'id': productId}));
|
115 |
-
});
|
116 |
-
}
|
117 |
-
|
118 |
-
|
119 |
-
var breadcrumbsLinks = EcwidStaticPageLoader.find('#' + this.staticId + ' .ec-breadcrumbs a');
|
120 |
-
if (breadcrumbsLinks && breadcrumbsLinks.length > 0) {
|
121 |
-
EcwidStaticPageLoader.forEach(breadcrumbsLinks, function (element) {
|
122 |
-
var categoryId = element.getAttribute('data-category-id');
|
123 |
-
if (categoryId !== EcwidStaticPageLoader.defaultCategoryId) {
|
124 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('category', {'id': categoryId}));
|
125 |
-
}
|
126 |
-
});
|
127 |
-
}
|
128 |
-
|
129 |
-
var orderByOptions = EcwidStaticPageLoader.find('#' + this.staticId + ' .grid__sort select');
|
130 |
-
if (orderByOptions != null) {
|
131 |
-
orderByOptions.onchange = function (e) {
|
132 |
-
EcwidStaticPageLoader.openEcwidPage('category', {
|
133 |
-
'id': EcwidStaticPageLoader.defaultCategoryId,
|
134 |
-
'sort': orderByOptions.value
|
135 |
-
}).bind(this)(e);
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
var trackOrdersLink = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .footer__link--track-order');
|
140 |
-
if (trackOrdersLink.length > 0) {
|
141 |
-
EcwidStaticPageLoader.forEach(trackOrdersLink, function (element) {
|
142 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('account/orders'));
|
143 |
-
});
|
144 |
-
}
|
145 |
-
|
146 |
-
var favoritesLink = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .footer__link--shopping-favorites');
|
147 |
-
if (favoritesLink.length > 0) {
|
148 |
-
EcwidStaticPageLoader.forEach(favoritesLink, function (element) {
|
149 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('account/favorites'));
|
150 |
-
});
|
151 |
-
}
|
152 |
-
|
153 |
-
var shoppingCartLink = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .footer__link--shopping-cart');
|
154 |
-
if (shoppingCartLink.length > 0) {
|
155 |
-
EcwidStaticPageLoader.forEach(shoppingCartLink, function (element) {
|
156 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('cart'));
|
157 |
-
});
|
158 |
-
}
|
159 |
-
|
160 |
-
var signInLink = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .footer__link--sigin-in');
|
161 |
-
if (signInLink.length > 0) {
|
162 |
-
EcwidStaticPageLoader.forEach(signInLink, function (element) {
|
163 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('signin'));
|
164 |
-
});
|
165 |
-
}
|
166 |
-
|
167 |
-
var pagerButtonLinks = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .pager__button');
|
168 |
-
if (pagerButtonLinks.length > 0) {
|
169 |
-
EcwidStaticPageLoader.forEach(pagerButtonLinks, function (element) {
|
170 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('category', {
|
171 |
-
'id': EcwidStaticPageLoader.defaultCategoryId,
|
172 |
-
'page': 2
|
173 |
-
}));
|
174 |
-
});
|
175 |
-
}
|
176 |
-
|
177 |
-
var pagerNumberLinks = EcwidStaticPageLoader.findAll('#' + this.staticId + ' .pager__number');
|
178 |
-
if (pagerNumberLinks.length > 0) {
|
179 |
-
EcwidStaticPageLoader.forEach(pagerNumberLinks, function (element) {
|
180 |
-
var pageNumber = element.getAttribute('data-page-number');
|
181 |
-
EcwidStaticPageLoader.addStaticClickEvent(element, EcwidStaticPageLoader.openEcwidPage('category', {
|
182 |
-
'id': EcwidStaticPageLoader.defaultCategoryId,
|
183 |
-
'page': pageNumber
|
184 |
-
}));
|
185 |
-
});
|
186 |
-
}
|
187 |
-
},
|
188 |
-
|
189 |
-
addStaticClickEvent: function (el, callback) {
|
190 |
-
var x = 0,
|
191 |
-
y = 0,
|
192 |
-
dx = 0,
|
193 |
-
dy = 0,
|
194 |
-
isTap = false;
|
195 |
-
|
196 |
-
if (this.isTouchDevice) {
|
197 |
-
el.addEventListener('touchstart', function (e) {
|
198 |
-
isTap = true;
|
199 |
-
x = e.originalEvent.touches[0].clientX;
|
200 |
-
y = e.originalEvent.touches[0].clientY;
|
201 |
-
dx = 0;
|
202 |
-
dy = 0;
|
203 |
-
}).addEventListener('touchmove', function (e) {
|
204 |
-
dx = e.originalEvent.changedTouches[0].clientX - x;
|
205 |
-
dy = e.originalEvent.changedTouches[0].clientY - y;
|
206 |
-
}).addEventListener('touchend', function (e) {
|
207 |
-
if (isTap && Math.abs(dx) < 10 && Math.abs(dy) < 10) {
|
208 |
-
callback.bind(this)(e);
|
209 |
-
}
|
210 |
-
});
|
211 |
-
}
|
212 |
-
|
213 |
-
el.addEventListener('click', function (e) {
|
214 |
-
if (!isTap) {
|
215 |
-
callback.bind(this)(e);
|
216 |
-
}
|
217 |
-
else {
|
218 |
-
isTap = false;
|
219 |
-
}
|
220 |
-
});
|
221 |
-
},
|
222 |
-
|
223 |
-
openEcwidPage: function (page, params) {
|
224 |
-
return function (e) {
|
225 |
-
e.preventDefault();
|
226 |
-
// we must wait for Ecwid first page to be ready before changing it
|
227 |
-
Ecwid.OnPageLoaded.add(function () {
|
228 |
-
var staticHtml = EcwidStaticPageLoader.find('#' + EcwidStaticPageLoader.staticId);
|
229 |
-
if (!EcwidStaticPageLoader.isVisible(staticHtml)) {
|
230 |
-
// if we've already switched to dynamic, we don't need to dispatch this event anymore
|
231 |
-
return;
|
232 |
-
}
|
233 |
-
Ecwid.openPage(page, params);
|
234 |
-
});
|
235 |
-
}
|
236 |
-
},
|
237 |
-
|
238 |
-
hideStorefront: function () {
|
239 |
-
var dynamicEl = EcwidStaticPageLoader.find('#' + this.dynamicId);
|
240 |
-
// the dynamic div container must be visible while loading Ecwid,
|
241 |
-
// so that the scripts could calculate available container width,
|
242 |
-
// therefore we ensure the element is visible and hide it via zero-height trick
|
243 |
-
dynamicEl.style.display = 'block';
|
244 |
-
dynamicEl.style.overflowY = 'auto';
|
245 |
-
dynamicEl.style.height = '0';
|
246 |
-
dynamicEl.style.minHeight = '0';
|
247 |
-
dynamicEl.style.maxHeight = '0';
|
248 |
-
},
|
249 |
-
|
250 |
-
showStorefront: function () {
|
251 |
-
var dynamicEl = EcwidStaticPageLoader.find('#' + this.dynamicId);
|
252 |
-
// disable zero-height trick to show the storefront
|
253 |
-
dynamicEl.style.height = '';
|
254 |
-
dynamicEl.style.minHeight = '';
|
255 |
-
dynamicEl.style.maxHeight = '';
|
256 |
-
},
|
257 |
-
|
258 |
-
hideStaticHtml: function () {
|
259 |
-
var staticEl = EcwidStaticPageLoader.find('#' + this.staticId);
|
260 |
-
staticEl.style.opacity = 0;
|
261 |
-
staticEl.style.display = 'none';
|
262 |
-
},
|
263 |
-
|
264 |
-
showStaticHtml: function () {
|
265 |
-
var staticEl = EcwidStaticPageLoader.find('#' + this.staticId);
|
266 |
-
staticEl.style.opacity = 1;
|
267 |
-
},
|
268 |
-
|
269 |
-
switchToDynamicMode: function () {
|
270 |
-
this.showStorefront();
|
271 |
-
this.hideStaticHtml();
|
272 |
-
},
|
273 |
-
|
274 |
-
switchToDynamicModeDeferred: function () {
|
275 |
-
// defer switching to dynamic to avoid blinking effect
|
276 |
-
setTimeout(function () {
|
277 |
-
EcwidStaticPageLoader.switchToDynamicMode();
|
278 |
-
}, 0);
|
279 |
-
}
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/sync.js
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function() {
|
2 |
-
jQuery('#ecwid-sync-products').click(function() {
|
3 |
-
jQuery('#ecwid-sync-products-success, #ecwid-sync-products-error').hide();
|
4 |
-
jQuery('#ecwid-sync-products-inprogress').show();
|
5 |
-
jQuery.get('admin-ajax.php?action=ecwid_sync_products', {}, function($msg) {
|
6 |
-
jQuery('#ecwid-sync-products-inprogress').hide();
|
7 |
-
if ($msg == 'OK') {
|
8 |
-
jQuery('#ecwid-sync-products-success').show();
|
9 |
-
} else {
|
10 |
-
jQuery('#ecwid-sync-products-error').show();
|
11 |
-
}
|
12 |
-
});
|
13 |
-
});
|
14 |
-
|
15 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/themes/vantage.js
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
(function(){
|
2 |
-
var originalAddClassMethod = jQuery.fn.addClass;
|
3 |
-
jQuery.fn.addClass = function(){
|
4 |
-
var result = originalAddClassMethod.apply( this, arguments );
|
5 |
-
jQuery(this).trigger('change');
|
6 |
-
return result;
|
7 |
-
}
|
8 |
-
|
9 |
-
var originalRemoveClassMethod = jQuery.fn.removeClass;
|
10 |
-
jQuery.fn.removeClass = function(){
|
11 |
-
var result = originalRemoveClassMethod.apply( this, arguments );
|
12 |
-
jQuery(this).trigger('change');
|
13 |
-
return result;
|
14 |
-
}
|
15 |
-
|
16 |
-
})();
|
17 |
-
|
18 |
-
jQuery(document).ready(function() {
|
19 |
-
if (typeof Ecwid == 'undefined') return;
|
20 |
-
|
21 |
-
var scroll = '#scroll-to-top',
|
22 |
-
minicart = '.ec-minicart';
|
23 |
-
|
24 |
-
var overlap = false,
|
25 |
-
overlap_init = false;
|
26 |
-
|
27 |
-
Ecwid.OnCartChanged.add( function( cart ) {
|
28 |
-
|
29 |
-
if( !jQuery( minicart ).parent().data('showEmptyCart') && !cart.productsQuantity ) {
|
30 |
-
jQuery( scroll ).unbind( 'change.Overlap' );
|
31 |
-
return;
|
32 |
-
}
|
33 |
-
|
34 |
-
jQuery( scroll ).on( 'change.Overlap', function() {
|
35 |
-
|
36 |
-
if( !jQuery( minicart ).length ) {
|
37 |
-
jQuery( scroll ).unbind( 'change.Overlap' );
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
|
41 |
-
var rect1 = jQuery( this ).get(0).getBoundingClientRect(),
|
42 |
-
rect2 = jQuery( minicart ).get(0).getBoundingClientRect();
|
43 |
-
|
44 |
-
if( !overlap_init ) {
|
45 |
-
overlap = !(rect1.right < rect2.left ||
|
46 |
-
rect1.left > rect2.right ||
|
47 |
-
rect1.bottom < rect2.top ||
|
48 |
-
rect1.top > rect2.bottom);
|
49 |
-
}
|
50 |
-
|
51 |
-
if( overlap ){
|
52 |
-
if( jQuery( this ).hasClass( 'displayed' ) ){
|
53 |
-
window.ec.storefront.cart_widget_vertical_indent = rect1.height + parseInt( jQuery( this ).css( 'bottom' ) ) + 10;
|
54 |
-
|
55 |
-
overlap_init = true;
|
56 |
-
} else {
|
57 |
-
window.ec.storefront.cart_widget_vertical_indent = jQuery( minicart ).parent().data( 'verticalIndent' );
|
58 |
-
}
|
59 |
-
Ecwid.refreshConfig();
|
60 |
-
}
|
61 |
-
});
|
62 |
-
|
63 |
-
setTimeout(function(){
|
64 |
-
if( jQuery( minicart ).length ) jQuery( document ).trigger('scroll');
|
65 |
-
}, 500);
|
66 |
-
|
67 |
-
});
|
68 |
-
|
69 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/ecwid_api_v3.php
CHANGED
@@ -19,7 +19,6 @@ class Ecwid_Api_V3
|
|
19 |
const API_STATUS_ERROR_TOKEN = 'fail_token';
|
20 |
|
21 |
const FEATURE_NEW_PRODUCT_LIST = 'NEW_PRODUCT_LIST';
|
22 |
-
const FEATURE_STATIC_HOME_PAGE = 'STATIC_HOME_PAGE';
|
23 |
const FEATURE_PRODUCT_FILTERS = 'PRODUCT_FILTERS';
|
24 |
|
25 |
public static function get_api_status_list()
|
19 |
const API_STATUS_ERROR_TOKEN = 'fail_token';
|
20 |
|
21 |
const FEATURE_NEW_PRODUCT_LIST = 'NEW_PRODUCT_LIST';
|
|
|
22 |
const FEATURE_PRODUCT_FILTERS = 'PRODUCT_FILTERS';
|
23 |
|
24 |
public static function get_api_status_list()
|
lib/ecwid_product_api.php
DELETED
@@ -1,263 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
include_once dirname(__FILE__) . '/ecwid_platform.php';
|
4 |
-
|
5 |
-
class EcwidProductApi {
|
6 |
-
|
7 |
-
var $store_id = '';
|
8 |
-
|
9 |
-
var $error = '';
|
10 |
-
|
11 |
-
var $error_code = '';
|
12 |
-
|
13 |
-
var $ECWID_PRODUCT_API_ENDPOINT = '';
|
14 |
-
|
15 |
-
function __construct($store_id) {
|
16 |
-
|
17 |
-
$this->ECWID_PRODUCT_API_ENDPOINT = 'http://' . Ecwid_Config::get_api_domain() . '/api/v1';
|
18 |
-
$this->ECWID_PRODUCT_API_ENDPOINT_HTTPS = 'https://' . Ecwid_Config::get_api_domain() . '/api/v1';
|
19 |
-
$this->store_id = intval($store_id);
|
20 |
-
}
|
21 |
-
|
22 |
-
function get_request($url) {
|
23 |
-
return Ecwid_HTTP::create_get(
|
24 |
-
'api_v1_request',
|
25 |
-
$url,
|
26 |
-
array(
|
27 |
-
Ecwid_HTTP::POLICY_RETURN_JSON_ARRAY, Ecwid_HTTP::POLICY_RETURN_VERBOSE
|
28 |
-
)
|
29 |
-
);
|
30 |
-
}
|
31 |
-
|
32 |
-
function process_request($url) {
|
33 |
-
|
34 |
-
$result = false;
|
35 |
-
|
36 |
-
$request = $this->get_request($url);
|
37 |
-
|
38 |
-
if (!$request) {
|
39 |
-
return false;
|
40 |
-
}
|
41 |
-
|
42 |
-
$fetch_result = $request->do_request();
|
43 |
-
|
44 |
-
if ($fetch_result['code'] == 200) {
|
45 |
-
$this->error = '';
|
46 |
-
$this->error_code = '';
|
47 |
-
$json = $fetch_result['data'];
|
48 |
-
$result = json_decode($json);
|
49 |
-
} else {
|
50 |
-
$this->error = $fetch_result['data'];
|
51 |
-
$this->error_code = $fetch_result['code'];
|
52 |
-
}
|
53 |
-
|
54 |
-
return $result;
|
55 |
-
}
|
56 |
-
|
57 |
-
function get_all_categories() {
|
58 |
-
|
59 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/categories';
|
60 |
-
$categories = $this->process_request($api_url);
|
61 |
-
|
62 |
-
return $categories;
|
63 |
-
}
|
64 |
-
|
65 |
-
function get_subcategories_by_id($parent_category_id = 0) {
|
66 |
-
|
67 |
-
$parent_category_id = intval($parent_category_id);
|
68 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/categories?parent=' . $parent_category_id;
|
69 |
-
$categories = $this->process_request($api_url);
|
70 |
-
|
71 |
-
return $categories;
|
72 |
-
}
|
73 |
-
|
74 |
-
function get_all_products() {
|
75 |
-
|
76 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/products';
|
77 |
-
$products = $this->process_request($api_url);
|
78 |
-
|
79 |
-
return $products;
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
function get_products_by_category_id($category_id = 0) {
|
84 |
-
|
85 |
-
$category_id = intval($category_id);
|
86 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products?category=" . $category_id;
|
87 |
-
|
88 |
-
$result = EcwidPlatform::get_from_products_cache($api_url);
|
89 |
-
if (!$result) {
|
90 |
-
|
91 |
-
$result = $this->process_request($api_url);
|
92 |
-
EcwidPlatform::store_in_products_cache($api_url, $result);
|
93 |
-
}
|
94 |
-
|
95 |
-
return $result;
|
96 |
-
}
|
97 |
-
|
98 |
-
function get_product($product_id) {
|
99 |
-
|
100 |
-
$product_id = intval($product_id);
|
101 |
-
|
102 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/product?id=" . $product_id;
|
103 |
-
|
104 |
-
$result = EcwidPlatform::get_from_products_cache($api_url);
|
105 |
-
if (!$result) {
|
106 |
-
|
107 |
-
$result = $this->process_request($api_url);
|
108 |
-
EcwidPlatform::store_in_products_cache($api_url, $result);
|
109 |
-
}
|
110 |
-
|
111 |
-
return $result;
|
112 |
-
}
|
113 |
-
|
114 |
-
function get_product_https($product_id) {
|
115 |
-
|
116 |
-
$product_id = intval($product_id);
|
117 |
-
|
118 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT_HTTPS . "/" . $this->store_id . "/product?id=" . $product_id;
|
119 |
-
|
120 |
-
$result = EcwidPlatform::get_from_products_cache($api_url);
|
121 |
-
if (!$result) {
|
122 |
-
|
123 |
-
$result = $this->process_request($api_url);
|
124 |
-
EcwidPlatform::store_in_products_cache($api_url, $result);
|
125 |
-
}
|
126 |
-
|
127 |
-
return $result;
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
function get_category($category_id) {
|
132 |
-
|
133 |
-
$category_id = intval($category_id);
|
134 |
-
|
135 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
|
136 |
-
;
|
137 |
-
|
138 |
-
|
139 |
-
$result = EcwidPlatform::get_from_categories_cache($api_url);
|
140 |
-
if (!$result) {
|
141 |
-
$result = $this->process_request($api_url);
|
142 |
-
EcwidPlatform::store_in_categories_cache($api_url, $result);
|
143 |
-
}
|
144 |
-
|
145 |
-
return $result;
|
146 |
-
}
|
147 |
-
|
148 |
-
function get_batch_request($params) {
|
149 |
-
|
150 |
-
if (!is_array($params)) {
|
151 |
-
return false;
|
152 |
-
}
|
153 |
-
|
154 |
-
$api_url = '';
|
155 |
-
foreach ($params as $param) {
|
156 |
-
|
157 |
-
$alias = $param["alias"];
|
158 |
-
$action = $param["action"];
|
159 |
-
|
160 |
-
if (isset($param['params']))
|
161 |
-
$action_params = $param["params"];
|
162 |
-
|
163 |
-
if (!empty($api_url))
|
164 |
-
$api_url .= "&";
|
165 |
-
|
166 |
-
$api_url .= ($alias . "=" . $action);
|
167 |
-
|
168 |
-
// if there are the parameters - add it to url
|
169 |
-
if (is_array($action_params)) {
|
170 |
-
|
171 |
-
$action_param_str = "?";
|
172 |
-
$is_first = true;
|
173 |
-
|
174 |
-
foreach ($action_params as $action_param_name => $action_param_value) {
|
175 |
-
if (!$is_first) {
|
176 |
-
$action_param_str .= "&";
|
177 |
-
}
|
178 |
-
$action_param_str .= $action_param_name . "=" . $action_param_value;
|
179 |
-
$is_first = false;
|
180 |
-
}
|
181 |
-
|
182 |
-
$action_param_str = urlencode($action_param_str);
|
183 |
-
$api_url .= $action_param_str;
|
184 |
-
}
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/batch?". $api_url;
|
189 |
-
|
190 |
-
$data = EcwidPlatform::get_from_products_cache($api_url);
|
191 |
-
|
192 |
-
if (!$data) {
|
193 |
-
$data = $this->process_request($api_url);
|
194 |
-
EcwidPlatform::store_in_products_cache($api_url, $data);
|
195 |
-
}
|
196 |
-
|
197 |
-
return $data;
|
198 |
-
}
|
199 |
-
|
200 |
-
function get_random_products($count) {
|
201 |
-
|
202 |
-
$count = intval($count);
|
203 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/random_products?count=" . $count;
|
204 |
-
$random_products = $this->process_request($api_url);
|
205 |
-
|
206 |
-
return $random_products;
|
207 |
-
}
|
208 |
-
|
209 |
-
function get_profile() {
|
210 |
-
|
211 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
|
212 |
-
$profile = $this->process_request($api_url);
|
213 |
-
|
214 |
-
return (array)$profile;
|
215 |
-
}
|
216 |
-
|
217 |
-
function is_api_enabled() {
|
218 |
-
|
219 |
-
// quick and lightweight request
|
220 |
-
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
|
221 |
-
|
222 |
-
$result = $this->process_request($api_url);
|
223 |
-
|
224 |
-
return $this->error_code === '' && $result && !isset($result->error);
|
225 |
-
}
|
226 |
-
|
227 |
-
function get_method_response_stream($method)
|
228 |
-
{
|
229 |
-
|
230 |
-
$request_url = '';
|
231 |
-
switch($method) {
|
232 |
-
|
233 |
-
case 'products':
|
234 |
-
case 'categories':
|
235 |
-
$request_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/' . $method;
|
236 |
-
break;
|
237 |
-
default:
|
238 |
-
return false;
|
239 |
-
}
|
240 |
-
|
241 |
-
$stream = null;
|
242 |
-
|
243 |
-
try {
|
244 |
-
|
245 |
-
if (ini_get('allow_url_fopen')) {
|
246 |
-
$stream = fopen($request_url, 'r');
|
247 |
-
} else {
|
248 |
-
$request = $this->get_request($request_url);
|
249 |
-
$response = $request->do_request();
|
250 |
-
$body = $response['data'];
|
251 |
-
$stream = fopen('php://temp', 'rw');
|
252 |
-
fwrite($stream, $body);
|
253 |
-
rewind($stream);
|
254 |
-
}
|
255 |
-
|
256 |
-
} catch (Exception $e) {
|
257 |
-
|
258 |
-
$stream = null;
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
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 - Jun 13, 2019 =
|
157 |
- **New cool feature — cache and speed up your store page**. Available on the Ecwid/Advanced settings page inside your WordPress admin backend. Tick the new checkbox there to make it cache and speed up the store home page on your ecommerce site. When it’s enabled, you and your customer will see your store page load way faster than before.
|
158 |
- **Compatibility with more multilingual plugins**. As we mentioned before, Ecwid now supports full-featured multilingual storefronts. Previously, we made it compatible with the WPML plugin. In this update, we are adding support for more multilingual plugins: Polylang, TranslatePress, WPGlobus, WP Multilang, Multisite Language Switcher, MultilingualPress, Multilanguage by BestWebSoft, Transposh WordPress Translation and more. In general, if some plugin or a custom code switches locale on your site, Ecwid should be compatible with it and change the storefront language accordingly. So, if you have enabled the multilingual mode in your ecommerce store and are supporting several languages on your WordPress site, your shop pages will be displayed in the language selected by a visitor.
|
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 |
* [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 |
+
|
159 |
= 6.8 - Jun 13, 2019 =
|
160 |
- **New cool feature — cache and speed up your store page**. Available on the Ecwid/Advanced settings page inside your WordPress admin backend. Tick the new checkbox there to make it cache and speed up the store home page on your ecommerce site. When it’s enabled, you and your customer will see your store page load way faster than before.
|
161 |
- **Compatibility with more multilingual plugins**. As we mentioned before, Ecwid now supports full-featured multilingual storefronts. Previously, we made it compatible with the WPML plugin. In this update, we are adding support for more multilingual plugins: Polylang, TranslatePress, WPGlobus, WP Multilang, Multisite Language Switcher, MultilingualPress, Multilanguage by BestWebSoft, Transposh WordPress Translation and more. In general, if some plugin or a custom code switches locale on your site, Ecwid should be compatible with it and change the storefront language accordingly. So, if you have enabled the multilingual mode in your ecommerce store and are supporting several languages on your WordPress site, your shop pages will be displayed in the language selected by a visitor.
|