Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.4.0

Version Description

  • 01/11/2021 =

  • In this release, we have added product type and custom attributes for the product sync capability which will help in enhancing your product feeds in Google Merchant Center. These attributed will automatically collected and pushed to GMC when you are syncing products.

Download this release

Release Info

Developer Tatvic
Plugin Icon 128x128 Enhanced Ecommerce Google Analytics Plugin for WooCommerce
Version 4.4.0
Comparing to
See all releases

Code changes from version 4.3.5 to 4.4.0

admin/class-tvc-admin-auto-product-sync-helper.php CHANGED
@@ -84,7 +84,26 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
84
  }
85
 
86
  }
87
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  public function import_last_sync_in_db(){
89
  $ee_prod_mapped_cats = unserialize(get_option('ee_prod_mapped_cats'));
90
  $ee_prod_mapped_attrs = unserialize(get_option('ee_prod_mapped_attrs'));
@@ -213,110 +232,95 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
213
 
214
  $product = array_merge($temp_product,$product);
215
  if( !empty($prd) && $prd->get_type() == "variable" ){
216
- $variation_attributes = $prd->get_variation_attributes();
217
- $can_add_item_group_id = false;
218
- $is_color_size = false;
219
- if(!empty($variation_attributes)){
220
- foreach($variation_attributes as $va_key => $va_value ){
221
- $va_key = str_replace("_", " ", $va_key);
222
- if (strpos($va_key, 'color') !== false) {
223
- $can_add_item_group_id = true;
224
- $is_color_size = true;
225
- break;
226
- }else if (strpos($va_key, 'size') !== false) {
227
- $can_add_item_group_id = true;
228
- $is_color_size = true;
229
- break;
 
230
  }
231
- }
232
- }
233
- if(isset($formArray['gender']) && $formArray['gender']!= ""){
234
- $can_add_item_group_id = true;
235
- }else if(isset($formArray['age_group']) && $formArray['age_group']!= ""){
236
- $can_add_item_group_id = true;
237
- }
238
- if($can_add_item_group_id == true){
239
- $p_variations = $prd->get_available_variations();
240
- if(!empty($p_variations)){
241
- foreach ($p_variations as $v_key => $v_value) {
242
- $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($v_value['variation_id']);
243
- $formArray_val = $formArray['title'];
244
- $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
245
- $tvc_temp_desc_key = $formArray['description'];
246
- $product['description'] = (isset($v_value['variation_description']) && $v_value['variation_description'] != "")?$v_value['variation_description']:$postObj->$tvc_temp_desc_key;
247
- $product['offer_id'] = $v_value['variation_id'];
248
- $product['id'] = $v_value['variation_id'];
249
- $product['item_group_id'] = $postvalue->w_product_id;
250
- $image_id = $v_value['image_id'];
251
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
252
- if($is_color_size == true){
253
- if(isset($v_value['attributes']) && !empty($v_value['attributes']) ){
254
- foreach($v_value['attributes'] as $va_key => $va_value ){
255
- $va_key = str_replace("_", " ", $va_key);
256
- if (strpos($va_key, 'color') !== false) {
257
- $product['color'] = $va_value;
258
- }else if (strpos($va_key, 'size') !== false) {
259
- $product['sizes'] = $va_value;
260
- }
261
- }
262
  }
263
  }
264
- foreach($formArray as $key => $value){
265
- if($key == 'price'){
266
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
267
- $product[$key]['value'] = $postmeta_var->$value;
268
- }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
269
- $product[$key]['value'] = $postmeta_var->_regular_price;
270
- }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
271
- $product[$key]['value'] = $postmeta_var->_price;
272
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
273
- $product[$key]['value'] = $postmeta_var->_sale_price;
274
- }
275
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
276
- $product[$key]['currency'] = $tvc_currency;
277
- }else{
278
- $skipProducts[$postmeta_var->ID] = $postmeta_var;
279
- }
280
- }else if($key == 'sale_price'){
281
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
282
- $product[$key]['value'] = $postmeta_var->$value;
283
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
284
- $product[$key]['value'] = $postmeta_var->_sale_price;
285
- }
286
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
287
- $product[$key]['currency'] = $tvc_currency;
288
- }
289
- }else if($key == 'availability'){
290
- $tvc_find = array("instock","outofstock","onbackorder");
291
- $tvc_replace = array("in stock","out of stock","preorder");
292
- if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
293
- $stock_status = $postmeta_var->$value;
294
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
295
- $product[$key] = $stock_status;
296
- }else{
297
- $stock_status = $postmeta_var->_stock_status;
298
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
299
- $product[$key] = $stock_status;
300
- }
301
- }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){$product[$key] = $postmeta_var->$value;
302
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
- $item = [
305
- 'merchant_id' => $merchantId,
306
- 'batch_id' => ++$batchId,
307
- 'method' => 'insert',
308
- 'product' => $product
309
- ];
310
- $items[] = $item;
311
  }
 
 
 
 
 
 
 
312
  }
313
- }else{
314
- goto simpleproduct;
315
  }
 
316
  }else if( !empty($prd) ){
317
- simpleproduct:
318
  $image_id = $prd->get_image_id();
319
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
 
 
 
 
320
  foreach($formArray as $key => $value){
321
  if($key == 'price'){
322
  if(isset($postObj->$value) && $postObj->$value > 0){
84
  }
85
 
86
  }
87
+ public function get_product_category($product_id){
88
+ $output = [];
89
+ $terms_ids = wp_get_post_terms( $product_id, 'product_cat', array('fields' => 'ids') );
90
+ // Loop though terms ids (product categories)
91
+ foreach( $terms_ids as $term_id ) {
92
+ $term_names = [];
93
+ // Loop through product category ancestors
94
+ foreach( get_ancestors( $term_id, 'product_cat') as $ancestor_id ){
95
+ $term_names[] = get_term( $ancestor_id, 'product_cat')->name;
96
+ if(isset($output[$ancestor_id]) && $output[$ancestor_id] != ""){
97
+ unset($output[$ancestor_id]);
98
+ }
99
+ }
100
+ $term_names[] = get_term( $term_id, 'product_cat' )->name;
101
+ // Add the formatted ancestors with the product category to main array
102
+ $output[$term_id] = implode(' > ', $term_names);
103
+ }
104
+ $output = array_values($output);
105
+ return $output;
106
+ }
107
  public function import_last_sync_in_db(){
108
  $ee_prod_mapped_cats = unserialize(get_option('ee_prod_mapped_cats'));
109
  $ee_prod_mapped_attrs = unserialize(get_option('ee_prod_mapped_attrs'));
232
 
233
  $product = array_merge($temp_product,$product);
234
  if( !empty($prd) && $prd->get_type() == "variable" ){
235
+ //$variation_attributes = $prd->get_variation_attributes();
236
+ $p_variations = $prd->get_available_variations();
237
+ if(!empty($p_variations)){
238
+ foreach ($p_variations as $v_key => $v_value) {
239
+ $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($v_value['variation_id']);
240
+ $formArray_val = $formArray['title'];
241
+ $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
242
+ $tvc_temp_desc_key = $formArray['description'];
243
+ $product['description'] = (isset($v_value['variation_description']) && $v_value['variation_description'] != "")?$v_value['variation_description']:$postObj->$tvc_temp_desc_key;
244
+ $product['offer_id'] = $v_value['variation_id'];
245
+ $product['id'] = $v_value['variation_id'];
246
+ $product['item_group_id'] = $postvalue->w_product_id;
247
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
248
+ if(!empty($productTypes)){
249
+ $product['productTypes'] = $productTypes;
250
  }
251
+ $image_id = $v_value['image_id'];
252
+ $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
253
+ if(isset($v_value['attributes']) && !empty($v_value['attributes']) ){
254
+ foreach($v_value['attributes'] as $va_key => $va_value ){
255
+ $va_key = str_replace("_", " ", $va_key);
256
+ if (strpos($va_key, 'color') !== false) {
257
+ $product['color'] = $va_value;
258
+ }else if (strpos($va_key, 'size') !== false) {
259
+ $product['sizes'] = $va_value;
260
+ }else{
261
+ $va_key = str_replace("attribute", "", $va_key);
262
+ $product['customAttributes'][] = array("name"=>$va_key, "value"=>$va_value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  }
264
  }
265
+ }
266
+
267
+ foreach($formArray as $key => $value){
268
+ if($key == 'price'){
269
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
270
+ $product[$key]['value'] = $postmeta_var->$value;
271
+ }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
272
+ $product[$key]['value'] = $postmeta_var->_regular_price;
273
+ }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
274
+ $product[$key]['value'] = $postmeta_var->_price;
275
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
276
+ $product[$key]['value'] = $postmeta_var->_sale_price;
277
+ }
278
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
279
+ $product[$key]['currency'] = $tvc_currency;
280
+ }else{
281
+ $skipProducts[$postmeta_var->ID] = $postmeta_var;
282
+ }
283
+ }else if($key == 'sale_price'){
284
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
285
+ $product[$key]['value'] = $postmeta_var->$value;
286
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
287
+ $product[$key]['value'] = $postmeta_var->_sale_price;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
289
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
290
+ $product[$key]['currency'] = $tvc_currency;
291
+ }
292
+ }else if($key == 'availability'){
293
+ $tvc_find = array("instock","outofstock","onbackorder");
294
+ $tvc_replace = array("in stock","out of stock","preorder");
295
+ if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
296
+ $stock_status = $postmeta_var->$value;
297
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
298
+ $product[$key] = $stock_status;
299
+ }else{
300
+ $stock_status = $postmeta_var->_stock_status;
301
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
302
+ $product[$key] = $stock_status;
303
+ }
304
+ }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){$product[$key] = $postmeta_var->$value;
305
  }
 
 
 
 
 
 
 
306
  }
307
+ $item = [
308
+ 'merchant_id' => $merchantId,
309
+ 'batch_id' => ++$batchId,
310
+ 'method' => 'insert',
311
+ 'product' => $product
312
+ ];
313
+ $items[] = $item;
314
  }
 
 
315
  }
316
+
317
  }else if( !empty($prd) ){
 
318
  $image_id = $prd->get_image_id();
319
+ $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
320
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
321
+ if(!empty($productTypes)){
322
+ $product['productTypes'] = $productTypes;
323
+ }
324
  foreach($formArray as $key => $value){
325
  if($key == 'price'){
326
  if(isset($postObj->$value) && $postObj->$value > 0){
enhanced-ecommerce-google-analytics.php CHANGED
@@ -12,10 +12,10 @@
12
  * @package Enhanced E-commerce for Woocommerce store
13
  *
14
  * @wordpress-plugin
15
- * Plugin Name: Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
- * Version: 4.3.5
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
@@ -37,7 +37,7 @@ if ( ! defined( 'WPINC' ) ) {
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
- define( 'PLUGIN_TVC_VERSION', '4.3.5' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
12
  * @package Enhanced E-commerce for Woocommerce store
13
  *
14
  * @wordpress-plugin
15
+ * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
+ * Version: 4.4.0
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
+ define( 'PLUGIN_TVC_VERSION', '4.4.0' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/setup/class-tvc-product-sync-helper.php CHANGED
@@ -57,6 +57,27 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
57
  }
58
  }
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  /*
61
  * careate products object for product sync
62
  */
@@ -123,111 +144,101 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
123
 
124
  $product = array_merge($temp_product,$product);
125
 
126
- if($prd->get_type() == "variable"){
127
- $variation_attributes = $prd->get_variation_attributes();
128
- $can_add_item_group_id = false;
129
- $is_color_size = false;
130
- if(!empty($variation_attributes)){
131
- foreach($variation_attributes as $va_key => $va_value ){
132
- $va_key = str_replace("_", " ", $va_key);
133
- if (strpos($va_key, 'color') !== false) {
134
- $can_add_item_group_id = true;
135
- $is_color_size = true;
136
- break;
137
- }else if (strpos($va_key, 'size') !== false) {
138
- $can_add_item_group_id = true;
139
- $is_color_size = true;
140
- break;
 
 
141
  }
142
- }
143
- }
144
- if(isset($formArray['gender']) && $formArray['gender']!= ""){
145
- $can_add_item_group_id = true;
146
- }else if(isset($formArray['age_group']) && $formArray['age_group']!= ""){
147
- $can_add_item_group_id = true;
148
- }
149
- if($can_add_item_group_id == true){
150
- $p_variations = $prd->get_available_variations();
151
- if(!empty($p_variations)){
152
- foreach ($p_variations as $v_key => $v_value) {
153
- $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($v_value['variation_id']);
154
- $formArray_val = $formArray['title'];
155
- $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
156
- $tvc_temp_desc_key = $formArray['description'];
157
- $product['description'] = (isset($v_value['variation_description']) && $v_value['variation_description'] != "")?$v_value['variation_description']:$postObj->$tvc_temp_desc_key;
158
- $product['offer_id'] = $v_value['variation_id'];
159
- $product['id'] = $v_value['variation_id'];
160
- $product['item_group_id'] = $postvalue->w_product_id;
161
- $image_id = $v_value['image_id'];
162
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
163
- if($is_color_size == true){
164
- if(isset($v_value['attributes']) && !empty($v_value['attributes']) ){
165
- foreach($v_value['attributes'] as $va_key => $va_value ){
166
- $va_key = str_replace("_", " ", $va_key);
167
- if (strpos($va_key, 'color') !== false) {
168
- $product['color'] = $va_value;
169
- }else if (strpos($va_key, 'size') !== false) {
170
- $product['sizes'] = $va_value;
171
- }
172
  }
173
  }
174
  }
175
- foreach($formArray as $key => $value){
176
- if($key == 'price'){
177
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
178
- $product[$key]['value'] = $postmeta_var->$value;
179
- }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
180
- $product[$key]['value'] = $postmeta_var->_regular_price;
181
- }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
182
- $product[$key]['value'] = $postmeta_var->_price;
183
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
184
- $product[$key]['value'] = $postmeta_var->_sale_price;
185
- }
186
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
187
- $product[$key]['currency'] = $tvc_currency;
188
- }else{
189
- $skipProducts[$postmeta_var->ID] = $postmeta_var;
190
- }
191
- }else if($key == 'sale_price'){
192
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
193
- $product[$key]['value'] = $postmeta_var->$value;
194
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
195
- $product[$key]['value'] = $postmeta_var->_sale_price;
196
- }
197
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
198
- $product[$key]['currency'] = $tvc_currency;
199
- }
200
- }else if($key == 'availability'){
201
- $tvc_find = array("instock","outofstock","onbackorder");
202
- $tvc_replace = array("in stock","out of stock","preorder");
203
- if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
204
- $stock_status = $postmeta_var->$value;
205
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
206
- $product[$key] = $stock_status;
207
- }else{
208
- $stock_status = $postmeta_var->_stock_status;
209
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
210
- $product[$key] = $stock_status;
211
- }
212
- }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){$product[$key] = $postmeta_var->$value;
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
- $item = [
216
- 'merchant_id' => $merchantId,
217
- 'batch_id' => ++$batchId,
218
- 'method' => 'insert',
219
- 'product' => $product
220
- ];
221
- $items[] = $item;
222
  }
 
 
 
 
 
 
 
223
  }
224
- }else{
225
- goto simpleproduct;
226
  }
 
227
  }else{
228
- simpleproduct:
229
  $image_id = $prd->get_image_id();
230
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
 
 
 
 
 
 
231
  foreach($formArray as $key => $value){
232
  if($key == 'price'){
233
  if(isset($postObj->$value) && $postObj->$value > 0){
57
  }
58
  }
59
  }
60
+
61
+ public function get_product_category($product_id){
62
+ $output = [];
63
+ $terms_ids = wp_get_post_terms( $product_id, 'product_cat', array('fields' => 'ids') );
64
+ // Loop though terms ids (product categories)
65
+ foreach( $terms_ids as $term_id ) {
66
+ $term_names = [];
67
+ // Loop through product category ancestors
68
+ foreach( get_ancestors( $term_id, 'product_cat') as $ancestor_id ){
69
+ $term_names[] = get_term( $ancestor_id, 'product_cat')->name;
70
+ if(isset($output[$ancestor_id]) && $output[$ancestor_id] != ""){
71
+ unset($output[$ancestor_id]);
72
+ }
73
+ }
74
+ $term_names[] = get_term( $term_id, 'product_cat' )->name;
75
+ // Add the formatted ancestors with the product category to main array
76
+ $output[$term_id] = implode(' > ', $term_names);
77
+ }
78
+ $output = array_values($output);
79
+ return $output;
80
+ }
81
  /*
82
  * careate products object for product sync
83
  */
144
 
145
  $product = array_merge($temp_product,$product);
146
 
147
+ if($prd->get_type() == "variable"){
148
+ /*$variation_attributes = $prd->get_variation_attributes();*/
149
+ $p_variations = $prd->get_available_variations();
150
+ if(!empty($p_variations)){
151
+ foreach ($p_variations as $v_key => $v_value) {
152
+ unset($product['customAttributes']);
153
+ $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($v_value['variation_id']);
154
+ $formArray_val = $formArray['title'];
155
+ $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
156
+ $tvc_temp_desc_key = $formArray['description'];
157
+ $product['description'] = (isset($v_value['variation_description']) && $v_value['variation_description'] != "")?$v_value['variation_description']:$postObj->$tvc_temp_desc_key;
158
+ $product['offer_id'] = $v_value['variation_id'];
159
+ $product['id'] = $v_value['variation_id'];
160
+ $product['item_group_id'] = $postvalue->w_product_id;
161
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
162
+ if(!empty($productTypes)){
163
+ $product['productTypes'] = $productTypes;
164
  }
165
+ $image_id = $v_value['image_id'];
166
+ $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
167
+ //if($is_color_size == true){
168
+ if(isset($v_value['attributes']) && !empty($v_value['attributes']) ){
169
+ foreach($v_value['attributes'] as $va_key => $va_value ){
170
+ $va_key = str_replace("_", " ", $va_key);
171
+ if (strpos($va_key, 'color') !== false) {
172
+ $product['color'] = $va_value;
173
+ }else if (strpos($va_key, 'size') !== false) {
174
+ $product['sizes'] = $va_value;
175
+ }else{
176
+ $va_key = str_replace("attribute", "", $va_key);
177
+ $product['customAttributes'][] = array("name"=>$va_key, "value"=>$va_value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
  }
180
  }
181
+ //}
182
+ foreach($formArray as $key => $value){
183
+ if($key == 'price'){
184
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
185
+ $product[$key]['value'] = $postmeta_var->$value;
186
+ }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
187
+ $product[$key]['value'] = $postmeta_var->_regular_price;
188
+ }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
189
+ $product[$key]['value'] = $postmeta_var->_price;
190
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
191
+ $product[$key]['value'] = $postmeta_var->_sale_price;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
194
+ $product[$key]['currency'] = $tvc_currency;
195
+ }else{
196
+ $skipProducts[$postmeta_var->ID] = $postmeta_var;
197
+ }
198
+ }else if($key == 'sale_price'){
199
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
200
+ $product[$key]['value'] = $postmeta_var->$value;
201
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
202
+ $product[$key]['value'] = $postmeta_var->_sale_price;
203
+ }
204
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
205
+ $product[$key]['currency'] = $tvc_currency;
206
+ }
207
+ }else if($key == 'availability'){
208
+ $tvc_find = array("instock","outofstock","onbackorder");
209
+ $tvc_replace = array("in stock","out of stock","preorder");
210
+ if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
211
+ $stock_status = $postmeta_var->$value;
212
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
213
+ $product[$key] = $stock_status;
214
+ }else{
215
+ $stock_status = $postmeta_var->_stock_status;
216
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
217
+ $product[$key] = $stock_status;
218
+ }
219
+ }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){$product[$key] = $postmeta_var->$value;
220
  }
 
 
 
 
 
 
 
221
  }
222
+ $item = [
223
+ 'merchant_id' => $merchantId,
224
+ 'batch_id' => ++$batchId,
225
+ 'method' => 'insert',
226
+ 'product' => $product
227
+ ];
228
+ $items[] = $item;
229
  }
 
 
230
  }
231
+
232
  }else{
233
+ //simpleproduct:
234
  $image_id = $prd->get_image_id();
235
+ $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
236
+ //echo $postvalue->w_product_id;
237
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
238
+ if(!empty($productTypes)){
239
+ $product['productTypes'] = $productTypes;
240
+ }
241
+ //$product['productTypes'] = "Apparel & Accessories";
242
  foreach($formArray as $key => $value){
243
  if($key == 'price'){
244
  if(isset($postObj->$value) && $postObj->$value > 0){
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === Google Analytics and Google Shopping plugin for WooCommerce ===
2
  Contributors: Tatvic, Conversios
3
  Plugin Name: Enhanced Ecommerce for WooCommerce Store
4
  Plugin URI: https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/
@@ -8,8 +8,8 @@ Author: Tatvic
8
  Requires at least: 1.4.1
9
  Tested up to: 5.8.1
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 4.3.5
12
- Version: 4.3.5
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
@@ -380,6 +380,10 @@ You can resolve the duplication of data by removing the manually implemented GA
380
 
381
  == Changelog ==
382
 
 
 
 
 
383
  = 4.3.5 - 23/10/2021 =
384
 
385
  * We have fixed the onboarding signup issue which was raised by some users.
1
+ === Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce ===
2
  Contributors: Tatvic, Conversios
3
  Plugin Name: Enhanced Ecommerce for WooCommerce Store
4
  Plugin URI: https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/
8
  Requires at least: 1.4.1
9
  Tested up to: 5.8.1
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 4.4.0
12
+ Version: 4.4.0
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
380
 
381
  == Changelog ==
382
 
383
+ = 4.4.0 - 01/11/2021 =
384
+
385
+ * In this release, we have added product type and custom attributes for the product sync capability which will help in enhancing your product feeds in Google Merchant Center. These attributed will automatically collected and pushed to GMC when you are syncing products.
386
+
387
  = 4.3.5 - 23/10/2021 =
388
 
389
  * We have fixed the onboarding signup issue which was raised by some users.