Ecwid Ecommerce Shopping Cart - Version 1.7

Version Description

  • [+] various additions to the indexable representation of Ecwid pages (product category in the title and on the page, product options, product SKU). Thanks to Uliya B.
Download this release

Release Info

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

Code changes from version 1.5 to 1.7

ecwid-shopping-cart.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Ecwid Shopping Cart
4
  Plugin URI: http://www.ecwid.com/
5
  Description: Ecwid is a free full-featured shopping cart. It can be easily integreted with any Wordpress blog and takes less than 5 minutes to set up.
6
  Author: Ecwid Team
7
- Version: 1.4
8
  Author URI: http://www.ecwid.com/
9
  */
10
 
@@ -116,22 +116,65 @@ function ecwid_meta() {
116
 
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  function ecwid_seo_title($content) {
120
- if (isset($_GET['_escaped_fragment_']) && ecwid_is_api_enabled()) {
121
  $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
122
  $ecwid_seo_title = '';
123
 
124
- $api = ecwid_new_product_api();
125
 
126
  if (isset($params['mode']) && !empty($params['mode'])) {
127
  if ($params['mode'] == 'product') {
128
  $ecwid_product = $api->get_product($params['id']);
129
  $ecwid_seo_title = $ecwid_product['name'];
130
- } elseif ($params['mode'] == 'category') {
131
- // define category's title. no API for that QQ
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
  }
134
 
 
 
 
 
 
 
135
  if (!empty($ecwid_seo_title))
136
  return $ecwid_seo_title . " | " . $content;
137
  else
@@ -142,6 +185,8 @@ function ecwid_seo_title($content) {
142
  }
143
  }
144
 
 
 
145
  function ecwid_get_scriptjs_code() {
146
  if (!defined('ECWID_SCRIPTJS')) {
147
  $ecwid_protocol = get_ecwid_protocol();
4
  Plugin URI: http://www.ecwid.com/
5
  Description: Ecwid is a free full-featured shopping cart. It can be easily integreted with any Wordpress blog and takes less than 5 minutes to set up.
6
  Author: Ecwid Team
7
+ Version: 1.7
8
  Author URI: http://www.ecwid.com/
9
  */
10
 
116
 
117
  }
118
 
119
+ function ecwid_get_product_and_category($category_id, $product_id) {
120
+ $params = array
121
+ (
122
+ array("alias" => "c", "action" => "category", "params" => array("id" => $category_id)),
123
+ array("alias" => "p", "action" => "product", "params" => array("id" => $product_id)),
124
+ );
125
+
126
+ $api = ecwid_new_product_api();
127
+ $batch_result = $api->get_batch_request($params);
128
+
129
+ $category = $batch_result["c"];
130
+ $product = $batch_result["p"];
131
+ $return = "";
132
+
133
+ if (is_array($product)) {
134
+ $return .=$product["name"];
135
+ }
136
+
137
+ if(is_array($category)) {
138
+ $return.=" | ";
139
+ $return .=$category["name"];
140
+ }
141
+ return $return;
142
+ }
143
+
144
  function ecwid_seo_title($content) {
145
+ if (isset($_GET['_escaped_fragment_']) && ecwid_is_api_enabled()) {
146
  $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
147
  $ecwid_seo_title = '';
148
 
149
+ $api = ecwid_new_product_api();
150
 
151
  if (isset($params['mode']) && !empty($params['mode'])) {
152
  if ($params['mode'] == 'product') {
153
  $ecwid_product = $api->get_product($params['id']);
154
  $ecwid_seo_title = $ecwid_product['name'];
155
+ if(isset($params['category']) && !empty($params['category'])){
156
+ $ecwid_seo_title= ecwid_get_product_and_category($params['category'], $params['id']);
157
+ }
158
+ elseif(empty($params['category'])){
159
+ $ecwid_product = $api->get_product($params['id']);
160
+ $ecwid_seo_title .=$ecwid_product['name'];
161
+ if(is_array($ecwid_product['categories'])){
162
+ foreach ($ecwid_product['categories'] as $ecwid_category){
163
+ if($ecwid_category['defaultCategory']==true){
164
+ $ecwid_seo_title .=" | ";
165
+ $ecwid_seo_title .= $ecwid_category['name'];
166
+ }
167
+ }
168
+ }
169
  }
170
  }
171
 
172
+ elseif ($params['mode'] == 'category'){
173
+ $api = ecwid_new_product_api();
174
+ $ecwid_category = $api->get_category($params['id']);
175
+ $ecwid_seo_title = $ecwid_category['name'];
176
+ }
177
+ }
178
  if (!empty($ecwid_seo_title))
179
  return $ecwid_seo_title . " | " . $content;
180
  else
185
  }
186
  }
187
 
188
+
189
+
190
  function ecwid_get_scriptjs_code() {
191
  if (!defined('ECWID_SCRIPTJS')) {
192
  $ecwid_protocol = get_ecwid_protocol();
lib/EcwidCatalog.php CHANGED
@@ -38,20 +38,79 @@ class EcwidCatalog
38
 
39
  $return = "<div itemscope itemtype=\"http://schema.org/Product\">";
40
  $return .= "<h1 class='ecwid_catalog_product_name' itemprop=\"name\">" . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "</h1>";
41
-
42
- if (!empty($product["thumbnailUrl"]))
 
 
43
  $return .= "<div class='ecwid_catalog_product_image'><img itemprop=\"image\" src='" . $product["thumbnailUrl"] . "' alt='" . htmlentities($product["sku"], ENT_COMPAT, 'UTF-8') . " " . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "'/></div>";
44
-
45
- $return .= "<div class='ecwid_catalog_product_price' itemprop=\"offers\" itemscope itemtype=\"http://schema.org/Offer\">Price: <span itemprop=\"price\">" . $product["price"] . "</span>&nbsp;<span itemprop=\"priceCurrency\">" . $profile["currency"] . "</span>";
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  if (!isset($product['quantity']) || (isset($product['quantity']) && $product['quantity'] > 0))
48
- $return .= "<link itemprop=\"availability\" href=\"http://schema.org/InStock\" />";
49
-
50
- $return .= "</div>";
51
  $return .= "<div class='ecwid_catalog_product_description' itemprop=\"description\">" . $product["description"] . "</div>";
52
 
53
- if (is_array($product["galleryImages"])) {
54
- foreach ($product["galleryImages"] as $galleryimage) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  if (empty($galleryimage["alt"])) $galleryimage["alt"] = htmlspecialchars($product["name"]);
56
  $return .= "<img src='" . $galleryimage["url"] . "' alt='" . htmlspecialchars($galleryimage["alt"]) ."' title='" . htmlspecialchars($galleryimage["alt"]) ."'><br />";
57
  }
38
 
39
  $return = "<div itemscope itemtype=\"http://schema.org/Product\">";
40
  $return .= "<h1 class='ecwid_catalog_product_name' itemprop=\"name\">" . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "</h1>";
41
+ $return .= "<p class='ecwid_catalog_product_sku' itemprop=\"sku\">" . htmlentities($product["sku"], ENT_COMPAT, 'UTF-8') . "</p>";
42
+
43
+ if (!empty($product["thumbnailUrl"]))
44
+ {
45
  $return .= "<div class='ecwid_catalog_product_image'><img itemprop=\"image\" src='" . $product["thumbnailUrl"] . "' alt='" . htmlentities($product["sku"], ENT_COMPAT, 'UTF-8') . " " . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "'/></div>";
46
+ }
47
+
48
+ if(is_array($product["categories"]))
49
+ {
50
+ foreach ($product["categories"] as $ecwid_category)
51
+ {
52
+ if($ecwid_category["defaultCategory"]==true)
53
+ {
54
+ $return .="<div class='ecwid_catalog_product_category' itemprop=\"category\">".$ecwid_category["name"]."</div>";
55
+ }
56
+ }
57
+ }
58
+
59
+ $return .= "<div class='ecwid_catalog_product_price' itemprop=\"offers\" itemscope itemtype=\"http://schema.org/Offer\">Price: <span itemprop=\"price\">" . $product["price"] . "</span>&nbsp;<span itemprop=\"priceCurrency\">" . $profile["currency"] . "</span></div>";
60
 
61
  if (!isset($product['quantity']) || (isset($product['quantity']) && $product['quantity'] > 0))
62
+ {
63
+ $return .= "<div class='ecwid_catalog_quantity' itemprop=\"availability\" itemscope itemtype=\"http://schema.org/InStock\"><span>In Stock</span></div>";
64
+ }
65
  $return .= "<div class='ecwid_catalog_product_description' itemprop=\"description\">" . $product["description"] . "</div>";
66
 
67
+ if (is_array($product["options"]))
68
+ {
69
+ foreach($product["options"] as $product_options)
70
+ {
71
+ if($product_options["type"]=="TEXTFIELD" || $product_options["type"]=="DATE")
72
+ {
73
+ $return .= "<div class='ecwid_catalog_product_options' itemprop=\"offers\"><span itemprop=\"condition\">". $product_options["name"]."</span></div>";
74
+ $return .='<input type="text" size="40" name='. $product_options["name"].'>';
75
+ }
76
+ if($product_options["type"]=="TEXTAREA")
77
+ {
78
+ $return .= "<div class='ecwid_catalog_product_options' itemprop=\"offers\"><span itemprop=\"condition\">". $product_options["name"]."</span></div>";
79
+ $return .='<textarea name='.$product_options["name"].'></textarea>';
80
+ }
81
+ if ($product_options["type"]=="SELECT")
82
+ {
83
+ $return .="<div class='ecwid_catalog_product_options' itemprop=\"offers\"><span itemprop=\"condition\">". $product_options["name"]."</span></div>";
84
+ $return .= '<select name='. $product_options["name"].'>';
85
+ foreach ($product_options["choices"] as $options_param)
86
+ {
87
+ $return .='<option value='. $options_param['text'].'>'. $options_param['text'].' ('.$options_param['priceModifier'].')</option>';
88
+ }
89
+ $return .= '</select>';
90
+ }
91
+ if($product_options["type"]=="RADIO")
92
+ {
93
+ $return .= "<div class='ecwid_catalog_product_options' itemprop=\"offers\"><span itemprop=\"condition\">". $product_options["name"]."</span></div>";
94
+ foreach ($product_options["choices"] as $options_param)
95
+ {
96
+ $return .='<input type="radio" name='.$product_options["name"].'value='. $options_param['text'].'>'. $options_param['text'].' ('.$options_param['priceModifier'].')<br>';
97
+ }
98
+ }
99
+ if($product_options["type"]=="CHECKBOX")
100
+ {
101
+ $return .= "<div class='ecwid_catalog_product_options' itemprop=\"offers\"><span itemprop=\"condition\">". $product_options["name"]."</span></div>";
102
+ foreach ($product_options["choices"] as $options_param)
103
+ {
104
+ $return .='<input type="checkbox" name='.$product_options["name"].'value='. $options_param['text'].'>'. $options_param['text'].' ('.$options_param['priceModifier'].')<br>';
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ if (is_array($product["galleryImages"]))
111
+ {
112
+ foreach ($product["galleryImages"] as $galleryimage)
113
+ {
114
  if (empty($galleryimage["alt"])) $galleryimage["alt"] = htmlspecialchars($product["name"]);
115
  $return .= "<img src='" . $galleryimage["url"] . "' alt='" . htmlspecialchars($galleryimage["alt"]) ."' title='" . htmlspecialchars($galleryimage["alt"]) ."'><br />";
116
  }
lib/ecwid_product_api.php CHANGED
@@ -104,6 +104,13 @@ class EcwidProductApi {
104
  return $product;
105
  }
106
 
 
 
 
 
 
 
 
107
  function get_batch_request($params) {
108
  if (!is_array($params)) {
109
  return false;
@@ -142,7 +149,6 @@ class EcwidProductApi {
142
  return $data;
143
  }
144
  }
145
-
146
  function get_random_products($count) {
147
  $count = intval($count);
148
  $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/random_products?count=" . $count;
104
  return $product;
105
  }
106
 
107
+ function get_category($category_id) {
108
+ $category_id = intval($category_id);
109
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
110
+ $category = $this->process_request($api_url);
111
+ return $category;
112
+ }
113
+
114
  function get_batch_request($params) {
115
  if (!is_array($params)) {
116
  return false;
149
  return $data;
150
  }
151
  }
 
152
  function get_random_products($count) {
153
  $count = intval($count);
154
  $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/random_products?count=" . $count;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Ecwid Team
3
  Tags: shopping cart, ecommerce, e-commerce, paypal, google checkout, 2checkout, store, shop, product catalog, inventory
4
  Requires at least: 2.8
5
- Tested up to: 3.5
6
- Stable tag: 1.5
7
 
8
  Ecwid is a free full-featured shopping cart that can easily be added to any blog
9
  and takes less than 5 minutes to set up.
@@ -36,8 +36,9 @@ Links
36
 
37
  1. Go to your WP admin panel → Plugins → Add New
38
  2. Under Search, type in 'Ecwid', click Search
39
- 3. In the search results find the 'Ecwid shopping cart' plugin and click 'Install now' to install it
40
- 4. Click Proceed to continue with the installation. The resulting installation screen will list the installation as successful or note any problems during the install
 
41
 
42
  **IMPORTANT**: when the plugin is installed, you will need to activate it on the Plugins page (click 'Activate' link) and configure it on the 'Settings → Ecwid shopping cart' page (at least, you will need to set your store ID there).
43
 
@@ -77,6 +78,8 @@ http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
77
  - Knowledge Base: [http://kb.ecwid.com](http://kb.ecwid.com)
78
 
79
  == Changelog ==
 
 
80
  = 1.5 =
81
  - [!] fixed a problem where in some rare occasions the SEO catalog would show a PHP error.
82
  = 1.4 =
2
  Contributors: Ecwid Team
3
  Tags: shopping cart, ecommerce, e-commerce, paypal, google checkout, 2checkout, store, shop, product catalog, inventory
4
  Requires at least: 2.8
5
+ Tested up to: 3.6
6
+ Stable tag: 1.7
7
 
8
  Ecwid is a free full-featured shopping cart that can easily be added to any blog
9
  and takes less than 5 minutes to set up.
36
 
37
  1. Go to your WP admin panel → Plugins → Add New
38
  2. Under Search, type in 'Ecwid', click Search
39
+ 3. In the search results find the 'Ecwid Shopping Cart' plugin and click 'Install now' to install it
40
+ 4. When plugin is installed click 'Activate Plugin' link
41
+ 5. Log in into Ecwid control panel at https://my.ecwid.com and copy your numeric Store ID. Go to 'Settings → Ecwid shopping cart' page in WP admin panel and paste Store ID in the corresponding field.
42
 
43
  **IMPORTANT**: when the plugin is installed, you will need to activate it on the Plugins page (click 'Activate' link) and configure it on the 'Settings → Ecwid shopping cart' page (at least, you will need to set your store ID there).
44
 
78
  - Knowledge Base: [http://kb.ecwid.com](http://kb.ecwid.com)
79
 
80
  == Changelog ==
81
+ = 1.7 =
82
+ - [+] various additions to the indexable representation of Ecwid pages (product category in the title and on the page, product options, product SKU). Thanks to Uliya B.
83
  = 1.5 =
84
  - [!] fixed a problem where in some rare occasions the SEO catalog would show a PHP error.
85
  = 1.4 =