Product Feed PRO for WooCommerce - Version 9.7.8

Version Description

Added a boolean check on the review feed creation

Download this release

Release Info

Developer jorisverwater
Plugin Icon 128x128 Product Feed PRO for WooCommerce
Version 9.7.8
Comparing to
See all releases

Code changes from version 9.3.7 to 9.7.8

TODO.txt CHANGED
@@ -5,18 +5,18 @@ Tutorial / Blog posts:
5
  - Explain all the different fields/attributes that can be selected from the drop-downs
6
 
7
  Priority issues:
 
8
  - License key input field needs to be a password field (asterixes)
 
9
  - Add a preview option so only 5-10 products are being generated
10
  - Own hosted plugin updating: https://rudrastyh.com/wordpress/self-hosted-plugin-update.html
11
  - Google local product feed inventory in XML format (not just TXT like it is now)
12
  - Add support for Multisites
13
  - Add a filter on review score (and amount of reviews)
14
  - Make extra woosea fields available for front-end usage
15
- - Only update feed when changes to products have been made
16
  - Add header to extra fields on product edit pages
17
  - Add possibility to create OR rules
18
  - Add support for Google My Business product feeds
19
- - Build a better WP Cron check, current one is not good enough
20
  - AMAZON integration:
21
  - requires a professional seller account, 39 dollar a month, before being able to create a developer account
22
  - only than we can use their MWS service needed to connect our plugin
5
  - Explain all the different fields/attributes that can be selected from the drop-downs
6
 
7
  Priority issues:
8
+ - Add Pinterest Tag; https://help.pinterest.com/nl/business/article/install-the-pinterest-tag
9
  - License key input field needs to be a password field (asterixes)
10
+ - A seperate FB pixel per WPML website / language
11
  - Add a preview option so only 5-10 products are being generated
12
  - Own hosted plugin updating: https://rudrastyh.com/wordpress/self-hosted-plugin-update.html
13
  - Google local product feed inventory in XML format (not just TXT like it is now)
14
  - Add support for Multisites
15
  - Add a filter on review score (and amount of reviews)
16
  - Make extra woosea fields available for front-end usage
 
17
  - Add header to extra fields on product edit pages
18
  - Add possibility to create OR rules
19
  - Add support for Google My Business product feeds
 
20
  - AMAZON integration:
21
  - requires a professional seller account, 39 dollar a month, before being able to create a developer account
22
  - only than we can use their MWS service needed to connect our plugin
classes/channels/class-google_local_products.php CHANGED
@@ -12,8 +12,8 @@ class WooSEA_google_local_products {
12
  $google_local_products = array(
13
  "Local products fields" => array(
14
  "Itemid" => array(
15
- "name" => "Itemid",
16
- "feed_name" => "g:itemid",
17
  "format" => "required",
18
  "woo_suggest" => "id",
19
  ),
12
  $google_local_products = array(
13
  "Local products fields" => array(
14
  "Itemid" => array(
15
+ "name" => "Id",
16
+ "feed_name" => "g:id",
17
  "format" => "required",
18
  "woo_suggest" => "id",
19
  ),
classes/channels/class-google_shopping.php CHANGED
@@ -356,6 +356,11 @@ class WooSEA_google_shopping {
356
  "feed_name" => "g:max_handling_time",
357
  "format" => "optional",
358
  ),
 
 
 
 
 
359
  ),
360
  "Tax" => array(
361
  "Tax" => array(
356
  "feed_name" => "g:max_handling_time",
357
  "format" => "optional",
358
  ),
359
+ "Ships from country" => array(
360
+ "name" => "ships_from_country",
361
+ "feed_name" => "g:ships_from_country",
362
+ "format" => "optional",
363
+ ),
364
  ),
365
  "Tax" => array(
366
  "Tax" => array(
classes/class-activate.php CHANGED
@@ -64,7 +64,14 @@ class WooSEA_Activation {
64
  "fields" => "google_shopping",
65
  "taxonomy" => "google_shopping",
66
  "utm_source" => "Bing Shopping",
67
- "type" => "Advertising" ),
 
 
 
 
 
 
 
68
  "Facebook Catalog Feed / Instagram" => array (
69
  "channel_hash" => md5("Facebook Remarketing"),
70
  "name" => "Facebook Catalog Feed / Instagram",
@@ -90,7 +97,7 @@ class WooSEA_Activation {
90
  "channel_hash" => md5("Snapchat Product Catalog"),
91
  "name" => "Snapchat Product Catalog",
92
  "fields" => "snapchat",
93
- "taxonomy" => "none",
94
  "utm_source" => "snapchat",
95
  "type" => "Advertising" ),
96
  ),
@@ -1112,6 +1119,13 @@ class WooSEA_Activation {
1112
  "taxonomy" => "none",
1113
  "utm_source" => "Tweakers.nl",
1114
  "type" => "Comparison shopping engine" ),
 
 
 
 
 
 
 
1115
  "Fashionchick.nl" => array (
1116
  "channel_hash" => md5("Fashionchick.nl"),
1117
  "name" => "Fashionchick.nl",
64
  "fields" => "google_shopping",
65
  "taxonomy" => "google_shopping",
66
  "utm_source" => "Bing Shopping",
67
+ "type" => "Advertising" ),
68
+ "Bing Shopping Promotions" => array (
69
+ "channel_hash" => md5("Bing Shopping Promotions"),
70
+ "name" => "Bing Shopping Promotions",
71
+ "fields" => "google_shopping_promotions",
72
+ "taxonomy" => "google_shopping_promotions",
73
+ "utm_source" => "Bing Shopping Promotions",
74
+ "type" => "Advertising" ),
75
  "Facebook Catalog Feed / Instagram" => array (
76
  "channel_hash" => md5("Facebook Remarketing"),
77
  "name" => "Facebook Catalog Feed / Instagram",
97
  "channel_hash" => md5("Snapchat Product Catalog"),
98
  "name" => "Snapchat Product Catalog",
99
  "fields" => "snapchat",
100
+ "taxonomy" => "google_shopping",
101
  "utm_source" => "snapchat",
102
  "type" => "Advertising" ),
103
  ),
1119
  "taxonomy" => "none",
1120
  "utm_source" => "Tweakers.nl",
1121
  "type" => "Comparison shopping engine" ),
1122
+ "Boetiek.nl" => array (
1123
+ "channel_hash" => md5("Boetiek.nl"),
1124
+ "name" => "Boetiek.nl",
1125
+ "fields" => "boetiek",
1126
+ "taxonomy" => "none",
1127
+ "utm_source" => "Boetiek.nl",
1128
+ "type" => "Comparison shopping engine" ),
1129
  "Fashionchick.nl" => array (
1130
  "channel_hash" => md5("Fashionchick.nl"),
1131
  "name" => "Fashionchick.nl",
classes/class-attributes.php CHANGED
@@ -48,7 +48,7 @@ private function get_dynamic_attributes(){
48
  global $wpdb;
49
  $list = array();
50
 
51
- $no_taxonomies = array("portfolio_category","portfolio_skills","portfolio_tags","nav_menu","post_format","slide-page","element_category","template_category","portfolio_category","portfolio_skills","portfolio_tags","faq_category","slide-page","yst_prominent_words","category","post_tag","nav_menu","link_category","post_format","product_type","product_visibility","product_cat","product_shipping_class","product_tag");
52
  $taxonomies = get_taxonomies();
53
  $diff_taxonomies = array_diff($taxonomies, $no_taxonomies);
54
 
@@ -205,13 +205,17 @@ public function get_mapping_attributes_dropdown() {
205
  "sku_item_group_id" => "SKU_ITEM_GROUP_ID (Facebook)",
206
  "wc_post_id_product_id" => "Wc_post_id_product_id (Facebook)",
207
  "title" => "Product name",
208
- "mother_title" => "Product name parent product",
209
  "title_hyphen" => "Product name hyphen",
 
 
210
  "title_lc" => "Product name lowercase",
 
211
  "description" => "Product description",
212
  "short_description" => "Product short description",
213
  "raw_description" => "Unfiltered product description",
214
  "raw_short_description" => "Unfiltered product short description",
 
 
215
  "price" => "Price",
216
  "regular_price" => "Regular price",
217
  "sale_price" => "Sale price",
@@ -247,9 +251,10 @@ public function get_mapping_attributes_dropdown() {
247
  "category_path" => "Category path",
248
  "category_path_short" => "Category path short",
249
  "category_path_skroutz" => "Category path Skroutz",
250
- "one_category" => "Primary category",
251
  "condition" => "Condition",
252
- "availability" => "Availability",
 
253
  "quantity" => "Quantity [Stock]",
254
  "product_type" => "Product Type",
255
  "content_type" => "Content Type",
@@ -267,7 +272,8 @@ public function get_mapping_attributes_dropdown() {
267
  "length" => "Length",
268
  "shipping" => "Shipping",
269
  "shipping_price" => "Shipping cost",
270
- "shipping_label" => "Shipping label",
 
271
  "visibility" => "Visibility",
272
  "rating_total" => "Total rating",
273
  "rating_average" => "Average rating",
@@ -350,9 +356,10 @@ public function get_mapping_attributes_dropdown() {
350
 
351
  foreach ($custom_attributes as $key => $value) {
352
  if (!preg_match("/pyre|sbg|fusion/i",$value)){
353
- if (strpos($value, 0, 1) !== "_") {
 
354
  $dropdown .= "<option value='$key'>" . ucfirst($value) . "</option>";
355
- }
356
  }
357
  }
358
 
@@ -398,15 +405,19 @@ public function get_mapping_attributes_dropdown() {
398
  "parent_sku" => "SKU parent variable product",
399
  "sku_item_group_id" => "SKU_ITEM_GROUP_ID (Facebook)",
400
  "wc_post_id_product_id" => "Wc_post_id_product_id (Facebook)",
401
- "title" => "Product name",
402
- "mother_title" => "Product name parent product",
403
- "title_hyphen" => "Product name hyphen",
 
404
  "title_lc" => "Product name lowercase",
 
405
  "description" => "Product description",
406
  "short_description" => "Product short description",
407
  "raw_description" => "Unfiltered product description",
408
  "raw_short_description" => "Unfiltered product short description",
409
- "link" => "Link",
 
 
410
  "variable_link" => "Product variable link",
411
  "add_to_cart_link" => "Add to cart link",
412
  "image" => "Main image",
@@ -429,10 +440,11 @@ public function get_mapping_attributes_dropdown() {
429
  "category_path" => "Category path",
430
  "category_path_short" => "Category path short",
431
  "category_path_skroutz" => "Category path Skroutz",
432
- "one_category" => "Primary category",
433
  "condition" => "Condition",
434
  "availability" => "Availability",
435
- "quantity" => "Quantity [Stock]",
 
436
  "price" => "Price",
437
  "regular_price" => "Regular price",
438
  "sale_price" => "Sale price",
@@ -464,7 +476,8 @@ public function get_mapping_attributes_dropdown() {
464
  "length" => "Length",
465
  "shipping" => "Shipping",
466
  "shipping_price" => "Shipping cost",
467
- "shipping_label" => "Shipping label",
 
468
  "visibility" => "Visibility",
469
  "rating_total" => "Total rating",
470
  "rating_average" => "Average rating",
48
  global $wpdb;
49
  $list = array();
50
 
51
+ $no_taxonomies = array("portfolio_category","portfolio_skills","portfolio_tags","nav_menu","post_format","slide-page","element_category","template_category","portfolio_category","portfolio_skills","portfolio_tags","faq_category","slide-page","category","post_tag","nav_menu","link_category","post_format","product_type","product_visibility","product_cat","product_shipping_class","product_tag");
52
  $taxonomies = get_taxonomies();
53
  $diff_taxonomies = array_diff($taxonomies, $no_taxonomies);
54
 
205
  "sku_item_group_id" => "SKU_ITEM_GROUP_ID (Facebook)",
206
  "wc_post_id_product_id" => "Wc_post_id_product_id (Facebook)",
207
  "title" => "Product name",
 
208
  "title_hyphen" => "Product name hyphen",
209
+ "mother_title" => "Product name parent product",
210
+ "mother_title_hyphen" => "Product name parent product hyphen",
211
  "title_lc" => "Product name lowercase",
212
+ "title_lcw" => "Product name uppercase first characters",
213
  "description" => "Product description",
214
  "short_description" => "Product short description",
215
  "raw_description" => "Unfiltered product description",
216
  "raw_short_description" => "Unfiltered product short description",
217
+ "mother_description" => "Product description parent product",
218
+ "mother_short_description" => "Product short description parent product",
219
  "price" => "Price",
220
  "regular_price" => "Regular price",
221
  "sale_price" => "Sale price",
251
  "category_path" => "Category path",
252
  "category_path_short" => "Category path short",
253
  "category_path_skroutz" => "Category path Skroutz",
254
+ "one_category" => "Yoast primary category",
255
  "condition" => "Condition",
256
+ "availability" => "Availability",
257
+ "stock_status" => "Stock Status WooCommerce",
258
  "quantity" => "Quantity [Stock]",
259
  "product_type" => "Product Type",
260
  "content_type" => "Content Type",
272
  "length" => "Length",
273
  "shipping" => "Shipping",
274
  "shipping_price" => "Shipping cost",
275
+ "shipping_label" => "Shipping class slug",
276
+ "shipping_label_name" => "Shipping class name",
277
  "visibility" => "Visibility",
278
  "rating_total" => "Total rating",
279
  "rating_average" => "Average rating",
356
 
357
  foreach ($custom_attributes as $key => $value) {
358
  if (!preg_match("/pyre|sbg|fusion/i",$value)){
359
+ $value = ltrim($value);
360
+ if (!empty($value)){
361
  $dropdown .= "<option value='$key'>" . ucfirst($value) . "</option>";
362
+ }
363
  }
364
  }
365
 
405
  "parent_sku" => "SKU parent variable product",
406
  "sku_item_group_id" => "SKU_ITEM_GROUP_ID (Facebook)",
407
  "wc_post_id_product_id" => "Wc_post_id_product_id (Facebook)",
408
+ "title" => "Product name",
409
+ "title_hyphen" => "Product name hyphen",
410
+ "mother_title" => "Product name parent product",
411
+ "mother_title_hyphen" => "Product name parent product hyphen",
412
  "title_lc" => "Product name lowercase",
413
+ "title_lcw" => "Product name uppercase first characters",
414
  "description" => "Product description",
415
  "short_description" => "Product short description",
416
  "raw_description" => "Unfiltered product description",
417
  "raw_short_description" => "Unfiltered product short description",
418
+ "mother_description" => "Product description parent product",
419
+ "mother_short_description" => "Product short description parent product",
420
+ "link" => "Link",
421
  "variable_link" => "Product variable link",
422
  "add_to_cart_link" => "Add to cart link",
423
  "image" => "Main image",
440
  "category_path" => "Category path",
441
  "category_path_short" => "Category path short",
442
  "category_path_skroutz" => "Category path Skroutz",
443
+ "one_category" => "Yoast primary category",
444
  "condition" => "Condition",
445
  "availability" => "Availability",
446
+ "stock_status" => "Stock Status WooCommerce",
447
+ "quantity" => "Quantity [Stock]",
448
  "price" => "Price",
449
  "regular_price" => "Regular price",
450
  "sale_price" => "Sale price",
476
  "length" => "Length",
477
  "shipping" => "Shipping",
478
  "shipping_price" => "Shipping cost",
479
+ "shipping_label" => "Shipping class slug",
480
+ "shipping_label_name" => "Shipping class name",
481
  "visibility" => "Visibility",
482
  "rating_total" => "Total rating",
483
  "rating_average" => "Average rating",
classes/class-get-products.php CHANGED
@@ -26,7 +26,6 @@ class WooSEA_Get_Products {
26
  return "<![CDATA[ $string ]]>";
27
  }
28
 
29
-
30
  /**
31
  * Check if a plugin is active
32
  */
@@ -57,6 +56,11 @@ class WooSEA_Get_Products {
57
  * Get all approved product review comments for Google's Product Review Feeds
58
  */
59
  public function woosea_get_reviews ( $product_data, $product ) {
 
 
 
 
 
60
  $approved_reviews = array();
61
  $prod_id = $product_data['id'];
62
 
@@ -84,8 +88,10 @@ class WooSEA_Get_Products {
84
  $cnt = 0;
85
  $name = "";
86
  foreach($name_pieces as $n_piece){
 
 
87
  if($cnt > 0){
88
- $n_piece = substr($n_piece, 0, 1);
89
  }
90
  $name .= $n_piece." ";
91
  $cnt++;
@@ -96,7 +102,7 @@ class WooSEA_Get_Products {
96
  $review['reviewer_name'] = html_entity_decode((str_replace("\r", "", $review['reviewer_name'])), ENT_QUOTES | ENT_XML1, 'UTF-8');
97
  $review['reviewer_name'] = preg_replace( '/\[(.*?)\]/', ' ', $review['reviewer_name'] );
98
  $review['reviewer_name'] = str_replace("&#xa0;", "", $review['reviewer_name']);
99
- $review['reviewer_name'] = $this->woosea_utf8_for_xml( $review['reviewer_name'] );
100
 
101
  $review['reviewer_id'] = $review_raw->user_id;
102
  $review['review_timestamp'] = $review_raw->comment_date;
@@ -324,7 +330,7 @@ class WooSEA_Get_Products {
324
  /**
325
  * Get category path (needed for Prisjakt)
326
  */
327
- public function woosea_get_term_parents( $id, $taxonomy, $link = false, $project_taxonomy, $nicename = false, $visited = array() ) {
328
  // Only add Home to the beginning of the chain when we start buildin the chain
329
  if(empty($visited)){
330
  $chain = 'Home';
@@ -931,6 +937,16 @@ class WooSEA_Get_Products {
931
  unset($shipping_cost);
932
  }
933
  }
 
 
 
 
 
 
 
 
 
 
934
  }
935
 
936
  if(isset($zone_details)){
@@ -957,12 +973,9 @@ class WooSEA_Get_Products {
957
  $zone_details['price'] = trim($shipping_cost);
958
  }
959
  } else {
960
- // $shipping_cost = 0;
961
  if(isset($shipping_cost)){
962
  $zone_details['price'] = trim($currency." ".$shipping_cost);
963
  }
964
- //unset($zone_details);
965
- //unset($shipping_cost);
966
  }
967
  }
968
  }
@@ -992,12 +1005,19 @@ class WooSEA_Get_Products {
992
 
993
  // Remove other shipping classes when free shipping is relevant
994
  $free_check = "yes";
995
- //$free_check = get_option ('free_shipping');
996
 
997
  if(in_array($free_check, array_column($shipping_arr, 'free'))) { // search value in the array
998
  foreach($shipping_arr as $k => $v) {
999
  if(!in_array($free_check, $v)){
1000
- unset($shipping_arr[$k]);
 
 
 
 
 
 
 
 
1001
  }
1002
  }
1003
  }
@@ -1005,8 +1025,6 @@ class WooSEA_Get_Products {
1005
  // Fix empty services
1006
  foreach($shipping_arr as $k => $v){
1007
  if(empty($v['service'])){
1008
- // $lalala = get_option( 'woocommerce_default_country' );
1009
- // $shipping_arr[$k]['country'] = get_option( 'woocommerce_default_country' );
1010
  unset($shipping_arr[$k]);
1011
  }
1012
  }
@@ -1145,16 +1163,19 @@ class WooSEA_Get_Products {
1145
  } elseif (preg_match("/g:product_detail/i",$k)){
1146
  if(!empty($v)){
1147
  $product_detail_split = explode("#", $v);
1148
- $product_detail = $product->addChild('g:product_detail', '', $namespace['g']);
1149
- $name = str_replace("_", " ", $product_detail_split[0]);
1150
-
1151
- $section_name = explode(":", $name);
1152
- $section_name_start = ucfirst($section_name[0]);
1153
- $name = ucfirst(trim($section_name[1]));
1154
-
1155
- $section_name = $product_detail->addChild('g:section_name', "General", $namespace['g']);
1156
- $product_detail_name = $product_detail->addChild('g:attribute_name', $section_name_start, $namespace['g']);
1157
- $product_detail_value = $product_detail->addChild('g:attribute_value', $product_detail_split[1], $namespace['g']);
 
 
 
1158
  }
1159
  } elseif ($k == "g:installment"){
1160
  if(!empty($v)){
@@ -1355,187 +1376,189 @@ class WooSEA_Get_Products {
1355
 
1356
  // For Google Product review template
1357
  if (($feed_config['name'] == "Google Product Review") AND (empty($xml->channel))) {
1358
- $product = $xml->addChild('reviews');
 
 
1359
 
1360
- foreach ($products as $key => $value){
1361
 
1362
- $expl = "||";
1363
- if(strpos($value['reviews'], $expl)) {
1364
- $review_data = explode("||", $value['reviews']);
1365
- foreach($review_data as $rk => $rv){
1366
 
1367
- $review_comp = explode(":::", $rv);
1368
- $nr_reviews = count($review_comp);
1369
 
1370
- if($nr_reviews > 1){
1371
- $productz = $xml->reviews->addChild('review');
1372
 
1373
- foreach($review_comp as $rck => $rcv){
1374
- $nodes = explode("##", $rcv);
1375
- $nodes = str_replace("::", "", $nodes);
1376
 
1377
- if($nodes[0] == "REVIEW_RATINGS"){
1378
- // Do nothing
1379
- } elseif($nodes[0] == "REVIEW_URL"){
1380
- $rev_url = $productz->addChild(strtolower($nodes[0]), htmlspecialchars($nodes[1]));
1381
- $rev_url->addAttribute('type', 'singleton');
1382
- } elseif(($nodes[0] == "REVIEWER_NAME") OR ($nodes[0] == "REVIEWER_ID")){
1383
- if(isset($productz->reviewer)){
1384
- if($nodes[0] == "REVIEWER_NAME"){
1385
- $name = $nodes[1];
1386
- if(empty($name)){
1387
- $reviewer->addChild('name','Anonymous');
1388
- $reviewer->name->addAttribute('is_anonymous', 'true');
 
 
 
1389
  } else {
1390
- $reviewer->addChild('name',$name);
1391
  }
1392
  } else {
1393
- $reviewer->addChild('reviewer_id',$nodes[1]);
1394
- }
1395
- } else {
1396
- $reviewer = $productz->addChild('reviewer');
1397
- if($nodes[0] == "REVIEWER_NAME"){
1398
- $name = $nodes[1];
1399
- if(empty($name)){
1400
- $reviewer->addChild('name','Anonymous');
1401
- $reviewer->name->addAttribute('is_anonymous', 'true');
1402
  } else {
1403
- $reviewer->addChild('name',$name);
1404
  }
1405
- } else {
1406
- $reviewer->addChild('reviewer_id',$nodes[1]);
1407
  }
1408
- }
1409
- } else {
1410
- if(isset($nodes[1])){
1411
- $content = html_entity_decode($nodes[1]);
1412
- $content = htmlspecialchars($content);
1413
- $rev = $productz->addChild(strtolower($nodes[0]), $content);
1414
  }
1415
  }
1416
- }
1417
 
1418
- foreach($review_comp as $rck => $rcv){
1419
- $nodes = explode("##", $rcv);
1420
- $nodes = str_replace("::", "", $nodes);
1421
 
1422
- if($nodes[0] == "REVIEW_RATINGS"){
1423
- $rev = $productz->addChild('ratings');
1424
- $over = $productz->ratings->addChild('overall', $nodes[1]);
1425
- $over->addAttribute('min', '1');
1426
- $over->addAttribute('max', '5');
 
1427
  }
1428
- }
1429
-
1430
 
1431
- $yo = $productz->addChild('products');
1432
- $po = $yo->addChild('product');
1433
 
1434
- $identifiers = array("gtin","mpn","sku","brand");
1435
 
1436
- // Start determining order of product_ids in the Google review feed
1437
- $proper_order = array("product_name","gtin","mpn","sku","brand","product_url","review_url","reviews");
1438
- $order_sorted = array();
1439
- foreach ($proper_order as &$order_value){
1440
- if(isset($value[$order_value])){
1441
- $order_sorted[$order_value] = $value[$order_value];
 
1442
  }
1443
- }
1444
- // End
1445
-
1446
- foreach($order_sorted as $k => $v) {
1447
- if(($k != "product_name") AND ($k != "product_url")){
1448
- if(!in_array($k, $identifiers)){
1449
- if(($k != "reviews") AND ($k != "review_url")){
1450
- $v = str_replace("&", "and", $v);
1451
- $poa = $po->addChild($k,htmlspecialchars($v));
1452
- }
1453
- } else {
1454
- if(isset($po->product_ids)){
1455
- if ($k == "gtin"){
1456
- $poig = $poi->addChild('gtins');
1457
- $poig->$k = $v;
1458
- } elseif ($k == "mpn"){
1459
- $poim = $poi->addChild('mpns');
1460
- $poim->$k = $v;
1461
- } elseif ($k == "sku"){
1462
- $poix = $poi->addChild('skus');
1463
- $poix->$k = $v;
1464
- } elseif($k == "brand"){
1465
- $poib = $poi->addChild('brands');
1466
- $poib->$k = $v;
1467
- } else {
1468
- // Do nothing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  }
1470
- } else {
1471
- $poi = $po->addChild('product_ids');
1472
- if ($k == "gtin"){
1473
- $poig = $poi->addChild('gtins');
1474
- $poig->$k = $v;
1475
- } elseif ($k == "mpn"){
1476
- $poim = $poi->addChild('mpns');
1477
- $poim->$k = $v;
1478
- } elseif ($k == "sku"){
1479
- $poix = $poi->addChild('skus');
1480
- $poix->$k = $v;
1481
- } elseif($k == "brand"){
1482
- $poib = $poi->addChild('brands');
1483
- $poib->$k = $v;
1484
- } else {
1485
- // Do nothing
1486
- }
1487
- }
1488
- }
1489
- }
1490
- }
1491
 
1492
- // foreach for product name and product url as order seems to mather to Google
1493
- foreach($value as $k => $v) {
1494
- if(($k == "product_name") OR ($k == "product_url")){
1495
- if(!in_array($k, $identifiers)){
1496
- if(($k != "reviews") AND ($k != "review_url")){
1497
- $v = str_replace("&", "and", $v);
1498
- $poa = $po->addChild($k,htmlspecialchars($v));
1499
- }
1500
- } else {
1501
- if(isset($po->product_ids)){
1502
- if ($k == "gtin"){
1503
- $poig = $poi->addChild('gtins');
1504
- $poig->$k = $v;
1505
- } elseif ($k == "mpn"){
1506
- $poim = $poi->addChild('mpns');
1507
- $poim->$k = $v;
1508
- } elseif($k == "sku"){
1509
- $poix = $poi->addChild('skus');
1510
- $poix->$k = $v;
1511
- } elseif($k == "brand"){
1512
- $poib = $poi->addChild('brands');
1513
- $poib->$k = $v;
1514
- } else {
1515
- // Do nothing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1516
  }
1517
- } else {
1518
- $poi = $po->addChild('product_ids');
1519
- if ($k == "gtin"){
1520
- $poig = $poi->addChild('gtins');
1521
- $poig->$k = $v;
1522
- } elseif ($k == "mpn"){
1523
- $poim = $poi->addChild('mpns');
1524
- $poim->$k = $v;
1525
- } elseif ($k == "sku"){
1526
- $poix = $poi->addChild('skus');
1527
- $poix->$k = $v;
1528
- } elseif($k == "brand"){
1529
- $poib = $poi->addChild('brands');
1530
- $poib->$k = $v;
1531
- } else {
1532
- // Do nothing
1533
- }
1534
- }
1535
- }
1536
- }
1537
- }
1538
- }
1539
  }
1540
  }
1541
  }
@@ -1993,7 +2016,7 @@ class WooSEA_Get_Products {
1993
  $xml_piece = "";
1994
 
1995
  // Get taxonomies
1996
- $no_taxonomies = array("element_category","template_category","portfolio_category","portfolio_skills","portfolio_tags","faq_category","slide-page","yst_prominent_words","category","post_tag","nav_menu","link_category","post_format","product_type","product_visibility","product_cat","product_shipping_class","product_tag");
1997
  $taxonomies = get_taxonomies();
1998
  $diff_taxonomies = array_diff($taxonomies, $no_taxonomies);
1999
 
@@ -2325,6 +2348,10 @@ class WooSEA_Get_Products {
2325
  $product_data['raw_description'] = substr($product_data['raw_description'], 0, 5000);
2326
  $product_data['raw_short_description'] = substr($product_data['raw_short_description'], 0, 5000);
2327
 
 
 
 
 
2328
  /**
2329
  * Check of we need to add Google Analytics UTM parameters
2330
  */
@@ -2358,6 +2385,7 @@ class WooSEA_Get_Products {
2358
  * Therefor, we need to check the stock_status and overwrite te availability value
2359
  */
2360
  $stock_status = $product->get_stock_status();
 
2361
  if ($stock_status == "outofstock"){
2362
  $product_data['availability'] = "out of stock";
2363
  } elseif ($stock_status == "onbackorder") {
@@ -2439,6 +2467,10 @@ class WooSEA_Get_Products {
2439
  }
2440
 
2441
  $product_data['shipping_label'] = $product->get_shipping_class();
 
 
 
 
2442
 
2443
  // Get product prices
2444
  $product_data['price'] = wc_get_price_including_tax($product, array('price'=> $product->get_price()));
@@ -2449,9 +2481,11 @@ class WooSEA_Get_Products {
2449
  $product_data['regular_price'] = wc_format_decimal($product_data['regular_price'],2);
2450
 
2451
  // Untouched raw system pricing - DO NOT CHANGE THESE
2452
- $product_data['system_net_price'] = round(wc_get_price_excluding_tax( $product ), 2);
2453
- $product_data['system_net_price'] = wc_format_decimal($product_data['system_net_price'],2);
2454
- $product_data['system_regular_price'] = round($product->get_regular_price(),2);
 
 
2455
  $product_data['system_regular_price'] = wc_format_decimal($product_data['system_regular_price'],2);
2456
 
2457
  $product_data['system_price'] = wc_get_price_including_tax($product, array('price'=> $product->get_price()));
@@ -2485,6 +2519,7 @@ class WooSEA_Get_Products {
2485
  if($product->get_type() == "bundle"){
2486
  if ($this->woosea_is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')){
2487
  $product_data['price'] = get_post_meta($product_data['id'], '_price', true);
 
2488
  if(is_numeric($tax_rates[1]['rate'])){
2489
  $product_data['price_forced'] = round(get_post_meta($product_data['id'], '_price', true) * (100+$tax_rates[1]['rate'])/100,2);
2490
  $product_data['regular_price'] = round(get_post_meta($product_data['id'], '_regular_price', true) * (100+$tax_rates[1]['rate'])/100,2);
@@ -2570,8 +2605,10 @@ class WooSEA_Get_Products {
2570
  $product_data['net_sale_price'] = "";
2571
  }
2572
  }
2573
- $product_data['net_price'] = round(wc_get_price_excluding_tax( $product ), 2);
2574
-
 
 
2575
  $price = wc_get_price_including_tax($product,array('price'=> $product->get_price()));
2576
  if($product_data['sale_price'] > 0){
2577
  $price = $product_data['sale_price'];
@@ -2582,6 +2619,7 @@ class WooSEA_Get_Products {
2582
  $discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', false, $product, 1, $product_data['sale_price'], 'discounted_price', true, true);
2583
  if($discount !== false){
2584
  $product_data['sale_price'] = $discount;
 
2585
  $price_incl_tax = get_option( 'woocommerce_prices_include_tax' );
2586
  if($price_incl_tax == "yes"){
2587
  $product_data['price_forced'] = $product_data['price']*($fullrate/100);
@@ -2722,9 +2760,12 @@ class WooSEA_Get_Products {
2722
  $product_data['system_sale_price'] = wc_format_localized_price($product_data['system_sale_price']);
2723
 
2724
  // Add rounded price options
2725
- $product_data['rounded_price'] = round($product_data['price']);
2726
- $product_data['rounded_regular_price'] = round($product_data['regular_price']);
2727
- $product_data['rounded_sale_price'] = round($product_data['sale_price']);
 
 
 
2728
 
2729
  // Calculate discount percentage
2730
  if($product_data['sale_price'] > 0){
@@ -2742,7 +2783,7 @@ class WooSEA_Get_Products {
2742
  }
2743
  }
2744
 
2745
- if ((array_key_exists('shipping', $project_config['attributes'])) OR (array_key_exists('shipping_price', $project_config['attributes'])) OR ($project_config['fields'] == "trovaprezzi")){
2746
  $product_data['shipping'] = $this->woosea_get_shipping_cost($class_cost_id, $project_config, $product_data['price'], $tax_rates, $shipping_zones, $product_data['id'], $product_data['item_group_id']);
2747
  $shipping_str = $product_data['shipping'];
2748
  }
@@ -2838,7 +2879,7 @@ class WooSEA_Get_Products {
2838
 
2839
  foreach($diff_taxonomies as $taxo){
2840
  $term_value = get_the_terms($product_data['id'], $taxo);
2841
- $product_data[$taxo] = "";
2842
 
2843
  if(is_array($term_value)){
2844
  // Do not add variation values to the feed when they are out of stock
@@ -2848,7 +2889,7 @@ class WooSEA_Get_Products {
2848
  $variations = $product_skroutz->get_available_variations();
2849
  $variations_id = wp_list_pluck( $variations, 'variation_id' );
2850
  $skroutz_att_array = array();
2851
-
2852
  foreach($variations_id as $var_id){
2853
  $stock_value = get_post_meta( $var_id, "_stock_status", true );
2854
  if($stock_value == "instock"){
@@ -2862,7 +2903,6 @@ class WooSEA_Get_Products {
2862
  $product_data[$taxo] = rtrim($product_data[$taxo],',');
2863
  }
2864
  }
2865
-
2866
  foreach($skroutz_att_array as $skrtz_value){
2867
  $product_data[$taxo] .= ",". $skrtz_value;
2868
  }
@@ -2977,7 +3017,7 @@ class WooSEA_Get_Products {
2977
  $data = $wpdb->get_results($sql);
2978
  if (count($data)) {
2979
  foreach ($data as $key => $value) {
2980
- $value_display = str_replace("_", " ",$value->name);
2981
  if (preg_match("/_product_attributes/i",$value->name)){
2982
  $product_attr = unserialize($value->type);
2983
  if(!empty($product_attr)){
@@ -2995,14 +3035,14 @@ class WooSEA_Get_Products {
2995
 
2996
  /**
2997
  * Get Product Attributes for Single products
 
2998
  */
2999
- if (($product->is_type('simple')) OR ($product->is_type('external')) OR ($product->is_type('mix-and-match')) OR ($product->is_type('bundle')) OR ($product->is_type('composite')) OR ($product->is_type('auction') OR ($product->is_type('subscription')))){
3000
  $single_attributes = $product->get_attributes();
3001
-
3002
  foreach ($single_attributes as $attribute){
3003
- $attr_name = strtolower($attribute->get_name());
3004
- $attr_value = $product->get_attribute($attr_name);
3005
- $product_data[$attr_name] = $attr_value;
3006
  }
3007
  }
3008
 
@@ -3028,9 +3068,9 @@ class WooSEA_Get_Products {
3028
  $product_variations = new WC_Product_Variation( $product_data['id'] );
3029
  $variations = $product_variations->get_variation_attributes();
3030
 
3031
- // For Skroutz apparal products we can only append colours to the product name
3032
  // When a product has both a size and color attribute we assume its an apparal product
3033
- if($project_config['fields'] == "skroutz"){
3034
  $size_found = "no";
3035
  $color_found = "no";
3036
 
@@ -3106,23 +3146,27 @@ class WooSEA_Get_Products {
3106
  }
3107
  }
3108
 
3109
-
3110
-
3111
  if((isset($project_config['lowest_price_variations'])) OR (isset($project_config['default_variations']))){
3112
-
3113
  // Determine the default variation product
3114
  if( ($product_data['item_group_id'] > 0) AND (is_object(wc_get_product( $product_data['item_group_id']))) AND (($product_data['product_type'] == "variation") OR ($product_data['product_type'] == "subscription_variation"))){
3115
- $mother_product = wc_get_product($product_data['item_group_id']);
3116
- $def_attributes = $mother_product->get_default_attributes();
 
3117
 
3118
  if(isset($project_config['lowest_price_variations'])){
3119
-
3120
  // Determine lowest priced variation
3121
  $variation_min_price = $mother_product->get_variation_price('min');
3122
  $variation_min_price = wc_format_decimal($variation_min_price,2);
3123
  $variation_min_price = wc_format_localized_price($variation_min_price);
3124
-
3125
- if($product_data['system_net_price'] == $variation_min_price){
 
 
 
 
 
 
3126
  $variation_pass = "true";
3127
  } else {
3128
  $variation_pass = "false";
@@ -3260,19 +3304,21 @@ class WooSEA_Get_Products {
3260
  /**
3261
  * Although this is a product variation we also need to grap the Dynamic attributes belonging to the simple mother prodict
3262
  */
 
 
3263
  foreach($diff_taxonomies as $taxo){
3264
  $term_value = get_the_terms($product_data['item_group_id'], $taxo);
3265
  unset($product_data[$taxo]);
3266
  if(is_array($term_value)){
3267
  foreach($term_value as $term){
3268
  if(empty($product_data[$taxo])){
3269
- $product_data[$taxo] = $term->name;
3270
  } else {
3271
- $product_data[$taxo] .= " ".$term->name;
3272
  }
3273
  }
3274
  }
3275
- }
3276
 
3277
  /**
3278
  * Add product tags to the product data array
@@ -3292,6 +3338,7 @@ class WooSEA_Get_Products {
3292
 
3293
  // Add attribute values to the variation product names to make them unique
3294
  $product_data['title_hyphen'] = $product_data['title']." - ";
 
3295
 
3296
  foreach($variations as $kk => $vv){
3297
  $custom_key = $kk;
@@ -3440,6 +3487,8 @@ class WooSEA_Get_Products {
3440
  * we will add CDATA brackets to the title and description attributes
3441
  */
3442
  $product_data['title_lc'] = ucfirst(strtolower($product_data['title']));
 
 
3443
  //$product_data['description'] = $this->woosea_append_cdata ( $product_data['description'] );
3444
  //$product_data['short_description'] = $this->woosea_append_cdata ( $product_data['short_description'] );
3445
 
@@ -3448,6 +3497,17 @@ class WooSEA_Get_Products {
3448
  */
3449
  $product_data['reviews'] = $this->woosea_get_reviews( $product_data, $product );
3450
 
 
 
 
 
 
 
 
 
 
 
 
3451
  /**
3452
  * Check if individual products need to be excluded
3453
  */
@@ -3513,16 +3573,19 @@ class WooSEA_Get_Products {
3513
  // For these channels parent products are allowed
3514
  $allowed_channel_parents = array(
3515
  "skroutz",
 
3516
  "google_dsa",
3517
  "google_product_review",
3518
  );
3519
 
3520
- if (!in_array($project_config['fields'], $allowed_channel_parents)){
3521
- if(($product->is_type('variable')) AND ($product_data['item_group_id'] == 0)){
3522
- $product_data = array();
3523
- $product_data = null;
3524
- }
3525
- }
 
 
3526
 
3527
  /**
3528
  * Remove variation products that are not THE default variation product
@@ -3549,6 +3612,51 @@ class WooSEA_Get_Products {
3549
  }
3550
  }
3551
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3552
  /**
3553
  * When product has passed the filter rules it can continue with the rest
3554
  */
@@ -3582,7 +3690,7 @@ class WooSEA_Get_Products {
3582
  }
3583
  } else {
3584
  if((strlen($attr_value['mapfrom'])) AND (array_key_exists($attr_value['mapfrom'], $product_data))){
3585
- if(($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "g:link_template") OR ($attr_value['attribute'] == "g:image_link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "Final URL") OR ($attr_value['attribute'] == "SKU")){
3586
  $attr_line = "'".$attr_value['prefix']."".$product_data[$attr_value['mapfrom']]."".$attr_value['suffix']."'";
3587
  } else {
3588
  $attr_line = "'".$attr_value['prefix']. "".$product_data[$attr_value['mapfrom']]."" .$attr_value['suffix']."'";
@@ -3654,7 +3762,7 @@ class WooSEA_Get_Products {
3654
  }
3655
  } else {
3656
  if(strlen($product_data[$attr_value['mapfrom']])){
3657
- if(($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "g:link_template") OR ($attr_value['attribute'] == "g:image_link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "Final URL") OR ($attr_value['attribute'] == "SKU")){
3658
  if(($product_data['product_type'] == "variation") AND (preg_match("/aelia_cs_currency/", $attr_value['suffix']))){
3659
  $attr_value['suffix'] = str_replace("?","&",$attr_value['suffix']);
3660
  $attr_line .= ",'".$attr_value['prefix']."".$product_data[$attr_value['mapfrom']]."".$attr_value['suffix']."'";
@@ -3874,7 +3982,7 @@ class WooSEA_Get_Products {
3874
  }
3875
  } else {
3876
  if(strlen($product_data[$attr_value['mapfrom']])){
3877
- if(($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "g:link_template")){
3878
  if(($product_data['product_type'] == "variation") AND (preg_match("/aelia_cs_currency/", $attr_value['suffix']))){
3879
  $attr_value['suffix'] = str_replace("?","&",$attr_value['suffix']);
3880
  $xml_product[$attr_value['attribute']] = "$attr_value[prefix]". $product_data[$attr_value['mapfrom']] ."$attr_value[suffix]";
@@ -4404,489 +4512,492 @@ class WooSEA_Get_Products {
4404
  return $product_data;
4405
  }
4406
 
4407
- /**
4408
- * Execute project rules
4409
- */
4410
  private function woocommerce_sea_rules( $project_rules2, $product_data ){
4411
- $aantal_prods = count($product_data);
4412
- if($aantal_prods > 0){
4413
 
4414
- foreach ($project_rules2 as $pr_key => $pr_array){
4415
 
4416
- foreach ($product_data as $pd_key => $pd_value){
4417
 
4418
- // Check is there is a rule on specific attributes
4419
- if($pd_key == $pr_array['attribute']){
4420
 
4421
- // This is because for data manipulation the than attribute is empty
4422
- if(!array_key_exists('than_attribute', $pr_array)){
4423
- $pr_array['than_attribute'] = $pd_key;
4424
- }
4425
 
4426
  // Check if a rule has been set for Google categories
4427
  if (!empty($product_data['categories']) AND ($pr_array['than_attribute'] == "google_category") AND ($product_data[$pr_array['attribute']] == $pr_array['criteria'])){
4428
-
4429
- $pr_array['than_attribute'] = "categories";
4430
  $category_id = explode("-", $pr_array['newvalue']);
4431
  $pr_array['newvalue'] = $category_id[0];
4432
- $product_data['categories'] = $pr_array['newvalue'];
4433
- }
4434
 
4435
- // Make sure that rules on numerics are on true numerics
4436
- if (!is_array($pd_value) AND (!preg_match('/[A-Za-z]/', $pd_value))){
4437
- $pd_value = strtr($pd_value, ',', '.');
4438
- }
4439
 
4440
 
4441
- // Make sure the price or sale price is numeric
4442
- if(($pr_array['attribute'] == "sale_price") OR ($pr_array['attribute'] == "price")){
4443
- settype($pd_value, "double");
4444
- }
4445
 
4446
- if (((is_numeric($pd_value)) AND ($pr_array['than_attribute'] != "shipping"))){
4447
 
4448
- // Rules for numeric values
4449
- switch ($pr_array['condition']) {
4450
- case($pr_array['condition'] = "contains"):
4451
- if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4452
- $product_data[$pr_array['than_attribute']] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $pd_value);
4453
- }
4454
- break;
4455
- case($pr_array['condition'] = "containsnot"):
4456
- if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4457
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4458
- }
4459
- break;
4460
- case($pr_array['condition'] = "="):
4461
- if (($pd_value == $pr_array['criteria'])){
4462
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4463
- }
4464
- break;
4465
- case($pr_array['condition'] = "!="):
4466
- if (($pd_value != $pr_array['criteria'])){
4467
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4468
- }
4469
- break;
4470
- case($pr_array['condition'] = ">"):
4471
- if (($pd_value > $pr_array['criteria'])){
4472
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4473
- }
4474
- break;
4475
- case($pr_array['condition'] = ">="):
4476
- if (($pd_value >= $pr_array['criteria'])){
4477
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4478
- }
4479
- break;
4480
- case($pr_array['condition'] = "<"):
4481
- if (($pd_value < $pr_array['criteria'])){
4482
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4483
- }
4484
- break;
4485
- case($pr_array['condition'] = "=<"):
4486
- if (($pd_value <= $pr_array['criteria'])){
4487
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4488
- }
4489
- break;
4490
- case($pr_array['condition'] = "empty"):
4491
- if(empty($product_data[$pr_array['attribute']])){
4492
- if ((strlen($pd_value) < 1)){
4493
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4494
- } else {
4495
- $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4496
- }
4497
- }
4498
- break;
4499
- case($pr_array['condition'] = "multiply"):
4500
- $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4501
- $convert_back = "false";
4502
- $pos = strpos($pd_value, ',');
4503
- if($pos !== false){
4504
- $convert_back = "true";
4505
- }
4506
- $pd_value = strtr($pd_value, ',', '.');
4507
- $newvalue = $pd_value*$pr_array['criteria'];
4508
- $newvalue = round($newvalue, 2);
4509
- if($convert_back == "true"){
4510
- $newvalue = strtr($newvalue, '.',',');
4511
- }
4512
- $product_data[$pr_array['attribute']] = $newvalue;
4513
- break;
4514
- case($pr_array['condition'] = "divide"):
4515
- $newvalue = ($pd_value / $pr_array['criteria']);
4516
- $newvalue = round($newvalue, 2);
4517
- $newvalue = strtr($newvalue, '.',',');
4518
- $product_data[$pr_array['attribute']] = $newvalue;
4519
- break;
4520
- case($pr_array['condition'] = "plus"):
4521
- $newvalue = ($pd_value + $pr_array['criteria']);
4522
- $product_data[$pr_array['attribute']] = $newvalue;
4523
- break;
4524
- case($pr_array['condition'] = "minus"):
4525
- $newvalue = ($pd_value - $pr_array['criteria']);
4526
- $product_data[$pr_array['attribute']] = $newvalue;
4527
- break;
4528
- case($pr_array['condition'] = "findreplace"):
4529
- if (strpos($pd_value, $pr_array['criteria']) !== false){
4530
  // Make sure that a new value has been set
4531
- if(!empty($pr_array['newvalue'])){
4532
- // Find and replace only work on same attribute field, otherwise create a contains rule
4533
  if($pr_array['attribute'] == $pr_array['than_attribute']){
4534
  $newvalue = str_replace($pr_array['criteria'],$pr_array['newvalue'], $pd_value);
4535
  $product_data[$pr_array['than_attribute']] = ucfirst($newvalue);
4536
  }
4537
- }
4538
- }
4539
- break;
4540
- default:
4541
- break;
4542
- }
4543
- } elseif (is_array($pd_value)) {
4544
-
4545
- // For now only shipping details are in an array
4546
- foreach ($pd_value as $k => $v){
4547
- if(is_array($v)){
4548
- foreach ($v as $kk => $vv){
4549
- // Only shipping detail rule can be on price for now
4550
- if($kk == "price"){
4551
- switch ($pr_array['condition']) {
4552
- case($pr_array['condition'] = "contains"):
4553
- if ((preg_match('/'.$pr_array['criteria'].'/', $vv))){
4554
- $pd_value[$k]['price'] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $vv);
4555
- $product_data[$pr_array['than_attribute']] = $pd_value;
4556
- }
4557
- break;
4558
- case($pr_array['condition'] = "containsnot"):
4559
- if ((!preg_match('/'.$pr_array['criteria'].'/', $vv))){
4560
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4561
- $product_data[$pr_array['than_attribute']] = $pd_value;
4562
- }
4563
- break;
4564
- case($pr_array['condition'] = "="):
4565
- if (($vv == $pr_array['criteria'])){
4566
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4567
- $product_data[$pr_array['than_attribute']] = $pd_value;
4568
- }
4569
- break;
4570
- case($pr_array['condition'] = "!="):
4571
- if (($vv != $pr_array['criteria'])){
4572
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4573
- $product_data[$pr_array['than_attribute']] = $pd_value;
4574
- }
4575
- break;
4576
- case($pr_array['condition'] = ">"):
4577
- if (($vv > $pr_array['criteria'])){
4578
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4579
- $product_data[$pr_array['than_attribute']] = $pd_value;
4580
- }
4581
- break;
4582
- case($pr_array['condition'] = ">="):
4583
- if (($vv >= $pr_array['criteria'])){
4584
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4585
- $product_data[$pr_array['than_attribute']] = $pd_value;
4586
- }
4587
- break;
4588
- case($pr_array['condition'] = "<"):
4589
- if (($vv < $pr_array['criteria'])){
4590
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4591
- $product_data[$pr_array['than_attribute']] = $pd_value;
4592
- }
4593
- break;
4594
- case($pr_array['condition'] = "=<"):
4595
- if (($vv <= $pr_array['criteria'])){
4596
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4597
- $product_data[$pr_array['than_attribute']] = $pd_value;
4598
- }
4599
- break;
4600
- case($pr_array['condition'] = "empty"):
4601
- if ((strlen($vv) < 1)){
4602
- $pd_value[$k]['price'] = $pr_array['newvalue'];
4603
- $product_data[$pr_array['than_attribute']] = $pd_value;
4604
- }
4605
- break;
4606
- case($pr_array['condition'] = "multiply"):
4607
- // Only shipping array
4608
- if(is_array($pd_value)){
4609
- $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4610
- foreach ($pd_value as $ship_a_key => $shipping_arr){
4611
- foreach($shipping_arr as $ship_key => $ship_value){
4612
- if($ship_key == "price"){
4613
- $ship_pieces = explode(" ", $ship_value);
4614
- $pd_value = strtr($ship_pieces[1], ',', '.');
4615
- $newvalue = $pd_value*$pr_array['criteria'];
4616
- $newvalue = round($newvalue, 2);
4617
- $newvalue = strtr($newvalue, '.',',');
4618
- $newvalue = $ship_pieces[0]." ".$newvalue;
4619
- $product_data[$pr_array['than_attribute']][$ship_a_key]['price'] = $newvalue;
4620
- }
4621
- }
4622
- }
4623
- }
4624
- break;
4625
- default:
4626
- break;
4627
- }
4628
- }
4629
- }
4630
- } else {
4631
- // Rules on product tags
4632
- foreach ($pd_value as $k => $v){
4633
-
4634
- // Rules for string values
4635
- if (!array_key_exists('cs', $pr_array)){
4636
- $v = strtolower($v);
4637
- $pr_array['criteria'] = strtolower($pr_array['criteria']);
4638
- }
4639
-
4640
- switch ($pr_array['condition']) {
4641
- case($pr_array['condition'] = "contains"):
4642
- if ((preg_match('/'.$pr_array['criteria'].'/', $v))){
4643
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4644
- }
4645
- break;
4646
- case($pr_array['condition'] = "containsnot"):
4647
- if ((!preg_match('/'.$pr_array['criteria'].'/', $v))){
4648
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4649
- }
4650
- break;
4651
- case($pr_array['condition'] = "="):
4652
- if (($v == $pr_array['criteria'])){
4653
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4654
- }
4655
- break;
4656
- case($pr_array['condition'] = "!="):
4657
- if (($v != $pr_array['criteria'])){
4658
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4659
- }
4660
- break;
4661
- case($pr_array['condition'] = ">"):
4662
- if (($v > $pr_array['criteria'])){
4663
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4664
- }
4665
- break;
4666
- case($pr_array['condition'] = ">="):
4667
- if (($v >= $pr_array['criteria'])){
4668
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4669
- }
4670
- break;
4671
- case($pr_array['condition'] = "<"):
4672
- if (($v < $pr_array['criteria'])){
4673
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4674
- }
4675
- break;
4676
- case($pr_array['condition'] = "=<"):
4677
- if (($v <= $pr_array['criteria'])){
4678
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4679
- }
4680
- break;
4681
- case($pr_array['condition'] = "empty"):
4682
- if ((strlen($v) < 1)){
4683
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4684
- }
4685
- break;
4686
- case($pr_array['condition'] = "multiply"):
4687
- // Only shipping array
4688
- if(is_array($v)){
4689
- $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4690
- foreach ($v as $ship_a_key => $shipping_arr){
4691
- foreach($shipping_arr as $ship_key => $ship_value){
4692
- if($ship_key == "price"){
4693
- $ship_pieces = explode(" ", $ship_value);
4694
- $pd_value = strtr($ship_pieces[1], ',', '.');
4695
- $newvalue = $pd_value*$pr_array['criteria'];
4696
- $newvalue = round($newvalue, 2);
4697
- $newvalue = strtr($newvalue, '.',',');
4698
- $newvalue = $ship_pieces[0]." ".$newvalue;
4699
- $product_data[$pr_array['than_attribute']][$ship_a_key]['price'] = $newvalue;
4700
- }
4701
- }
4702
- }
4703
- }
4704
- break;
4705
- default:
4706
- break;
4707
- }
4708
- }
4709
- }
4710
- }
4711
- } else {
4712
- // Rules for string values
4713
- if (!array_key_exists('cs', $pr_array)){
4714
- $pd_value = strtolower($pd_value);
4715
- $pr_array['criteria'] = strtolower($pr_array['criteria']);
4716
- }
4717
-
4718
- switch ($pr_array['condition']) {
4719
- case($pr_array['condition'] = "contains"):
4720
- if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4721
- // Specifically for shipping price rules
4722
- if(!empty($product_data[$pr_array['than_attribute']])){
4723
- if(is_array($product_data[$pr_array['than_attribute']])){
4724
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4725
- for ($x = 0; $x <= $arr_size; $x++) {
4726
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4727
- }
4728
- } else {
4729
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4730
- }
4731
- } else {
4732
- // This attribute value is empty for this product
4733
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4734
- }
4735
- }
4736
- break;
4737
- case($pr_array['condition'] = "containsnot"):
4738
- if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4739
- // Specifically for shipping price rules
4740
- if(is_array($product_data[$pr_array['than_attribute']])){
4741
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4742
- for ($x = 0; $x <= $arr_size; $x++) {
4743
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4744
- }
4745
- } else {
4746
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4747
- }
4748
- }
4749
- break;
4750
- case($pr_array['condition'] = "="):
4751
- if (($pr_array['criteria'] == "$pd_value")){
4752
- // Specifically for shipping price rules
4753
- if(is_array($product_data[$pr_array['than_attribute']])){
4754
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4755
- for ($x = 0; $x <= $arr_size; $x++) {
4756
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4757
- }
4758
- } else {
4759
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4760
- }
4761
- }
4762
- $ship = $product_data['shipping'];
4763
- break;
4764
- case($pr_array['condition'] = "!="):
4765
- if (($pr_array['criteria'] != "$pd_value")){
4766
- // Specifically for shipping price rules
4767
- if(is_array($product_data[$pr_array['than_attribute']])){
4768
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4769
- for ($x = 0; $x <= $arr_size; $x++) {
4770
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4771
- }
4772
- } else {
4773
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4774
- }
4775
- }
4776
- break;
4777
- case($pr_array['condition'] = ">"):
4778
- // Use a lexical order on relational string operators
4779
- if (($pd_value > $pr_array['criteria'])){
4780
- // Specifically for shipping price rules
4781
- if(is_array($product_data[$pr_array['than_attribute']])){
4782
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4783
- for ($x = 0; $x <= $arr_size; $x++) {
4784
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4785
- }
4786
- } else {
4787
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4788
- }
4789
- }
4790
- break;
4791
- case($pr_array['condition'] = ">="):
4792
- // Use a lexical order on relational string operators
4793
- if (($pd_value >= $pr_array['criteria'])){
4794
- // Specifically for shipping price rules
4795
- if(is_array($product_data[$pr_array['than_attribute']])){
4796
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4797
- for ($x = 0; $x <= $arr_size; $x++) {
4798
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4799
- }
4800
- } else {
4801
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4802
- }
4803
- }
4804
- break;
4805
- case($pr_array['condition'] = "<"):
4806
- // Use a lexical order on relational string operators
4807
- if (($pd_value < $pr_array['criteria'])){
4808
- // Specifically for shipping price rules
4809
- if(isset($product_data[$pr_array['than_attribute']]) AND (is_array($product_data[$pr_array['than_attribute']]))){
4810
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4811
- for ($x = 0; $x <= $arr_size; $x++) {
4812
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4813
- }
4814
- } else {
4815
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4816
- }
4817
- }
4818
- break;
4819
- case($pr_array['condition'] = "=<"):
4820
- // Use a lexical order on relational string operators
4821
- if (($pd_value <= $pr_array['criteria'])){
4822
- // Specifically for shipping price rules
4823
- if(is_array($product_data[$pr_array['than_attribute']])){
4824
- $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4825
- for ($x = 0; $x <= $arr_size; $x++) {
4826
- $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4827
- }
4828
- } else {
4829
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4830
- }
4831
- }
4832
- break;
4833
-
4834
- case($pr_array['condition'] = "empty"):
4835
- if(empty($product_data[$pr_array['attribute']])){
4836
- if(empty($product_data[$pr_array['than_attribute']])){
4837
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4838
- } else {
4839
- $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4840
- }
4841
- }
4842
- break;
4843
- case($pr_array['condition'] = "replace"):
4844
- $product_data[$pr_array['than_attribute']] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $product_data[$pr_array['than_attribute']]);
4845
- break;
4846
- case($pr_array['condition'] = "findreplace"):
4847
- if (strpos($pd_value, $pr_array['criteria']) !== false){
4848
- // Make sure that a new value has been set
4849
- if(!empty($pr_array['newvalue'])){
4850
- // Find and replace only work on same attribute field, otherwise create a contains rule
4851
- if($pr_array['attribute'] == $pr_array['than_attribute']){
4852
- $newvalue = str_replace($pr_array['criteria'],$pr_array['newvalue'], $pd_value);
4853
- $product_data[$pr_array['than_attribute']] = ucfirst($newvalue);
4854
- }
4855
- }
4856
- }
4857
  break;
4858
- default:
4859
- break;
4860
- }
4861
- }
4862
- } else {
4863
- // When a rule has been set on an attribute that is not in product_data
4864
- // Add the newvalue to product_data
4865
- if (!array_key_exists($pr_array['attribute'], $product_data)){
4866
- if(!empty($pr_array['newvalue'])){
4867
- $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4868
- } else {
4869
- if(array_key_exists($pr_array['than_attribute'], $product_data)){
4870
- $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4871
- }
4872
- }
4873
- }
4874
- }
4875
- }
4876
- }
4877
- }
4878
- return $product_data;
4879
- }
4880
-
4881
- /**
4882
- * Function to exclude products based on individual product exclusions
4883
- */
4884
- private function woosea_exclude_individual( $product_data ){
4885
- $allowed = 1;
4886
-
4887
- // Check if product was already excluded from the feed
4888
- $product_excluded = ucfirst( get_post_meta( $product_data['id'], '_woosea_exclude_product', true ) );
4889
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4890
  if( $product_excluded == "Yes"){
4891
  $allowed = 0;
4892
  }
@@ -4899,525 +5010,530 @@ class WooSEA_Get_Products {
4899
  }
4900
  }
4901
 
4902
- /**
4903
- * Execute project filters (include / exclude)
4904
- */
 
4905
  private function woocommerce_sea_filters( $project_rules, $product_data ){
4906
- $allowed = 1;
4907
 
4908
- // Check if product was already excluded from the feed
4909
- $product_excluded = ucfirst( get_post_meta( $product_data['id'], '_woosea_exclude_product', true ) );
4910
 
4911
- if( $product_excluded == "Yes"){
4912
- $allowed = 0;
4913
- }
4914
 
4915
- foreach ($project_rules as $pr_key => $pr_array){
4916
 
4917
- if($pr_array['attribute'] == "categories"){
4918
- $pr_array['attribute'] = "raw_categories";
4919
- }
4920
 
4921
- //if(array_key_exists($pr_array['attribute'], $product_data)){
4922
 
4923
- if(!array_key_exists($pr_array['attribute'], $product_data)) {
4924
- $product_data[$pr_array['attribute']] = ""; // Sets an empty postmeta value in place of a missing one.
4925
- }
4926
 
4927
- foreach ($product_data as $pd_key => $pd_value){
4928
- // Check is there is a rule on specific attributes
 
4929
 
4930
- if(in_array($pd_key, $pr_array, TRUE)){
 
 
 
4931
 
4932
- if($pd_key == "price"){
4933
- //$pd_value = @number_format($pd_value,2);
4934
- $pd_value = wc_format_decimal($pd_value);
4935
- }
4936
-
4937
- if (is_numeric($pd_value)){
4938
- $old_value = $pd_value;
4939
- if($pd_key == "price"){
4940
- $pd_value = @number_format($pd_value,2);
4941
- }
4942
-
4943
- // Rules for numeric values
4944
- switch ($pr_array['condition']) {
4945
- case($pr_array['condition'] = "contains"):
4946
- if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
4947
- $allowed = 0;
4948
- } elseif ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
4949
- $allowed = 0;
4950
- }
4951
- break;
4952
- case($pr_array['condition'] = "containsnot"):
4953
- if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
4954
- $allowed = 0;
4955
- } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
4956
- $allowed = 0;
4957
- }
4958
- break;
4959
  case($pr_array['condition'] = "="):
4960
- if (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4961
- $allowed = 0;
4962
- } elseif (($old_value != $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
4963
- $allowed = 0;
4964
- }
4965
- break;
4966
- case($pr_array['condition'] = "!="):
4967
- if (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4968
- if($allowed <> 0){
4969
- $allowed = 1;
4970
- }
4971
- } elseif (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
4972
- $allowed = 0;
4973
- }
4974
- break;
4975
- case($pr_array['condition'] = ">"):
4976
- if (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4977
- $allowed = 0;
4978
- } elseif (($old_value <= $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
4979
- $allowed = 0;
4980
- }
4981
- break;
4982
- case($pr_array['condition'] = ">="):
4983
- if (($old_value >= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4984
- $allowed = 0;
4985
- } elseif (($old_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
4986
- $allowed = 0;
4987
- }
4988
- break;
4989
- case($pr_array['condition'] = "<"):
4990
- if (($old_value < $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4991
- $allowed = 0;
4992
- } elseif (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
4993
- $allowed = 0;
4994
- }
4995
- break;
4996
- case($pr_array['condition'] = "=<"):
4997
- if (($old_value <= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
4998
- $allowed = 0;
4999
- } elseif (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5000
- $allowed = 0;
5001
- }
5002
- break;
5003
- case($pr_array['condition'] = "empty"):
5004
- if ((strlen($pd_value) < 1) && ($pr_array['than'] == "exclude")){
5005
- $allowed = 0;
5006
- } elseif ((strlen($pd_value > 0)) && ($pr_array['than'] == "include_only")){
5007
- $allowed = 0;
5008
- }
5009
- break;
5010
- default:
5011
- break;
5012
- }
5013
- } elseif (is_array($pd_value)){
5014
- // Tis can either be a shipping or product_tag array
5015
- if($pr_array['attribute'] == "product_tag"){
5016
- $in_tag_array = "not";
5017
-
5018
- foreach($pd_value as $pt_key => $pt_value){
5019
- // Rules for string values
5020
- if (!array_key_exists('cs', $pr_array)){
5021
- $pt_value = strtolower($pt_value);
5022
- $pr_array['criteria'] = strtolower($pr_array['criteria']);
5023
- }
5024
-
5025
- if(preg_match('/'.$pr_array['criteria'].'/', $pt_value)){
5026
- $in_tag_array = "yes";
5027
- }
5028
- }
5029
-
5030
- if($in_tag_array == "yes"){
5031
- //if(in_array($pr_array['criteria'], $pd_value, TRUE)) {
5032
- $v = $pr_array['criteria'];
5033
-
5034
- switch ($pr_array['condition']) {
5035
- case($pr_array['condition'] = "contains"):
5036
- if ((preg_match('/'.$pr_array['criteria'].'/', $v))){
5037
- if($pr_array['than'] == "include_only"){
5038
- if($allowed <> 0){
5039
- $allowed = 1;
5040
- }
5041
- } else {
5042
- $allowed = 0;
5043
- }
5044
- } else {
5045
- $allowed = 0;
5046
- }
5047
- break;
5048
- case($pr_array['condition'] = "containsnot"):
5049
- if ((!preg_match('/'.$pr_array['criteria'].'/', $v))){
5050
- if($pr_array['than'] == "include_only"){
5051
- if($allowed <> 0){
5052
- $allowed = 1;
5053
- }
5054
- } else {
5055
- $allowed = 0;
5056
- }
5057
- } else {
5058
- $allowed = 0;
5059
- }
5060
- break;
5061
- case($pr_array['condition'] = "="):
5062
- if (($v == $pr_array['criteria'])){
5063
- if($pr_array['than'] == "include_only"){
5064
- if($allowed <> 0){
5065
- $allowed = 1;
5066
- }
5067
- } else {
5068
- $allowed = 0;
5069
- }
5070
- } else {
5071
- $allowed = 0;
5072
- }
5073
- break;
5074
- case($pr_array['condition'] = "!="):
5075
- if (($v != $pr_array['criteria'])){
5076
- if($pr_array['than'] == "include_only"){
5077
- if($allowed <> 0){
5078
- $allowed = 1;
5079
- }
5080
- } else {
5081
- $allowed = 0;
5082
- }
5083
- }
5084
- break;
5085
- case($pr_array['condition'] = ">"):
5086
- if (($v > $pr_array['criteria'])){
5087
- if($pr_array['than'] == "include_only"){
5088
- if($allowed <> 0){
5089
- $allowed = 1;
5090
- }
5091
- } else {
5092
- $allowed = 0;
5093
- }
5094
- }
5095
- break;
5096
- case($pr_array['condition'] = ">="):
5097
- if (($v >= $pr_array['criteria'])){
5098
- if($pr_array['than'] == "include_only"){
5099
- if($allowed <> 0){
5100
- $allowed = 1;
5101
- }
5102
- } else {
5103
- $allowed = 0;
5104
- }
5105
- }
5106
- break;
5107
- case($pr_array['condition'] = "<"):
5108
- if (($v < $pr_array['criteria'])){
5109
- if($pr_array['than'] == "include_only"){
5110
- if($allowed <> 0){
5111
- $allowed = 1;
5112
- }
5113
- } else {
5114
- $allowed = 0;
5115
- }
5116
- }
5117
- break;
5118
- case($pr_array['condition'] = "=<"):
5119
- if (($v <= $pr_array['criteria'])){
5120
- if($pr_array['than'] == "include_only"){
5121
- if($allowed <> 0){
5122
- $allowed = 1;
5123
- }
5124
- } else {
5125
- $allowed = 0;
5126
- }
5127
- }
5128
- break;
5129
- case($pr_array['condition'] = "empty"):
5130
- if (strlen($v) < 1){
5131
- if($pr_array['than'] == "include_only"){
5132
- if($allowed <> 0){
5133
- $allowed = 1;
5134
- }
5135
- } else {
5136
- $allowed = 0;
5137
- }
5138
- }
5139
- break;
5140
- default:
5141
- break;
5142
- }
5143
- } else {
5144
- switch ($pr_array['condition']) {
5145
- case($pr_array['condition'] = "contains"):
5146
- if($pr_array['than'] == "include_only"){
5147
- $allowed = 0;
5148
- } else {
5149
- if($allowed <> 0){
5150
- $allowed = 1;
5151
- }
5152
- }
5153
- break;
5154
- case($pr_array['condition'] = "containsnot"):
5155
- if($pr_array['than'] == "include_only"){
5156
- if($allowed <> 0){
5157
- $allowed = 1;
5158
- }
5159
- } else {
5160
- $allowed = 0;
5161
- }
5162
- break;
5163
- case($pr_array['condition'] = "="):
5164
- if($pr_array['than'] == "include_only"){
5165
- $allowed = 0;
5166
- } else {
5167
- if($allowed <> 0){
5168
- $allowed = 1;
5169
- }
5170
- }
5171
- break;
5172
- case($pr_array['condition'] = "!="):
5173
- if($pr_array['than'] == "include_only"){
5174
- if($allowed <> 0){
5175
- $allowed = 1;
5176
- }
5177
- } else {
5178
- $allowed = 0;
5179
- }
5180
- break;
5181
- case($pr_array['condition'] = ">"):
5182
- if($pr_array['than'] == "include_only"){
5183
- $allowed = 0;
5184
- } else {
5185
- $allowed = 0;
5186
- }
5187
- break;
5188
- case($pr_array['condition'] = ">="):
5189
- if($pr_array['than'] == "include_only"){
5190
- $allowed = 0;
5191
- } else {
5192
- $allowed = 0;
5193
- }
5194
- break;
5195
- case($pr_array['condition'] = "<"):
5196
- if($pr_array['than'] == "include_only"){
5197
- $allowed = 0;
5198
- } else {
5199
- $allowed = 0;
5200
- }
5201
- break;
5202
- case($pr_array['condition'] = "=<"):
5203
- if($pr_array['than'] == "include_only"){
5204
- $allowed = 0;
5205
- } else {
5206
- $allowed = 0;
5207
- }
5208
- break;
5209
- case($pr_array['condition'] = "empty"):
5210
- if($pr_array['than'] == "include_only"){
5211
- if($allowed <> 0){
5212
- $allowed = 1;
5213
- }
5214
- } else {
5215
- $allowed = 0;
5216
- }
5217
- break;
5218
- default:
5219
- break;
5220
- }
5221
- }
5222
- } else {
5223
- // For now only shipping details are in an array
5224
- foreach ($pd_value as $k => $v){
5225
- foreach ($v as $kk => $vv){
5226
- // Only shipping detail rule can be on price for now
5227
- if($kk == "price"){
5228
- switch ($pr_array['condition']) {
5229
- case($pr_array['condition'] = "contains"):
5230
- if ((preg_match('/'.$pr_array['criteria'].'/', $vv))){
5231
- $allowed = 0;
5232
- }
5233
- break;
5234
- case($pr_array['condition'] = "containsnot"):
5235
- if ((!preg_match('/'.$pr_array['criteria'].'/', $vv))){
5236
- $allowed = 0;
5237
- }
5238
- break;
5239
- case($pr_array['condition'] = "="):
5240
- if (($vv == $pr_array['criteria'])){
5241
- $allowed = 0;
5242
- }
5243
- break;
5244
- case($pr_array['condition'] = "!="):
5245
- if (($vv != $pr_array['criteria'])){
5246
- $allowed = 0;
5247
- }
5248
- break;
5249
- case($pr_array['condition'] = ">"):
5250
- if (($vv > $pr_array['criteria'])){
5251
- $allowed = 0;
5252
- }
5253
- break;
5254
- case($pr_array['condition'] = ">="):
5255
- if (($vv >= $pr_array['criteria'])){
5256
- $allowed = 0;
5257
- }
5258
- break;
5259
- case($pr_array['condition'] = "<"):
5260
- if (($vv < $pr_array['criteria'])){
5261
- $allowed = 0;
5262
- }
5263
- break;
5264
- case($pr_array['condition'] = "=<"):
5265
- if (($vv <= $pr_array['criteria'])){
5266
- $allowed = 0;
5267
- }
5268
- break;
5269
- case($pr_array['condition'] = "empty"):
5270
- if (strlen($vv) < 1){
5271
- $allowed = 0;
5272
- }
5273
- break;
5274
- default:
5275
- break;
5276
- }
5277
- }
5278
  }
5279
- }
5280
- }
5281
- } else {
5282
- // Filters for string values
5283
- // If case-sensitve is off than lowercase both the criteria and attribute value
5284
- if (array_key_exists('cs', $pr_array)){
5285
- if ($pr_array['cs'] != "on"){
5286
- $pd_value = strtolower($pd_value);
5287
- $pr_array['criteria'] = strtolower($pr_array['criteria']);
5288
- }
5289
- }
5290
- $pos = strpos($pd_value, '&amp;');
5291
- $pos_slash = strpos($pr_array['criteria'], '\\');
5292
- if($pos !== false){
5293
- $pd_value = str_replace("&amp;","&",$pd_value);
5294
- }
5295
- if($pos_slash !== false){
5296
- $pr_array['criteria'] = str_replace("\\","",$pr_array['criteria']);
5297
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5298
 
5299
- switch ($pr_array['condition']) {
5300
- case($pr_array['condition'] = "contains"):
5301
- if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5302
- $allowed = 0;
5303
- } elseif ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5304
- $allowed = 0;
5305
- } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5306
- if($allowed <> 0){
5307
- $allowed = 1;
5308
- }
5309
- }
5310
- break;
5311
- case($pr_array['condition'] = "containsnot"):
5312
- if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5313
- $allowed = 0;
5314
- } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5315
- $allowed = 0;
5316
- }
5317
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5318
  case($pr_array['condition'] = "="):
5319
- if (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "exclude")){
5320
- $allowed = 0;
5321
- } elseif (($pr_array['criteria'] != "$pd_value") && ($pr_array['than'] == "include_only")){
5322
- $found = strpos($pd_value,$pr_array['criteria']);
5323
- if ($found !== false) {
5324
- //for category mapping check if its an array
5325
- if($pr_array['attribute'] == "raw_categories"){
5326
- $raw_cats_arr = explode("||",$pd_value);
5327
- if(is_array($raw_cats_arr)){
5328
- if(in_array($pr_array['criteria'],$raw_cats_arr, TRUE)){
5329
- if($allowed <> 0){
5330
- $allowed = 1;
5331
- }
5332
- } else {
5333
- $allowed = 0;
5334
- }
5335
- }
5336
- } else {
5337
- if($allowed <> 0){
5338
- $allowed = 1;
5339
- }
5340
- }
5341
- } else {
5342
- $allowed = 0;
5343
- }
5344
- } elseif (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "include_only")){
5345
- if($allowed <> 0){
5346
- $allowed = 1;
5347
- }
5348
- } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5349
- $allowed = 0;
5350
- } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5351
- $allowed = 1;
5352
- }
5353
- break;
5354
- case($pr_array['condition'] = "!="):
5355
- if (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "exclude")){
5356
- if($allowed <> 0){
5357
- $allowed = 1;
5358
- }
5359
- } elseif (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "include_only")){
5360
- $allowed = 0;
5361
- } elseif (($pr_array['criteria'] != "$pd_value") && ($pr_array['than'] == "exclude")){
5362
- $allowed = 0;
5363
- }
5364
- break;
5365
- case($pr_array['condition'] = ">"):
5366
- // Use a lexical order on relational string operators
5367
- if (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5368
- $allowed = 0;
5369
- } elseif (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5370
- $allowed = 0;
5371
- }
5372
- break;
5373
- case($pr_array['condition'] = ">="):
5374
- // Use a lexical order on relational string operators
5375
- if (($pd_value >= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5376
- $allowed = 0;
5377
- } elseif (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5378
- $allowed = 0;
5379
- }
5380
- break;
5381
- case($pr_array['condition'] = "<"):
5382
- // Use a lexical order on relational string operators
5383
- if (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5384
- $allowed = 0;
5385
- } elseif (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5386
  $allowed = 0;
5387
- }
5388
- break;
5389
- case($pr_array['condition'] = "=<"):
5390
- // Use a lexical order on relational string operators
5391
- if (($pd_value <= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5392
- $allowed = 0;
5393
- } elseif (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5394
- $allowed = 0;
5395
- }
5396
- break;
5397
- case($pr_array['condition'] = "empty"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5398
  if ((strlen($pd_value) < 1) && ($pr_array['than'] == "exclude")){
5399
- $allowed = 0;
5400
- } elseif ((strlen($pd_value) > 0) && ($pr_array['than'] == "exclude")){
5401
- if($allowed <> 0){
5402
- $allowed = 1;
5403
- }
5404
- } elseif ((strlen($pd_value) > 0) && ($pr_array['than'] == "include_only")){
5405
- $allowed = 0;
5406
- }
5407
- break;
5408
- default:
5409
- break;
5410
- }
5411
- }
5412
- }
5413
- }
5414
- }
5415
 
5416
- if ($allowed < 1){
5417
- $product_data = array();
5418
- $product_data = null;
5419
- } else {
5420
- return $product_data;
5421
- }
5422
- }
5423
  }
26
  return "<![CDATA[ $string ]]>";
27
  }
28
 
 
29
  /**
30
  * Check if a plugin is active
31
  */
56
  * Get all approved product review comments for Google's Product Review Feeds
57
  */
58
  public function woosea_get_reviews ( $product_data, $product ) {
59
+ // Rwviews for the parent variable product itself can be skipped, the review is added for the variation
60
+ if($product_data['product_type'] == "variable"){
61
+ return;
62
+ }
63
+
64
  $approved_reviews = array();
65
  $prod_id = $product_data['id'];
66
 
88
  $cnt = 0;
89
  $name = "";
90
  foreach($name_pieces as $n_piece){
91
+ $n_piece = str_replace("&amp;", "", $n_piece);
92
+
93
  if($cnt > 0){
94
+ $n_piece = ucfirst(substr($n_piece, 0, 1));
95
  }
96
  $name .= $n_piece." ";
97
  $cnt++;
102
  $review['reviewer_name'] = html_entity_decode((str_replace("\r", "", $review['reviewer_name'])), ENT_QUOTES | ENT_XML1, 'UTF-8');
103
  $review['reviewer_name'] = preg_replace( '/\[(.*?)\]/', ' ', $review['reviewer_name'] );
104
  $review['reviewer_name'] = str_replace("&#xa0;", "", $review['reviewer_name']);
105
+ $review['reviewer_name'] = $this->woosea_utf8_for_xml( $review['reviewer_name'] );
106
 
107
  $review['reviewer_id'] = $review_raw->user_id;
108
  $review['review_timestamp'] = $review_raw->comment_date;
330
  /**
331
  * Get category path (needed for Prisjakt)
332
  */
333
+ public function woosea_get_term_parents( $id, $taxonomy, string $link = null, $project_taxonomy, $nicename = false, $visited = array() ) {
334
  // Only add Home to the beginning of the chain when we start buildin the chain
335
  if(empty($visited)){
336
  $chain = 'Home';
937
  unset($shipping_cost);
938
  }
939
  }
940
+
941
+ // User do not want to have free shipping in their feed
942
+ $remove_free_shipping = "no";
943
+ $remove_free_shipping = get_option ('remove_free_shipping');
944
+
945
+ if($remove_free_shipping == "yes"){
946
+ unset($zone_details['service']);
947
+ unset($zone_details['price']);
948
+ unset($shipping_cost);
949
+ }
950
  }
951
 
952
  if(isset($zone_details)){
973
  $zone_details['price'] = trim($shipping_cost);
974
  }
975
  } else {
 
976
  if(isset($shipping_cost)){
977
  $zone_details['price'] = trim($currency." ".$shipping_cost);
978
  }
 
 
979
  }
980
  }
981
  }
1005
 
1006
  // Remove other shipping classes when free shipping is relevant
1007
  $free_check = "yes";
 
1008
 
1009
  if(in_array($free_check, array_column($shipping_arr, 'free'))) { // search value in the array
1010
  foreach($shipping_arr as $k => $v) {
1011
  if(!in_array($free_check, $v)){
1012
+
1013
+ // User do not want to have free shipping in their feed
1014
+ // Only remove the other shipping classes when free shipping is not being removed
1015
+ $remove_free_shipping = "no";
1016
+ $remove_free_shipping = get_option ('remove_free_shipping');
1017
+
1018
+ if($remove_free_shipping == "no"){
1019
+ unset($shipping_arr[$k]);
1020
+ }
1021
  }
1022
  }
1023
  }
1025
  // Fix empty services
1026
  foreach($shipping_arr as $k => $v){
1027
  if(empty($v['service'])){
 
 
1028
  unset($shipping_arr[$k]);
1029
  }
1030
  }
1163
  } elseif (preg_match("/g:product_detail/i",$k)){
1164
  if(!empty($v)){
1165
  $product_detail_split = explode("#", $v);
1166
+ $detail_complete = count($product_detail_split);
1167
+ if($detail_complete == 2){
1168
+ $product_detail = $product->addChild('g:product_detail', '', $namespace['g']);
1169
+ $name = str_replace("_", " ", $product_detail_split[0]);
1170
+
1171
+ $section_name = explode(":", $name);
1172
+ $section_name_start = ucfirst($section_name[0]);
1173
+ $name = ucfirst(trim($section_name[1]));
1174
+
1175
+ $section_name = $product_detail->addChild('g:section_name', "General", $namespace['g']);
1176
+ $product_detail_name = $product_detail->addChild('g:attribute_name', $section_name_start, $namespace['g']);
1177
+ $product_detail_value = $product_detail->addChild('g:attribute_value', $product_detail_split[1], $namespace['g']);
1178
+ }
1179
  }
1180
  } elseif ($k == "g:installment"){
1181
  if(!empty($v)){
1376
 
1377
  // For Google Product review template
1378
  if (($feed_config['name'] == "Google Product Review") AND (empty($xml->channel))) {
1379
+
1380
+ if(!is_bool($xml)){
1381
+ $product = $xml->addChild('reviews');
1382
 
1383
+ foreach ($products as $key => $value){
1384
 
1385
+ $expl = "||";
1386
+ if(strpos($value['reviews'], $expl)) {
1387
+ $review_data = explode("||", $value['reviews']);
1388
+ foreach($review_data as $rk => $rv){
1389
 
1390
+ $review_comp = explode(":::", $rv);
1391
+ $nr_reviews = count($review_comp);
1392
 
1393
+ if($nr_reviews > 1){
1394
+ $productz = $xml->reviews->addChild('review');
1395
 
1396
+ foreach($review_comp as $rck => $rcv){
1397
+ $nodes = explode("##", $rcv);
1398
+ $nodes = str_replace("::", "", $nodes);
1399
 
1400
+ if($nodes[0] == "REVIEW_RATINGS"){
1401
+ // Do nothing
1402
+ } elseif($nodes[0] == "REVIEW_URL"){
1403
+ $rev_url = $productz->addChild(strtolower($nodes[0]), htmlspecialchars($nodes[1]));
1404
+ $rev_url->addAttribute('type', 'singleton');
1405
+ } elseif(($nodes[0] == "REVIEWER_NAME") OR ($nodes[0] == "REVIEWER_ID")){
1406
+ if(isset($productz->reviewer)){
1407
+ if($nodes[0] == "REVIEWER_NAME"){
1408
+ $name = $nodes[1];
1409
+ if(empty($name)){
1410
+ $reviewer->addChild('name','Anonymous');
1411
+ $reviewer->name->addAttribute('is_anonymous', 'true');
1412
+ } else {
1413
+ $reviewer->addChild('name',$name);
1414
+ }
1415
  } else {
1416
+ $reviewer->addChild('reviewer_id',$nodes[1]);
1417
  }
1418
  } else {
1419
+ $reviewer = $productz->addChild('reviewer');
1420
+ if($nodes[0] == "REVIEWER_NAME"){
1421
+ $name = $nodes[1];
1422
+ if(empty($name)){
1423
+ $reviewer->addChild('name','Anonymous');
1424
+ $reviewer->name->addAttribute('is_anonymous', 'true');
1425
+ } else {
1426
+ $reviewer->addChild('name',$name);
1427
+ }
1428
  } else {
1429
+ $reviewer->addChild('reviewer_id',$nodes[1]);
1430
  }
 
 
1431
  }
1432
+ } else {
1433
+ if(isset($nodes[1])){
1434
+ $content = html_entity_decode($nodes[1]);
1435
+ $content = htmlspecialchars($content);
1436
+ $rev = $productz->addChild(strtolower($nodes[0]), $content);
1437
+ }
1438
  }
1439
  }
 
1440
 
1441
+ foreach($review_comp as $rck => $rcv){
1442
+ $nodes = explode("##", $rcv);
1443
+ $nodes = str_replace("::", "", $nodes);
1444
 
1445
+ if($nodes[0] == "REVIEW_RATINGS"){
1446
+ $rev = $productz->addChild('ratings');
1447
+ $over = $productz->ratings->addChild('overall', $nodes[1]);
1448
+ $over->addAttribute('min', '1');
1449
+ $over->addAttribute('max', '5');
1450
+ }
1451
  }
 
 
1452
 
1453
+ $yo = $productz->addChild('products');
1454
+ $po = $yo->addChild('product');
1455
 
1456
+ $identifiers = array("gtin","mpn","sku","brand");
1457
 
1458
+ // Start determining order of product_ids in the Google review feed
1459
+ $proper_order = array("product_name","gtin","mpn","sku","brand","product_url","review_url","reviews");
1460
+ $order_sorted = array();
1461
+ foreach ($proper_order as &$order_value){
1462
+ if(isset($value[$order_value])){
1463
+ $order_sorted[$order_value] = $value[$order_value];
1464
+ }
1465
  }
1466
+ // End
1467
+
1468
+ foreach($order_sorted as $k => $v) {
1469
+ if(($k != "product_name") AND ($k != "product_url")){
1470
+ if(!in_array($k, $identifiers)){
1471
+ if(($k != "reviews") AND ($k != "review_url")){
1472
+ $v = str_replace("&", "and", $v);
1473
+ $poa = $po->addChild($k,htmlspecialchars($v));
1474
+ }
1475
+ } else {
1476
+ if(isset($po->product_ids)){
1477
+ if ($k == "gtin"){
1478
+ $poig = $poi->addChild('gtins');
1479
+ $poig->$k = $v;
1480
+ } elseif ($k == "mpn"){
1481
+ $poim = $poi->addChild('mpns');
1482
+ $poim->$k = $v;
1483
+ } elseif ($k == "sku"){
1484
+ $poix = $poi->addChild('skus');
1485
+ $poix->$k = $v;
1486
+ } elseif($k == "brand"){
1487
+ $poib = $poi->addChild('brands');
1488
+ $poib->$k = $v;
1489
+ } else {
1490
+ // Do nothing
1491
+ }
1492
+ } else {
1493
+ $poi = $po->addChild('product_ids');
1494
+ if ($k == "gtin"){
1495
+ $poig = $poi->addChild('gtins');
1496
+ $poig->$k = $v;
1497
+ } elseif ($k == "mpn"){
1498
+ $poim = $poi->addChild('mpns');
1499
+ $poim->$k = $v;
1500
+ } elseif ($k == "sku"){
1501
+ $poix = $poi->addChild('skus');
1502
+ $poix->$k = $v;
1503
+ } elseif($k == "brand"){
1504
+ $poib = $poi->addChild('brands');
1505
+ $poib->$k = $v;
1506
+ } else {
1507
+ // Do nothing
1508
+ }
1509
  }
1510
+ }
1511
+ }
1512
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1513
 
1514
+ // foreach for product name and product url as order seems to mather to Google
1515
+ foreach($value as $k => $v) {
1516
+ if(($k == "product_name") OR ($k == "product_url")){
1517
+ if(!in_array($k, $identifiers)){
1518
+ if(($k != "reviews") AND ($k != "review_url")){
1519
+ $v = str_replace("&", "and", $v);
1520
+ $poa = $po->addChild($k,htmlspecialchars($v));
1521
+ }
1522
+ } else {
1523
+ if(isset($po->product_ids)){
1524
+ if ($k == "gtin"){
1525
+ $poig = $poi->addChild('gtins');
1526
+ $poig->$k = $v;
1527
+ } elseif ($k == "mpn"){
1528
+ $poim = $poi->addChild('mpns');
1529
+ $poim->$k = $v;
1530
+ } elseif($k == "sku"){
1531
+ $poix = $poi->addChild('skus');
1532
+ $poix->$k = $v;
1533
+ } elseif($k == "brand"){
1534
+ $poib = $poi->addChild('brands');
1535
+ $poib->$k = $v;
1536
+ } else {
1537
+ // Do nothing
1538
+ }
1539
+ } else {
1540
+ $poi = $po->addChild('product_ids');
1541
+ if ($k == "gtin"){
1542
+ $poig = $poi->addChild('gtins');
1543
+ $poig->$k = $v;
1544
+ } elseif ($k == "mpn"){
1545
+ $poim = $poi->addChild('mpns');
1546
+ $poim->$k = $v;
1547
+ } elseif ($k == "sku"){
1548
+ $poix = $poi->addChild('skus');
1549
+ $poix->$k = $v;
1550
+ } elseif($k == "brand"){
1551
+ $poib = $poi->addChild('brands');
1552
+ $poib->$k = $v;
1553
+ } else {
1554
+ // Do nothing
1555
+ }
1556
  }
1557
+ }
1558
+ }
1559
+ }
1560
+ }
1561
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1562
  }
1563
  }
1564
  }
2016
  $xml_piece = "";
2017
 
2018
  // Get taxonomies
2019
+ $no_taxonomies = array("element_category","template_category","portfolio_category","portfolio_skills","portfolio_tags","faq_category","slide-page","category","post_tag","nav_menu","link_category","post_format","product_type","product_visibility","product_cat","product_shipping_class","product_tag");
2020
  $taxonomies = get_taxonomies();
2021
  $diff_taxonomies = array_diff($taxonomies, $no_taxonomies);
2022
 
2348
  $product_data['raw_description'] = substr($product_data['raw_description'], 0, 5000);
2349
  $product_data['raw_short_description'] = substr($product_data['raw_short_description'], 0, 5000);
2350
 
2351
+ // Parent variable description
2352
+ $product_data['mother_description'] = $product_data['description'];
2353
+ $product_data['mother_short_description'] = $product_data['short_description'];
2354
+
2355
  /**
2356
  * Check of we need to add Google Analytics UTM parameters
2357
  */
2385
  * Therefor, we need to check the stock_status and overwrite te availability value
2386
  */
2387
  $stock_status = $product->get_stock_status();
2388
+ $product_data['stock_status'] = $stock_status;
2389
  if ($stock_status == "outofstock"){
2390
  $product_data['availability'] = "out of stock";
2391
  } elseif ($stock_status == "onbackorder") {
2467
  }
2468
 
2469
  $product_data['shipping_label'] = $product->get_shipping_class();
2470
+ $term = get_term_by( 'slug', $product->get_shipping_class(), 'product_shipping_class' );
2471
+ if(is_object($term)){
2472
+ $product_data['shipping_label_name'] = $term->name;
2473
+ }
2474
 
2475
  // Get product prices
2476
  $product_data['price'] = wc_get_price_including_tax($product, array('price'=> $product->get_price()));
2481
  $product_data['regular_price'] = wc_format_decimal($product_data['regular_price'],2);
2482
 
2483
  // Untouched raw system pricing - DO NOT CHANGE THESE
2484
+ $float_system_net_price = floatval(wc_get_price_excluding_tax( $product ));
2485
+ $product_data['system_net_price'] = round($float_system_net_price, 2);
2486
+ $product_data['system_net_price'] = wc_format_decimal($product_data['system_net_price'],2);
2487
+ $float_system_regular_price = floatval($product->get_regular_price());
2488
+ $product_data['system_regular_price'] = round($float_system_regular_price,2);
2489
  $product_data['system_regular_price'] = wc_format_decimal($product_data['system_regular_price'],2);
2490
 
2491
  $product_data['system_price'] = wc_get_price_including_tax($product, array('price'=> $product->get_price()));
2519
  if($product->get_type() == "bundle"){
2520
  if ($this->woosea_is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')){
2521
  $product_data['price'] = get_post_meta($product_data['id'], '_price', true);
2522
+ $product_data['sale_price'] = get_post_meta($product_data['id'], '_sale_price', true);
2523
  if(is_numeric($tax_rates[1]['rate'])){
2524
  $product_data['price_forced'] = round(get_post_meta($product_data['id'], '_price', true) * (100+$tax_rates[1]['rate'])/100,2);
2525
  $product_data['regular_price'] = round(get_post_meta($product_data['id'], '_regular_price', true) * (100+$tax_rates[1]['rate'])/100,2);
2605
  $product_data['net_sale_price'] = "";
2606
  }
2607
  }
2608
+ $float_net_price = floatval(wc_get_price_excluding_tax( $product ));
2609
+ $product_data['net_price'] = round($float_net_price, 2);
2610
+ $product_data['net_price'] = wc_format_decimal($product_data['net_price'],2);
2611
+
2612
  $price = wc_get_price_including_tax($product,array('price'=> $product->get_price()));
2613
  if($product_data['sale_price'] > 0){
2614
  $price = $product_data['sale_price'];
2619
  $discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', false, $product, 1, $product_data['sale_price'], 'discounted_price', true, true);
2620
  if($discount !== false){
2621
  $product_data['sale_price'] = $discount;
2622
+ $product_data['price'] = $discount;
2623
  $price_incl_tax = get_option( 'woocommerce_prices_include_tax' );
2624
  if($price_incl_tax == "yes"){
2625
  $product_data['price_forced'] = $product_data['price']*($fullrate/100);
2760
  $product_data['system_sale_price'] = wc_format_localized_price($product_data['system_sale_price']);
2761
 
2762
  // Add rounded price options
2763
+ $float_price = floatval($product_data['price']);
2764
+ $float_regular_price = floatval($product_data['regular_price']);
2765
+ $float_sale_price = floatval($product_data['sale_price']);
2766
+ $product_data['rounded_price'] = round($float_price,0);
2767
+ $product_data['rounded_regular_price'] = round($float_regular_price,0);
2768
+ $product_data['rounded_sale_price'] = round($float_sale_price,0);
2769
 
2770
  // Calculate discount percentage
2771
  if($product_data['sale_price'] > 0){
2783
  }
2784
  }
2785
 
2786
+ if ((array_key_exists('shipping', $project_config['attributes'])) OR (array_key_exists('shipping_price', $project_config['attributes'])) OR ($project_config['fields'] == "trovaprezzi") OR ($project_config['fields'] == "customfeed")){
2787
  $product_data['shipping'] = $this->woosea_get_shipping_cost($class_cost_id, $project_config, $product_data['price'], $tax_rates, $shipping_zones, $product_data['id'], $product_data['item_group_id']);
2788
  $shipping_str = $product_data['shipping'];
2789
  }
2879
 
2880
  foreach($diff_taxonomies as $taxo){
2881
  $term_value = get_the_terms($product_data['id'], $taxo);
2882
+ $product_data["$taxo"] = "";
2883
 
2884
  if(is_array($term_value)){
2885
  // Do not add variation values to the feed when they are out of stock
2889
  $variations = $product_skroutz->get_available_variations();
2890
  $variations_id = wp_list_pluck( $variations, 'variation_id' );
2891
  $skroutz_att_array = array();
2892
+
2893
  foreach($variations_id as $var_id){
2894
  $stock_value = get_post_meta( $var_id, "_stock_status", true );
2895
  if($stock_value == "instock"){
2903
  $product_data[$taxo] = rtrim($product_data[$taxo],',');
2904
  }
2905
  }
 
2906
  foreach($skroutz_att_array as $skrtz_value){
2907
  $product_data[$taxo] .= ",". $skrtz_value;
2908
  }
3017
  $data = $wpdb->get_results($sql);
3018
  if (count($data)) {
3019
  foreach ($data as $key => $value) {
3020
+ $value_display = str_replace("_", " ",$value->name);
3021
  if (preg_match("/_product_attributes/i",$value->name)){
3022
  $product_attr = unserialize($value->type);
3023
  if(!empty($product_attr)){
3035
 
3036
  /**
3037
  * Get Product Attributes for Single products
3038
+ * These are the attributes users create themselves in WooCommerce
3039
  */
3040
+ if (($product->is_type('simple')) OR ($product->is_type('external')) OR ($product->is_type('mix-and-match')) OR ($product->is_type('bundle')) OR ($product->is_type('composite')) OR ($product->is_type('auction') OR ($product->is_type('subscription')) OR ($product->is_type('variable')))){
3041
  $single_attributes = $product->get_attributes();
 
3042
  foreach ($single_attributes as $attribute){
3043
+ $attr_name = strtolower($attribute->get_name());
3044
+ $attr_value = $product->get_attribute($attr_name);
3045
+ $product_data[$attr_name] = $attr_value;
3046
  }
3047
  }
3048
 
3068
  $product_variations = new WC_Product_Variation( $product_data['id'] );
3069
  $variations = $product_variations->get_variation_attributes();
3070
 
3071
+ // For Skroutz and Bestprice apparal products we can only append colours to the product name
3072
  // When a product has both a size and color attribute we assume its an apparal product
3073
+ if(($project_config['fields'] == "skroutz") OR ($project_config['fields'] == "bestprice")){
3074
  $size_found = "no";
3075
  $color_found = "no";
3076
 
3146
  }
3147
  }
3148
 
 
 
3149
  if((isset($project_config['lowest_price_variations'])) OR (isset($project_config['default_variations']))){
 
3150
  // Determine the default variation product
3151
  if( ($product_data['item_group_id'] > 0) AND (is_object(wc_get_product( $product_data['item_group_id']))) AND (($product_data['product_type'] == "variation") OR ($product_data['product_type'] == "subscription_variation"))){
3152
+ $mother_product = new WC_Product_Variable($product_data['item_group_id']);
3153
+ //$mother_product = wc_get_product($product_data['item_group_id']);
3154
+ $def_attributes = $mother_product->get_default_attributes();
3155
 
3156
  if(isset($project_config['lowest_price_variations'])){
3157
+
3158
  // Determine lowest priced variation
3159
  $variation_min_price = $mother_product->get_variation_price('min');
3160
  $variation_min_price = wc_format_decimal($variation_min_price,2);
3161
  $variation_min_price = wc_format_localized_price($variation_min_price);
3162
+ $var_price = get_post_meta($product_data['id'], '_price', true);
3163
+ $var_price = wc_format_decimal($var_price,2);
3164
+ $var_price = wc_format_localized_price($var_price);
3165
+ $variation_prices = $mother_product->get_variation_prices();
3166
+ $variation_prices_price = array_values($variation_prices['price']);
3167
+ $lowest_price = min($variation_prices_price);
3168
+
3169
+ if(($var_price == $lowest_price) OR ($var_price == $variation_min_price) OR ($product_data['system_regular_price'] == $variation_min_price) OR ($product_data['system_net_price'] == $variation_min_price)){
3170
  $variation_pass = "true";
3171
  } else {
3172
  $variation_pass = "false";
3304
  /**
3305
  * Although this is a product variation we also need to grap the Dynamic attributes belonging to the simple mother prodict
3306
  */
3307
+ $stock_value = get_post_meta( $product_data['id'], "_stock_status", true );
3308
+ //if($stock_value == "instock"){
3309
  foreach($diff_taxonomies as $taxo){
3310
  $term_value = get_the_terms($product_data['item_group_id'], $taxo);
3311
  unset($product_data[$taxo]);
3312
  if(is_array($term_value)){
3313
  foreach($term_value as $term){
3314
  if(empty($product_data[$taxo])){
3315
+ $product_data[$taxo] = $term->name;
3316
  } else {
3317
+ $product_data[$taxo] .= " ".$term->name;
3318
  }
3319
  }
3320
  }
3321
+ }
3322
 
3323
  /**
3324
  * Add product tags to the product data array
3338
 
3339
  // Add attribute values to the variation product names to make them unique
3340
  $product_data['title_hyphen'] = $product_data['title']." - ";
3341
+ $product_data['mother_title_hyphen'] = $product_data['mother_title']." - ";
3342
 
3343
  foreach($variations as $kk => $vv){
3344
  $custom_key = $kk;
3487
  * we will add CDATA brackets to the title and description attributes
3488
  */
3489
  $product_data['title_lc'] = ucfirst(strtolower($product_data['title']));
3490
+ $product_data['title_lcw'] = ucwords(strtolower($product_data['title']));
3491
+
3492
  //$product_data['description'] = $this->woosea_append_cdata ( $product_data['description'] );
3493
  //$product_data['short_description'] = $this->woosea_append_cdata ( $product_data['short_description'] );
3494
 
3497
  */
3498
  $product_data['reviews'] = $this->woosea_get_reviews( $product_data, $product );
3499
 
3500
+ /**
3501
+ * Filter out reviews that do not have text
3502
+ */
3503
+ if(!empty($product_data['reviews'])){
3504
+ foreach($product_data['reviews'] as $review_id => $review_details){
3505
+ if(empty($review_details['content'])){
3506
+ unset($product_data['reviews'][$review_id]);
3507
+ }
3508
+ }
3509
+ }
3510
+
3511
  /**
3512
  * Check if individual products need to be excluded
3513
  */
3573
  // For these channels parent products are allowed
3574
  $allowed_channel_parents = array(
3575
  "skroutz",
3576
+ "bestprice",
3577
  "google_dsa",
3578
  "google_product_review",
3579
  );
3580
 
3581
+ if(array_key_exists('fields', $project_config)){
3582
+ if (!in_array($project_config['fields'], $allowed_channel_parents)){
3583
+ if(($product->is_type('variable')) AND ($product_data['item_group_id'] == 0)){
3584
+ $product_data = array();
3585
+ $product_data = null;
3586
+ }
3587
+ }
3588
+ }
3589
 
3590
  /**
3591
  * Remove variation products that are not THE default variation product
3612
  }
3613
  }
3614
 
3615
+ /**
3616
+ * Do final check on Skroutz out of stock sizes
3617
+ * When a size is not on stock remove it
3618
+ */
3619
+ if($project_config['fields'] == "skroutz"){
3620
+ if(isset($product_data['id'])){
3621
+ foreach($project_config['attributes'] as $ky => $vy){
3622
+ if(isset($vy['attribute'])){
3623
+ if($vy['attribute'] == "size"){
3624
+ $size_found = "yes";
3625
+ $sz_attribute = $vy['mapfrom'];
3626
+ }
3627
+ if($vy['attribute'] == "color"){
3628
+ $color_found = "yes";
3629
+ $clr_attribute = $vy['mapfrom'];
3630
+ }
3631
+ }
3632
+ }
3633
+
3634
+ $stock_value = get_post_meta( $product_data['id'], "_stock_status", true );
3635
+ $sz_attr_value = get_post_meta( $product_data['id'], $sz_attribute, true );
3636
+ $clr_attr_value = get_post_meta( $product_data['id'], "attribute_".$clr_attribute, true );
3637
+ if(isset($product_data['item_group_id']) AND ($product_data['item_group_id'] > 0)){
3638
+ $product_skroutz = wc_get_product($product_data['item_group_id']);
3639
+ $variations = $product_skroutz->get_available_variations();
3640
+ $variations_id = wp_list_pluck( $variations, 'variation_id' );
3641
+
3642
+ foreach($variations_id as $var_id){
3643
+ $clr_variation = get_post_meta( $var_id, "attribute_".$clr_attribute, true );
3644
+ $size_variation = get_post_meta( $var_id, "attribute_".$sz_attribute, true );
3645
+ $stock_variation = get_post_meta( $var_id, "_stock_status", true );
3646
+
3647
+ if($clr_variation == $clr_attr_value){
3648
+ if($stock_variation == "outofstock"){
3649
+ // Remove this size as it is not on stock
3650
+ if(array_key_exists($sz_attribute, $product_data)){
3651
+ $product_data[$sz_attribute] = str_replace(ucfirst($size_variation),"",$product_data[$sz_attribute]);
3652
+ }
3653
+ }
3654
+ }
3655
+ }
3656
+ }
3657
+ }
3658
+ }
3659
+
3660
  /**
3661
  * When product has passed the filter rules it can continue with the rest
3662
  */
3690
  }
3691
  } else {
3692
  if((strlen($attr_value['mapfrom'])) AND (array_key_exists($attr_value['mapfrom'], $product_data))){
3693
+ if(($attr_value['attribute'] == "URL") OR ($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "g:link_template") OR ($attr_value['attribute'] == "g:image_link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "Final URL") OR ($attr_value['attribute'] == "SKU")){
3694
  $attr_line = "'".$attr_value['prefix']."".$product_data[$attr_value['mapfrom']]."".$attr_value['suffix']."'";
3695
  } else {
3696
  $attr_line = "'".$attr_value['prefix']. "".$product_data[$attr_value['mapfrom']]."" .$attr_value['suffix']."'";
3762
  }
3763
  } else {
3764
  if(strlen($product_data[$attr_value['mapfrom']])){
3765
+ if(($attr_value['attribute'] == "URL") OR ($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "g:link_template") OR ($attr_value['attribute'] == "g:image_link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "Final URL") OR ($attr_value['attribute'] == "SKU")){
3766
  if(($product_data['product_type'] == "variation") AND (preg_match("/aelia_cs_currency/", $attr_value['suffix']))){
3767
  $attr_value['suffix'] = str_replace("?","&",$attr_value['suffix']);
3768
  $attr_line .= ",'".$attr_value['prefix']."".$product_data[$attr_value['mapfrom']]."".$attr_value['suffix']."'";
3982
  }
3983
  } else {
3984
  if(strlen($product_data[$attr_value['mapfrom']])){
3985
+ if(($attr_value['attribute'] == "URL") OR ($attr_value['attribute'] == "g:link") OR ($attr_value['attribute'] == "link") OR ($attr_value['attribute'] == "g:link_template")){
3986
  if(($product_data['product_type'] == "variation") AND (preg_match("/aelia_cs_currency/", $attr_value['suffix']))){
3987
  $attr_value['suffix'] = str_replace("?","&",$attr_value['suffix']);
3988
  $xml_product[$attr_value['attribute']] = "$attr_value[prefix]". $product_data[$attr_value['mapfrom']] ."$attr_value[suffix]";
4512
  return $product_data;
4513
  }
4514
 
4515
+ /**
4516
+ * Execute project rules
4517
+ */
4518
  private function woocommerce_sea_rules( $project_rules2, $product_data ){
4519
+ $aantal_prods = count($product_data);
4520
+ if($aantal_prods > 0){
4521
 
4522
+ foreach ($project_rules2 as $pr_key => $pr_array){
4523
 
4524
+ foreach ($product_data as $pd_key => $pd_value){
4525
 
4526
+ // Check is there is a rule on specific attributes
4527
+ if($pd_key == $pr_array['attribute']){
4528
 
4529
+ // This is because for data manipulation the than attribute is empty
4530
+ if(!array_key_exists('than_attribute', $pr_array)){
4531
+ $pr_array['than_attribute'] = $pd_key;
4532
+ }
4533
 
4534
  // Check if a rule has been set for Google categories
4535
  if (!empty($product_data['categories']) AND ($pr_array['than_attribute'] == "google_category") AND ($product_data[$pr_array['attribute']] == $pr_array['criteria'])){
4536
+
4537
+ $pr_array['than_attribute'] = "categories";
4538
  $category_id = explode("-", $pr_array['newvalue']);
4539
  $pr_array['newvalue'] = $category_id[0];
4540
+ $product_data['categories'] = $pr_array['newvalue'];
4541
+ }
4542
 
4543
+ // Make sure that rules on numerics are on true numerics
4544
+ if (!is_array($pd_value) AND (!preg_match('/[A-Za-z]/', $pd_value))){
4545
+ $pd_value = strtr($pd_value, ',', '.');
4546
+ }
4547
 
4548
 
4549
+ // Make sure the price or sale price is numeric
4550
+ if(($pr_array['attribute'] == "sale_price") OR ($pr_array['attribute'] == "price")){
4551
+ settype($pd_value, "double");
4552
+ }
4553
 
4554
+ if (((is_numeric($pd_value)) AND ($pr_array['than_attribute'] != "shipping"))){
4555
 
4556
+ // Rules for numeric values
4557
+ switch ($pr_array['condition']) {
4558
+ case($pr_array['condition'] = "contains"):
4559
+ if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4560
+ $product_data[$pr_array['than_attribute']] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $pd_value);
4561
+ }
4562
+ break;
4563
+ case($pr_array['condition'] = "containsnot"):
4564
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4565
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4566
+ }
4567
+ break;
4568
+ case($pr_array['condition'] = "="):
4569
+ if (($pd_value == $pr_array['criteria'])){
4570
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4571
+ }
4572
+ break;
4573
+ case($pr_array['condition'] = "!="):
4574
+ if (($pd_value != $pr_array['criteria'])){
4575
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4576
+ }
4577
+ break;
4578
+ case($pr_array['condition'] = ">"):
4579
+ if (($pd_value > $pr_array['criteria'])){
4580
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4581
+ }
4582
+ break;
4583
+ case($pr_array['condition'] = ">="):
4584
+ if (($pd_value >= $pr_array['criteria'])){
4585
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4586
+ }
4587
+ break;
4588
+ case($pr_array['condition'] = "<"):
4589
+ if (($pd_value < $pr_array['criteria'])){
4590
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4591
+ }
4592
+ break;
4593
+ case($pr_array['condition'] = "=<"):
4594
+ if (($pd_value <= $pr_array['criteria'])){
4595
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4596
+ }
4597
+ break;
4598
+ case($pr_array['condition'] = "empty"):
4599
+ if(empty($product_data[$pr_array['attribute']])){
4600
+ if ((strlen($pd_value) < 1)){
4601
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4602
+ } else {
4603
+ $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4604
+ }
4605
+ }
4606
+ break;
4607
+ case($pr_array['condition'] = "multiply"):
4608
+ $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4609
+ $convert_back = "false";
4610
+ $pos = strpos($pd_value, ',');
4611
+ if($pos !== false){
4612
+ $convert_back = "true";
4613
+ }
4614
+ $pd_value = strtr($pd_value, ',', '.');
4615
+ $newvalue = $pd_value*$pr_array['criteria'];
4616
+ $newvalue = round($newvalue, 2);
4617
+ if($convert_back == "true"){
4618
+ $newvalue = strtr($newvalue, '.',',');
4619
+ }
4620
+ $product_data[$pr_array['attribute']] = $newvalue;
4621
+ break;
4622
+ case($pr_array['condition'] = "divide"):
4623
+ $newvalue = ($pd_value / $pr_array['criteria']);
4624
+ $newvalue = round($newvalue, 2);
4625
+ $newvalue = strtr($newvalue, '.',',');
4626
+ $product_data[$pr_array['attribute']] = $newvalue;
4627
+ break;
4628
+ case($pr_array['condition'] = "plus"):
4629
+ $newvalue = ($pd_value + $pr_array['criteria']);
4630
+ $product_data[$pr_array['attribute']] = $newvalue;
4631
+ break;
4632
+ case($pr_array['condition'] = "minus"):
4633
+ $newvalue = ($pd_value - $pr_array['criteria']);
4634
+ $product_data[$pr_array['attribute']] = $newvalue;
4635
+ break;
4636
+ case($pr_array['condition'] = "findreplace"):
4637
+ if (strpos($pd_value, $pr_array['criteria']) !== false){
4638
  // Make sure that a new value has been set
4639
+ if(!empty($pr_array['newvalue'])){
4640
+ // Find and replace only work on same attribute field, otherwise create a contains rule
4641
  if($pr_array['attribute'] == $pr_array['than_attribute']){
4642
  $newvalue = str_replace($pr_array['criteria'],$pr_array['newvalue'], $pd_value);
4643
  $product_data[$pr_array['than_attribute']] = ucfirst($newvalue);
4644
  }
4645
+ }
4646
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4647
  break;
4648
+ default:
4649
+ break;
4650
+ }
4651
+ } elseif (is_array($pd_value)) {
4652
+
4653
+ // For now only shipping details are in an array
4654
+ foreach ($pd_value as $k => $v){
4655
+ if(is_array($v)){
4656
+ foreach ($v as $kk => $vv){
4657
+ // Only shipping detail rule can be on price for now
4658
+ if($kk == "price"){
4659
+ switch ($pr_array['condition']) {
4660
+ case($pr_array['condition'] = "contains"):
4661
+ if ((preg_match('/'.$pr_array['criteria'].'/', $vv))){
4662
+ $pd_value[$k]['price'] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $vv);
4663
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4664
+ }
4665
+ break;
4666
+ case($pr_array['condition'] = "containsnot"):
4667
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $vv))){
4668
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4669
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4670
+ }
4671
+ break;
4672
+ case($pr_array['condition'] = "="):
4673
+ if (($vv == $pr_array['criteria'])){
4674
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4675
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4676
+ }
4677
+ break;
4678
+ case($pr_array['condition'] = "!="):
4679
+ if (($vv != $pr_array['criteria'])){
4680
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4681
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4682
+ }
4683
+ break;
4684
+ case($pr_array['condition'] = ">"):
4685
+ if (($vv > $pr_array['criteria'])){
4686
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4687
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4688
+ }
4689
+ break;
4690
+ case($pr_array['condition'] = ">="):
4691
+ if (($vv >= $pr_array['criteria'])){
4692
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4693
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4694
+ }
4695
+ break;
4696
+ case($pr_array['condition'] = "<"):
4697
+ if (($vv < $pr_array['criteria'])){
4698
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4699
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4700
+ }
4701
+ break;
4702
+ case($pr_array['condition'] = "=<"):
4703
+ if (($vv <= $pr_array['criteria'])){
4704
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4705
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4706
+ }
4707
+ break;
4708
+ case($pr_array['condition'] = "empty"):
4709
+ if ((strlen($vv) < 1)){
4710
+ $pd_value[$k]['price'] = $pr_array['newvalue'];
4711
+ $product_data[$pr_array['than_attribute']] = $pd_value;
4712
+ }
4713
+ break;
4714
+ case($pr_array['condition'] = "multiply"):
4715
+ // Only shipping array
4716
+ if(is_array($pd_value)){
4717
+ $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4718
+ foreach ($pd_value as $ship_a_key => $shipping_arr){
4719
+ foreach($shipping_arr as $ship_key => $ship_value){
4720
+ if($ship_key == "price"){
4721
+ $ship_pieces = explode(" ", $ship_value);
4722
+ $pd_value = strtr($ship_pieces[1], ',', '.');
4723
+ $newvalue = $pd_value*$pr_array['criteria'];
4724
+ $newvalue = round($newvalue, 2);
4725
+ $newvalue = strtr($newvalue, '.',',');
4726
+ $newvalue = $ship_pieces[0]." ".$newvalue;
4727
+ $product_data[$pr_array['than_attribute']][$ship_a_key]['price'] = $newvalue;
4728
+ }
4729
+ }
4730
+ }
4731
+ }
4732
+ break;
4733
+ default:
4734
+ break;
4735
+ }
4736
+ }
4737
+ }
4738
+ } else {
4739
+ // Rules on product tags
4740
+ foreach ($pd_value as $k => $v){
4741
+
4742
+ // Rules for string values
4743
+ if (!array_key_exists('cs', $pr_array)){
4744
+ $v = strtolower($v);
4745
+ $pr_array['criteria'] = strtolower($pr_array['criteria']);
4746
+ }
4747
+
4748
+ switch ($pr_array['condition']) {
4749
+ case($pr_array['condition'] = "contains"):
4750
+ if ((preg_match('/'.$pr_array['criteria'].'/', $v))){
4751
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4752
+ }
4753
+ break;
4754
+ case($pr_array['condition'] = "containsnot"):
4755
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $v))){
4756
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4757
+ }
4758
+ break;
4759
+ case($pr_array['condition'] = "="):
4760
+ if (($v == $pr_array['criteria'])){
4761
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4762
+ }
4763
+ break;
4764
+ case($pr_array['condition'] = "!="):
4765
+ if (($v != $pr_array['criteria'])){
4766
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4767
+ }
4768
+ break;
4769
+ case($pr_array['condition'] = ">"):
4770
+ if (($v > $pr_array['criteria'])){
4771
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4772
+ }
4773
+ break;
4774
+ case($pr_array['condition'] = ">="):
4775
+ if (($v >= $pr_array['criteria'])){
4776
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4777
+ }
4778
+ break;
4779
+ case($pr_array['condition'] = "<"):
4780
+ if (($v < $pr_array['criteria'])){
4781
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4782
+ }
4783
+ break;
4784
+ case($pr_array['condition'] = "=<"):
4785
+ if (($v <= $pr_array['criteria'])){
4786
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4787
+ }
4788
+ break;
4789
+ case($pr_array['condition'] = "empty"):
4790
+ if ((strlen($v) < 1)){
4791
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4792
+ }
4793
+ break;
4794
+ case($pr_array['condition'] = "multiply"):
4795
+ // Only shipping array
4796
+ if(is_array($v)){
4797
+ $pr_array['criteria'] = strtr($pr_array['criteria'], ',', '.');
4798
+ foreach ($v as $ship_a_key => $shipping_arr){
4799
+ foreach($shipping_arr as $ship_key => $ship_value){
4800
+ if($ship_key == "price"){
4801
+ $ship_pieces = explode(" ", $ship_value);
4802
+ $pd_value = strtr($ship_pieces[1], ',', '.');
4803
+ $newvalue = $pd_value*$pr_array['criteria'];
4804
+ $newvalue = round($newvalue, 2);
4805
+ $newvalue = strtr($newvalue, '.',',');
4806
+ $newvalue = $ship_pieces[0]." ".$newvalue;
4807
+ $product_data[$pr_array['than_attribute']][$ship_a_key]['price'] = $newvalue;
4808
+ }
4809
+ }
4810
+ }
4811
+ }
4812
+ break;
4813
+ default:
4814
+ break;
4815
+ }
4816
+ }
4817
+ }
4818
+ }
4819
+ } else {
4820
+ // Rules for string values
4821
+ if (!array_key_exists('cs', $pr_array)){
4822
+ if($pr_array['attribute'] != "image"){
4823
+ $pd_value = strtolower($pd_value);
4824
+ $pr_array['criteria'] = strtolower($pr_array['criteria']);
4825
+ }
4826
+ }
4827
+
4828
+ switch ($pr_array['condition']) {
4829
+ case($pr_array['condition'] = "contains"):
4830
+ if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4831
+ // Specifically for shipping price rules
4832
+ if(!empty($product_data[$pr_array['than_attribute']])){
4833
+ if(is_array($product_data[$pr_array['than_attribute']])){
4834
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4835
+ for ($x = 0; $x <= $arr_size; $x++) {
4836
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4837
+ }
4838
+ } else {
4839
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4840
+ }
4841
+ } else {
4842
+ // This attribute value is empty for this product
4843
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4844
+ }
4845
+ }
4846
+ break;
4847
+ case($pr_array['condition'] = "containsnot"):
4848
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value))){
4849
+ // Specifically for shipping price rules
4850
+ if(is_array($product_data[$pr_array['than_attribute']])){
4851
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4852
+ for ($x = 0; $x <= $arr_size; $x++) {
4853
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4854
+ }
4855
+ } else {
4856
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4857
+ }
4858
+ }
4859
+ break;
4860
+ case($pr_array['condition'] = "="):
4861
+ if (($pr_array['criteria'] == "$pd_value")){
4862
+ // Specifically for shipping price rules
4863
+ if(is_array($product_data[$pr_array['than_attribute']])){
4864
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4865
+ for ($x = 0; $x <= $arr_size; $x++) {
4866
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4867
+ }
4868
+ } else {
4869
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4870
+ }
4871
+ }
4872
+ $ship = $product_data['shipping'];
4873
+ break;
4874
+ case($pr_array['condition'] = "!="):
4875
+ if (($pr_array['criteria'] != "$pd_value")){
4876
+ // Specifically for shipping price rules
4877
+ if(is_array($product_data[$pr_array['than_attribute']])){
4878
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4879
+ for ($x = 0; $x <= $arr_size; $x++) {
4880
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4881
+ }
4882
+ } else {
4883
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4884
+ }
4885
+ }
4886
+ break;
4887
+ case($pr_array['condition'] = ">"):
4888
+ // Use a lexical order on relational string operators
4889
+ if (($pd_value > $pr_array['criteria'])){
4890
+ // Specifically for shipping price rules
4891
+ if(is_array($product_data[$pr_array['than_attribute']])){
4892
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4893
+ for ($x = 0; $x <= $arr_size; $x++) {
4894
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4895
+ }
4896
+ } else {
4897
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4898
+ }
4899
+ }
4900
+ break;
4901
+ case($pr_array['condition'] = ">="):
4902
+ // Use a lexical order on relational string operators
4903
+ if (($pd_value >= $pr_array['criteria'])){
4904
+ // Specifically for shipping price rules
4905
+ if(is_array($product_data[$pr_array['than_attribute']])){
4906
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4907
+ for ($x = 0; $x <= $arr_size; $x++) {
4908
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4909
+ }
4910
+ } else {
4911
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4912
+ }
4913
+ }
4914
+ break;
4915
+ case($pr_array['condition'] = "<"):
4916
+ // Use a lexical order on relational string operators
4917
+ if (($pd_value < $pr_array['criteria'])){
4918
+ // Specifically for shipping price rules
4919
+ if(isset($product_data[$pr_array['than_attribute']]) AND (is_array($product_data[$pr_array['than_attribute']]))){
4920
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4921
+ for ($x = 0; $x <= $arr_size; $x++) {
4922
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4923
+ }
4924
+ } else {
4925
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4926
+ }
4927
+ }
4928
+ break;
4929
+ case($pr_array['condition'] = "=<"):
4930
+ // Use a lexical order on relational string operators
4931
+ if (($pd_value <= $pr_array['criteria'])){
4932
+ // Specifically for shipping price rules
4933
+ if(is_array($product_data[$pr_array['than_attribute']])){
4934
+ $arr_size = (count($product_data[$pr_array['than_attribute']])-1);
4935
+ for ($x = 0; $x <= $arr_size; $x++) {
4936
+ $product_data[$pr_array['than_attribute']][$x]['price'] = $pr_array['newvalue'];
4937
+ }
4938
+ } else {
4939
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4940
+ }
4941
+ }
4942
+ break;
4943
+
4944
+ case($pr_array['condition'] = "empty"):
4945
+ if(empty($product_data[$pr_array['attribute']])){
4946
+ if(empty($product_data[$pr_array['than_attribute']])){
4947
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4948
+ } else {
4949
+ $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4950
+ }
4951
+ }
4952
+ break;
4953
+ case($pr_array['condition'] = "replace"):
4954
+ $product_data[$pr_array['than_attribute']] = str_replace($pr_array['criteria'], $pr_array['newvalue'], $product_data[$pr_array['than_attribute']]);
4955
+ break;
4956
+ case($pr_array['condition'] = "findreplace"):
4957
+ if (strpos($pd_value, $pr_array['criteria']) !== false){
4958
+ // Make sure that a new value has been set
4959
+ if(!empty($pr_array['newvalue'])){
4960
+ // Find and replace only work on same attribute field, otherwise create a contains rule
4961
+ if($pr_array['attribute'] == $pr_array['than_attribute']){
4962
+ $newvalue = str_replace($pr_array['criteria'],$pr_array['newvalue'], $pd_value);
4963
+ //$product_data[$pr_array['than_attribute']] = ucfirst($newvalue);
4964
+ $product_data[$pr_array['than_attribute']] = $newvalue;
4965
+ }
4966
+ }
4967
+ }
4968
+ break;
4969
+ default:
4970
+ break;
4971
+ }
4972
+ }
4973
+ } else {
4974
+ // When a rule has been set on an attribute that is not in product_data
4975
+ // Add the newvalue to product_data
4976
+ if (!array_key_exists($pr_array['attribute'], $product_data)){
4977
+ if(!empty($pr_array['newvalue'])){
4978
+ $product_data[$pr_array['than_attribute']] = $pr_array['newvalue'];
4979
+ } else {
4980
+ if(array_key_exists($pr_array['than_attribute'], $product_data)){
4981
+ $product_data[$pr_array['attribute']] = $product_data[$pr_array['than_attribute']];
4982
+ }
4983
+ }
4984
+ }
4985
+ }
4986
+ }
4987
+ }
4988
+ }
4989
+ return $product_data;
4990
+ }
4991
+
4992
+ /**
4993
+ * Function to exclude products based on individual product exclusions
4994
+ */
4995
+ private function woosea_exclude_individual( $product_data ){
4996
+ $allowed = 1;
4997
+
4998
+ // Check if product was already excluded from the feed
4999
+ $product_excluded = ucfirst( get_post_meta( $product_data['id'], '_woosea_exclude_product', true ) );
5000
+
5001
  if( $product_excluded == "Yes"){
5002
  $allowed = 0;
5003
  }
5010
  }
5011
  }
5012
 
5013
+
5014
+ /**
5015
+ * Execute project filters (include / exclude)
5016
+ */
5017
  private function woocommerce_sea_filters( $project_rules, $product_data ){
5018
+ $allowed = 1;
5019
 
5020
+ // Check if product was already excluded from the feed
5021
+ $product_excluded = ucfirst( get_post_meta( $product_data['id'], '_woosea_exclude_product', true ) );
5022
 
5023
+ if( $product_excluded == "Yes"){
5024
+ $allowed = 0;
5025
+ }
5026
 
5027
+ foreach ($project_rules as $pr_key => $pr_array){
5028
 
5029
+ if($pr_array['attribute'] == "categories"){
5030
+ $pr_array['attribute'] = "raw_categories";
5031
+ }
5032
 
5033
+ //if(array_key_exists($pr_array['attribute'], $product_data)){
5034
 
5035
+ if(!array_key_exists($pr_array['attribute'], $product_data)) {
5036
+ $product_data[$pr_array['attribute']] = ""; // Sets an empty postmeta value in place of a missing one.
5037
+ }
5038
 
5039
+ foreach ($product_data as $pd_key => $pd_value){
5040
+ // Check is there is a rule on specific attributes
5041
+ if(in_array($pd_key, $pr_array, TRUE)){
5042
 
5043
+ if($pd_key == "price"){
5044
+ //$pd_value = @number_format($pd_value,2);
5045
+ $pd_value = wc_format_decimal($pd_value);
5046
+ }
5047
 
5048
+ if (is_numeric($pd_value)){
5049
+ $old_value = $pd_value;
5050
+ if($pd_key == "price"){
5051
+ $pd_value = @number_format($pd_value,2);
5052
+ }
5053
+
5054
+ // Rules for numeric values
5055
+ switch ($pr_array['condition']) {
5056
+ case($pr_array['condition'] = "contains"):
5057
+ if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5058
+ $allowed = 0;
5059
+ } elseif ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5060
+ $allowed = 0;
5061
+ }
5062
+ break;
5063
+ case($pr_array['condition'] = "containsnot"):
5064
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5065
+ $allowed = 0;
5066
+ } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5067
+ $allowed = 0;
5068
+ }
5069
+ break;
 
 
 
 
 
5070
  case($pr_array['condition'] = "="):
5071
+ if (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5072
+ $allowed = 0;
5073
+ } elseif (($old_value != $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5074
+ $allowed = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5075
  }
5076
+ break;
5077
+ case($pr_array['condition'] = "!="):
5078
+ if (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5079
+ if($allowed <> 0){
5080
+ $allowed = 1;
5081
+ }
5082
+ } elseif (($old_value == $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5083
+ $allowed = 0;
5084
+ }
5085
+ break;
5086
+ case($pr_array['condition'] = ">"):
5087
+ if (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5088
+ $allowed = 0;
5089
+ } elseif (($old_value <= $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5090
+ $allowed = 0;
5091
+ }
5092
+ break;
5093
+ case($pr_array['condition'] = ">="):
5094
+ if (($old_value >= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5095
+ $allowed = 0;
5096
+ } elseif (($old_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5097
+ $allowed = 0;
5098
+ }
5099
+ break;
5100
+ case($pr_array['condition'] = "<"):
5101
+ if (($old_value < $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5102
+ $allowed = 0;
5103
+ } elseif (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5104
+ $allowed = 0;
5105
+ }
5106
+ break;
5107
+ case($pr_array['condition'] = "=<"):
5108
+ if (($old_value <= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5109
+ $allowed = 0;
5110
+ } elseif (($old_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5111
+ $allowed = 0;
5112
+ }
5113
+ break;
5114
+ case($pr_array['condition'] = "empty"):
5115
+ if ((strlen($pd_value) < 1) && ($pr_array['than'] == "exclude")){
5116
+ $allowed = 0;
5117
+ } elseif ((strlen($pd_value > 0)) && ($pr_array['than'] == "include_only")){
5118
+ $allowed = 0;
5119
+ }
5120
+ break;
5121
+ default:
5122
+ break;
5123
+ }
5124
+ } elseif (is_array($pd_value)){
5125
+ // Tis can either be a shipping or product_tag array
5126
+ if($pr_array['attribute'] == "product_tag"){
5127
+ $in_tag_array = "not";
5128
+
5129
+ foreach($pd_value as $pt_key => $pt_value){
5130
+ // Rules for string values
5131
+ if (!array_key_exists('cs', $pr_array)){
5132
+ $pt_value = strtolower($pt_value);
5133
+ $pr_array['criteria'] = strtolower($pr_array['criteria']);
5134
+ }
5135
 
5136
+ if(preg_match('/'.$pr_array['criteria'].'/', $pt_value)){
5137
+ $in_tag_array = "yes";
5138
+ }
5139
+ }
5140
+
5141
+ if($in_tag_array == "yes"){
5142
+ //if(in_array($pr_array['criteria'], $pd_value, TRUE)) {
5143
+ $v = $pr_array['criteria'];
5144
+ switch ($pr_array['condition']) {
5145
+ case($pr_array['condition'] = "contains"):
5146
+ if ((preg_match('/'.$pr_array['criteria'].'/', $v))){
5147
+ if($pr_array['than'] == "include_only"){
5148
+ if($allowed <> 0){
5149
+ $allowed = 1;
5150
+ }
5151
+ } else {
5152
+ $allowed = 0;
5153
+ }
5154
+ } else {
5155
+ $allowed = 0;
5156
+ }
5157
+ break;
5158
+ case($pr_array['condition'] = "containsnot"):
5159
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $v))){
5160
+ if($pr_array['than'] == "include_only"){
5161
+ if($allowed <> 0){
5162
+ $allowed = 1;
5163
+ }
5164
+ } else {
5165
+ $allowed = 0;
5166
+ }
5167
+ } else {
5168
+ $allowed = 0;
5169
+ }
5170
+ break;
5171
+ case($pr_array['condition'] = "="):
5172
+ if (($v == $pr_array['criteria'])){
5173
+ if($pr_array['than'] == "include_only"){
5174
+ if($allowed <> 0){
5175
+ $allowed = 1;
5176
+ }
5177
+ } else {
5178
+ $allowed = 0;
5179
+ }
5180
+ } else {
5181
+ $allowed = 0;
5182
+ }
5183
+ break;
5184
+ case($pr_array['condition'] = "!="):
5185
+ if (($v != $pr_array['criteria'])){
5186
+ if($pr_array['than'] == "include_only"){
5187
+ if($allowed <> 0){
5188
+ $allowed = 1;
5189
+ }
5190
+ } else {
5191
+ $allowed = 0;
5192
+ }
5193
+ }
5194
+ break;
5195
+ case($pr_array['condition'] = ">"):
5196
+ if (($v > $pr_array['criteria'])){
5197
+ if($pr_array['than'] == "include_only"){
5198
+ if($allowed <> 0){
5199
+ $allowed = 1;
5200
+ }
5201
+ } else {
5202
+ $allowed = 0;
5203
+ }
5204
+ }
5205
+ break;
5206
+ case($pr_array['condition'] = ">="):
5207
+ if (($v >= $pr_array['criteria'])){
5208
+ if($pr_array['than'] == "include_only"){
5209
+ if($allowed <> 0){
5210
+ $allowed = 1;
5211
+ }
5212
+ } else {
5213
+ $allowed = 0;
5214
+ }
5215
+ }
5216
+ break;
5217
+ case($pr_array['condition'] = "<"):
5218
+ if (($v < $pr_array['criteria'])){
5219
+ if($pr_array['than'] == "include_only"){
5220
+ if($allowed <> 0){
5221
+ $allowed = 1;
5222
+ }
5223
+ } else {
5224
+ $allowed = 0;
5225
+ }
5226
+ }
5227
+ break;
5228
+ case($pr_array['condition'] = "=<"):
5229
+ if (($v <= $pr_array['criteria'])){
5230
+ if($pr_array['than'] == "include_only"){
5231
+ if($allowed <> 0){
5232
+ $allowed = 1;
5233
+ }
5234
+ } else {
5235
+ $allowed = 0;
5236
+ }
5237
+ }
5238
+ break;
5239
+ case($pr_array['condition'] = "empty"):
5240
+ if (strlen($v) < 1){
5241
+ if($pr_array['than'] == "include_only"){
5242
+ if($allowed <> 0){
5243
+ $allowed = 1;
5244
+ }
5245
+ } else {
5246
+ if(!empty($pt_value)){
5247
+ $allowed = 1;
5248
+ } else {
5249
+ $allowed = 0;
5250
+ }
5251
+ }
5252
+ }
5253
+ break;
5254
+ default:
5255
+ break;
5256
+ }
5257
+ } else {
5258
+ switch ($pr_array['condition']) {
5259
+ case($pr_array['condition'] = "contains"):
5260
+ if($pr_array['than'] == "include_only"){
5261
+ $allowed = 0;
5262
+ } else {
5263
+ if($allowed <> 0){
5264
+ $allowed = 1;
5265
+ }
5266
+ }
5267
+ break;
5268
+ case($pr_array['condition'] = "containsnot"):
5269
+ if($pr_array['than'] == "include_only"){
5270
+ if($allowed <> 0){
5271
+ $allowed = 1;
5272
+ }
5273
+ } else {
5274
+ $allowed = 0;
5275
+ }
5276
+ break;
5277
+ case($pr_array['condition'] = "="):
5278
+ if($pr_array['than'] == "include_only"){
5279
+ $allowed = 0;
5280
+ } else {
5281
+ if($allowed <> 0){
5282
+ $allowed = 1;
5283
+ }
5284
+ }
5285
+ break;
5286
+ case($pr_array['condition'] = "!="):
5287
+ if($pr_array['than'] == "include_only"){
5288
+ if($allowed <> 0){
5289
+ $allowed = 1;
5290
+ }
5291
+ } else {
5292
+ $allowed = 0;
5293
+ }
5294
+ break;
5295
+ case($pr_array['condition'] = ">"):
5296
+ if($pr_array['than'] == "include_only"){
5297
+ $allowed = 0;
5298
+ } else {
5299
+ $allowed = 0;
5300
+ }
5301
+ break;
5302
+ case($pr_array['condition'] = ">="):
5303
+ if($pr_array['than'] == "include_only"){
5304
+ $allowed = 0;
5305
+ } else {
5306
+ $allowed = 0;
5307
+ }
5308
+ break;
5309
+ case($pr_array['condition'] = "<"):
5310
+ if($pr_array['than'] == "include_only"){
5311
+ $allowed = 0;
5312
+ } else {
5313
+ $allowed = 0;
5314
+ }
5315
+ break;
5316
+ case($pr_array['condition'] = "=<"):
5317
+ if($pr_array['than'] == "include_only"){
5318
+ $allowed = 0;
5319
+ } else {
5320
+ $allowed = 0;
5321
+ }
5322
+ break;
5323
+ case($pr_array['condition'] = "empty"):
5324
+ if($pr_array['than'] == "include_only"){
5325
+ if($allowed <> 0){
5326
+ $allowed = 1;
5327
+ }
5328
+ } else {
5329
+ $allowed = 0;
5330
+ }
5331
+ break;
5332
+ default:
5333
+ break;
5334
+ }
5335
+ }
5336
+ } else {
5337
+ // For now only shipping details are in an array
5338
+ foreach ($pd_value as $k => $v){
5339
+ foreach ($v as $kk => $vv){
5340
+ // Only shipping detail rule can be on price for now
5341
+ if($kk == "price"){
5342
+ switch ($pr_array['condition']) {
5343
+ case($pr_array['condition'] = "contains"):
5344
+ if ((preg_match('/'.$pr_array['criteria'].'/', $vv))){
5345
+ $allowed = 0;
5346
+ }
5347
+ break;
5348
+ case($pr_array['condition'] = "containsnot"):
5349
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $vv))){
5350
+ $allowed = 0;
5351
+ }
5352
+ break;
5353
+ case($pr_array['condition'] = "="):
5354
+ if (($vv == $pr_array['criteria'])){
5355
+ $allowed = 0;
5356
+ }
5357
+ break;
5358
+ case($pr_array['condition'] = "!="):
5359
+ if (($vv != $pr_array['criteria'])){
5360
+ $allowed = 0;
5361
+ }
5362
+ break;
5363
+ case($pr_array['condition'] = ">"):
5364
+ if (($vv > $pr_array['criteria'])){
5365
+ $allowed = 0;
5366
+ }
5367
+ break;
5368
+ case($pr_array['condition'] = ">="):
5369
+ if (($vv >= $pr_array['criteria'])){
5370
+ $allowed = 0;
5371
+ }
5372
+ break;
5373
+ case($pr_array['condition'] = "<"):
5374
+ if (($vv < $pr_array['criteria'])){
5375
+ $allowed = 0;
5376
+ }
5377
+ break;
5378
+ case($pr_array['condition'] = "=<"):
5379
+ if (($vv <= $pr_array['criteria'])){
5380
+ $allowed = 0;
5381
+ }
5382
+ break;
5383
+ case($pr_array['condition'] = "empty"):
5384
+ if (strlen($vv) < 1){
5385
+ $allowed = 0;
5386
+ }
5387
+ break;
5388
+ default:
5389
+ break;
5390
+ }
5391
+ }
5392
+ }
5393
+ }
5394
+ }
5395
+ } else {
5396
+ // Filters for string values
5397
+ // If case-sensitve is off than lowercase both the criteria and attribute value
5398
+ if (array_key_exists('cs', $pr_array)){
5399
+ if ($pr_array['cs'] != "on"){
5400
+ $pd_value = strtolower($pd_value);
5401
+ $pr_array['criteria'] = strtolower($pr_array['criteria']);
5402
+ }
5403
+ }
5404
+ $pos = strpos($pd_value, '&amp;');
5405
+ $pos_slash = strpos($pr_array['criteria'], '\\');
5406
+ if($pos !== false){
5407
+ $pd_value = str_replace("&amp;","&",$pd_value);
5408
+ }
5409
+ if($pos_slash !== false){
5410
+ $pr_array['criteria'] = str_replace("\\","",$pr_array['criteria']);
5411
+ }
5412
+
5413
+ switch ($pr_array['condition']) {
5414
+ case($pr_array['condition'] = "contains"):
5415
+ if ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5416
+ $allowed = 0;
5417
+ } elseif ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5418
+ $allowed = 0;
5419
+ } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5420
+ if($allowed <> 0){
5421
+ $allowed = 1;
5422
+ }
5423
+ }
5424
+ break;
5425
+ case($pr_array['condition'] = "containsnot"):
5426
+ if ((!preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5427
+ $allowed = 0;
5428
+ } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5429
+ $allowed = 0;
5430
+ }
5431
+ break;
5432
  case($pr_array['condition'] = "="):
5433
+ if (($pr_array['criteria'] == "$pd_value") AND ($pr_array['than'] == "exclude")){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5434
  $allowed = 0;
5435
+ } elseif (($pr_array['criteria'] != "$pd_value") && ($pr_array['than'] == "include_only")){
5436
+ $found = strpos($pd_value,$pr_array['criteria']);
5437
+ if ($found !== false) {
5438
+ //for category mapping check if its an array
5439
+ if($pr_array['attribute'] == "raw_categories"){
5440
+ $raw_cats_arr = explode("||",$pd_value);
5441
+ if(is_array($raw_cats_arr)){
5442
+ if(in_array($pr_array['criteria'],$raw_cats_arr, TRUE)){
5443
+ if($allowed <> 0){
5444
+ $allowed = 1;
5445
+ }
5446
+ } else {
5447
+ $allowed = 0;
5448
+ }
5449
+ }
5450
+ } else {
5451
+ if($allowed <> 0){
5452
+ $allowed = 1;
5453
+ }
5454
+ }
5455
+ } else {
5456
+ $allowed = 0;
5457
+ }
5458
+ } elseif (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "include_only")){
5459
+ if($allowed <> 0){
5460
+ $allowed = 1;
5461
+ }
5462
+ } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "exclude")){
5463
+ // $allowed = 0;
5464
+ } elseif ((preg_match('/'.$pr_array['criteria'].'/', $pd_value)) && ($pr_array['than'] == "include_only")){
5465
+ $allowed = 1;
5466
+ } else {
5467
+ // $allowed = 1; // Change made on February 24th 2021
5468
+ }
5469
+ break;
5470
+ case($pr_array['condition'] = "!="):
5471
+ if (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "exclude")){
5472
+ if($allowed <> 0){
5473
+ $allowed = 1;
5474
+ }
5475
+ } elseif (($pr_array['criteria'] == "$pd_value") && ($pr_array['than'] == "include_only")){
5476
+ $allowed = 0;
5477
+ } elseif (($pr_array['criteria'] != "$pd_value") && ($pr_array['than'] == "exclude")){
5478
+ $allowed = 0;
5479
+ }
5480
+ break;
5481
+ case($pr_array['condition'] = ">"):
5482
+ // Use a lexical order on relational string operators
5483
+ if (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5484
+ $allowed = 0;
5485
+ } elseif (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5486
+ $allowed = 0;
5487
+ }
5488
+ break;
5489
+ case($pr_array['condition'] = ">="):
5490
+ // Use a lexical order on relational string operators
5491
+ if (($pd_value >= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5492
+ $allowed = 0;
5493
+ } elseif (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5494
+ $allowed = 0;
5495
+ }
5496
+ break;
5497
+ case($pr_array['condition'] = "<"):
5498
+ // Use a lexical order on relational string operators
5499
+ if (($pd_value < $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5500
+ $allowed = 0;
5501
+ } elseif (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5502
+ $allowed = 0;
5503
+ }
5504
+ break;
5505
+ case($pr_array['condition'] = "=<"):
5506
+ // Use a lexical order on relational string operators
5507
+ if (($pd_value <= $pr_array['criteria']) && ($pr_array['than'] == "exclude")){
5508
+ $allowed = 0;
5509
+ } elseif (($pd_value > $pr_array['criteria']) && ($pr_array['than'] == "include_only")){
5510
+ $allowed = 0;
5511
+ }
5512
+ break;
5513
+ case($pr_array['condition'] = "empty"):
5514
  if ((strlen($pd_value) < 1) && ($pr_array['than'] == "exclude")){
5515
+ $allowed = 0;
5516
+ } elseif ((strlen($pd_value) > 0) && ($pr_array['than'] == "exclude")){
5517
+ if($allowed <> 0){
5518
+ $allowed = 1;
5519
+ }
5520
+ } elseif ((strlen($pd_value) > 0) && ($pr_array['than'] == "include_only")){
5521
+ $allowed = 0;
5522
+ }
5523
+ break;
5524
+ default:
5525
+ break;
5526
+ }
5527
+ }
5528
+ }
5529
+ }
5530
+ }
5531
 
5532
+ if ($allowed < 1){
5533
+ $product_data = array();
5534
+ $product_data = null;
5535
+ } else {
5536
+ return $product_data;
5537
+ }
5538
+ }
5539
  }
js/woosea_autocomplete.js CHANGED
@@ -5695,8 +5695,10 @@ jQuery(document).ready(function($) {
5695
  jQuery(".js-autosuggest").on('click',function(){
5696
  var className = $(this).attr("class").split(' ')[3];
5697
  var rowCount = className.split("_")[1]
5698
-
5699
- jQuery( ".autocomplete_" + rowCount ).typeahead({
 
 
5700
  input: '.js-autosuggest',
5701
  source: google_taxonomy,
5702
  hint: true,
@@ -5708,7 +5710,6 @@ jQuery(document).ready(function($) {
5708
  });
5709
  jQuery( ".autocomplete_" + rowCount ).focus();
5710
 
5711
-
5712
  jQuery(this).on('change', function(){ // on change of state
5713
 
5714
  var minimum = 1;
@@ -5741,7 +5742,6 @@ jQuery(document).ready(function($) {
5741
  }
5742
  } else {
5743
  var map_to_category = "";
5744
-
5745
  jQuery.ajax({
5746
  method: "POST",
5747
  url: ajaxurl,
5695
  jQuery(".js-autosuggest").on('click',function(){
5696
  var className = $(this).attr("class").split(' ')[3];
5697
  var rowCount = className.split("_")[1]
5698
+
5699
+ //$('#the-basics-11603 .autocomplete_11603').typeahead({
5700
+ jQuery("." + className).typeahead({
5701
+ //jQuery(".autocomplete_" + rowCount ).typeahead({
5702
  input: '.js-autosuggest',
5703
  source: google_taxonomy,
5704
  hint: true,
5710
  });
5711
  jQuery( ".autocomplete_" + rowCount ).focus();
5712
 
 
5713
  jQuery(this).on('change', function(){ // on change of state
5714
 
5715
  var minimum = 1;
5742
  }
5743
  } else {
5744
  var map_to_category = "";
 
5745
  jQuery.ajax({
5746
  method: "POST",
5747
  url: ajaxurl,
js/woosea_key.js CHANGED
@@ -27,7 +27,7 @@ jQuery(document).ready(function($) {
27
  var license_key = $('#license-key').val();
28
 
29
  jQuery.ajax({
30
- url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=9.3.7',
31
  jsonp: 'callback',
32
  dataType: 'jsonp',
33
  type: 'GET',
27
  var license_key = $('#license-key').val();
28
 
29
  jQuery.ajax({
30
+ url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=9.7.8',
31
  jsonp: 'callback',
32
  dataType: 'jsonp',
33
  type: 'GET',
js/woosea_manage.js CHANGED
@@ -256,6 +256,26 @@ jQuery(function($) {
256
  }
257
  })
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  // Check if user would like to enable debug logging
260
  $('#add_woosea_logging').on('change', function(){ // on change of state
261
  if(this.checked){
256
  }
257
  })
258
 
259
+ // Check if user would like the plugin to remove the free shipping class
260
+ $('#remove_free_shipping').on('change', function(){ // on change of state
261
+ if(this.checked){
262
+
263
+ // Checkbox is on
264
+ jQuery.ajax({
265
+ method: "POST",
266
+ url: ajaxurl,
267
+ data: { 'action': 'woosea_remove_free_shipping', 'status': "on" }
268
+ })
269
+ } else {
270
+ // Checkbox is off
271
+ jQuery.ajax({
272
+ method: "POST",
273
+ url: ajaxurl,
274
+ data: { 'action': 'woosea_remove_free_shipping', 'status': "off" }
275
+ })
276
+ }
277
+ })
278
+
279
  // Check if user would like to enable debug logging
280
  $('#add_woosea_logging').on('change', function(){ // on change of state
281
  if(this.checked){
pages/admin/woosea-generate-feed-step-1.php CHANGED
@@ -101,7 +101,7 @@ function woosea_hierarchical_term_tree($category, $prev_mapped){
101
 
102
  $r .= "<tr class=\"catmapping\">";
103
  $r .= "<td><input type=\"hidden\" name=\"mappings[$x][rowCount]\" value=\"$x\"><input type=\"hidden\" name=\"mappings[$x][categoryId]\" value=\"$woo_category_id\"><input type=\"hidden\" name=\"mappings[$x][criteria]\" class=\"input-field-large\" id=\"$woo_category_id\" value=\"$woo_category\">$woo_category ($sub_category->count)</td>";
104
- $r .= "<td><input type=\"search\" name=\"mappings[$x][map_to_category]\" class=\"$mapped_active_class js-typeahead js-autosuggest autocomplete_$x\" value=\"$mapped_category\"></td>";
105
  if(($yo == $nr_categories) AND ($nr_subcats == 0)){
106
  $r .= "<td><span class=\"copy_category_$x\" style=\"display: inline-block;\" title=\"Copy this category to all others\"></span></td>";
107
  } else {
@@ -115,7 +115,7 @@ function woosea_hierarchical_term_tree($category, $prev_mapped){
115
  } else {
116
  $r .= "<tr class=\"catmapping\">";
117
  $r .= "<td><input type=\"hidden\" name=\"mappings[$x][rowCount]\" value=\"$x\"><input type=\"hidden\" name=\"mappings[$x][categoryId]\" value=\"$woo_category_id\"><input type=\"hidden\" name=\"mappings[$x][criteria]\" class=\"input-field-large\" id=\"$woo_category_id\" value=\"$woo_category\">-- $woo_category ($sub_category->count)</td>";
118
- $r .= "<td><input type=\"search\" name=\"mappings[$x][map_to_category]\" class=\"$mapped_active_class js-typeahead js-autosuggest autocomplete_$x mother_$sub_category->parent\" value=\"$mapped_category\"></td>";
119
  $r .= "<td><span class=\"copy_category_$x\" style=\"display: inline-block;\" title=\"Copy this category to all others\"></span></td>";
120
  $r .= "</tr>";
121
  }
@@ -227,7 +227,7 @@ function woosea_hierarchical_term_tree($category, $prev_mapped){
227
 
228
  <table class="woo-product-feed-pro-table">
229
  <tr>
230
- <td><strong><?php _e( 'We\’ve got you covered!','woo-product-feed-pro' );?></strong></td>
231
  </tr>
232
  <tr>
233
  <td>
101
 
102
  $r .= "<tr class=\"catmapping\">";
103
  $r .= "<td><input type=\"hidden\" name=\"mappings[$x][rowCount]\" value=\"$x\"><input type=\"hidden\" name=\"mappings[$x][categoryId]\" value=\"$woo_category_id\"><input type=\"hidden\" name=\"mappings[$x][criteria]\" class=\"input-field-large\" id=\"$woo_category_id\" value=\"$woo_category\">$woo_category ($sub_category->count)</td>";
104
+ $r .= "<td><div id=\"the-basics-$x\"><input type=\"search\" name=\"mappings[$x][map_to_category]\" class=\"$mapped_active_class js-typeahead js-autosuggest autocomplete_$x\" value=\"$mapped_category\"></div></td>";
105
  if(($yo == $nr_categories) AND ($nr_subcats == 0)){
106
  $r .= "<td><span class=\"copy_category_$x\" style=\"display: inline-block;\" title=\"Copy this category to all others\"></span></td>";
107
  } else {
115
  } else {
116
  $r .= "<tr class=\"catmapping\">";
117
  $r .= "<td><input type=\"hidden\" name=\"mappings[$x][rowCount]\" value=\"$x\"><input type=\"hidden\" name=\"mappings[$x][categoryId]\" value=\"$woo_category_id\"><input type=\"hidden\" name=\"mappings[$x][criteria]\" class=\"input-field-large\" id=\"$woo_category_id\" value=\"$woo_category\">-- $woo_category ($sub_category->count)</td>";
118
+ $r .= "<td><div id=\"the-basics-$x\"><input type=\"search\" name=\"mappings[$x][map_to_category]\" class=\"$mapped_active_class js-typeahead js-autosuggest autocomplete_$x mother_$sub_category->parent\" value=\"$mapped_category\"></div></td>";
119
  $r .= "<td><span class=\"copy_category_$x\" style=\"display: inline-block;\" title=\"Copy this category to all others\"></span></td>";
120
  $r .= "</tr>";
121
  }
227
 
228
  <table class="woo-product-feed-pro-table">
229
  <tr>
230
+ <td><strong><?php _e( 'We have got you covered!','woo-product-feed-pro' );?></strong></td>
231
  </tr>
232
  <tr>
233
  <td>
pages/admin/woosea-manage-feed.php CHANGED
@@ -67,6 +67,7 @@ if(!empty($license_information)){
67
  if (!wp_next_scheduled( 'woosea_cron_hook' ) ) {
68
  $notifications_box = $notifications_obj->get_admin_notifications ( '12', 'false' );
69
  }
 
70
  ?>
71
  <div class="wrap">
72
  <div class="woo-product-feed-pro-form-style-2">
@@ -124,6 +125,18 @@ if (!wp_next_scheduled( 'woosea_cron_hook' ) ) {
124
  <?php
125
  }
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
127
  ?>
128
 
129
  <div class="woo-product-feed-pro-form-style-2-heading"><?php _e( 'Manage feeds','woo-product-feed-pro' );?></div>
67
  if (!wp_next_scheduled( 'woosea_cron_hook' ) ) {
68
  $notifications_box = $notifications_obj->get_admin_notifications ( '12', 'false' );
69
  }
70
+
71
  ?>
72
  <div class="wrap">
73
  <div class="woo-product-feed-pro-form-style-2">
125
  <?php
126
  }
127
  }
128
+
129
+
130
+ if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
131
+ ?>
132
+ <div class="notice notice-error is-dismissible">
133
+ <p>
134
+ <strong><?php _e( 'WARNING: Your WP-Cron is disabled', 'woo-product-feed-pro' );?></strong><br/></br/>
135
+ We detected that your WP-cron has been disabled in your wp-config.php file. Our plugin heavily depends on the WP-cron being active otherwise it cannot update and generate your product feeds. <a href="https://adtribes.io/help-my-feed-processing-is-stuck/?utm_source=<?php print"$host";?>&utm_medium=manage-feed&utm_campaign=cron-warning&utm_content=notification" target="_blank"><strong>Please enable your WP-cron first</strong></a>.
136
+ </p>
137
+ </div>
138
+ <?php
139
+ }
140
  ?>
141
 
142
  <div class="woo-product-feed-pro-form-style-2-heading"><?php _e( 'Manage feeds','woo-product-feed-pro' );?></div>
pages/admin/woosea-manage-settings.php CHANGED
@@ -101,6 +101,20 @@ if(isset($_GET["tab"])) {
101
  ?>
102
  </span>
103
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  <!-- wordpress provides the styling for tabs. -->
106
  <h2 class="nav-tab-wrapper">
@@ -290,6 +304,24 @@ if(isset($_GET["tab"])) {
290
  </label>
291
  </td>
292
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  <tr>
294
  <td>
295
  <span><?php _e( 'Remove the local pickup shipping zone from feed (Google Shopping / Facebook only)', 'woo-product-feed-pro');?></span>
@@ -440,11 +472,11 @@ if(isset($_GET["tab"])) {
440
  $external_path_tsv = $external_base . "/woo-product-feed-pro/";
441
  $external_path_logs = $external_base . "/woo-product-feed-pro/";
442
  $test_file = $external_path . "/tesfile.txt";
443
- $test_file_xml = $external_path . "/xml/tesfile.txt";
444
- $test_file_csv = $external_path . "/csv/tesfile.txt";
445
- $test_file_txt = $external_path . "/txt/tesfile.txt";
446
- $test_file_tsv = $external_path . "/tsv/tesfile.txt";
447
- $test_file_logs = $external_path . "/logs/tesfile.txt";
448
 
449
  if (is_writable($external_path)) {
450
  // Normal root category
@@ -515,6 +547,10 @@ if(isset($_GET["tab"])) {
515
  $cron_enabled = "True";
516
  }
517
 
 
 
 
 
518
  print "<table class=\"woo-product-feed-pro-table\">";
519
  print "<tr><td><strong>System check</strong></td><td><strong>Status</strong></td></tr>";
520
  print "<tr><td>WP-Cron enabled</td><td>$cron_enabled</td></tr>";
101
  ?>
102
  </span>
103
  </div>
104
+
105
+ <?php
106
+ if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
107
+ ?>
108
+ <div class="notice notice-error is-dismissible">
109
+ <p>
110
+ <strong><?php _e( 'WARNING: Your WP-Cron is disabled', 'woo-product-feed-pro' );?></strong><br/></br/>
111
+ We detected that your WP-cron has been disabled in your wp-config.php file. Our plugin heavily depends on the WP-cron being active for it to be able to update and generate your product feeds. More information on the inner workings of our plugin and instructions on how to enable your WP-Cron can be found here: <a href="https://adtribes.io/help-my-feed-processing-is-stuck/?utm_source=<?php print"$host";?>&utm_medium=manage-feed&utm_campaign=cron-warning&utm_content=notification" target="_blank"><strong>My feed won't update or is stuck processing</strong></a>.
112
+ </p>
113
+ </div>
114
+ <?php
115
+ }
116
+ ?>
117
+
118
 
119
  <!-- wordpress provides the styling for tabs. -->
120
  <h2 class="nav-tab-wrapper">
304
  </label>
305
  </td>
306
  </tr>
307
+ <tr>
308
+ <td>
309
+ <span><?php _e( 'Remove the free shipping zone from feed (Google Shopping / Facebook only)', 'woo-product-feed-pro');?></span>
310
+ </td>
311
+ <td>
312
+ <label class="woo-product-feed-pro-switch">
313
+ <?php
314
+ $remove_free_shipping = get_option ('remove_free_shipping');
315
+ if($remove_free_shipping == "yes"){
316
+ print "<input type=\"checkbox\" id=\"remove_free_shipping\" name=\"remove_free_shipping\" class=\"checkbox-field\" checked>";
317
+ } else {
318
+ print "<input type=\"checkbox\" id=\"remove_free_shipping\" name=\"remove_free_shipping\" class=\"checkbox-field\">";
319
+ }
320
+ ?>
321
+ <div class="woo-product-feed-pro-slider round"></div>
322
+ </label>
323
+ </td>
324
+ </tr>
325
  <tr>
326
  <td>
327
  <span><?php _e( 'Remove the local pickup shipping zone from feed (Google Shopping / Facebook only)', 'woo-product-feed-pro');?></span>
472
  $external_path_tsv = $external_base . "/woo-product-feed-pro/";
473
  $external_path_logs = $external_base . "/woo-product-feed-pro/";
474
  $test_file = $external_path . "/tesfile.txt";
475
+ $test_file_xml = $external_path . "xml/tesfile.txt";
476
+ $test_file_csv = $external_path . "csv/tesfile.txt";
477
+ $test_file_txt = $external_path . "txt/tesfile.txt";
478
+ $test_file_tsv = $external_path . "tsv/tesfile.txt";
479
+ $test_file_logs = $external_path . "logs/tesfile.txt";
480
 
481
  if (is_writable($external_path)) {
482
  // Normal root category
547
  $cron_enabled = "True";
548
  }
549
 
550
+ if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
551
+ $cron_enabled = "<strong>False</strong>";
552
+ }
553
+
554
  print "<table class=\"woo-product-feed-pro-table\">";
555
  print "<tr><td><strong>System check</strong></td><td><strong>Status</strong></td></tr>";
556
  print "<tr><td>WP-Cron enabled</td><td>$cron_enabled</td></tr>";
readme.txt CHANGED
@@ -5,11 +5,11 @@ License URI: http://www.gnu.org/licenses/gpl.html
5
  Tags: Product Feed, Google Shopping, Google Shopping Feed, WooCommerce Product Feed, WooCommerce Product Feed PRO, Bing Shopping, Bing product feed, Bing remarking, Google Merchant Feed, Google DRM Feed, Google Dynamic Remarketing Feed, Facebook feed, Google feed, Bing feed, Facebook Product Feed, Facebook Dynamic remarketing, Data Feed, WooCommerce Feed, XML product feed, CSV product feed, TSV, TXT product feed, comparison shopping engines, comparison shopping websites, vergelijk.nl, vergelijk.be, vertaa.fi, beslist.nl, kieskeurig.nl, bol.com, raketten, pricerunner, pricegrabber, Buy, leGuide, Kelkoo, Twenga, Yandex, Etsy, Dealtime, Shopzilla, Billiger, Google Product Review feed
6
  Requires at least: 4.5
7
  Tested up to: 5.6
8
- Stable tag: 9.3.7
9
 
10
  == Description ==
11
 
12
- Generate WooCommerce product feeds for all your marketing channels, such as Google Shopping (merchant center), Facebook Remarketing, Bing Ads, Billiger.de, Pricerunner, Vergelijk.nl and many more. Next to custom feeds there are over 100 pre-defined templates included for marketplaces, comparison shopping engines and search engines. This plugin provides high-quality product feed for Google Shopping and many many more.
13
 
14
  = Why choose this plugin? =
15
  Simply because this is the most complete plugin offering support for an unlimited number of products and feeds, including features such as category- & field-mapping and advanced, rule-based, filtering and product variables support.
@@ -160,6 +160,7 @@ Some of the above mentioned feature can only be used by users who upgraded to th
160
  * Google Shopping Actions
161
  * Facebook Dynamic Ad’s / remarketing
162
  * Bing Shopping
 
163
  * Pinterest
164
  * <a href="https://businesshelp.snapchat.com/en-US/a/product-catalog-specs" target="_blank">Snapchat</a>
165
  * <a href="https://yandex.com/support/market-tech-requirements/index.html" target="_blank">Yandex</a>
@@ -175,6 +176,7 @@ Some of the above mentioned feature can only be used by users who upgraded to th
175
  * <a href="https://www.beslist.nl" target="_blank" rel="nofollow">Beslist.nl</a>
176
  * <a href="https://www.beslist.be" target="_blank" rel="nofollow">Beslist.be</a>
177
  * <a href="https://www.fashionchick.nl" target="_blank">Fashionchick.nl</a>
 
178
  * Bol.com
179
  * Stylight
180
  * Incurvy
@@ -229,6 +231,7 @@ Some of the above mentioned feature can only be used by users who upgraded to th
229
  * <a href="https://www.guenstiger.de" target="_blank" rel="nofollow">Guenstiger.de</a>
230
  * Hood.de
231
  * Ladenzeile.de
 
232
  * Livingo.de
233
  * Medizinfuchs.de
234
  * <a href="https://www.moebel.de" target="_blank">Moebel.de</a>
@@ -322,6 +325,135 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
322
 
323
  === Changelog ===
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  = 9.3.7 (2021-01-12) =
326
  * Added the Bestprice.gr template
327
 
@@ -2988,6 +3120,135 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
2988
 
2989
  == Upgrade Notice ==
2990
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2991
  = 9.3.7 =
2992
  Added the Bestprice.gr template
2993
 
5
  Tags: Product Feed, Google Shopping, Google Shopping Feed, WooCommerce Product Feed, WooCommerce Product Feed PRO, Bing Shopping, Bing product feed, Bing remarking, Google Merchant Feed, Google DRM Feed, Google Dynamic Remarketing Feed, Facebook feed, Google feed, Bing feed, Facebook Product Feed, Facebook Dynamic remarketing, Data Feed, WooCommerce Feed, XML product feed, CSV product feed, TSV, TXT product feed, comparison shopping engines, comparison shopping websites, vergelijk.nl, vergelijk.be, vertaa.fi, beslist.nl, kieskeurig.nl, bol.com, raketten, pricerunner, pricegrabber, Buy, leGuide, Kelkoo, Twenga, Yandex, Etsy, Dealtime, Shopzilla, Billiger, Google Product Review feed
6
  Requires at least: 4.5
7
  Tested up to: 5.6
8
+ Stable tag: 9.7.8
9
 
10
  == Description ==
11
 
12
+ Generate WooCommerce product feeds for all your marketing channels, such as Google Shopping (merchant center), Facebook Remarketing, Bing Ads, Billiger.de, Pricerunner, Skroutz and many more. Next to custom feeds there are over 100 pre-defined templates included for marketplaces, comparison shopping engines and search engines. This plugin provides high-quality product feed for Google Shopping and many many more.
13
 
14
  = Why choose this plugin? =
15
  Simply because this is the most complete plugin offering support for an unlimited number of products and feeds, including features such as category- & field-mapping and advanced, rule-based, filtering and product variables support.
160
  * Google Shopping Actions
161
  * Facebook Dynamic Ad’s / remarketing
162
  * Bing Shopping
163
+ * Bing Shopping Promotions
164
  * Pinterest
165
  * <a href="https://businesshelp.snapchat.com/en-US/a/product-catalog-specs" target="_blank">Snapchat</a>
166
  * <a href="https://yandex.com/support/market-tech-requirements/index.html" target="_blank">Yandex</a>
176
  * <a href="https://www.beslist.nl" target="_blank" rel="nofollow">Beslist.nl</a>
177
  * <a href="https://www.beslist.be" target="_blank" rel="nofollow">Beslist.be</a>
178
  * <a href="https://www.fashionchick.nl" target="_blank">Fashionchick.nl</a>
179
+ * <a href="https://www.boetiek.nl" target="_blank">Boetiek.nl</a>
180
  * Bol.com
181
  * Stylight
182
  * Incurvy
231
  * <a href="https://www.guenstiger.de" target="_blank" rel="nofollow">Guenstiger.de</a>
232
  * Hood.de
233
  * Ladenzeile.de
234
+ * Idealo.de
235
  * Livingo.de
236
  * Medizinfuchs.de
237
  * <a href="https://www.moebel.de" target="_blank">Moebel.de</a>
325
 
326
  === Changelog ===
327
 
328
+ = 9.7.8 (2021-03-10) =
329
+ Added a boolean check on the review feed creation
330
+
331
+ = 9.7.7 (2021-03-09) =
332
+ Removed the woosea_add_cart.js from the source as it was an empty file
333
+
334
+ = 9.7.6 (2021-03-08) =
335
+ * Fixed an issue with the Facebook Purchase event that did not track the order value correct
336
+
337
+ = 9.7.5 (2021-03-07) =
338
+ * Another recode of the lowest price variation feature
339
+
340
+ = 9.7.4 (2021-03-05) =
341
+ * Added Bing Shopping Promotions template
342
+
343
+ = 9.7.3 (2021-03-04) =
344
+ * Added a new attribute "Stock Status WooCommerce"
345
+ * Fixed another quote issue with the Facebook pixel
346
+
347
+ = 9.7.2 (2021-03-03) =
348
+ * Fixed an issue with the Facebook pixel. Product names that had an apostrophe in them were not measured.
349
+
350
+ = 9.7.1 (2021-03-03) =
351
+ * Added another fix to take into account prices excluding VAT for filtering out all but the minimum priced variation
352
+
353
+ = 9.7.0 (2021-03-03) =
354
+ * Fixed a bug where lowest priced variations where not making it to feeds
355
+
356
+ = 9.6.9 (2021-02-28) =
357
+ * Added product name parent hyphen attribute
358
+
359
+ = 9.6.8 (2021-02-25) =
360
+ * Added Google category taxonomy mapping for Snapchat feeds
361
+
362
+ = 9.6.7 (2021-02-25) =
363
+ * When suffixes and prefixes are used for the Heureka URL fields spaces are removed
364
+
365
+ = 9.6.6 (2021-02-24) =
366
+ * Added support for PHP 8.0
367
+
368
+ = 9.6.5 (2021-02-24) =
369
+ * Do not add Skroutz variable products to the feed when they do not have item_group_id's
370
+
371
+ = 9.6.4 (2021-02-24) =
372
+ * Fixed an issue with rules and filters
373
+ * When a rule was set on an image link, no longer lowercase the image link
374
+
375
+ = 9.6.3 (2021-02-23) =
376
+ * Fixed a bug, the Facebook pixel is now also measuing revenue for multiple items in Cart, InititiateCheckout and Purchase events
377
+ * Reverted back some changes in filters and rules
378
+
379
+ = 9.6.2 (2021-02-22) =
380
+ * For Skroutz feed removing sizes from feeds when they are out-of-stock
381
+
382
+ = 9.6.1 (2021-02-19) =
383
+ * Added attribute that will allow you to uppercase every first character of a string in product names
384
+
385
+ = 9.6.0 (2021-02-19) =
386
+ * Changed g:itemid to g:id for the Google Local Product Feeds
387
+
388
+ = 9.5.9 (2021-02-19) =
389
+ * Added a fail-safe when users do not select a marketing channel which let to PHP notices in logs
390
+
391
+ = 9.5.8 (2021-02-18) =
392
+ * Added shipping class name attribute
393
+
394
+ = 9.5.7 (2021-02-17) =
395
+ * Dynamic attribute values are now also added to parent variable products for Skroutz feeds
396
+
397
+ = 9.5.6 (2021-02-17) =
398
+ * Changed attribute name primary category to Yoast primary category as it caused lots of confussion
399
+
400
+ = 9.5.5 (2021-02-11) =
401
+ * Fixed a PHP notice that showed when creating a new rule
402
+ * Tested for compatibility with WooCommerce 5.0
403
+
404
+ = 9.5.4 (2021-02-09) =
405
+ * When free shipping zones are removed do not remove the other shipping zones
406
+
407
+ = 9.5.3 (2021-02-08) =
408
+ * Added a feature to remove free shipping zones from Google and Facebook feeds
409
+
410
+ = 9.5.2 (2021-02-08) =
411
+ * Fixed a minor issue in exclude rules for WooCommerce category names
412
+
413
+ = 9.5.1 (2021-02-02) =
414
+ * Dynamic attributes without values that are used for product details should be skipped which not always happened. This is fixed now.
415
+
416
+ = 9.5.0 (2021-02-01) =
417
+ * Discount rules created with the FlyCart plugin did not make it to Skroutz feeds. This has been solved now
418
+
419
+ = 9.4.9 (2021-01-31) =
420
+ * Added a seperate sale price attribute for bundled products
421
+ * Reviews for parent variable products are removed, the reviews are attached to its variations
422
+
423
+ = 9.4.8 (2021-01-30) =
424
+ * Fixed an issue with the ecomm_prodid on the cart page
425
+
426
+ = 9.4.7 (2021-01-29) =
427
+ * Solved an issue that shipping costs to the first product in a custom feed where empty
428
+
429
+ = 9.4.6 (2021-01-28) =
430
+ * Added a new attribute: product description parent product
431
+
432
+ = 9.4.5 (2021-01-28) =
433
+ * Added a Google Shopping field to their template: g:ship_from_country
434
+ * Stripping & characters from review names as it breaks the review feeds
435
+
436
+ = 9.4.4 (2021-01-27) =
437
+ * Fixed an issue where reviews without review text caused the feed to be disapproved by Google. We now remove reviews from feeds that have no review texts.
438
+
439
+ = 9.4.3 (2021-01-27) =
440
+ * Fixed an issue with an undefined ecomm_price variable on product variable pages
441
+
442
+ = 9.4.2 (2021-01-26) =
443
+ * Added the Dutch Boetiek.nl template
444
+
445
+ = 9.4.1 (2021-01-19) =
446
+ * Fixed a bug: exclude filters on empty product tags were broken. This is fixed now.
447
+
448
+ = 9.4.0 (2021-01-14) =
449
+ * Added a WP-cron check and notifications
450
+
451
+ = 9.3.9 (2021-01-14) =
452
+ * Bestprice.gr apparel products are now grouped by color
453
+
454
+ = 9.3.8 (2021-01-13) =
455
+ * Tested for compatibility with WooCommerce 4.9
456
+
457
  = 9.3.7 (2021-01-12) =
458
  * Added the Bestprice.gr template
459
 
3120
 
3121
  == Upgrade Notice ==
3122
 
3123
+ = 9.7.8 =
3124
+ Added a boolean check on the review feed creation
3125
+
3126
+ = 9.7.7 =
3127
+ Removed the woosea_add_cart.js from the source as it was an empty file
3128
+
3129
+ = 9.7.6 =
3130
+ Fixed an issue with the Facebook Purchase event that did not track the order value correct
3131
+
3132
+ = 9.7.5 =
3133
+ Another recode of the lowest price variation feature
3134
+
3135
+ = 9.7.4 =
3136
+ Added Bing Shopping Promotions template
3137
+
3138
+ = 9.7.3 =
3139
+ Added a new attribute "Stock Status WooCommerce"
3140
+ Fixed another quote issue with the Facebook pixel
3141
+
3142
+ = 9.7.2 =
3143
+ Fixed an issue with the Facebook pixel. Product names that had an apostrophe in them were not measured.
3144
+
3145
+ = 9.7.1 =
3146
+ Added another fix to take into account prices excluding VAT for filtering out all but the minimum priced variation
3147
+
3148
+ = 9.7.0 =
3149
+ Fixed a bug where lowest priced variations where not making it to feeds
3150
+
3151
+ = 9.6.9 =
3152
+ Added product name parent hyphen attribute
3153
+
3154
+ = 9.6.8 =
3155
+ Added Google category taxonomy mapping for Snapchat feeds
3156
+
3157
+ = 9.6.7 =
3158
+ When suffixes and prefixes are used for the Heureka URL fields spaces are removed
3159
+
3160
+ = 9.6.6 =
3161
+ Added support for PHP 8.0
3162
+
3163
+ = 9.6.5 =
3164
+ Do not add Skroutz variable products to the feed when they do not have item_group_id's
3165
+
3166
+ = 9.6.4 =
3167
+ Fixed an issue with rules and filters
3168
+ When a rule was set on an image link, no longer lowercase the image link
3169
+
3170
+ = 9.6.3 =
3171
+ Fixed a bug, the Facebook pixel is now also measuing revenue for multiple items in Cart, InititiateCheckout and Purchase events
3172
+ Reverted back some changes in filters and rules
3173
+
3174
+ = 9.6.2 =
3175
+ For Skroutz feed removing sizes from feeds when they are out-of-stock
3176
+
3177
+ = 9.6.1 =
3178
+ Added attribute that will allow you to uppercase every first character of a string in product names
3179
+
3180
+ = 9.6.0 =
3181
+ Changed g:itemid to g:id for the Google Local Product Feeds
3182
+
3183
+ = 9.5.9 =
3184
+ * Added a fail-safe when users do not select a marketing channel which let to PHP notices in logs
3185
+
3186
+ = 9.5.8 =
3187
+ Added shipping class name attribute
3188
+
3189
+ = 9.5.7 =
3190
+ Dynamic attribute values are now also added to parent variable products for Skroutz feeds
3191
+
3192
+ = 9.5.6 =
3193
+ Changed attribute name primary category to Yoast primary category as it caused lots of confussion
3194
+
3195
+ = 9.5.5 =
3196
+ Fixed a PHP notice that showed when creating a new rule
3197
+ Tested for compatibility with WooCommerce 5.0
3198
+
3199
+ = 9.5.4 =
3200
+ When free shipping zones are removed do not remove the other shipping zones
3201
+
3202
+ = 9.5.3 =
3203
+ Added a feature to remove free shipping zones from Google and Facebook feeds
3204
+
3205
+ = 9.5.2 =
3206
+ Fixed a minor issue in exclude rules for WooCommerce category names
3207
+
3208
+ = 9.5.1 =
3209
+ Dynamic attributes without values that are used for product details should be skipped which not always happened. This is fixed now.
3210
+
3211
+ = 9.5.0 =
3212
+ Discount rules created with the FlyCart plugin did not make it to Skroutz feeds. This has been solved now
3213
+
3214
+ = 9.4.9 =
3215
+ Added a seperate sale price attribute for bundled products
3216
+ Reviews for parent variable products are removed, the reviews are attached to its variations
3217
+
3218
+ = 9.4.8 =
3219
+ Fixed an issue with the ecomm_prodid on the cart page
3220
+
3221
+ = 9.4.7 =
3222
+ Solved an issue that shipping costs to the first product in a custom feed where empty
3223
+
3224
+ = 9.4.6 =
3225
+ Added a new attribute: product description parent product
3226
+
3227
+ = 9.4.5 =
3228
+ Added a Google Shopping field to their template: g:ship_from_country
3229
+ Stripping & characters from review names as it breaks the review feeds
3230
+
3231
+ = 9.4.4 =
3232
+ Fixed an issue where reviews without review text caused the feed to be disapproved by Google. We now remove reviews from feeds that have no review texts.
3233
+
3234
+ = 9.4.3 =
3235
+ Fixed an issue with an undefined ecomm_price variable on product variable pages
3236
+
3237
+ = 9.4.2 =
3238
+ Added the Dutch Boetiek.nl template
3239
+
3240
+ = 9.4.1 =
3241
+ Fixed a bug: exclude filters on empty product tags were broken. This is fixed now.
3242
+
3243
+ = 9.4.0 =
3244
+ Added a WP-cron check and notifications
3245
+
3246
+ = 9.3.9 =
3247
+ Bestprice.gr apparel products are now grouped by color
3248
+
3249
+ = 9.3.8 =
3250
+ Tested for compatibility with WooCommerce 4.9
3251
+
3252
  = 9.3.7 =
3253
  Added the Bestprice.gr template
3254
 
woocommerce-sea.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: Product Feed PRO for WooCommerce
4
- * Version: 9.3.7
5
  * Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
6
  * Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
7
  * Author: AdTribes.io
@@ -17,7 +17,7 @@
17
  * Domain Path: /languages
18
  *
19
  * WC requires at least: 4.4
20
- * WC tested up to: 4.8
21
  *
22
  * Product Feed PRO for WooCommerce is free software: you can redistribute it and/or modify
23
  * it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ if (!defined('ABSPATH')) {
48
  * Plugin versionnumber, please do not override.
49
  * Define some constants
50
  */
51
- define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '9.3.7' );
52
  define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
53
  define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
54
 
@@ -115,7 +115,7 @@ function woosea_scripts($hook) {
115
  wp_enqueue_script( 'typeahead-js' );
116
 
117
  // JS for adding input field validation
118
- wp_register_script( 'woosea_validation-js', plugin_dir_url( __FILE__ ) . 'js/woosea_validation.js?BLAAT=999', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
119
  wp_enqueue_script( 'woosea_validation-js' );
120
 
121
  // JS for autocomplete
@@ -123,7 +123,7 @@ function woosea_scripts($hook) {
123
  wp_enqueue_script( 'woosea_autocomplete-js' );
124
 
125
  // JS for adding table rows to the rules page
126
- wp_register_script( 'woosea_rules-js', plugin_dir_url( __FILE__ ) . 'js/woosea_rules.js?BLAAT=1', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
127
  wp_enqueue_script( 'woosea_rules-js' );
128
 
129
  // JS for adding table rows to the field mappings page
@@ -279,7 +279,7 @@ add_filter('plugin_action_links', 'woosea_plugin_action_links', 10, 2);
279
  /**
280
  * Get category path for Facebook pixel
281
  */
282
- function woosea_get_term_parents( $id, $taxonomy, $link = false, $project_taxonomy, $nicename = false, $visited = array() ) {
283
  // Only add Home to the beginning of the chain when we start buildin the chain
284
  if(empty($visited)){
285
  $chain = 'Home';
@@ -302,7 +302,7 @@ function woosea_get_term_parents( $id, $taxonomy, $link = false, $project_taxono
302
 
303
  if ($parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited, TRUE )){
304
  $visited[] = $parent->parent;
305
- $chain .= woosea_get_term_parents( $parent->parent, $taxonomy, $link, $separator, $nicename, $visited );
306
  }
307
 
308
  if ($link){
@@ -335,6 +335,9 @@ function woosea_add_facebook_pixel( $product = null ){
335
 
336
  $fb_prodid = get_the_id();
337
  $product_name = $product->get_name();
 
 
 
338
  $cats = "";
339
  $all_cats = get_the_terms( $fb_prodid, 'product_cat' );
340
  if(!empty($all_cats)){
@@ -345,9 +348,10 @@ function woosea_add_facebook_pixel( $product = null ){
345
  // strip last comma
346
  $cats = rtrim($cats, ",");
347
  $cats = str_replace("&amp;","&", $cats);
 
 
348
 
349
  if(!empty($fb_prodid)){
350
-
351
  if(!$product) {
352
  return -1;
353
  }
@@ -436,6 +440,8 @@ function woosea_add_facebook_pixel( $product = null ){
436
  $order_real = 0;
437
  $contents = "";
438
 
 
 
439
  if ( !is_wp_error( $order_items )) {
440
  foreach( $order_items as $item_id => $order_item) {
441
  $prod_id = $order_item->get_product_id();
@@ -447,9 +453,9 @@ function woosea_add_facebook_pixel( $product = null ){
447
  $prod_quantity = $order_item->get_quantity();
448
  $order_real = wc_format_localized_price( $order_item->get_total() );
449
 
450
- // $order_subtotal = number_format(($order_item->get_subtotal()),2, '.', '');
451
- // $order_subtotal_tax= number_format(($order_item->get_subtotal_tax()),2, '.', '');
452
- // $order_real = number_format(($order_subtotal+$order_subtotal_tax+$order_real),2,',','');
453
  $contents .= "{'id': '$prod_id', 'quantity': $prod_quantity},";
454
  }
455
  }
@@ -463,6 +469,8 @@ function woosea_add_facebook_pixel( $product = null ){
463
  $cart_real = 0;
464
  $contents = "";
465
 
 
 
466
  $checkoutpage = wc_get_checkout_url();
467
  $current_url = get_permalink(get_the_ID());
468
 
@@ -477,20 +485,15 @@ function woosea_add_facebook_pixel( $product = null ){
477
  //$contents .= "$prod_id,";
478
 
479
  $cart_real = wc_format_localized_price( $cart_item['line_total'] );
480
-
481
- // $line_total = number_format(($cart_item['line_total']),2, '.','');
482
- // $line_tax = number_format(($cart_item['line_tax']),2, '.','');
483
- // $cart_real = number_format($cart_real,2, '.','');
484
- // $cart_real = number_format(($line_total+$line_tax+$cart_real),2,',','');
485
  }
486
  $contents = rtrim($contents, ",");
487
 
488
  // User is on the billing pages
489
  if($checkoutpage == $current_url){
490
- $viewContent = "fbq(\"track\",\"InitiateCheckout\",{currency:\"$currency\", value:\"$cart_real\", content_type:\"product\", content_ids:[$contents]});";
491
  } else {
492
  // User is on the basket page
493
- $viewContent = "fbq(\"track\",\"AddToCart\",{currency:\"$currency\", value:\"$cart_real\", content_type:\"product\", content_ids:[$contents]});";
494
  }
495
  }
496
  }
@@ -523,8 +526,8 @@ function woosea_add_facebook_pixel( $product = null ){
523
  }
524
  $fb_prodid = rtrim($fb_prodid, ",");
525
  $category_name = $term->name;
526
- $category_path = woosea_get_term_parents( $term->term_id, 'product_cat', $link = false, $project_taxonomy = false, $nicename = false, $visited = array() );
527
- $viewContent = "fbq(\"track\",\"ViewCategory\",{content_category:\"$category_path\", content_name:\"$category_name\", content_type:\"product\", content_ids:\"[$fb_prodid]\"});";
528
  } elseif ($fb_pagetype == "searchresults"){
529
  $term = get_queried_object();
530
  $search_string = sanitize_text_field($_GET['s']);
@@ -622,7 +625,7 @@ function woosea_add_remarketing_tags( $product = null ){
622
  // In that case we need to put in the AggregateOffer structured data
623
  $variation_id = woosea_find_matching_product_variation( $product, $_GET );
624
  $nr_get = count($_GET);
625
-
626
  if($nr_get > 0){
627
  $variable_product = wc_get_product($variation_id);
628
 
@@ -659,7 +662,9 @@ function woosea_add_remarketing_tags( $product = null ){
659
  $ecomm_price = wc_format_decimal( $lowest, wc_get_price_decimals());
660
  } else {
661
  $ecomm_lowprice = wc_format_decimal( $lowest, wc_get_price_decimals() );
662
- $ecomm_highprice = wc_format_decimal( $highest, wc_get_price_decimals() );
 
 
663
  }
664
  }
665
  } else {
@@ -671,14 +676,18 @@ function woosea_add_remarketing_tags( $product = null ){
671
  var google_tag_params = {
672
  ecomm_prodid: <?php print "$ecomm_prodid";?>,
673
  ecomm_pagetype: '<?php print "$ecomm_pagetype";?>',
674
- ecomm_totalvalue: '<?php print "$ecomm_price";?>',
675
  };
676
  </script>
677
 
678
  <?php
679
  }
680
  } elseif ($ecomm_pagetype == "cart"){
681
- $ecomm_prodid = get_the_id();
 
 
 
 
682
  ?>
683
  <script type="text/javascript">
684
  var google_tag_params = {
@@ -804,6 +813,7 @@ function woosea_request_review(){
804
  }
805
  add_action('admin_notices', 'woosea_request_review');
806
 
 
807
  /**
808
  * Create a seperate MySql table for saving conversion information
809
  */
@@ -2285,6 +2295,21 @@ function woosea_local_pickup_shipping (){
2285
  }
2286
  add_action( 'wp_ajax_woosea_local_pickup_shipping', 'woosea_local_pickup_shipping' );
2287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2288
  /**
2289
  * This function enables the setting to use
2290
  * logging
@@ -4623,8 +4648,11 @@ add_action('wp_dashboard_setup', 'woosea_blog_widgets');
4623
  /**
4624
  * Creates the RSS metabox
4625
  */
 
 
 
 
4626
  function woosea_my_rss_box() {
4627
-
4628
  // Get RSS Feed(s)
4629
  include_once(ABSPATH . WPINC . '/feed.php');
4630
  $domain = $_SERVER['HTTP_HOST'];
@@ -4633,6 +4661,8 @@ function woosea_my_rss_box() {
4633
  $my_feeds = array(
4634
  'https://www.adtribes.io/feed/'
4635
  );
 
 
4636
 
4637
  // Loop through Feeds
4638
  foreach ( $my_feeds as $feed) :
1
  <?php
2
  /**
3
  * Plugin Name: Product Feed PRO for WooCommerce
4
+ * Version: 9.7.8
5
  * Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
6
  * Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
7
  * Author: AdTribes.io
17
  * Domain Path: /languages
18
  *
19
  * WC requires at least: 4.4
20
+ * WC tested up to: 5.0
21
  *
22
  * Product Feed PRO for WooCommerce is free software: you can redistribute it and/or modify
23
  * it under the terms of the GNU General Public License as published by
48
  * Plugin versionnumber, please do not override.
49
  * Define some constants
50
  */
51
+ define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '9.7.8' );
52
  define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
53
  define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
54
 
115
  wp_enqueue_script( 'typeahead-js' );
116
 
117
  // JS for adding input field validation
118
+ wp_register_script( 'woosea_validation-js', plugin_dir_url( __FILE__ ) . 'js/woosea_validation.js', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
119
  wp_enqueue_script( 'woosea_validation-js' );
120
 
121
  // JS for autocomplete
123
  wp_enqueue_script( 'woosea_autocomplete-js' );
124
 
125
  // JS for adding table rows to the rules page
126
+ wp_register_script( 'woosea_rules-js', plugin_dir_url( __FILE__ ) . 'js/woosea_rules.js', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
127
  wp_enqueue_script( 'woosea_rules-js' );
128
 
129
  // JS for adding table rows to the field mappings page
279
  /**
280
  * Get category path for Facebook pixel
281
  */
282
+ function woosea_get_term_parents( $id, $taxonomy, $project_taxonomy, $link = false, $nicename = false, $visited = array() ) {
283
  // Only add Home to the beginning of the chain when we start buildin the chain
284
  if(empty($visited)){
285
  $chain = 'Home';
302
 
303
  if ($parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited, TRUE )){
304
  $visited[] = $parent->parent;
305
+ $chain .= woosea_get_term_parents( $parent->parent, $taxonomy, $separator, $link = false, $nicename, $visited );
306
  }
307
 
308
  if ($link){
335
 
336
  $fb_prodid = get_the_id();
337
  $product_name = $product->get_name();
338
+ $product_name = str_replace("\"","",$product_name);
339
+ $product_name = str_replace("'","",$product_name);
340
+
341
  $cats = "";
342
  $all_cats = get_the_terms( $fb_prodid, 'product_cat' );
343
  if(!empty($all_cats)){
348
  // strip last comma
349
  $cats = rtrim($cats, ",");
350
  $cats = str_replace("&amp;","&", $cats);
351
+ $cats = str_replace("\"","",$cats);
352
+ $cats = str_replace("'","",$cats);
353
 
354
  if(!empty($fb_prodid)){
 
355
  if(!$product) {
356
  return -1;
357
  }
440
  $order_real = 0;
441
  $contents = "";
442
 
443
+ $cart_total_amount = wc_format_localized_price(WC()->cart->get_cart_contents_total());
444
+
445
  if ( !is_wp_error( $order_items )) {
446
  foreach( $order_items as $item_id => $order_item) {
447
  $prod_id = $order_item->get_product_id();
453
  $prod_quantity = $order_item->get_quantity();
454
  $order_real = wc_format_localized_price( $order_item->get_total() );
455
 
456
+ $order_subtotal = number_format(($order_item->get_subtotal()),2, '.', '');
457
+ $order_subtotal_tax= number_format(($order_item->get_subtotal_tax()),2, '.', '');
458
+ $order_real = number_format(($order_subtotal+$order_subtotal_tax),2,',','');
459
  $contents .= "{'id': '$prod_id', 'quantity': $prod_quantity},";
460
  }
461
  }
469
  $cart_real = 0;
470
  $contents = "";
471
 
472
+ $cart_total_amount = wc_format_localized_price(WC()->cart->get_cart_contents_total());
473
+
474
  $checkoutpage = wc_get_checkout_url();
475
  $current_url = get_permalink(get_the_ID());
476
 
485
  //$contents .= "$prod_id,";
486
 
487
  $cart_real = wc_format_localized_price( $cart_item['line_total'] );
 
 
 
 
 
488
  }
489
  $contents = rtrim($contents, ",");
490
 
491
  // User is on the billing pages
492
  if($checkoutpage == $current_url){
493
+ $viewContent = "fbq(\"track\",\"InitiateCheckout\",{currency:\"$currency\", value:\"$cart_total_amount\", content_type:\"product\", content_ids:[$contents]});";
494
  } else {
495
  // User is on the basket page
496
+ $viewContent = "fbq(\"track\",\"AddToCart\",{currency:\"$currency\", value:\"$cart_total_amount\", content_type:\"product\", content_ids:[$contents]});";
497
  }
498
  }
499
  }
526
  }
527
  $fb_prodid = rtrim($fb_prodid, ",");
528
  $category_name = $term->name;
529
+ $category_path = woosea_get_term_parents( $term->term_id, 'product_cat', $project_taxonomy = false, $link = false, $nicename = false, $visited = array() );
530
+ $viewContent = "fbq(\"track\",\"ViewCategory\",{content_category:'$category_path', content_name:'$category_name', content_type:\"product\", content_ids:\"[$fb_prodid]\"});";
531
  } elseif ($fb_pagetype == "searchresults"){
532
  $term = get_queried_object();
533
  $search_string = sanitize_text_field($_GET['s']);
625
  // In that case we need to put in the AggregateOffer structured data
626
  $variation_id = woosea_find_matching_product_variation( $product, $_GET );
627
  $nr_get = count($_GET);
628
+
629
  if($nr_get > 0){
630
  $variable_product = wc_get_product($variation_id);
631
 
662
  $ecomm_price = wc_format_decimal( $lowest, wc_get_price_decimals());
663
  } else {
664
  $ecomm_lowprice = wc_format_decimal( $lowest, wc_get_price_decimals() );
665
+ $ecomm_highprice = wc_format_decimal( $highest, wc_get_price_decimals() );
666
+ $ecomm_price = $ecomm_lowprice;
667
+
668
  }
669
  }
670
  } else {
676
  var google_tag_params = {
677
  ecomm_prodid: <?php print "$ecomm_prodid";?>,
678
  ecomm_pagetype: '<?php print "$ecomm_pagetype";?>',
679
+ ecomm_totalvalue: <?php print "$ecomm_price";?>,
680
  };
681
  </script>
682
 
683
  <?php
684
  }
685
  } elseif ($ecomm_pagetype == "cart"){
686
+ // Get the first product from cart and use that product ID
687
+ foreach( WC()->cart->get_cart() as $cart_item ){
688
+ $ecomm_prodid = $cart_item['product_id'];
689
+ break;
690
+ }
691
  ?>
692
  <script type="text/javascript">
693
  var google_tag_params = {
813
  }
814
  add_action('admin_notices', 'woosea_request_review');
815
 
816
+
817
  /**
818
  * Create a seperate MySql table for saving conversion information
819
  */
2295
  }
2296
  add_action( 'wp_ajax_woosea_local_pickup_shipping', 'woosea_local_pickup_shipping' );
2297
 
2298
+ /**
2299
+ * This function enables the setting to remove
2300
+ * free shipping zones
2301
+ */
2302
+ function woosea_remove_free_shipping (){
2303
+ $status = sanitize_text_field($_POST['status']);
2304
+
2305
+ if ($status == "off"){
2306
+ update_option( 'remove_free_shipping', 'no', 'yes');
2307
+ } else {
2308
+ update_option( 'remove_free_shipping', 'yes', 'yes');
2309
+ }
2310
+ }
2311
+ add_action( 'wp_ajax_woosea_remove_free_shipping', 'woosea_remove_free_shipping' );
2312
+
2313
  /**
2314
  * This function enables the setting to use
2315
  * logging
4648
  /**
4649
  * Creates the RSS metabox
4650
  */
4651
+ function woosea_feed_interval( $seconds ) {
4652
+ return 172800; // Cache the feed for 2 days
4653
+ }
4654
+
4655
  function woosea_my_rss_box() {
 
4656
  // Get RSS Feed(s)
4657
  include_once(ABSPATH . WPINC . '/feed.php');
4658
  $domain = $_SERVER['HTTP_HOST'];
4661
  $my_feeds = array(
4662
  'https://www.adtribes.io/feed/'
4663
  );
4664
+
4665
+ add_filter( 'wp_feed_cache_transient_lifetime' , 'woosea_feed_interval' );
4666
 
4667
  // Loop through Feeds
4668
  foreach ( $my_feeds as $feed) :