Version Description
(2020-09-30) = * Added: The Moebel.de template.
Download this release
Release Info
Developer | wahid0003 |
Plugin | CTX Feed – WooCommerce Product Feed Manager Plugin |
Version | 3.9.0 |
Comparing to | |
See all releases |
Code changes from version 3.8.9 to 3.9.0
- README.txt +4 -1
- includes/classes/class-woo-feed-default-attributes.php +93 -93
- includes/classes/class-woo-feed-dropdown.php +3 -3
- includes/classes/class-woo-feed-merchant.php +1 -0
- includes/classes/class-woo-feed-products-v3.php +440 -523
- includes/cron-helper.php +5 -5
- includes/feeds/merchant_infos.php +4 -0
- includes/feeds/merchant_templates.php +10 -0
- includes/feeds/merchant_templates_override.php +17 -17
- includes/helper.php +90 -96
- includes/widget.php +2 -2
- woo-feed.php +23 -24
README.txt
CHANGED
@@ -5,7 +5,7 @@ Tags:product feed,woocommerce product feed,google shopping feed,google shopping,
|
|
5 |
Requires at least: 3.6
|
6 |
Tested Up To: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -308,6 +308,9 @@ Using pro version:
|
|
308 |
|
309 |
== Changelog ==
|
310 |
|
|
|
|
|
|
|
311 |
= 3.8.9 (2020-09-29) =
|
312 |
* Added: The Heureka Slovakia template.
|
313 |
|
5 |
Requires at least: 3.6
|
6 |
Tested Up To: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.9.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
308 |
|
309 |
== Changelog ==
|
310 |
|
311 |
+
= 3.9.0 (2020-09-30) =
|
312 |
+
* Added: The Moebel.de template.
|
313 |
+
|
314 |
= 3.8.9 (2020-09-29) =
|
315 |
* Added: The Heureka Slovakia template.
|
316 |
|
includes/classes/class-woo-feed-default-attributes.php
CHANGED
@@ -49,16 +49,16 @@ class Woo_Feed_Default_Attributes {
|
|
49 |
'upc' => array( 'g:gtin', true ),
|
50 |
'identifier_exists' => array( 'g:identifier_exists', true ),
|
51 |
'item_group_id' => array( 'g:item_group_id', false ),
|
52 |
-
'product_highlight_1'
|
53 |
-
'product_highlight_2'
|
54 |
-
'product_highlight_3'
|
55 |
-
'product_highlight_4'
|
56 |
-
'product_highlight_5'
|
57 |
-
'product_highlight_6'
|
58 |
-
'product_highlight_7'
|
59 |
-
'product_highlight_8'
|
60 |
-
'product_highlight_9'
|
61 |
-
'product_highlight_10'
|
62 |
'color' => array( 'g:color', true ),
|
63 |
'gender' => array( 'g:gender', true ),
|
64 |
'age_group' => array( 'g:age_group', true ),
|
@@ -154,16 +154,16 @@ class Woo_Feed_Default_Attributes {
|
|
154 |
'upc' => array( 'gtin', true ),
|
155 |
'identifier_exists' => array( 'identifier exists', true ),
|
156 |
'item_group_id' => array( 'item group id', false ),
|
157 |
-
'product_highlight_1'
|
158 |
-
'product_highlight_2'
|
159 |
-
'product_highlight_3'
|
160 |
-
'product_highlight_4'
|
161 |
-
'product_highlight_5'
|
162 |
-
'product_highlight_6'
|
163 |
-
'product_highlight_7'
|
164 |
-
'product_highlight_8'
|
165 |
-
'product_highlight_9'
|
166 |
-
'product_highlight_10'
|
167 |
'color' => array( 'color', true ),
|
168 |
'gender' => array( 'gender', true ),
|
169 |
'age_group' => array( 'age group', true ),
|
@@ -190,7 +190,7 @@ class Woo_Feed_Default_Attributes {
|
|
190 |
'multipack' => array( 'multipack', true ),
|
191 |
'is_bundle' => array( 'is bundle', true ),
|
192 |
'adult' => array( 'adult', true ),
|
193 |
-
'ads_redirect'
|
194 |
'custom_label_0' => array( 'custom label 0', true ),
|
195 |
'custom_label_1' => array( 'custom label 1', true ),
|
196 |
'custom_label_2' => array( 'custom label 2', true ),
|
@@ -236,16 +236,16 @@ class Woo_Feed_Default_Attributes {
|
|
236 |
'current_category' => array( 'g:google_product_category', true ),
|
237 |
'image' => array( 'g:image_link', true ),
|
238 |
'images' => array( 'g:additional_image_link', false ),
|
239 |
-
'images_1'
|
240 |
-
'images_2'
|
241 |
-
'images_3'
|
242 |
-
'images_4'
|
243 |
-
'images_5'
|
244 |
-
'images_6'
|
245 |
-
'images_7'
|
246 |
-
'images_8'
|
247 |
-
'images_9'
|
248 |
-
'images_10'
|
249 |
'condition' => array( 'g:condition', false ),
|
250 |
'availability' => array( 'g:availability', false ),
|
251 |
'inventory' => array( 'g:inventory', false ),
|
@@ -309,16 +309,16 @@ class Woo_Feed_Default_Attributes {
|
|
309 |
'current_category' => array( 'google product category', true ),
|
310 |
'image' => array( 'image link', true ),
|
311 |
'images' => array( 'additional image link', true ),
|
312 |
-
'images_1'
|
313 |
-
'images_2'
|
314 |
-
'images_3'
|
315 |
-
'images_4'
|
316 |
-
'images_5'
|
317 |
-
'images_6'
|
318 |
-
'images_7'
|
319 |
-
'images_8'
|
320 |
-
'images_9'
|
321 |
-
'images_10'
|
322 |
'condition' => array( 'condition', false ),
|
323 |
'availability' => array( 'availability', false ),
|
324 |
'inventory' => array( 'inventory', false ),
|
@@ -382,16 +382,16 @@ class Woo_Feed_Default_Attributes {
|
|
382 |
'current_category' => array( 'g:google_product_category', true ),
|
383 |
'image' => array( 'g:image_link', true ),
|
384 |
'images' => array( 'g:additional_image_link', false ),
|
385 |
-
'images_1'
|
386 |
-
'images_2'
|
387 |
-
'images_3'
|
388 |
-
'images_4'
|
389 |
-
'images_5'
|
390 |
-
'images_6'
|
391 |
-
'images_7'
|
392 |
-
'images_8'
|
393 |
-
'images_9'
|
394 |
-
'images_10'
|
395 |
'condition' => array( 'g:condition', false ),
|
396 |
'availability' => array( 'g:availability', false ),
|
397 |
'availability_date' => array( 'g:availability_date', false ),
|
@@ -458,16 +458,16 @@ class Woo_Feed_Default_Attributes {
|
|
458 |
'current_category' => array( 'google_product_category', true ),
|
459 |
'image' => array( 'image_link', true ),
|
460 |
'images' => array( 'additional_image_link', true ),
|
461 |
-
'images_1'
|
462 |
-
'images_2'
|
463 |
-
'images_3'
|
464 |
-
'images_4'
|
465 |
-
'images_5'
|
466 |
-
'images_6'
|
467 |
-
'images_7'
|
468 |
-
'images_8'
|
469 |
-
'images_9'
|
470 |
-
'images_10'
|
471 |
'condition' => array( 'condition', false ),
|
472 |
'availability' => array( 'availability', false ),
|
473 |
'availability_date' => array( 'availability_date', false ),
|
@@ -611,16 +611,16 @@ class Woo_Feed_Default_Attributes {
|
|
611 |
'size' => 'Size of the item[size]',
|
612 |
'size_type' => 'Size Type[size_type]',
|
613 |
'size_system' => 'Size System[size_system]',
|
614 |
-
'product_highlight_1'
|
615 |
-
'product_highlight_2'
|
616 |
-
'product_highlight_3'
|
617 |
-
'product_highlight_4'
|
618 |
-
'product_highlight_5'
|
619 |
-
'product_highlight_6'
|
620 |
-
'product_highlight_7'
|
621 |
-
'product_highlight_8'
|
622 |
-
'product_highlight_9'
|
623 |
-
'product_highlight_10'
|
624 |
'section_name' => 'Section Name (Product Detail)[section_name]',
|
625 |
'attribute_name' => 'Attribute Name (Product Detail)[attribute_name]',
|
626 |
'attribute_value' => 'Attribute Value (Product Detail)[attribute_value]',
|
@@ -653,7 +653,7 @@ class Woo_Feed_Default_Attributes {
|
|
653 |
'adult' => 'Adult[adult]',
|
654 |
'---7' => '',
|
655 |
'--8' => 'Ads Attributes',
|
656 |
-
'ads_redirect'
|
657 |
'---8' => '',
|
658 |
'--9' => 'Custom Label Attributes',
|
659 |
'custom_label_0' => 'Custom label 0 [custom_label_0]',
|
@@ -677,7 +677,7 @@ class Woo_Feed_Default_Attributes {
|
|
677 |
'subscription_period' => 'Subscription Period[period]',
|
678 |
'subscription_period_length' => 'Subscription Period Length[period_length]',
|
679 |
'subscription_amount' => 'Subscription Amount[amount]',
|
680 |
-
'loyalty_points'
|
681 |
'---11' => '',
|
682 |
'--12' => 'Energy Labels',
|
683 |
'energy_efficiency_class' => 'Energy Efficiency Class[energy_efficiency_class]',
|
@@ -691,7 +691,7 @@ class Woo_Feed_Default_Attributes {
|
|
691 |
'installment' => 'Installment[installment]',
|
692 |
'---14' => '',
|
693 |
'--15' => 'Merchant Promotions Attribute',
|
694 |
-
'promotion_id'
|
695 |
'---15' => '',
|
696 |
'--16' => 'Shopping Action Attributes',
|
697 |
'sell_on_google_quantity' => 'Number of Product Sold On Google [sell_on_google_quantity]',
|
@@ -738,26 +738,26 @@ class Woo_Feed_Default_Attributes {
|
|
738 |
*/
|
739 |
public function bestpriceAttributes() {
|
740 |
return [
|
741 |
-
'--1'
|
742 |
-
'productId'
|
743 |
-
'name'
|
744 |
-
'description'
|
745 |
-
'link'
|
746 |
-
'image'
|
747 |
-
'categoryPath'
|
748 |
-
'categoryID'
|
749 |
-
'price'
|
750 |
-
'manufacturer'
|
751 |
-
'mpn'
|
752 |
-
'availability'
|
753 |
-
'---1'
|
754 |
-
'instock'
|
755 |
-
'ean'
|
756 |
'additional_image' => 'Additional Image Link',
|
757 |
-
'color'
|
758 |
-
'size'
|
759 |
-
'weight'
|
760 |
-
'features'
|
761 |
];
|
762 |
}
|
763 |
/**
|
49 |
'upc' => array( 'g:gtin', true ),
|
50 |
'identifier_exists' => array( 'g:identifier_exists', true ),
|
51 |
'item_group_id' => array( 'g:item_group_id', false ),
|
52 |
+
'product_highlight_1' => array( 'g:product_highlight', true ),
|
53 |
+
'product_highlight_2' => array( 'g:product_highlight', true ),
|
54 |
+
'product_highlight_3' => array( 'g:product_highlight', true ),
|
55 |
+
'product_highlight_4' => array( 'g:product_highlight', true ),
|
56 |
+
'product_highlight_5' => array( 'g:product_highlight', true ),
|
57 |
+
'product_highlight_6' => array( 'g:product_highlight', true ),
|
58 |
+
'product_highlight_7' => array( 'g:product_highlight', true ),
|
59 |
+
'product_highlight_8' => array( 'g:product_highlight', true ),
|
60 |
+
'product_highlight_9' => array( 'g:product_highlight', true ),
|
61 |
+
'product_highlight_10' => array( 'g:product_highlight', true ),
|
62 |
'color' => array( 'g:color', true ),
|
63 |
'gender' => array( 'g:gender', true ),
|
64 |
'age_group' => array( 'g:age_group', true ),
|
154 |
'upc' => array( 'gtin', true ),
|
155 |
'identifier_exists' => array( 'identifier exists', true ),
|
156 |
'item_group_id' => array( 'item group id', false ),
|
157 |
+
'product_highlight_1' => array( 'product highlight 1', true ),
|
158 |
+
'product_highlight_2' => array( 'product highlight 2', true ),
|
159 |
+
'product_highlight_3' => array( 'product highlight 3', true ),
|
160 |
+
'product_highlight_4' => array( 'product highlight 4', true ),
|
161 |
+
'product_highlight_5' => array( 'product highlight 5', true ),
|
162 |
+
'product_highlight_6' => array( 'product highlight 6', true ),
|
163 |
+
'product_highlight_7' => array( 'product highlight 7', true ),
|
164 |
+
'product_highlight_8' => array( 'product highlight 8', true ),
|
165 |
+
'product_highlight_9' => array( 'product highlight 9', true ),
|
166 |
+
'product_highlight_10' => array( 'product highlight 10', true ),
|
167 |
'color' => array( 'color', true ),
|
168 |
'gender' => array( 'gender', true ),
|
169 |
'age_group' => array( 'age group', true ),
|
190 |
'multipack' => array( 'multipack', true ),
|
191 |
'is_bundle' => array( 'is bundle', true ),
|
192 |
'adult' => array( 'adult', true ),
|
193 |
+
'ads_redirect' => array( 'ads redirect', true ),
|
194 |
'custom_label_0' => array( 'custom label 0', true ),
|
195 |
'custom_label_1' => array( 'custom label 1', true ),
|
196 |
'custom_label_2' => array( 'custom label 2', true ),
|
236 |
'current_category' => array( 'g:google_product_category', true ),
|
237 |
'image' => array( 'g:image_link', true ),
|
238 |
'images' => array( 'g:additional_image_link', false ),
|
239 |
+
'images_1' => array( 'g:additional_image_link', true ),
|
240 |
+
'images_2' => array( 'g:additional_image_link', true ),
|
241 |
+
'images_3' => array( 'g:additional_image_link', true ),
|
242 |
+
'images_4' => array( 'g:additional_image_link', true ),
|
243 |
+
'images_5' => array( 'g:additional_image_link', true ),
|
244 |
+
'images_6' => array( 'g:additional_image_link', true ),
|
245 |
+
'images_7' => array( 'g:additional_image_link', true ),
|
246 |
+
'images_8' => array( 'g:additional_image_link', true ),
|
247 |
+
'images_9' => array( 'g:additional_image_link', true ),
|
248 |
+
'images_10' => array( 'g:additional_image_link', true ),
|
249 |
'condition' => array( 'g:condition', false ),
|
250 |
'availability' => array( 'g:availability', false ),
|
251 |
'inventory' => array( 'g:inventory', false ),
|
309 |
'current_category' => array( 'google product category', true ),
|
310 |
'image' => array( 'image link', true ),
|
311 |
'images' => array( 'additional image link', true ),
|
312 |
+
'images_1' => array( 'additional image link', true ),
|
313 |
+
'images_2' => array( 'additional image link', true ),
|
314 |
+
'images_3' => array( 'additional image link', true ),
|
315 |
+
'images_4' => array( 'additional image link', true ),
|
316 |
+
'images_5' => array( 'additional image link', true ),
|
317 |
+
'images_6' => array( 'additional image link', true ),
|
318 |
+
'images_7' => array( 'additional image link', true ),
|
319 |
+
'images_8' => array( 'additional image link', true ),
|
320 |
+
'images_9' => array( 'additional image link', true ),
|
321 |
+
'images_10' => array( 'additional image link', true ),
|
322 |
'condition' => array( 'condition', false ),
|
323 |
'availability' => array( 'availability', false ),
|
324 |
'inventory' => array( 'inventory', false ),
|
382 |
'current_category' => array( 'g:google_product_category', true ),
|
383 |
'image' => array( 'g:image_link', true ),
|
384 |
'images' => array( 'g:additional_image_link', false ),
|
385 |
+
'images_1' => array( 'g:additional_image_link', true ),
|
386 |
+
'images_2' => array( 'g:additional_image_link', true ),
|
387 |
+
'images_3' => array( 'g:additional_image_link', true ),
|
388 |
+
'images_4' => array( 'g:additional_image_link', true ),
|
389 |
+
'images_5' => array( 'g:additional_image_link', true ),
|
390 |
+
'images_6' => array( 'g:additional_image_link', true ),
|
391 |
+
'images_7' => array( 'g:additional_image_link', true ),
|
392 |
+
'images_8' => array( 'g:additional_image_link', true ),
|
393 |
+
'images_9' => array( 'g:additional_image_link', true ),
|
394 |
+
'images_10' => array( 'g:additional_image_link', true ),
|
395 |
'condition' => array( 'g:condition', false ),
|
396 |
'availability' => array( 'g:availability', false ),
|
397 |
'availability_date' => array( 'g:availability_date', false ),
|
458 |
'current_category' => array( 'google_product_category', true ),
|
459 |
'image' => array( 'image_link', true ),
|
460 |
'images' => array( 'additional_image_link', true ),
|
461 |
+
'images_1' => array( 'additional image link', true ),
|
462 |
+
'images_2' => array( 'additional image link', true ),
|
463 |
+
'images_3' => array( 'additional image link', true ),
|
464 |
+
'images_4' => array( 'additional image link', true ),
|
465 |
+
'images_5' => array( 'additional image link', true ),
|
466 |
+
'images_6' => array( 'additional image link', true ),
|
467 |
+
'images_7' => array( 'additional image link', true ),
|
468 |
+
'images_8' => array( 'additional image link', true ),
|
469 |
+
'images_9' => array( 'additional image link', true ),
|
470 |
+
'images_10' => array( 'additional image link', true ),
|
471 |
'condition' => array( 'condition', false ),
|
472 |
'availability' => array( 'availability', false ),
|
473 |
'availability_date' => array( 'availability_date', false ),
|
611 |
'size' => 'Size of the item[size]',
|
612 |
'size_type' => 'Size Type[size_type]',
|
613 |
'size_system' => 'Size System[size_system]',
|
614 |
+
'product_highlight_1' => 'Product Highlight 1[product_highlight]',
|
615 |
+
'product_highlight_2' => 'Product Highlight 2[product_highlight]',
|
616 |
+
'product_highlight_3' => 'Product Highlight 3[product_highlight]',
|
617 |
+
'product_highlight_4' => 'Product Highlight 4[product_highlight]',
|
618 |
+
'product_highlight_5' => 'Product Highlight 5[product_highlight]',
|
619 |
+
'product_highlight_6' => 'Product Highlight 6[product_highlight]',
|
620 |
+
'product_highlight_7' => 'Product Highlight 7[product_highlight]',
|
621 |
+
'product_highlight_8' => 'Product Highlight 8[product_highlight]',
|
622 |
+
'product_highlight_9' => 'Product Highlight 9[product_highlight]',
|
623 |
+
'product_highlight_10' => 'Product Highlight 10[product_highlight]',
|
624 |
'section_name' => 'Section Name (Product Detail)[section_name]',
|
625 |
'attribute_name' => 'Attribute Name (Product Detail)[attribute_name]',
|
626 |
'attribute_value' => 'Attribute Value (Product Detail)[attribute_value]',
|
653 |
'adult' => 'Adult[adult]',
|
654 |
'---7' => '',
|
655 |
'--8' => 'Ads Attributes',
|
656 |
+
'ads_redirect' => 'Ads Redirect[ads_redirect]',
|
657 |
'---8' => '',
|
658 |
'--9' => 'Custom Label Attributes',
|
659 |
'custom_label_0' => 'Custom label 0 [custom_label_0]',
|
677 |
'subscription_period' => 'Subscription Period[period]',
|
678 |
'subscription_period_length' => 'Subscription Period Length[period_length]',
|
679 |
'subscription_amount' => 'Subscription Amount[amount]',
|
680 |
+
'loyalty_points' => 'Loyalty Points[loyalty_points]',
|
681 |
'---11' => '',
|
682 |
'--12' => 'Energy Labels',
|
683 |
'energy_efficiency_class' => 'Energy Efficiency Class[energy_efficiency_class]',
|
691 |
'installment' => 'Installment[installment]',
|
692 |
'---14' => '',
|
693 |
'--15' => 'Merchant Promotions Attribute',
|
694 |
+
'promotion_id' => 'Promotion Id[promotion_id]',
|
695 |
'---15' => '',
|
696 |
'--16' => 'Shopping Action Attributes',
|
697 |
'sell_on_google_quantity' => 'Number of Product Sold On Google [sell_on_google_quantity]',
|
738 |
*/
|
739 |
public function bestpriceAttributes() {
|
740 |
return [
|
741 |
+
'--1' => 'Required Attributes',
|
742 |
+
'productId' => 'Product ID[productId]',
|
743 |
+
'name' => 'Product Title[name]',
|
744 |
+
'description' => 'Product Description[description]',
|
745 |
+
'link' => 'Product Link[link]',
|
746 |
+
'image' => 'Image Link[image]',
|
747 |
+
'categoryPath' => 'Category Path[categoryPath]',
|
748 |
+
'categoryID' => 'Category Id[categoryID]',
|
749 |
+
'price' => 'Price[price]',
|
750 |
+
'manufacturer' => 'Manufacturer[manufacturer]',
|
751 |
+
'mpn' => 'MPN / ISBN',
|
752 |
+
'availability' => 'Availability',
|
753 |
+
'---1' => 'Recommended Attributes',
|
754 |
+
'instock' => 'Stock Status[instock]',
|
755 |
+
'ean' => 'EAN/Barcode',
|
756 |
'additional_image' => 'Additional Image Link',
|
757 |
+
'color' => 'Color',
|
758 |
+
'size' => 'Size',
|
759 |
+
'weight' => 'Weight',
|
760 |
+
'features' => 'Features',
|
761 |
];
|
762 |
}
|
763 |
/**
|
includes/classes/class-woo-feed-dropdown.php
CHANGED
@@ -240,9 +240,9 @@ class Woo_Feed_Dropdown {
|
|
240 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
241 |
$attributes = array_merge( $attributes,
|
242 |
[
|
243 |
-
'subscription_period'
|
244 |
-
'subscription_period_interval'
|
245 |
-
'subscription_amount'
|
246 |
] );
|
247 |
}
|
248 |
|
240 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
241 |
$attributes = array_merge( $attributes,
|
242 |
[
|
243 |
+
'subscription_period' => esc_html__( 'Subscription Period', 'woo-feed' ),
|
244 |
+
'subscription_period_interval' => esc_html__( 'Subscription Period Interval', 'woo-feed' ),
|
245 |
+
'subscription_amount' => esc_html__( 'Subscription Amount', 'woo-feed' ),
|
246 |
] );
|
247 |
}
|
248 |
|
includes/classes/class-woo-feed-merchant.php
CHANGED
@@ -395,6 +395,7 @@ class Woo_Feed_Merchant {
|
|
395 |
'marktplaats.nl' => esc_html__( 'Marktplaats.nl', 'woo-feed' ),
|
396 |
'miinto.nl' => esc_html__( 'Miinto.nl', 'woo-feed' ),
|
397 |
'modina.de' => esc_html__( 'Modina.de', 'woo-feed' ),
|
|
|
398 |
'myshopping.com.au' => esc_html__( 'Myshopping.com.au', 'woo-feed' ),
|
399 |
'nextad' => esc_html__( 'TheNextAd', 'woo-feed' ),
|
400 |
'nextag' => esc_html__( 'Nextag', 'woo-feed' ),
|
395 |
'marktplaats.nl' => esc_html__( 'Marktplaats.nl', 'woo-feed' ),
|
396 |
'miinto.nl' => esc_html__( 'Miinto.nl', 'woo-feed' ),
|
397 |
'modina.de' => esc_html__( 'Modina.de', 'woo-feed' ),
|
398 |
+
'moebel.de' => esc_html__( 'Moebel.de', 'woo-feed' ),
|
399 |
'myshopping.com.au' => esc_html__( 'Myshopping.com.au', 'woo-feed' ),
|
400 |
'nextad' => esc_html__( 'TheNextAd', 'woo-feed' ),
|
401 |
'nextag' => esc_html__( 'Nextag', 'woo-feed' ),
|
includes/classes/class-woo-feed-products-v3.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Time: 5:10 PM
|
8 |
*/
|
9 |
|
10 |
-
if (!defined('ABSPATH')) {
|
11 |
die();
|
12 |
}
|
13 |
|
@@ -79,7 +79,7 @@ class Woo_Feed_Products_v3
|
|
79 |
* To replace google product highlight attribute for CSV & TXT feed
|
80 |
* @var array
|
81 |
*/
|
82 |
-
protected $google_product_highlights=array(
|
83 |
'product highlight 1',
|
84 |
'product highlight 2',
|
85 |
'product highlight 3',
|
@@ -96,7 +96,7 @@ class Woo_Feed_Products_v3
|
|
96 |
* To replace google additional image link attribute for CSV & TXT feed
|
97 |
* @var array
|
98 |
*/
|
99 |
-
protected $google_additional_image=array(
|
100 |
'additional image link 1',
|
101 |
'additional image link 2',
|
102 |
'additional image link 3',
|
@@ -142,7 +142,7 @@ class Woo_Feed_Products_v3
|
|
142 |
* @var array
|
143 |
*/
|
144 |
protected $skipped_merchant_attributes = array(
|
145 |
-
'google'
|
146 |
'shipping_country',
|
147 |
'shipping_region',
|
148 |
'shipping_service',
|
@@ -202,7 +202,7 @@ class Woo_Feed_Products_v3
|
|
202 |
'variable-subscription',
|
203 |
'bundle',
|
204 |
'yith_bundle',
|
205 |
-
'woosb'
|
206 |
);
|
207 |
/**
|
208 |
* Post meta prefix for dropdown item
|
@@ -229,8 +229,7 @@ class Woo_Feed_Products_v3
|
|
229 |
*/
|
230 |
const PRODUCT_CATEGORY_MAPPING_PREFIX = 'wf_cmapping_';
|
231 |
|
232 |
-
public function __construct($config)
|
233 |
-
{
|
234 |
$this->config = woo_feed_parse_feed_rules($config);
|
235 |
$this->queryType = woo_feed_get_options('product_query_type');
|
236 |
$this->process_xml_wrapper();
|
@@ -242,31 +241,30 @@ class Woo_Feed_Products_v3
|
|
242 |
* @param string $type
|
243 |
* @return array
|
244 |
*/
|
245 |
-
protected function get_query_args($type = 'wc')
|
246 |
-
{
|
247 |
$args = [];
|
248 |
-
if ('wc' === $type) {
|
249 |
$args = array(
|
250 |
'limit' => -1, // phpcs:ignore
|
251 |
-
'status'
|
252 |
-
'type'
|
253 |
-
'orderby'
|
254 |
-
'order'
|
255 |
-
'return'
|
256 |
'suppress_filters' => false,
|
257 |
);
|
258 |
}
|
259 |
-
if ('wp' === $type) {
|
260 |
$args = array(
|
261 |
'posts_per_page' => -1, // phpcs:ignore
|
262 |
-
'post_type'
|
263 |
-
'post_status'
|
264 |
-
'order'
|
265 |
-
'fields'
|
266 |
-
'cache_results'
|
267 |
'update_post_meta_cache' => false,
|
268 |
'update_post_term_cache' => false,
|
269 |
-
'suppress_filters'
|
270 |
);
|
271 |
}
|
272 |
return $args;
|
@@ -277,15 +275,14 @@ class Woo_Feed_Products_v3
|
|
277 |
*
|
278 |
* @return array
|
279 |
*/
|
280 |
-
public function get_wc_query_products()
|
281 |
-
{
|
282 |
$args = $this->get_query_args('wc');
|
283 |
-
if (woo_feed_is_debugging_enabled()) {
|
284 |
woo_feed_log_feed_process($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
285 |
woo_feed_log($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true), 'info'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
286 |
}
|
287 |
$query = new WC_Product_Query($args);
|
288 |
-
if (woo_feed_is_debugging_enabled()) {
|
289 |
woo_feed_log_feed_process($this->config['filename'], sprintf('WC_Product_Query Args ::' . PHP_EOL . '%s', print_r($args, true))); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
290 |
}
|
291 |
return $query->get_products();
|
@@ -296,11 +293,10 @@ class Woo_Feed_Products_v3
|
|
296 |
*
|
297 |
* @return array
|
298 |
*/
|
299 |
-
public function get_wp_query_products()
|
300 |
-
{
|
301 |
$args = $this->get_query_args('wp');
|
302 |
$query = new WP_Query($args);
|
303 |
-
if (woo_feed_is_debugging_enabled()) {
|
304 |
woo_feed_log_feed_process($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
305 |
woo_feed_log_feed_process($this->config['filename'], sprintf('WP_Query Request ::' . PHP_EOL . '%s', $query->request));
|
306 |
woo_feed_log($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true), 'info'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
@@ -314,14 +310,13 @@ class Woo_Feed_Products_v3
|
|
314 |
*
|
315 |
* @return array
|
316 |
*/
|
317 |
-
public function query_products()
|
318 |
-
{
|
319 |
$products = [];
|
320 |
-
if ('wc' == $this->queryType) {
|
321 |
$products = $this->get_wc_query_products();
|
322 |
-
} elseif ('wp' == $this->queryType) {
|
323 |
$products = $this->get_wp_query_products();
|
324 |
-
} elseif ('both' == $this->queryType) {
|
325 |
$wc = $this->get_wc_query_products();
|
326 |
$wp = $this->get_wp_query_products();
|
327 |
$products = array_unique(array_merge($wc, $wp));
|
@@ -334,25 +329,24 @@ class Woo_Feed_Products_v3
|
|
334 |
* Organize Feed Attribute config
|
335 |
* @return array|bool
|
336 |
*/
|
337 |
-
public function get_attribute_config()
|
338 |
-
|
339 |
-
if (empty($this->config)) {
|
340 |
return false;
|
341 |
}
|
342 |
|
343 |
$attributeConfig = array();
|
344 |
$merchantAttributes = $this->config['mattributes'];
|
345 |
-
if (!empty($merchantAttributes)) {
|
346 |
$i = 0;
|
347 |
-
foreach ($merchantAttributes as $key => $value) {
|
348 |
-
$attributeConfig[$i]['mattributes'] = $value;
|
349 |
-
$attributeConfig[$i]['prefix'] = $this->config['prefix'][$key];
|
350 |
-
$attributeConfig[$i]['type'] = $this->config['type'][$key];
|
351 |
-
$attributeConfig[$i]['attributes'] = $this->config['attributes'][$key];
|
352 |
-
$attributeConfig[$i]['default'] = $this->config['default'][$key];
|
353 |
-
$attributeConfig[$i]['suffix'] = $this->config['suffix'][$key];
|
354 |
-
$attributeConfig[$i]['output_type'] = $this->config['output_type'][$key];
|
355 |
-
$attributeConfig[$i]['limit'] = $this->config['limit'][$key];
|
356 |
$i++;
|
357 |
}
|
358 |
}
|
@@ -369,10 +363,9 @@ class Woo_Feed_Products_v3
|
|
369 |
* @since 3.2.0
|
370 |
*
|
371 |
*/
|
372 |
-
public function get_products($productIds)
|
373 |
-
{
|
374 |
|
375 |
-
if (empty($productIds)) {
|
376 |
return [];
|
377 |
}
|
378 |
|
@@ -386,19 +379,19 @@ class Woo_Feed_Products_v3
|
|
386 |
*/
|
387 |
do_action('woo_feed_before_product_loop', $productIds, $this->config);
|
388 |
|
389 |
-
foreach ($productIds as $key => $pid) {
|
390 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Loading Product Data For %d.', $pid));
|
391 |
$product = wc_get_product($pid);
|
392 |
|
393 |
-
if ($this->exclude_from_loop($product)) {
|
394 |
continue;
|
395 |
}
|
396 |
|
397 |
-
if ($this->process_variation($product)) {
|
398 |
continue;
|
399 |
}
|
400 |
|
401 |
-
if (
|
402 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Matched with filter conditions');
|
403 |
continue;
|
404 |
}
|
@@ -406,7 +399,7 @@ class Woo_Feed_Products_v3
|
|
406 |
woo_feed_log_feed_process($this->config['filename'], 'Formatting Feed Data...');
|
407 |
|
408 |
// Add Single item wrapper before product info loop start
|
409 |
-
if ('xml' == $this->config['feedType']) {
|
410 |
$this->feedBody .= "\n";
|
411 |
$this->feedBody .= '<' . $this->config['itemWrapper'] . '>';
|
412 |
$this->feedBody .= "\n";
|
@@ -421,14 +414,14 @@ class Woo_Feed_Products_v3
|
|
421 |
woo_feed_log_feed_process($this->config['filename'], 'Processing Merchant Specific Fields');
|
422 |
// Process feed data for uncommon merchant feed like Google,Facebook,Pinterest
|
423 |
$this->process_for_merchant($product, $this->pi);
|
424 |
-
} catch (Exception $e) {
|
425 |
$message = 'Error Processing Merchant Specific Fields.' . PHP_EOL . 'Caught Exception :: ' . $e->getMessage();
|
426 |
woo_feed_log($this->config['filename'], $message, 'critical', $e, true);
|
427 |
woo_feed_log_fatal_error($message, $e);
|
428 |
}
|
429 |
|
430 |
-
if ('xml' == $this->config['feedType']) {
|
431 |
-
if (empty($this->feedHeader)) {
|
432 |
$this->feedHeader = $this->process_xml_feed_header();
|
433 |
$this->feedFooter = $this->process_xml_feed_footer();
|
434 |
|
@@ -437,13 +430,13 @@ class Woo_Feed_Products_v3
|
|
437 |
$this->feedBody .= '</' . $this->config['itemWrapper'] . '>';
|
438 |
|
439 |
|
440 |
-
} elseif ('txt' == $this->config['feedType']) {
|
441 |
-
if (empty($this->feedHeader)) {
|
442 |
$this->process_txt_feed_header();
|
443 |
}
|
444 |
$this->process_txt_feed_body();
|
445 |
} else {
|
446 |
-
if (empty($this->feedHeader)) {
|
447 |
$this->process_csv_feed_header();
|
448 |
}
|
449 |
$this->process_csv_feed_body();
|
@@ -472,14 +465,13 @@ class Woo_Feed_Products_v3
|
|
472 |
* @return bool
|
473 |
* @since 3.3.9
|
474 |
*/
|
475 |
-
protected function process_variation($product)
|
476 |
-
{
|
477 |
// Apply variable and variation settings
|
478 |
-
if ($product->is_type('variable') && $product->has_child()) {
|
479 |
$this->pi++;
|
480 |
$variations = $product->get_visible_children();
|
481 |
-
if (is_array($variations) && (sizeof($variations) > 0)) {
|
482 |
-
if (woo_feed_is_debugging_enabled()) {
|
483 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Getting Variation Product(s) :: %s', implode(', ', $variations)));
|
484 |
}
|
485 |
$this->get_products($variations);
|
@@ -497,44 +489,43 @@ class Woo_Feed_Products_v3
|
|
497 |
* @return void
|
498 |
* @since 3.3.9
|
499 |
*/
|
500 |
-
protected function process_attributes($product)
|
501 |
-
{
|
502 |
// Get Product Attribute values by type and assign to product array
|
503 |
-
foreach ($this->config['attributes'] as $attr_key => $attribute) {
|
504 |
|
505 |
-
$merchant_attribute = isset($this->config['mattributes'][$attr_key])
|
506 |
|
507 |
-
if ($this->exclude_current_attribute($product, $merchant_attribute, $attribute)) {
|
508 |
continue;
|
509 |
}
|
510 |
|
511 |
// Add Prefix and Suffix into Output
|
512 |
-
$prefix = $this->config['prefix'][$attr_key];
|
513 |
-
$suffix = $this->config['suffix'][$attr_key];
|
514 |
$merchant = $this->config['provider'];
|
515 |
$feedType = $this->config['feedType'];
|
516 |
|
517 |
-
if ('pattern' == $this->config['type'][$attr_key]) {
|
518 |
-
$attributeValue = $this->config['default'][$attr_key];
|
519 |
} else { // Get Pattern value
|
520 |
$attributeValue = $this->getAttributeValueByType($product, $attribute);
|
521 |
}
|
522 |
|
523 |
// Format Output according to Output Type config.
|
524 |
-
if (isset($this->config['output_type'][$attr_key])) {
|
525 |
-
$outputType = $this->config['output_type'][$attr_key];
|
526 |
-
$attributeValue = $this->format_output($attributeValue, $this->config['output_type'][$attr_key], $product, $attribute);
|
527 |
}
|
528 |
|
529 |
// Limit Output.
|
530 |
-
if (isset($this->config['limit'][$attr_key])) {
|
531 |
-
$attributeValue = $this->crop_string($attributeValue, 0, $this->config['limit'][$attr_key]);
|
532 |
}
|
533 |
|
534 |
// Process prefix and suffix.
|
535 |
$attributeValue = $this->process_prefix_suffix($attributeValue, $prefix, $suffix, $attribute);
|
536 |
|
537 |
-
if ('xml' == $feedType) {
|
538 |
|
539 |
// Replace XML Nodes according to merchant requirement.
|
540 |
$getReplacedAttribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
@@ -542,18 +533,18 @@ class Woo_Feed_Products_v3
|
|
542 |
// XML does not support space in node. So replace Space with Underscore.
|
543 |
$getReplacedAttribute = str_replace(' ', '_', $getReplacedAttribute);
|
544 |
|
545 |
-
if (!empty($attributeValue)) {
|
546 |
$attributeValue = trim($attributeValue);
|
547 |
}
|
548 |
|
549 |
// Add closing XML node if value is empty
|
550 |
-
if ('' != $attributeValue) {
|
551 |
// Add CDATA wrapper for XML feed to prevent XML error.
|
552 |
$attributeValue = woo_feed_add_cdata($merchant_attribute, $attributeValue, $merchant);
|
553 |
|
554 |
// TODO Move to proper place
|
555 |
// Replace Google Color attribute value according to requirements
|
556 |
-
if ('g:color' == $getReplacedAttribute) {
|
557 |
$attributeValue = str_replace(', ', '/', $attributeValue);
|
558 |
}
|
559 |
|
@@ -567,17 +558,17 @@ class Woo_Feed_Products_v3
|
|
567 |
$this->feedBody .= '<' . $getReplacedAttribute . '/>';
|
568 |
$this->feedBody .= "\n";
|
569 |
}
|
570 |
-
} elseif ('csv' == $feedType) {
|
571 |
$merchant_attribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
572 |
$merchant_attribute = $this->processStringForCSV($merchant_attribute);
|
573 |
$attributeValue = $this->processStringForCSV($attributeValue);
|
574 |
-
} elseif ('txt' == $feedType) {
|
575 |
$merchant_attribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
576 |
$merchant_attribute = $this->processStringForTXT($merchant_attribute);
|
577 |
$attributeValue = $this->processStringForTXT($attributeValue);
|
578 |
}
|
579 |
|
580 |
-
$this->products[$this->pi][$merchant_attribute] = $attributeValue;
|
581 |
}
|
582 |
}
|
583 |
|
@@ -591,22 +582,21 @@ class Woo_Feed_Products_v3
|
|
591 |
* @since 3.3.9
|
592 |
*
|
593 |
*/
|
594 |
-
protected function exclude_from_loop($product)
|
595 |
-
{
|
596 |
// For WP_Query check available product types
|
597 |
-
if ('wp' == $this->queryType && !in_array($product->get_type(), $this->product_types)) {
|
598 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Skipping Product :: Invalid Post/Product Type : %s.', $product->get_type()));
|
599 |
return true;
|
600 |
}
|
601 |
|
602 |
// Skip for invalid products
|
603 |
-
if (!is_object($product)) {
|
604 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Product data is not a valid WC_Product object.');
|
605 |
return true;
|
606 |
}
|
607 |
|
608 |
// Skip for invisible products
|
609 |
-
if (
|
610 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Product is not visible.');
|
611 |
return true;
|
612 |
}
|
@@ -627,22 +617,21 @@ class Woo_Feed_Products_v3
|
|
627 |
* @since 3.3.9
|
628 |
*
|
629 |
*/
|
630 |
-
protected function exclude_current_attribute($product, $merchant_attribute, $product_attribute, $feedType = 'xml')
|
631 |
-
|
632 |
-
if(empty($merchant_attribute)){
|
633 |
return true;
|
634 |
}
|
635 |
|
636 |
if (
|
637 |
$feedType == $this->config['feedType'] &&
|
638 |
in_array($this->config['provider'], array_keys($this->skipped_merchant_attributes)) &&
|
639 |
-
in_array($merchant_attribute, $this->skipped_merchant_attributes[$this->config['provider']])
|
640 |
|
641 |
) {
|
642 |
return true;
|
643 |
}
|
644 |
|
645 |
-
if ('shopping_ads_excluded_country'!== $merchant_attribute && in_array($merchant_attribute, $this->processed_merchant_attributes)) {
|
646 |
return true;
|
647 |
}
|
648 |
|
@@ -662,13 +651,12 @@ class Woo_Feed_Products_v3
|
|
662 |
*
|
663 |
* @return string
|
664 |
*/
|
665 |
-
protected function crop_string($string, $start = 0, $limit = null)
|
666 |
-
{
|
667 |
$limit = absint($limit);
|
668 |
-
if ($limit > 0) {
|
669 |
$start = absint($start);
|
670 |
-
if (strpos($string, '<![CDATA[') !== false) {
|
671 |
-
$string = str_replace(array('<![CDATA[', ']]>'), array('', ''), $string);
|
672 |
$string = substr($string, $start, $limit);
|
673 |
$string = '<![CDATA[' . $string . ']]>';
|
674 |
} else {
|
@@ -687,18 +675,17 @@ class Woo_Feed_Products_v3
|
|
687 |
* @since 3.2.0
|
688 |
*
|
689 |
*/
|
690 |
-
protected function process_for_merchant($productObj, $index)
|
691 |
-
|
692 |
-
$product = $this->products[$index];
|
693 |
$merchantAttributes = $this->config['mattributes'];
|
694 |
|
695 |
// Format Shipping and Tax data for CSV and TXT feed only for google and facebook
|
696 |
-
if ('xml' != $this->config['feedType'] && in_array($this->config['provider'], ['google', 'facebook'])) {
|
697 |
|
698 |
$shipping = array();
|
699 |
$tax = array();
|
700 |
$installment = array();
|
701 |
-
$product_detail=array();
|
702 |
$s = 0; // Shipping Index
|
703 |
$t = 0; // Tax Index
|
704 |
$i = 0; // Installment Index
|
@@ -716,46 +703,46 @@ class Woo_Feed_Products_v3
|
|
716 |
'attribute_name',
|
717 |
'attribute_value',
|
718 |
);
|
719 |
-
foreach ($this->products[$this->pi] as $attribute => $value) {
|
720 |
-
if (in_array($attribute, $shippingAttr)) {
|
721 |
|
722 |
-
if ('tax_country' == $attribute) {
|
723 |
$t++;
|
724 |
-
$tax[$t] .= $value . ':';
|
725 |
-
} elseif ('tax_region' == $attribute) {
|
726 |
-
$tax[$t] .= $value . ':';
|
727 |
-
} elseif ('tax_rate' == $attribute) {
|
728 |
-
$tax[$t] .= $value . ':';
|
729 |
-
} elseif ('tax_ship' == $attribute) {
|
730 |
-
$tax[$t] .= $value . ':';
|
731 |
}
|
732 |
|
733 |
-
if ('shipping_country' == $attribute) {
|
734 |
$s++;
|
735 |
-
$shipping[$s] .= $value . ':';
|
736 |
-
} elseif ('shipping_service' == $attribute) {
|
737 |
-
$shipping[$s] .= $value . ':';
|
738 |
-
} elseif ('shipping_price' == $attribute) {
|
739 |
-
$shipping[$s] .= $value . ':';
|
740 |
-
} elseif ('shipping_region' == $attribute) {
|
741 |
-
$shipping[$s] .= $value . ':';
|
742 |
}
|
743 |
|
744 |
|
745 |
-
unset($this->products[$this->pi][$attribute]);
|
746 |
}
|
747 |
}
|
748 |
|
749 |
-
foreach ($shipping as $key => $val) {
|
750 |
-
$this->products[$this->pi]['shipping(country:region:service:price)'] = $val;
|
751 |
}
|
752 |
|
753 |
-
foreach ($tax as $key => $val) {
|
754 |
-
$this->products[$this->pi]['tax(country:region:rate:tax_ship)'] = $val;
|
755 |
}
|
756 |
}
|
757 |
|
758 |
-
if ('google' == $this->config['provider']) {
|
759 |
|
760 |
// Reformat Shipping attributes for google, facebook
|
761 |
$t = 0;
|
@@ -764,42 +751,42 @@ class Woo_Feed_Products_v3
|
|
764 |
$shipping = '';
|
765 |
$sub = 0;
|
766 |
$subscription = '';
|
767 |
-
$product_detail='';
|
768 |
-
$pd=0;
|
769 |
-
if ('xml' == $this->config['feedType']) {
|
770 |
-
foreach ($merchantAttributes as $key => $value) {
|
771 |
|
772 |
-
if (!in_array($value, $this->google_shipping_tax)) {
|
773 |
continue;
|
774 |
}
|
775 |
|
776 |
-
$prefix = $this->config['prefix'][$key];
|
777 |
-
$suffix = $this->config['suffix'][$key];
|
778 |
|
779 |
-
if ('pattern' == $this->config['type'][$key]) {
|
780 |
-
$output = $this->config['default'][$key];
|
781 |
} else { // Get Pattern value.
|
782 |
-
$attribute = $this->config['attributes'][$key];
|
783 |
$output = $this->getAttributeValueByType($productObj, $attribute);
|
784 |
}
|
785 |
|
786 |
-
if (false !== strpos($value, 'price') || false !== strpos($value, 'rate')) {
|
787 |
$suffix = '' . $suffix;
|
788 |
}
|
789 |
|
790 |
|
791 |
$output = $prefix . $output . $suffix;
|
792 |
|
793 |
-
if ('shipping_country' == $value) {
|
794 |
-
if (0 == $s) {
|
795 |
$shipping .= '<g:shipping>';
|
796 |
$s = 1;
|
797 |
} else {
|
798 |
$shipping .= '</g:shipping>' . "\n";
|
799 |
$shipping .= '<g:shipping>';
|
800 |
}
|
801 |
-
} elseif (!in_array('shipping_country', $merchantAttributes) && 'shipping_price' == $value) {
|
802 |
-
if (0 == $s) {
|
803 |
$shipping .= '<g:shipping>';
|
804 |
$s = 1;
|
805 |
} else {
|
@@ -808,16 +795,16 @@ class Woo_Feed_Products_v3
|
|
808 |
}
|
809 |
}
|
810 |
|
811 |
-
if ('shipping_country' == $value) {
|
812 |
$shipping .= '<g:country>' . $output . '</g:country>' . "\n";
|
813 |
-
} elseif ('shipping_region' == $value) {
|
814 |
$shipping .= '<g:region>' . $output . '</g:region>' . "\n";
|
815 |
-
} elseif ('shipping_service' == $value) {
|
816 |
$shipping .= '<g:service>' . $output . '</g:service>' . "\n";
|
817 |
-
} elseif ('shipping_price' == $value) {
|
818 |
$shipping .= '<g:price>' . $output . '</g:price>' . "\n";
|
819 |
-
} elseif ('tax_country' == $value) {
|
820 |
-
if (0 == $t) {
|
821 |
$tax .= '<g:tax>';
|
822 |
$t = 1;
|
823 |
} else {
|
@@ -825,11 +812,11 @@ class Woo_Feed_Products_v3
|
|
825 |
$tax .= '<g:tax>';
|
826 |
}
|
827 |
$tax .= '<g:country>' . $output . '</g:country>' . "\n";
|
828 |
-
} elseif ('tax_region' == $value) {
|
829 |
$tax .= '<g:region>' . $output . '</g:region>' . "\n";
|
830 |
-
} elseif ('tax_rate' == $value) {
|
831 |
$tax .= '<g:rate>' . $output . '</g:rate>' . "\n";
|
832 |
-
} elseif ('tax_ship' == $value) {
|
833 |
$tax .= '<g:tax_ship>' . $output . '</g:tax_ship>' . "\n";
|
834 |
}elseif ( 'subscription_period' == $value ) {
|
835 |
if ( 0 == $sub ) {
|
@@ -844,16 +831,16 @@ class Woo_Feed_Products_v3
|
|
844 |
$subscription .= '<g:period_length>' . $output . '</g:period_length>' . "\n";
|
845 |
}elseif ( 'subscription_amount' == $value ) {
|
846 |
$subscription .= '<g:amount>' . $output . '</g:amount>' . "\n";
|
847 |
-
}
|
848 |
-
if (0 == $pd) {
|
849 |
$product_detail .= '<g:product_detail>';
|
850 |
$pd = 1;
|
851 |
} else {
|
852 |
$product_detail .= '</g:product_detail>' . "\n";
|
853 |
$product_detail .= '<g:product_detail>';
|
854 |
}
|
855 |
-
} elseif (!in_array('section_name', $merchantAttributes) && 'attribute_name' == $value) {
|
856 |
-
if (0 == $pd) {
|
857 |
$product_detail .= '<g:product_detail>';
|
858 |
$pd = 1;
|
859 |
} else {
|
@@ -871,14 +858,14 @@ class Woo_Feed_Products_v3
|
|
871 |
}
|
872 |
}
|
873 |
|
874 |
-
if (1 == $pd) {
|
875 |
$product_detail .= '</g:product_detail>';
|
876 |
}
|
877 |
|
878 |
-
if (1 == $s) {
|
879 |
$shipping .= '</g:shipping>';
|
880 |
}
|
881 |
-
if (1 == $t) {
|
882 |
$tax .= '</g:tax>';
|
883 |
}
|
884 |
|
@@ -890,47 +877,47 @@ class Woo_Feed_Products_v3
|
|
890 |
$this->feedBody .= $tax;
|
891 |
$this->feedBody .= $product_detail;
|
892 |
|
893 |
-
if($productObj->is_type('subscription') ||
|
894 |
$productObj->is_type('variable-subscription') ||
|
895 |
-
$productObj->is_type('subscription_variation')){
|
896 |
$this->feedBody .= $subscription;
|
897 |
}
|
898 |
}
|
899 |
// ADD g:identifier_exists
|
900 |
-
$identifier = array('brand', 'upc', 'sku', 'mpn', 'gtin');
|
901 |
$countIdentifier = 0;
|
902 |
-
if (!in_array('identifier_exists', $merchantAttributes)) {
|
903 |
-
if (count(array_intersect_key(array_flip($identifier), $product)) >= 2) {
|
904 |
// Any 2 required keys exist!
|
905 |
// @TODO Refactor with OR
|
906 |
-
if (array_key_exists('brand', $product) && !empty($product['brand'])) {
|
907 |
$countIdentifier++;
|
908 |
}
|
909 |
-
if (array_key_exists('upc', $product) && !empty($product['upc'])) {
|
910 |
$countIdentifier++;
|
911 |
}
|
912 |
-
if (array_key_exists('sku', $product) && !empty($product['sku'])) {
|
913 |
$countIdentifier++;
|
914 |
}
|
915 |
-
if (array_key_exists('mpn', $product) && !empty($product['mpn'])) {
|
916 |
$countIdentifier++;
|
917 |
}
|
918 |
-
if (array_key_exists('gtin', $product) && !empty($product['gtin'])) {
|
919 |
$countIdentifier++;
|
920 |
}
|
921 |
}
|
922 |
|
923 |
-
if ('xml' == $this->config['feedType']) {
|
924 |
-
if ($countIdentifier >= 2) {
|
925 |
$this->feedBody .= '<g:identifier_exists>yes</g:identifier_exists>';
|
926 |
} else {
|
927 |
$this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
|
928 |
}
|
929 |
} else {
|
930 |
-
if ($countIdentifier >= 2) {
|
931 |
-
$this->products[$this->pi]['identifier exists'] = 'yes';
|
932 |
} else {
|
933 |
-
$this->products[$this->pi]['identifier exists'] = 'no';
|
934 |
}
|
935 |
}
|
936 |
}
|
@@ -941,13 +928,11 @@ class Woo_Feed_Products_v3
|
|
941 |
* Get Query Type Settings
|
942 |
* @return string
|
943 |
*/
|
944 |
-
public function get_query_type()
|
945 |
-
{
|
946 |
return $this->queryType;
|
947 |
}
|
948 |
|
949 |
-
public function get_product_types()
|
950 |
-
{
|
951 |
return $this->product_types;
|
952 |
}
|
953 |
|
@@ -958,21 +943,20 @@ class Woo_Feed_Products_v3
|
|
958 |
* @since 3.2.0
|
959 |
*
|
960 |
*/
|
961 |
-
protected function process_txt_feed_header()
|
962 |
-
{
|
963 |
// Set Delimiter
|
964 |
-
if ('tab' == $this->config['delimiter']) {
|
965 |
$this->delimiter = "\t";
|
966 |
} else {
|
967 |
$this->delimiter = $this->config['delimiter'];
|
968 |
}
|
969 |
|
970 |
// Set Enclosure
|
971 |
-
if (!empty($this->config['enclosure'])) {
|
972 |
$this->enclosure = $this->config['enclosure'];
|
973 |
-
if ('double' == $this->enclosure) {
|
974 |
$this->enclosure = '"';
|
975 |
-
} elseif ('single' == $this->enclosure) {
|
976 |
$this->enclosure = "'";
|
977 |
} else {
|
978 |
$this->enclosure = '';
|
@@ -982,17 +966,17 @@ class Woo_Feed_Products_v3
|
|
982 |
}
|
983 |
|
984 |
$eol = PHP_EOL;
|
985 |
-
if ('trovaprezzi' === $this->config['provider']) {
|
986 |
$eol = '<endrecord>' . PHP_EOL;
|
987 |
}
|
988 |
|
989 |
-
$product = $this->products[$this->pi];
|
990 |
$headers = array_keys($product);
|
991 |
$this->feedHeader .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $headers) . $this->enclosure . $eol;
|
992 |
|
993 |
-
if('google'
|
994 |
-
$this->feedHeader=str_replace($this->google_product_highlights,'product highlight',$this->feedHeader);
|
995 |
-
$this->feedHeader=str_replace($this->google_additional_image,'additional image link',$this->feedHeader);
|
996 |
}
|
997 |
|
998 |
return $this->feedHeader;
|
@@ -1005,11 +989,10 @@ class Woo_Feed_Products_v3
|
|
1005 |
* @since 3.2.0
|
1006 |
*
|
1007 |
*/
|
1008 |
-
protected function process_txt_feed_body()
|
1009 |
-
|
1010 |
-
$productInfo = array_values($this->products[$this->pi]);
|
1011 |
$eol = PHP_EOL;
|
1012 |
-
if ('trovaprezzi' === $this->config['provider']) {
|
1013 |
$eol = '<endrecord>' . PHP_EOL;
|
1014 |
}
|
1015 |
$this->feedBody .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $productInfo) . $this->enclosure . $eol;
|
@@ -1024,21 +1007,20 @@ class Woo_Feed_Products_v3
|
|
1024 |
* @since 3.2.0
|
1025 |
*
|
1026 |
*/
|
1027 |
-
protected function process_csv_feed_header()
|
1028 |
-
{
|
1029 |
// Set Delimiter
|
1030 |
-
if ('tab' == $this->config['delimiter']) {
|
1031 |
$this->delimiter = "\t";
|
1032 |
} else {
|
1033 |
$this->delimiter = $this->config['delimiter'];
|
1034 |
}
|
1035 |
|
1036 |
// Set Enclosure
|
1037 |
-
if (!empty($this->config['enclosure'])) {
|
1038 |
$this->enclosure = $this->config['enclosure'];
|
1039 |
-
if ('double' == $this->enclosure) {
|
1040 |
$this->enclosure = '"';
|
1041 |
-
} elseif ('single' == $this->enclosure) {
|
1042 |
$this->enclosure = "'";
|
1043 |
} else {
|
1044 |
$this->enclosure = '';
|
@@ -1047,12 +1029,12 @@ class Woo_Feed_Products_v3
|
|
1047 |
$this->enclosure = '';
|
1048 |
}
|
1049 |
|
1050 |
-
$product = $this->products[$this->pi];
|
1051 |
$this->feedHeader = array_keys($product);
|
1052 |
|
1053 |
-
if('google'
|
1054 |
-
$this->feedHeader=str_replace($this->google_product_highlights,'product highlight',$this->feedHeader);
|
1055 |
-
$this->feedHeader=str_replace($this->google_additional_image,'additional image link',$this->feedHeader);
|
1056 |
}
|
1057 |
|
1058 |
return $this->feedHeader;
|
@@ -1063,16 +1045,14 @@ class Woo_Feed_Products_v3
|
|
1063 |
* @return array
|
1064 |
* @since 3.2.0
|
1065 |
*/
|
1066 |
-
protected function process_csv_feed_body()
|
1067 |
-
|
1068 |
-
$product = $this->products[$this->pi];
|
1069 |
$this->feedBody[] = array_values($product);
|
1070 |
|
1071 |
return $this->feedBody;
|
1072 |
}
|
1073 |
|
1074 |
-
protected function process_xml_wrapper()
|
1075 |
-
{
|
1076 |
|
1077 |
$this->xml_wrapper = [
|
1078 |
'header' => '<?xml version="1.0" encoding="UTF-8" ?>' . PHP_EOL . '<' . $this->config['itemsWrapper'] . '>',
|
@@ -1081,17 +1061,17 @@ class Woo_Feed_Products_v3
|
|
1081 |
$this->config['itemWrapper'] = str_replace(' ', '_', $this->config['itemWrapper']);
|
1082 |
$this->config['itemsWrapper'] = str_replace(' ', '_', $this->config['itemsWrapper']);
|
1083 |
|
1084 |
-
if (file_exists(WOO_FEED_FREE_ADMIN_PATH . 'partials/templates/' . $this->config['provider'] . '.txt')) {
|
1085 |
$txt = file_get_contents(WOO_FEED_FREE_ADMIN_PATH . 'partials/templates/' . $this->config['provider'] . '.txt');
|
1086 |
$txt = trim($txt);
|
1087 |
$txt = explode('{separator}', $txt);
|
1088 |
-
if (2 === count($txt)) {
|
1089 |
$this->xml_wrapper['header'] = trim($txt[0]);
|
1090 |
$this->xml_wrapper['footer'] = trim($txt[1]);
|
1091 |
}
|
1092 |
}
|
1093 |
|
1094 |
-
if (!empty($this->config['extraHeader'])) {
|
1095 |
$this->xml_wrapper['header'] .= PHP_EOL . $this->config['extraHeader'];
|
1096 |
}
|
1097 |
|
@@ -1103,8 +1083,8 @@ class Woo_Feed_Products_v3
|
|
1103 |
$blog_email = get_bloginfo('admin_email'); // {BlogEmail}
|
1104 |
|
1105 |
$this->xml_wrapper['header'] = str_replace(
|
1106 |
-
['{DateTimeNow}', '{BlogName}', '{BlogURL}', '{BlogDescription}', '{BlogEmail}'],
|
1107 |
-
[$datetime_now, $blog_name, $blog_url, $blog_desc, $blog_email],
|
1108 |
$this->xml_wrapper['header']
|
1109 |
);
|
1110 |
}
|
@@ -1114,8 +1094,7 @@ class Woo_Feed_Products_v3
|
|
1114 |
* @return string
|
1115 |
* @since 3.2.0
|
1116 |
*/
|
1117 |
-
protected function process_xml_feed_header()
|
1118 |
-
{
|
1119 |
return $this->xml_wrapper['header'];
|
1120 |
}
|
1121 |
|
@@ -1124,8 +1103,7 @@ class Woo_Feed_Products_v3
|
|
1124 |
* @return string
|
1125 |
* @since 3.2.0
|
1126 |
*/
|
1127 |
-
protected function process_xml_feed_footer()
|
1128 |
-
{
|
1129 |
return $this->xml_wrapper['footer'];
|
1130 |
}
|
1131 |
|
@@ -1138,12 +1116,11 @@ class Woo_Feed_Products_v3
|
|
1138 |
* @since 3.2.0
|
1139 |
*
|
1140 |
*/
|
1141 |
-
protected function processStringForTXT($string)
|
1142 |
-
|
1143 |
-
if (!empty($string)) {
|
1144 |
$string = html_entity_decode($string, ENT_HTML401 | ENT_QUOTES); // Convert any HTML entities
|
1145 |
|
1146 |
-
if (stristr($string, '"')) {
|
1147 |
$string = str_replace('"', '""', $string);
|
1148 |
}
|
1149 |
$string = str_replace("\n", ' ', $string);
|
@@ -1153,7 +1130,7 @@ class Woo_Feed_Products_v3
|
|
1153 |
$string = stripslashes($string);
|
1154 |
|
1155 |
return $string;
|
1156 |
-
} elseif ('0' == $string) {
|
1157 |
return '0';
|
1158 |
} else {
|
1159 |
return '';
|
@@ -1169,16 +1146,15 @@ class Woo_Feed_Products_v3
|
|
1169 |
* @since 3.2.0
|
1170 |
*
|
1171 |
*/
|
1172 |
-
protected function processStringForCSV($string)
|
1173 |
-
|
1174 |
-
if (!empty($string)) {
|
1175 |
$string = str_replace("\n", ' ', $string);
|
1176 |
$string = str_replace("\r", ' ', $string);
|
1177 |
$string = trim($string);
|
1178 |
$string = stripslashes($string);
|
1179 |
|
1180 |
return $string;
|
1181 |
-
} elseif ('0' == $string) {
|
1182 |
return '0';
|
1183 |
} else {
|
1184 |
return '';
|
@@ -1195,37 +1171,36 @@ class Woo_Feed_Products_v3
|
|
1195 |
* @since 3.2.0
|
1196 |
*
|
1197 |
*/
|
1198 |
-
protected function getAttributeValueByType($product, $attribute)
|
1199 |
-
{
|
1200 |
|
1201 |
-
if (method_exists($this, $attribute)) {
|
1202 |
-
$output = call_user_func_array(array($this, $attribute), array($product));
|
1203 |
-
} elseif (false !== strpos($attribute, self::PRODUCT_ATTRIBUTE_PREFIX)) {
|
1204 |
$attribute = str_replace(self::PRODUCT_ATTRIBUTE_PREFIX, '', $attribute);
|
1205 |
$output = $this->getProductAttribute($product, $attribute);
|
1206 |
-
} elseif (false !== strpos($attribute, self::POST_META_PREFIX)) {
|
1207 |
$attribute = str_replace(self::POST_META_PREFIX, '', $attribute);
|
1208 |
$output = $this->getProductMeta($product, $attribute);
|
1209 |
-
} elseif (false !== strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX)) {
|
1210 |
$attribute = str_replace(self::PRODUCT_TAXONOMY_PREFIX, '', $attribute);
|
1211 |
$output = $this->getProductTaxonomy($product, $attribute);
|
1212 |
}elseif ( false !== strpos( $attribute, self::PRODUCT_CATEGORY_MAPPING_PREFIX ) ) {
|
1213 |
$id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
|
1214 |
$output = woo_feed_get_category_mapping_value( $attribute, $id );
|
1215 |
-
} elseif ('image_' == substr($attribute, 0, 6)) {
|
1216 |
// For additional image method images() will be used with extra parameter - image number
|
1217 |
$imageKey = explode('_', $attribute);
|
1218 |
-
if (!isset($imageKey[1]) || (isset($imageKey[1]) && (empty($imageKey[1]) || !is_numeric($imageKey[1])))) {
|
1219 |
$imageKey[1] = '';
|
1220 |
}
|
1221 |
-
$output = call_user_func_array(array($this, 'images'), array($product, $imageKey[1]));
|
1222 |
} else {
|
1223 |
// return the attribute so multiple attribute can be join with separator to make custom attribute.
|
1224 |
$output = $attribute;
|
1225 |
}
|
1226 |
|
1227 |
// Json encode if value is an array
|
1228 |
-
if (is_array($output)) {
|
1229 |
$output = wp_json_encode($output);
|
1230 |
}
|
1231 |
|
@@ -1276,8 +1251,7 @@ class Woo_Feed_Products_v3
|
|
1276 |
* @return mixed
|
1277 |
* @since 3.2.0
|
1278 |
*/
|
1279 |
-
protected function id($product)
|
1280 |
-
{
|
1281 |
return $product->get_id();
|
1282 |
}
|
1283 |
|
@@ -1290,8 +1264,7 @@ class Woo_Feed_Products_v3
|
|
1290 |
* @since 3.2.0
|
1291 |
*
|
1292 |
*/
|
1293 |
-
protected function title($product)
|
1294 |
-
{
|
1295 |
|
1296 |
return $this->remove_short_codes($product->get_name());
|
1297 |
}
|
@@ -1305,19 +1278,18 @@ class Woo_Feed_Products_v3
|
|
1305 |
* @since 3.2.0
|
1306 |
*
|
1307 |
*/
|
1308 |
-
protected function yoast_wpseo_title($product)
|
1309 |
-
{
|
1310 |
$yoast_title = get_post_meta($product->get_id(), '_yoast_wpseo_title', true);
|
1311 |
-
if (strpos($yoast_title, '%%') !== false) {
|
1312 |
$title = strstr($yoast_title, '%%', true);
|
1313 |
-
if (empty($title)) {
|
1314 |
$title = get_the_title($product->get_id());
|
1315 |
}
|
1316 |
$wpseo_titles = get_option('wpseo_titles');
|
1317 |
|
1318 |
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
|
1319 |
-
if (isset($wpseo_titles['separator']) && isset($sep_options[$wpseo_titles['separator']])) {
|
1320 |
-
$sep = $sep_options[$wpseo_titles['separator']];
|
1321 |
} else {
|
1322 |
$sep = '-'; //setting default separator if Admin didn't set it from backed
|
1323 |
}
|
@@ -1326,10 +1298,10 @@ class Woo_Feed_Products_v3
|
|
1326 |
|
1327 |
$meta_title = $title . ' ' . $sep . ' ' . $site_title;
|
1328 |
|
1329 |
-
if (!empty($meta_title)) {
|
1330 |
return $meta_title;
|
1331 |
}
|
1332 |
-
}elseif (!empty($yoast_title)){
|
1333 |
return $yoast_title;
|
1334 |
}
|
1335 |
|
@@ -1353,27 +1325,26 @@ class Woo_Feed_Products_v3
|
|
1353 |
* @since 3.2.0
|
1354 |
*
|
1355 |
*/
|
1356 |
-
protected function _aioseop_title($product)
|
1357 |
-
{
|
1358 |
$title = '';
|
1359 |
-
if (class_exists('All_in_One_SEO_Pack')) {
|
1360 |
global $aioseop_options, $aiosp;
|
1361 |
-
if (!is_array($aioseop_options)) {
|
1362 |
$aioseop_options = get_option('aioseop_options');
|
1363 |
}
|
1364 |
-
if (!($aiosp instanceof All_in_One_SEO_Pack)) {
|
1365 |
$aiosp = new All_in_One_SEO_Pack();
|
1366 |
}
|
1367 |
|
1368 |
-
if (in_array('product', $aioseop_options['aiosp_cpostactive'], true)) {
|
1369 |
-
if (!empty($aioseop_options['aiosp_rewrite_titles'])) {
|
1370 |
$title = $aiosp->get_aioseop_title(get_post($product->get_id()));
|
1371 |
$title = $aiosp->apply_cf_fields($title);
|
1372 |
}
|
1373 |
$title = apply_filters('aioseop_title', $title);
|
1374 |
}
|
1375 |
}
|
1376 |
-
if (!empty($title)) {
|
1377 |
return $title;
|
1378 |
}
|
1379 |
|
@@ -1389,22 +1360,21 @@ class Woo_Feed_Products_v3
|
|
1389 |
* @since 3.2.0
|
1390 |
*
|
1391 |
*/
|
1392 |
-
protected function description($product)
|
1393 |
-
{
|
1394 |
|
1395 |
$description = $product->get_description();
|
1396 |
|
1397 |
// Get Variation Description
|
1398 |
-
if ($product->is_type('variation') && empty($description)) {
|
1399 |
$parent = wc_get_product($product->get_parent_id());
|
1400 |
$description = $parent->get_description();
|
1401 |
}
|
1402 |
$description = $this->remove_short_codes($description);
|
1403 |
|
1404 |
// Add variations attributes after description to prevent Facebook error
|
1405 |
-
if ('facebook' == $this->config['provider']) {
|
1406 |
$variationInfo = explode('-', $product->get_name());
|
1407 |
-
if (isset($variationInfo[1])) {
|
1408 |
$extension = $variationInfo[1];
|
1409 |
} else {
|
1410 |
$extension = $product->get_id();
|
@@ -1424,14 +1394,13 @@ class Woo_Feed_Products_v3
|
|
1424 |
* @since 3.2.0
|
1425 |
*
|
1426 |
*/
|
1427 |
-
protected function yoast_wpseo_metadesc($product)
|
1428 |
-
{
|
1429 |
$description = '';
|
1430 |
-
if (class_exists('WPSEO_Frontend')) {
|
1431 |
$description = wpseo_replace_vars(WPSEO_Meta::get_value('metadesc', $product->get_id()),
|
1432 |
get_post($product->get_id()));
|
1433 |
}
|
1434 |
-
if (!empty($description)) {
|
1435 |
return $description;
|
1436 |
}
|
1437 |
|
@@ -1447,25 +1416,24 @@ class Woo_Feed_Products_v3
|
|
1447 |
* @since 3.2.0
|
1448 |
*
|
1449 |
*/
|
1450 |
-
protected function _aioseop_description($product)
|
1451 |
-
{
|
1452 |
$description = '';
|
1453 |
-
if (class_exists('All_in_One_SEO_Pack')) {
|
1454 |
global $aioseop_options, $aiosp;
|
1455 |
-
if (!is_array($aioseop_options)) {
|
1456 |
$aioseop_options = get_option('aioseop_options');
|
1457 |
}
|
1458 |
-
if (!($aiosp instanceof All_in_One_SEO_Pack)) {
|
1459 |
$aiosp = new All_in_One_SEO_Pack();
|
1460 |
}
|
1461 |
-
if (in_array('product', $aioseop_options['aiosp_cpostactive'], true)) {
|
1462 |
$description = $aiosp->get_main_description(get_post($product->get_id())); // Get the description.
|
1463 |
$description = $aiosp->trim_description($description);
|
1464 |
$description = apply_filters('aioseop_description_full',
|
1465 |
$aiosp->apply_description_format($description, get_post($product->get_id())));
|
1466 |
}
|
1467 |
}
|
1468 |
-
if (!empty($description)) {
|
1469 |
return $description;
|
1470 |
}
|
1471 |
|
@@ -1481,13 +1449,12 @@ class Woo_Feed_Products_v3
|
|
1481 |
* @since 3.2.0
|
1482 |
*
|
1483 |
*/
|
1484 |
-
protected function short_description($product)
|
1485 |
-
{
|
1486 |
|
1487 |
$short_description = $product->get_short_description();
|
1488 |
|
1489 |
// Get Variation Short Description
|
1490 |
-
if ($product->is_type('variation') && empty($short_description)) {
|
1491 |
$parent = wc_get_product($product->get_parent_id());
|
1492 |
$short_description = $parent->get_short_description();
|
1493 |
}
|
@@ -1538,22 +1505,21 @@ class Woo_Feed_Products_v3
|
|
1538 |
* @return string
|
1539 |
*
|
1540 |
*/
|
1541 |
-
protected function primary_category($product)
|
1542 |
-
{
|
1543 |
$id = $product->get_id();
|
1544 |
-
if ($product->is_type('variation')) {
|
1545 |
$id = $product->get_parent_id();
|
1546 |
}
|
1547 |
$wpseo_primary_term = false;
|
1548 |
$main_category = '';
|
1549 |
-
if (class_exists('WPSEO_Primary_Term')) {
|
1550 |
$wpseo_primary_term = new WPSEO_Primary_Term('product_cat', $id);
|
1551 |
$main_category = $wpseo_primary_term->get_primary_term();
|
1552 |
$main_category = get_term($main_category, 'product_cat');
|
1553 |
}
|
1554 |
-
if (!($wpseo_primary_term instanceof WPSEO_Primary_Term) || empty($main_category)) {
|
1555 |
$term = wp_get_post_terms($id, 'product_cat');
|
1556 |
-
if (!is_wp_error($term) && !empty($term)) {
|
1557 |
$main_category = $term[0];
|
1558 |
}
|
1559 |
}
|
@@ -1569,22 +1535,21 @@ class Woo_Feed_Products_v3
|
|
1569 |
* @return string
|
1570 |
*
|
1571 |
*/
|
1572 |
-
protected function primary_category_id($product)
|
1573 |
-
{
|
1574 |
$id = $product->get_id();
|
1575 |
-
if ($product->is_type('variation')) {
|
1576 |
$id = $product->get_parent_id();
|
1577 |
}
|
1578 |
$wpseo_primary_term = false;
|
1579 |
$main_category = '';
|
1580 |
-
if (class_exists('WPSEO_Primary_Term')) {
|
1581 |
$wpseo_primary_term = new WPSEO_Primary_Term('product_cat', $id);
|
1582 |
$main_category = $wpseo_primary_term->get_primary_term();
|
1583 |
$main_category = get_term($main_category, 'product_cat');
|
1584 |
}
|
1585 |
-
if (!($wpseo_primary_term instanceof WPSEO_Primary_Term) || empty($main_category)) {
|
1586 |
$term = wp_get_post_terms($id, 'product_cat');
|
1587 |
-
if (!is_wp_error($term) && !empty($term)) {
|
1588 |
$main_category = $term[0];
|
1589 |
}
|
1590 |
}
|
@@ -1603,7 +1568,7 @@ class Woo_Feed_Products_v3
|
|
1603 |
$id = $product->get_id();
|
1604 |
$terms = get_the_terms( $id, 'product_cat' );
|
1605 |
$last_cat = ! empty($terms) && is_array($terms) ? end($terms) : [];
|
1606 |
-
$child_category = isset($last_cat->name) && !empty($last_cat->name) ? $last_cat->name : '';
|
1607 |
|
1608 |
return $child_category;
|
1609 |
}
|
@@ -1631,10 +1596,9 @@ class Woo_Feed_Products_v3
|
|
1631 |
* @since 3.2.0
|
1632 |
*
|
1633 |
*/
|
1634 |
-
protected function product_type($product)
|
1635 |
-
{
|
1636 |
$id = $product->get_id();
|
1637 |
-
if ($product->is_type('variation')) {
|
1638 |
$id = $product->get_parent_id();
|
1639 |
}
|
1640 |
|
@@ -1652,16 +1616,15 @@ class Woo_Feed_Products_v3
|
|
1652 |
* @since 3.2.0
|
1653 |
*
|
1654 |
*/
|
1655 |
-
protected function link($product)
|
1656 |
-
{
|
1657 |
$utm = $this->config['campaign_parameters'];
|
1658 |
-
if (!empty($utm['utm_source']) && !empty($utm['utm_medium']) && !empty($utm['utm_campaign'])) {
|
1659 |
$utm = [
|
1660 |
-
'utm_source'
|
1661 |
-
'utm_medium'
|
1662 |
'utm_campaign' => $utm['utm_campaign'],
|
1663 |
-
'utm_term'
|
1664 |
-
'utm_content'
|
1665 |
];
|
1666 |
|
1667 |
return add_query_arg(array_filter($utm), $product->get_permalink());
|
@@ -1675,9 +1638,9 @@ class Woo_Feed_Products_v3
|
|
1675 |
* @param WC_Product $product
|
1676 |
* @return mixed
|
1677 |
*/
|
1678 |
-
protected function canonical_link($product){
|
1679 |
-
if ($product->is_type('variation')) {
|
1680 |
-
$product=wc_get_product($product->get_parent_id());
|
1681 |
return $product->get_permalink();
|
1682 |
}
|
1683 |
|
@@ -1693,9 +1656,8 @@ class Woo_Feed_Products_v3
|
|
1693 |
* @since 3.2.0
|
1694 |
*
|
1695 |
*/
|
1696 |
-
protected function ex_link($product)
|
1697 |
-
|
1698 |
-
if ($product->is_type('external')) {
|
1699 |
return $product->get_product_url();
|
1700 |
}
|
1701 |
|
@@ -1711,12 +1673,11 @@ class Woo_Feed_Products_v3
|
|
1711 |
* @since 3.2.0
|
1712 |
*
|
1713 |
*/
|
1714 |
-
protected function image($product)
|
1715 |
-
|
1716 |
-
if ($product->is_type('variation')) {
|
1717 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_id()),
|
1718 |
'single-post-thumbnail');
|
1719 |
-
if (has_post_thumbnail($product->get_id()) && !empty($getImage[0])) :
|
1720 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
1721 |
else :
|
1722 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()),
|
@@ -1724,7 +1685,7 @@ class Woo_Feed_Products_v3
|
|
1724 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
1725 |
endif;
|
1726 |
} else {
|
1727 |
-
if (has_post_thumbnail($product->get_id())) :
|
1728 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_id()),
|
1729 |
'single-post-thumbnail');
|
1730 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
@@ -1745,8 +1706,7 @@ class Woo_Feed_Products_v3
|
|
1745 |
* @since 3.2.0
|
1746 |
*
|
1747 |
*/
|
1748 |
-
protected function feature_image($product)
|
1749 |
-
{
|
1750 |
return $this->image($product);
|
1751 |
}
|
1752 |
|
@@ -1760,9 +1720,8 @@ class Woo_Feed_Products_v3
|
|
1760 |
* @since 3.2.0
|
1761 |
*
|
1762 |
*/
|
1763 |
-
protected function images($product, $additionalImg = '')
|
1764 |
-
|
1765 |
-
if ($product->is_type('variation')) {
|
1766 |
// TODO Test Variation Images
|
1767 |
$imgUrls = $this->get_product_gallery(wc_get_product($product->get_parent_id()));
|
1768 |
} else {
|
@@ -1770,9 +1729,9 @@ class Woo_Feed_Products_v3
|
|
1770 |
}
|
1771 |
|
1772 |
// Return Specific Additional Image URL
|
1773 |
-
if ('' != $additionalImg) {
|
1774 |
-
if (array_key_exists($additionalImg, $imgUrls)) {
|
1775 |
-
return $imgUrls[$additionalImg];
|
1776 |
} else {
|
1777 |
return '';
|
1778 |
}
|
@@ -1790,14 +1749,13 @@ class Woo_Feed_Products_v3
|
|
1790 |
* @return string[]
|
1791 |
* @since 3.2.6
|
1792 |
*/
|
1793 |
-
protected function get_product_gallery($product)
|
1794 |
-
{
|
1795 |
$attachmentIds = $product->get_gallery_image_ids();
|
1796 |
$imgUrls = array();
|
1797 |
-
if ($attachmentIds && is_array($attachmentIds)) {
|
1798 |
$mKey = 1;
|
1799 |
-
foreach ($attachmentIds as $attachmentId) {
|
1800 |
-
$imgUrls[$mKey] = woo_feed_get_formatted_url(wp_get_attachment_url($attachmentId));
|
1801 |
$mKey++;
|
1802 |
}
|
1803 |
}
|
@@ -1814,8 +1772,7 @@ class Woo_Feed_Products_v3
|
|
1814 |
* @since 3.2.0
|
1815 |
*
|
1816 |
*/
|
1817 |
-
protected function condition($product)
|
1818 |
-
{
|
1819 |
return apply_filters('woo_feed_product_condition', 'new', $product);
|
1820 |
}
|
1821 |
|
@@ -1828,8 +1785,7 @@ class Woo_Feed_Products_v3
|
|
1828 |
* @since 3.2.0
|
1829 |
*
|
1830 |
*/
|
1831 |
-
protected function type($product)
|
1832 |
-
{
|
1833 |
return $product->get_type();
|
1834 |
}
|
1835 |
|
@@ -1842,9 +1798,8 @@ class Woo_Feed_Products_v3
|
|
1842 |
* @since 3.2.0
|
1843 |
*
|
1844 |
*/
|
1845 |
-
protected function is_bundle($product)
|
1846 |
-
|
1847 |
-
if ($product->is_type('bundle') || $product->is_type('yith_bundle')) {
|
1848 |
return 'yes';
|
1849 |
}
|
1850 |
|
@@ -1860,11 +1815,10 @@ class Woo_Feed_Products_v3
|
|
1860 |
* @since 3.2.0
|
1861 |
*
|
1862 |
*/
|
1863 |
-
protected function multipack($product)
|
1864 |
-
{
|
1865 |
$multi_pack = '';
|
1866 |
-
if ($product->is_type('grouped')) {
|
1867 |
-
$multi_pack = (!empty($product->get_children())) ? count($product->get_children()) : '';
|
1868 |
}
|
1869 |
|
1870 |
return $multi_pack;
|
@@ -1879,8 +1833,7 @@ class Woo_Feed_Products_v3
|
|
1879 |
* @since 3.2.0
|
1880 |
*
|
1881 |
*/
|
1882 |
-
protected function visibility($product)
|
1883 |
-
{
|
1884 |
return $product->get_catalog_visibility();
|
1885 |
}
|
1886 |
|
@@ -1893,8 +1846,7 @@ class Woo_Feed_Products_v3
|
|
1893 |
* @since 3.2.0
|
1894 |
*
|
1895 |
*/
|
1896 |
-
protected function rating_total($product)
|
1897 |
-
{
|
1898 |
return $product->get_rating_count();
|
1899 |
}
|
1900 |
|
@@ -1907,8 +1859,7 @@ class Woo_Feed_Products_v3
|
|
1907 |
* @since 3.2.0
|
1908 |
*
|
1909 |
*/
|
1910 |
-
protected function rating_average($product)
|
1911 |
-
{
|
1912 |
return $product->get_average_rating();
|
1913 |
}
|
1914 |
|
@@ -1921,10 +1872,9 @@ class Woo_Feed_Products_v3
|
|
1921 |
* @since 3.2.0
|
1922 |
*
|
1923 |
*/
|
1924 |
-
protected function tags($product)
|
1925 |
-
{
|
1926 |
$id = $product->get_id();
|
1927 |
-
if ($product->is_type('variation')) {
|
1928 |
$id = $product->get_parent_id();
|
1929 |
}
|
1930 |
|
@@ -1949,10 +1899,9 @@ class Woo_Feed_Products_v3
|
|
1949 |
* @since 3.2.0
|
1950 |
*
|
1951 |
*/
|
1952 |
-
protected function item_group_id($product)
|
1953 |
-
{
|
1954 |
$id = $product->get_id();
|
1955 |
-
if ($product->is_type('variation')) {
|
1956 |
$id = $product->get_parent_id();
|
1957 |
}
|
1958 |
|
@@ -1968,8 +1917,7 @@ class Woo_Feed_Products_v3
|
|
1968 |
* @since 3.2.0
|
1969 |
*
|
1970 |
*/
|
1971 |
-
protected function sku($product)
|
1972 |
-
{
|
1973 |
return $product->get_sku();
|
1974 |
}
|
1975 |
|
@@ -1982,9 +1930,8 @@ class Woo_Feed_Products_v3
|
|
1982 |
* @since 3.2.0
|
1983 |
*
|
1984 |
*/
|
1985 |
-
protected function parent_sku($product)
|
1986 |
-
|
1987 |
-
if ($product->is_type('variation')) {
|
1988 |
$id = $product->get_parent_id();
|
1989 |
$parent = wc_get_product($id);
|
1990 |
|
@@ -2003,14 +1950,13 @@ class Woo_Feed_Products_v3
|
|
2003 |
* @since 3.2.0
|
2004 |
*
|
2005 |
*/
|
2006 |
-
protected function availability($product)
|
2007 |
-
{
|
2008 |
$status = $product->get_stock_status();
|
2009 |
-
if ('instock' == $status) {
|
2010 |
return 'in stock';
|
2011 |
-
} elseif ('outofstock' == $status) {
|
2012 |
return 'out of stock';
|
2013 |
-
} elseif ('onbackorder' == $status) {
|
2014 |
return 'on backorder';
|
2015 |
} else {
|
2016 |
return 'in stock';
|
@@ -2026,26 +1972,25 @@ class Woo_Feed_Products_v3
|
|
2026 |
* @since 3.2.0
|
2027 |
*
|
2028 |
*/
|
2029 |
-
protected function quantity($product)
|
2030 |
-
|
2031 |
-
if ($product->is_type('variable') && $product->has_child()) {
|
2032 |
$visible_children = $product->get_visible_children();
|
2033 |
$qty = array();
|
2034 |
-
foreach ($visible_children as $key => $child) {
|
2035 |
$childQty = get_post_meta($child, '_stock', true);
|
2036 |
$qty[] = (int)$childQty + 0;
|
2037 |
}
|
2038 |
|
2039 |
-
if (isset($this->config['variable_quantity'])) {
|
2040 |
$vaQty = $this->config['variable_quantity'];
|
2041 |
-
if ('max' == $vaQty) {
|
2042 |
return max($qty);
|
2043 |
-
} elseif ('min' == $vaQty) {
|
2044 |
return min($qty);
|
2045 |
-
} elseif ('sum' == $vaQty) {
|
2046 |
return array_sum($qty);
|
2047 |
-
} elseif ('first' == $vaQty) {
|
2048 |
-
return ((int)$qty[0]);
|
2049 |
}
|
2050 |
|
2051 |
return array_sum($qty);
|
@@ -2064,10 +2009,9 @@ class Woo_Feed_Products_v3
|
|
2064 |
* @since 3.2.0
|
2065 |
*
|
2066 |
*/
|
2067 |
-
protected function sale_price_sdate($product)
|
2068 |
-
{
|
2069 |
$startDate = $product->get_date_on_sale_from();
|
2070 |
-
if (is_object($startDate)) {
|
2071 |
return $startDate->date_i18n();
|
2072 |
}
|
2073 |
|
@@ -2083,10 +2027,9 @@ class Woo_Feed_Products_v3
|
|
2083 |
* @since 3.2.0
|
2084 |
*
|
2085 |
*/
|
2086 |
-
protected function sale_price_edate($product)
|
2087 |
-
{
|
2088 |
$endDate = $product->get_date_on_sale_to();
|
2089 |
-
if (is_object($endDate)) {
|
2090 |
return $endDate->date_i18n();
|
2091 |
}
|
2092 |
|
@@ -2102,11 +2045,10 @@ class Woo_Feed_Products_v3
|
|
2102 |
* @since 3.2.0
|
2103 |
*
|
2104 |
*/
|
2105 |
-
protected function price($product)
|
2106 |
-
|
2107 |
-
if ($product->is_type('variable')) {
|
2108 |
return $this->getVariableProductPrice($product, 'regular_price');
|
2109 |
-
} elseif ($product->is_type('grouped')) {
|
2110 |
return $this->getGroupProductPrice($product,
|
2111 |
'regular'); // this calls self::price() so no need to use self::getWPMLPrice()
|
2112 |
} else {
|
@@ -2123,11 +2065,10 @@ class Woo_Feed_Products_v3
|
|
2123 |
* @since 3.2.0
|
2124 |
*
|
2125 |
*/
|
2126 |
-
protected function current_price($product)
|
2127 |
-
|
2128 |
-
if ($product->is_type('variable')) {
|
2129 |
return $this->getVariableProductPrice($product, 'price');
|
2130 |
-
} elseif ($product->is_type('grouped')) {
|
2131 |
return $this->getGroupProductPrice($product, 'current');
|
2132 |
} else {
|
2133 |
return $product->get_price();
|
@@ -2143,11 +2084,10 @@ class Woo_Feed_Products_v3
|
|
2143 |
* @since 3.2.0
|
2144 |
*
|
2145 |
*/
|
2146 |
-
protected function sale_price($product)
|
2147 |
-
|
2148 |
-
if ($product->is_type('variable')) {
|
2149 |
return $this->getVariableProductPrice($product, 'sale_price');
|
2150 |
-
} elseif ($product->is_type('grouped')) {
|
2151 |
return $this->getGroupProductPrice($product, 'sale');
|
2152 |
} else {
|
2153 |
$price = $product->get_sale_price();
|
@@ -2165,17 +2105,16 @@ class Woo_Feed_Products_v3
|
|
2165 |
* @since 3.2.0
|
2166 |
*
|
2167 |
*/
|
2168 |
-
protected function price_with_tax($product)
|
2169 |
-
|
2170 |
-
if ($product->is_type('variable')) {
|
2171 |
return $this->getVariableProductPrice($product, 'regular_price', true);
|
2172 |
-
} elseif ($product->is_type('grouped')) {
|
2173 |
return $this->getGroupProductPrice($product, 'regular', true);
|
2174 |
} else {
|
2175 |
$price = $this->price($product);
|
2176 |
|
2177 |
// Get price with tax.
|
2178 |
-
return ($product->is_taxable() && !empty($price)) ? $this->get_price_with_tax($product,
|
2179 |
$price) : $price;
|
2180 |
}
|
2181 |
}
|
@@ -2189,17 +2128,16 @@ class Woo_Feed_Products_v3
|
|
2189 |
* @since 3.2.0
|
2190 |
*
|
2191 |
*/
|
2192 |
-
protected function current_price_with_tax($product)
|
2193 |
-
|
2194 |
-
if ($product->is_type('variable')) {
|
2195 |
return $this->getVariableProductPrice($product, 'current_price', true);
|
2196 |
-
} elseif ($product->is_type('grouped')) {
|
2197 |
return $this->getGroupProductPrice($product, 'current', true);
|
2198 |
} else {
|
2199 |
$price = $this->current_price($product);
|
2200 |
|
2201 |
// Get price with tax
|
2202 |
-
return ($product->is_taxable() && !empty($price)) ? $this->get_price_with_tax($product,
|
2203 |
$price) : $price;
|
2204 |
}
|
2205 |
}
|
@@ -2213,15 +2151,14 @@ class Woo_Feed_Products_v3
|
|
2213 |
* @since 3.2.0
|
2214 |
*
|
2215 |
*/
|
2216 |
-
protected function sale_price_with_tax($product)
|
2217 |
-
|
2218 |
-
if ($product->is_type('variable')) {
|
2219 |
return $this->getVariableProductPrice($product, 'sale_price', true);
|
2220 |
-
} elseif ($product->is_type('grouped')) {
|
2221 |
return $this->getGroupProductPrice($product, 'sale', true);
|
2222 |
} else {
|
2223 |
$price = $this->sale_price($product);
|
2224 |
-
if ($product->is_taxable() && !empty($price)) {
|
2225 |
$price = $this->get_price_with_tax($product, $price);
|
2226 |
}
|
2227 |
|
@@ -2240,23 +2177,22 @@ class Woo_Feed_Products_v3
|
|
2240 |
* @since 3.2.0
|
2241 |
*
|
2242 |
*/
|
2243 |
-
protected function getGroupProductPrice($grouped, $type, $tax = false)
|
2244 |
-
{
|
2245 |
$groupProductIds = $grouped->get_children();
|
2246 |
$sum = 0;
|
2247 |
-
if (!empty($groupProductIds)) {
|
2248 |
-
foreach ($groupProductIds as $id) {
|
2249 |
$product = wc_get_product($id);
|
2250 |
|
2251 |
-
if (!is_object($product)) {
|
2252 |
continue; // make sure that the product exists..
|
2253 |
}
|
2254 |
|
2255 |
-
if ($tax) {
|
2256 |
-
if ('regular' == $type) {
|
2257 |
$regularPrice = $this->price_with_tax($product);
|
2258 |
$sum += (float)$regularPrice;
|
2259 |
-
} elseif ('current' == $type) {
|
2260 |
$currentPrice = $this->current_price_with_tax($product);
|
2261 |
$sum += (float)$currentPrice;
|
2262 |
} else {
|
@@ -2264,10 +2200,10 @@ class Woo_Feed_Products_v3
|
|
2264 |
$sum += (float)$salePrice;
|
2265 |
}
|
2266 |
} else {
|
2267 |
-
if ('regular' == $type) {
|
2268 |
$regularPrice = $this->price($product);
|
2269 |
$sum += (float)$regularPrice;
|
2270 |
-
} elseif ('current' == $type) {
|
2271 |
$currentPrice = $this->current_price($product);
|
2272 |
$sum += (float)$currentPrice;
|
2273 |
} else {
|
@@ -2278,7 +2214,7 @@ class Woo_Feed_Products_v3
|
|
2278 |
}
|
2279 |
}
|
2280 |
|
2281 |
-
if ('sale' == $type) {
|
2282 |
$sum = $sum > 0 ? $sum : '';
|
2283 |
}
|
2284 |
|
@@ -2296,20 +2232,19 @@ class Woo_Feed_Products_v3
|
|
2296 |
* @since 3.2.0
|
2297 |
*
|
2298 |
*/
|
2299 |
-
protected function getVariableProductPrice($variable, $type, $tax = false)
|
2300 |
-
{
|
2301 |
$price = 0;
|
2302 |
-
if ('regular_price' == $type) {
|
2303 |
$price = $variable->get_variation_regular_price();
|
2304 |
-
} elseif ('sale_price' == $type) {
|
2305 |
$price = $variable->get_variation_sale_price();
|
2306 |
} else {
|
2307 |
$price = $variable->get_variation_price();
|
2308 |
}
|
2309 |
-
if (true === $tax && $variable->is_taxable()) {
|
2310 |
$price = $this->get_price_with_tax($variable, $price);
|
2311 |
}
|
2312 |
-
if ('sale_price' != $type) {
|
2313 |
$price = $price > 0 ? $price : '';
|
2314 |
}
|
2315 |
|
@@ -2326,10 +2261,9 @@ class Woo_Feed_Products_v3
|
|
2326 |
* @since 3.2.0
|
2327 |
*
|
2328 |
*/
|
2329 |
-
protected function get_price_with_tax($product, $price)
|
2330 |
-
|
2331 |
-
|
2332 |
-
return wc_get_price_including_tax($product, array('price' => $price));
|
2333 |
} else {
|
2334 |
return $product->get_price_including_tax(1, $price);
|
2335 |
}
|
@@ -2344,8 +2278,7 @@ class Woo_Feed_Products_v3
|
|
2344 |
* @since 3.2.0
|
2345 |
*
|
2346 |
*/
|
2347 |
-
protected function weight($product)
|
2348 |
-
{
|
2349 |
return $product->get_weight();
|
2350 |
}
|
2351 |
|
@@ -2358,8 +2291,7 @@ class Woo_Feed_Products_v3
|
|
2358 |
* @since 3.2.0
|
2359 |
*
|
2360 |
*/
|
2361 |
-
protected function width($product)
|
2362 |
-
{
|
2363 |
return $product->get_width();
|
2364 |
}
|
2365 |
|
@@ -2372,8 +2304,7 @@ class Woo_Feed_Products_v3
|
|
2372 |
* @since 3.2.0
|
2373 |
*
|
2374 |
*/
|
2375 |
-
protected function height($product)
|
2376 |
-
{
|
2377 |
return $product->get_height();
|
2378 |
}
|
2379 |
|
@@ -2386,8 +2317,7 @@ class Woo_Feed_Products_v3
|
|
2386 |
* @since 3.2.0
|
2387 |
*
|
2388 |
*/
|
2389 |
-
protected function length($product)
|
2390 |
-
{
|
2391 |
return $product->get_length();
|
2392 |
}
|
2393 |
|
@@ -2400,8 +2330,7 @@ class Woo_Feed_Products_v3
|
|
2400 |
* @since 3.2.0
|
2401 |
*
|
2402 |
*/
|
2403 |
-
protected function shipping_class($product)
|
2404 |
-
{
|
2405 |
return $product->get_shipping_class();
|
2406 |
}
|
2407 |
|
@@ -2414,8 +2343,7 @@ class Woo_Feed_Products_v3
|
|
2414 |
* @since 3.2.0
|
2415 |
*
|
2416 |
*/
|
2417 |
-
protected function author_name($product)
|
2418 |
-
{
|
2419 |
$post = get_post($product->get_id());
|
2420 |
|
2421 |
return get_the_author_meta('user_login', $post->post_author);
|
@@ -2430,8 +2358,7 @@ class Woo_Feed_Products_v3
|
|
2430 |
* @since 3.2.0
|
2431 |
*
|
2432 |
*/
|
2433 |
-
protected function author_email($product)
|
2434 |
-
{
|
2435 |
$post = get_post($product->get_id());
|
2436 |
|
2437 |
return get_the_author_meta('user_email', $post->post_author);
|
@@ -2446,8 +2373,7 @@ class Woo_Feed_Products_v3
|
|
2446 |
* @since 3.2.0
|
2447 |
*
|
2448 |
*/
|
2449 |
-
protected function date_created($product)
|
2450 |
-
{
|
2451 |
return gmdate('Y-m-d', strtotime($product->get_date_created()));
|
2452 |
}
|
2453 |
|
@@ -2460,8 +2386,7 @@ class Woo_Feed_Products_v3
|
|
2460 |
* @since 3.2.0
|
2461 |
*
|
2462 |
*/
|
2463 |
-
protected function date_updated($product)
|
2464 |
-
{
|
2465 |
return gmdate('Y-m-d', strtotime($product->get_date_modified()));
|
2466 |
}
|
2467 |
|
@@ -2470,7 +2395,7 @@ class Woo_Feed_Products_v3
|
|
2470 |
* @param WC_Product $product Product object.
|
2471 |
* @return string
|
2472 |
*/
|
2473 |
-
protected function tax_class($product){
|
2474 |
return $product->get_tax_class();
|
2475 |
}
|
2476 |
|
@@ -2479,7 +2404,7 @@ class Woo_Feed_Products_v3
|
|
2479 |
* @param WC_Product $product Product object.
|
2480 |
* @return string
|
2481 |
*/
|
2482 |
-
protected function tax_status($product){
|
2483 |
return $product->get_tax_status();
|
2484 |
}
|
2485 |
|
@@ -2488,11 +2413,11 @@ class Woo_Feed_Products_v3
|
|
2488 |
* @param WC_Product $product Product object.
|
2489 |
* @return string
|
2490 |
*/
|
2491 |
-
protected function woo_feed_gtin($product) {
|
2492 |
-
$id
|
2493 |
-
$meta='woo_feed_gtin';
|
2494 |
-
if($product->is_type('variation')) {
|
2495 |
-
$meta='woo_feed_gtin_var';
|
2496 |
}
|
2497 |
return $this->getProductMeta($product,$meta);
|
2498 |
}
|
@@ -2502,11 +2427,11 @@ class Woo_Feed_Products_v3
|
|
2502 |
* @param WC_Product $product Product object.
|
2503 |
* @return string
|
2504 |
*/
|
2505 |
-
protected function woo_feed_mpn($product) {
|
2506 |
-
$id
|
2507 |
-
$meta='woo_feed_mpn';
|
2508 |
-
if($product->is_type('variation')) {
|
2509 |
-
$meta='woo_feed_mpn_var';
|
2510 |
}
|
2511 |
return $this->getProductMeta($product,$meta);
|
2512 |
}
|
@@ -2516,11 +2441,11 @@ class Woo_Feed_Products_v3
|
|
2516 |
* @param WC_Product $product Product object.
|
2517 |
* @return string
|
2518 |
*/
|
2519 |
-
protected function woo_feed_ean($product) {
|
2520 |
-
$id
|
2521 |
-
$meta='woo_feed_ean';
|
2522 |
-
if($product->is_type('variation')) {
|
2523 |
-
$meta='woo_feed_ean_var';
|
2524 |
}
|
2525 |
return $this->getProductMeta($product,$meta);
|
2526 |
}
|
@@ -2534,12 +2459,11 @@ class Woo_Feed_Products_v3
|
|
2534 |
* @since 3.2.0
|
2535 |
*
|
2536 |
*/
|
2537 |
-
protected function sale_price_effective_date($product)
|
2538 |
-
{
|
2539 |
$effective_date = '';
|
2540 |
$from = $this->sale_price_sdate($product);
|
2541 |
$to = $this->sale_price_edate($product);
|
2542 |
-
if (!empty($from) && !empty($to)) {
|
2543 |
$from = gmdate('c', strtotime($from));
|
2544 |
$to = gmdate('c', strtotime($to));
|
2545 |
|
@@ -2559,19 +2483,18 @@ class Woo_Feed_Products_v3
|
|
2559 |
* @since 2.2.3
|
2560 |
*
|
2561 |
*/
|
2562 |
-
protected function getProductAttribute($product, $attr)
|
2563 |
-
{
|
2564 |
$id = $product->get_id();
|
2565 |
|
2566 |
-
if (woo_feed_wc_version_check(3.2)) {
|
2567 |
-
if (woo_feed_wc_version_check(3.6)) {
|
2568 |
$attr = str_replace('pa_', '', $attr);
|
2569 |
}
|
2570 |
$value = $product->get_attribute($attr);
|
2571 |
|
2572 |
return $value;
|
2573 |
} else {
|
2574 |
-
return implode(',', wc_get_product_terms($id, $attr, array('fields' => 'names')));
|
2575 |
}
|
2576 |
}
|
2577 |
|
@@ -2585,11 +2508,10 @@ class Woo_Feed_Products_v3
|
|
2585 |
* @since 2.2.3
|
2586 |
*
|
2587 |
*/
|
2588 |
-
protected function getProductMeta($product, $meta)
|
2589 |
-
{
|
2590 |
$value = get_post_meta($product->get_id(), $meta, true);
|
2591 |
// if empty get meta value of parent post
|
2592 |
-
if ('' == $value && $product->get_parent_id()) {
|
2593 |
$value = get_post_meta($product->get_parent_id(), $meta, true);
|
2594 |
}
|
2595 |
|
@@ -2605,8 +2527,7 @@ class Woo_Feed_Products_v3
|
|
2605 |
* @since 3.2.0
|
2606 |
*
|
2607 |
*/
|
2608 |
-
public function filter_product($product)
|
2609 |
-
{
|
2610 |
return true;
|
2611 |
}
|
2612 |
|
@@ -2620,10 +2541,9 @@ class Woo_Feed_Products_v3
|
|
2620 |
* @since 2.2.3
|
2621 |
*
|
2622 |
*/
|
2623 |
-
protected function getProductTaxonomy($product, $taxonomy)
|
2624 |
-
{
|
2625 |
$id = $product->get_id();
|
2626 |
-
if ($product->is_type('variation')) {
|
2627 |
$id = $product->get_parent_id();
|
2628 |
}
|
2629 |
|
@@ -2643,33 +2563,32 @@ class Woo_Feed_Products_v3
|
|
2643 |
* @since 3.2.0
|
2644 |
*
|
2645 |
*/
|
2646 |
-
protected function price_format($name, $conditionName, $result)
|
2647 |
-
{
|
2648 |
$plus = '+';
|
2649 |
$minus = '-';
|
2650 |
$percent = '%';
|
2651 |
|
2652 |
-
if (strpos($name, 'price') !== false) {
|
2653 |
-
if (strpos($result, $plus) !== false && strpos($result, $percent) !== false) {
|
2654 |
$result = str_replace('+', '', $result);
|
2655 |
$result = str_replace('%', '', $result);
|
2656 |
-
if (is_numeric($result)) {
|
2657 |
$result = $conditionName + (($conditionName * $result) / 100);
|
2658 |
}
|
2659 |
-
} elseif (strpos($result, $minus) !== false && strpos($result, $percent) !== false) {
|
2660 |
$result = str_replace('-', '', $result);
|
2661 |
$result = str_replace('%', '', $result);
|
2662 |
-
if (is_numeric($result)) {
|
2663 |
$result = $conditionName - (($conditionName * $result) / 100);
|
2664 |
}
|
2665 |
-
} elseif (strpos($result, $plus) !== false) {
|
2666 |
$result = str_replace('+', '', $result);
|
2667 |
-
if (is_numeric($result)) {
|
2668 |
$result = ($conditionName + $result);
|
2669 |
}
|
2670 |
-
} elseif (strpos($result, $minus) !== false) {
|
2671 |
$result = str_replace('-', '', $result);
|
2672 |
-
if (is_numeric($result)) {
|
2673 |
$result = $conditionName - $result;
|
2674 |
}
|
2675 |
}
|
@@ -2690,98 +2609,97 @@ class Woo_Feed_Products_v3
|
|
2690 |
* @since 3.2.0
|
2691 |
*
|
2692 |
*/
|
2693 |
-
protected function format_output($output, $outputTypes, $product, $productAttribute)
|
2694 |
-
|
2695 |
-
if (!empty($outputTypes) && is_array($outputTypes)) {
|
2696 |
|
2697 |
// Format Output According to output type
|
2698 |
-
if (in_array(2, $outputTypes)) { // Strip Tags
|
2699 |
$output = wp_strip_all_tags(html_entity_decode($output));
|
2700 |
}
|
2701 |
|
2702 |
-
if (in_array(3, $outputTypes)) { // UTF-8 Encode
|
2703 |
$output = utf8_encode($output);
|
2704 |
}
|
2705 |
|
2706 |
-
if (in_array(4, $outputTypes)) { // htmlentities
|
2707 |
$output = htmlentities($output, ENT_QUOTES, 'UTF-8');
|
2708 |
}
|
2709 |
|
2710 |
-
if (in_array(5, $outputTypes)) { // Integer
|
2711 |
$output = intval($output);
|
2712 |
}
|
2713 |
|
2714 |
-
if (in_array(6, $outputTypes)) { // Format Price
|
2715 |
-
if (!empty($output) && $output > 0) {
|
2716 |
$output = (float)$output;
|
2717 |
$output = number_format($output, 2, '.', '');
|
2718 |
}
|
2719 |
}
|
2720 |
|
2721 |
-
if (in_array(7, $outputTypes)) { // Delete Space
|
2722 |
$output = trim($output);
|
2723 |
$output = preg_replace('!\s+!', ' ', $output);
|
2724 |
}
|
2725 |
|
2726 |
-
if (in_array(9, $outputTypes)) { // Remove Invalid Character
|
2727 |
$output = woo_feed_stripInvalidXml($output);
|
2728 |
}
|
2729 |
|
2730 |
-
if (in_array(10, $outputTypes)) { // Remove ShortCodes
|
2731 |
$output = $this->remove_short_codes($output);
|
2732 |
}
|
2733 |
|
2734 |
-
if (in_array(11, $outputTypes)) {
|
2735 |
$output = ucwords(strtolower($output));
|
2736 |
}
|
2737 |
|
2738 |
-
if (in_array(12, $outputTypes)) {
|
2739 |
$output = ucfirst(strtolower($output));
|
2740 |
}
|
2741 |
|
2742 |
-
if (in_array(13, $outputTypes)) {
|
2743 |
$output = strtoupper(strtolower($output));
|
2744 |
}
|
2745 |
|
2746 |
-
if (in_array(14, $outputTypes)) {
|
2747 |
$output = strtolower($output);
|
2748 |
}
|
2749 |
|
2750 |
-
if (in_array(15, $outputTypes)) {
|
2751 |
-
if ('http' == substr($output, 0, 4)) {
|
2752 |
$output = str_replace('http://', 'https://', $output);
|
2753 |
}
|
2754 |
}
|
2755 |
|
2756 |
-
if (in_array(16, $outputTypes)) {
|
2757 |
-
if ('http' == substr($output, 0, 4)) {
|
2758 |
$output = str_replace('https://', 'http://', $output);
|
2759 |
}
|
2760 |
}
|
2761 |
|
2762 |
-
if (in_array(17, $outputTypes)) { // only parent
|
2763 |
-
if ($product->is_type('variation')) {
|
2764 |
$id = $product->get_parent_id();
|
2765 |
$parentProduct = wc_get_product($id);
|
2766 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
2767 |
}
|
2768 |
}
|
2769 |
|
2770 |
-
if (in_array(18, $outputTypes)) { // child if parent empty
|
2771 |
-
if ($product->is_type('variation')) {
|
2772 |
$id = $product->get_parent_id();
|
2773 |
$parentProduct = wc_get_product($id);
|
2774 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
2775 |
-
if (empty($output)) {
|
2776 |
$output = $this->getAttributeValueByType($product, $productAttribute);
|
2777 |
}
|
2778 |
}
|
2779 |
}
|
2780 |
|
2781 |
-
if (in_array(19, $outputTypes)) { // parent if child empty
|
2782 |
-
if ($product->is_type('variation')) {
|
2783 |
$output = $this->getAttributeValueByType($product, $productAttribute);
|
2784 |
-
if (empty($output)) {
|
2785 |
$id = $product->get_parent_id();
|
2786 |
$parentProduct = wc_get_product($id);
|
2787 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
@@ -2789,7 +2707,7 @@ class Woo_Feed_Products_v3
|
|
2789 |
}
|
2790 |
}
|
2791 |
|
2792 |
-
if (in_array(8, $outputTypes) && !empty($output)) { // Add CDATA
|
2793 |
$output = '<![CDATA[' . $output . ']]>';
|
2794 |
}
|
2795 |
}
|
@@ -2809,20 +2727,19 @@ class Woo_Feed_Products_v3
|
|
2809 |
* @since 3.2.0
|
2810 |
*
|
2811 |
*/
|
2812 |
-
public function process_prefix_suffix($output, $prefix, $suffix, $attribute = '')
|
2813 |
-
{
|
2814 |
|
2815 |
-
if ('' == $output) {
|
2816 |
return $output;
|
2817 |
}
|
2818 |
|
2819 |
// Add Prefix before Output
|
2820 |
-
if ('' != $prefix) {
|
2821 |
$output = "$prefix" . $output;
|
2822 |
}
|
2823 |
|
2824 |
// Add Suffix after Output
|
2825 |
-
if ('' !== $suffix) {
|
2826 |
if (
|
2827 |
'price' == $attribute
|
2828 |
|| 'sale_price' == $attribute
|
@@ -2834,7 +2751,7 @@ class Woo_Feed_Products_v3
|
|
2834 |
|| 'tax_rate' == $attribute
|
2835 |
) { // Add space before suffix if attribute contain price.
|
2836 |
$output = $output . ' ' . $suffix;
|
2837 |
-
} elseif (substr($output, 0, 4) === 'http') {
|
2838 |
// Parse URL Parameters if available into suffix field
|
2839 |
$output = woo_feed_make_url_with_parameter($output, $suffix);
|
2840 |
|
@@ -2855,7 +2772,7 @@ class Woo_Feed_Products_v3
|
|
2855 |
* @since 3.6.3
|
2856 |
*
|
2857 |
*/
|
2858 |
-
protected function subscription_period($product){
|
2859 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
2860 |
return $this->getProductMeta($product,'_subscription_period');
|
2861 |
}
|
@@ -2870,7 +2787,7 @@ class Woo_Feed_Products_v3
|
|
2870 |
* @since 3.6.3
|
2871 |
*
|
2872 |
*/
|
2873 |
-
protected function subscription_period_interval($product){
|
2874 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
2875 |
return $this->getProductMeta($product,'_subscription_period_interval');
|
2876 |
}
|
@@ -2886,7 +2803,7 @@ class Woo_Feed_Products_v3
|
|
2886 |
* @since 3.6.3
|
2887 |
*
|
2888 |
*/
|
2889 |
-
protected function subscription_amount($product){
|
2890 |
return $this->price($product);
|
2891 |
}
|
2892 |
}
|
7 |
* Time: 5:10 PM
|
8 |
*/
|
9 |
|
10 |
+
if ( ! defined('ABSPATH') ) {
|
11 |
die();
|
12 |
}
|
13 |
|
79 |
* To replace google product highlight attribute for CSV & TXT feed
|
80 |
* @var array
|
81 |
*/
|
82 |
+
protected $google_product_highlights = array(
|
83 |
'product highlight 1',
|
84 |
'product highlight 2',
|
85 |
'product highlight 3',
|
96 |
* To replace google additional image link attribute for CSV & TXT feed
|
97 |
* @var array
|
98 |
*/
|
99 |
+
protected $google_additional_image = array(
|
100 |
'additional image link 1',
|
101 |
'additional image link 2',
|
102 |
'additional image link 3',
|
142 |
* @var array
|
143 |
*/
|
144 |
protected $skipped_merchant_attributes = array(
|
145 |
+
'google' => array(
|
146 |
'shipping_country',
|
147 |
'shipping_region',
|
148 |
'shipping_service',
|
202 |
'variable-subscription',
|
203 |
'bundle',
|
204 |
'yith_bundle',
|
205 |
+
'woosb',
|
206 |
);
|
207 |
/**
|
208 |
* Post meta prefix for dropdown item
|
229 |
*/
|
230 |
const PRODUCT_CATEGORY_MAPPING_PREFIX = 'wf_cmapping_';
|
231 |
|
232 |
+
public function __construct( $config ) {
|
|
|
233 |
$this->config = woo_feed_parse_feed_rules($config);
|
234 |
$this->queryType = woo_feed_get_options('product_query_type');
|
235 |
$this->process_xml_wrapper();
|
241 |
* @param string $type
|
242 |
* @return array
|
243 |
*/
|
244 |
+
protected function get_query_args( $type = 'wc' ) {
|
|
|
245 |
$args = [];
|
246 |
+
if ( 'wc' === $type ) {
|
247 |
$args = array(
|
248 |
'limit' => -1, // phpcs:ignore
|
249 |
+
'status' => $this->post_status,
|
250 |
+
'type' => [ 'simple', 'variable', 'grouped', 'external', 'subscription', 'variable-subscription', 'bundle', 'yith_bundle', 'woosb' ],
|
251 |
+
'orderby' => 'date',
|
252 |
+
'order' => 'DESC',
|
253 |
+
'return' => 'ids',
|
254 |
'suppress_filters' => false,
|
255 |
);
|
256 |
}
|
257 |
+
if ( 'wp' === $type ) {
|
258 |
$args = array(
|
259 |
'posts_per_page' => -1, // phpcs:ignore
|
260 |
+
'post_type' => 'product',
|
261 |
+
'post_status' => 'publish',
|
262 |
+
'order' => 'DESC',
|
263 |
+
'fields' => 'ids',
|
264 |
+
'cache_results' => false,
|
265 |
'update_post_meta_cache' => false,
|
266 |
'update_post_term_cache' => false,
|
267 |
+
'suppress_filters' => false,
|
268 |
);
|
269 |
}
|
270 |
return $args;
|
275 |
*
|
276 |
* @return array
|
277 |
*/
|
278 |
+
public function get_wc_query_products() {
|
|
|
279 |
$args = $this->get_query_args('wc');
|
280 |
+
if ( woo_feed_is_debugging_enabled() ) {
|
281 |
woo_feed_log_feed_process($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
282 |
woo_feed_log($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true), 'info'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
283 |
}
|
284 |
$query = new WC_Product_Query($args);
|
285 |
+
if ( woo_feed_is_debugging_enabled() ) {
|
286 |
woo_feed_log_feed_process($this->config['filename'], sprintf('WC_Product_Query Args ::' . PHP_EOL . '%s', print_r($args, true))); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
287 |
}
|
288 |
return $query->get_products();
|
293 |
*
|
294 |
* @return array
|
295 |
*/
|
296 |
+
public function get_wp_query_products() {
|
|
|
297 |
$args = $this->get_query_args('wp');
|
298 |
$query = new WP_Query($args);
|
299 |
+
if ( woo_feed_is_debugging_enabled() ) {
|
300 |
woo_feed_log_feed_process($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true)); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
301 |
woo_feed_log_feed_process($this->config['filename'], sprintf('WP_Query Request ::' . PHP_EOL . '%s', $query->request));
|
302 |
woo_feed_log($this->config['filename'], 'WC_Product_Query Args::' . PHP_EOL . print_r($args, true), 'info'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
310 |
*
|
311 |
* @return array
|
312 |
*/
|
313 |
+
public function query_products() {
|
|
|
314 |
$products = [];
|
315 |
+
if ( 'wc' == $this->queryType ) {
|
316 |
$products = $this->get_wc_query_products();
|
317 |
+
} elseif ( 'wp' == $this->queryType ) {
|
318 |
$products = $this->get_wp_query_products();
|
319 |
+
} elseif ( 'both' == $this->queryType ) {
|
320 |
$wc = $this->get_wc_query_products();
|
321 |
$wp = $this->get_wp_query_products();
|
322 |
$products = array_unique(array_merge($wc, $wp));
|
329 |
* Organize Feed Attribute config
|
330 |
* @return array|bool
|
331 |
*/
|
332 |
+
public function get_attribute_config() {
|
333 |
+
if ( empty($this->config) ) {
|
|
|
334 |
return false;
|
335 |
}
|
336 |
|
337 |
$attributeConfig = array();
|
338 |
$merchantAttributes = $this->config['mattributes'];
|
339 |
+
if ( ! empty($merchantAttributes) ) {
|
340 |
$i = 0;
|
341 |
+
foreach ( $merchantAttributes as $key => $value ) {
|
342 |
+
$attributeConfig[ $i ]['mattributes'] = $value;
|
343 |
+
$attributeConfig[ $i ]['prefix'] = $this->config['prefix'][ $key ];
|
344 |
+
$attributeConfig[ $i ]['type'] = $this->config['type'][ $key ];
|
345 |
+
$attributeConfig[ $i ]['attributes'] = $this->config['attributes'][ $key ];
|
346 |
+
$attributeConfig[ $i ]['default'] = $this->config['default'][ $key ];
|
347 |
+
$attributeConfig[ $i ]['suffix'] = $this->config['suffix'][ $key ];
|
348 |
+
$attributeConfig[ $i ]['output_type'] = $this->config['output_type'][ $key ];
|
349 |
+
$attributeConfig[ $i ]['limit'] = $this->config['limit'][ $key ];
|
350 |
$i++;
|
351 |
}
|
352 |
}
|
363 |
* @since 3.2.0
|
364 |
*
|
365 |
*/
|
366 |
+
public function get_products( $productIds ) {
|
|
|
367 |
|
368 |
+
if ( empty($productIds) ) {
|
369 |
return [];
|
370 |
}
|
371 |
|
379 |
*/
|
380 |
do_action('woo_feed_before_product_loop', $productIds, $this->config);
|
381 |
|
382 |
+
foreach ( $productIds as $key => $pid ) {
|
383 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Loading Product Data For %d.', $pid));
|
384 |
$product = wc_get_product($pid);
|
385 |
|
386 |
+
if ( $this->exclude_from_loop($product) ) {
|
387 |
continue;
|
388 |
}
|
389 |
|
390 |
+
if ( $this->process_variation($product) ) {
|
391 |
continue;
|
392 |
}
|
393 |
|
394 |
+
if ( ! $this->filter_product($product) ) {
|
395 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Matched with filter conditions');
|
396 |
continue;
|
397 |
}
|
399 |
woo_feed_log_feed_process($this->config['filename'], 'Formatting Feed Data...');
|
400 |
|
401 |
// Add Single item wrapper before product info loop start
|
402 |
+
if ( 'xml' == $this->config['feedType'] ) {
|
403 |
$this->feedBody .= "\n";
|
404 |
$this->feedBody .= '<' . $this->config['itemWrapper'] . '>';
|
405 |
$this->feedBody .= "\n";
|
414 |
woo_feed_log_feed_process($this->config['filename'], 'Processing Merchant Specific Fields');
|
415 |
// Process feed data for uncommon merchant feed like Google,Facebook,Pinterest
|
416 |
$this->process_for_merchant($product, $this->pi);
|
417 |
+
} catch ( Exception $e ) {
|
418 |
$message = 'Error Processing Merchant Specific Fields.' . PHP_EOL . 'Caught Exception :: ' . $e->getMessage();
|
419 |
woo_feed_log($this->config['filename'], $message, 'critical', $e, true);
|
420 |
woo_feed_log_fatal_error($message, $e);
|
421 |
}
|
422 |
|
423 |
+
if ( 'xml' == $this->config['feedType'] ) {
|
424 |
+
if ( empty($this->feedHeader) ) {
|
425 |
$this->feedHeader = $this->process_xml_feed_header();
|
426 |
$this->feedFooter = $this->process_xml_feed_footer();
|
427 |
|
430 |
$this->feedBody .= '</' . $this->config['itemWrapper'] . '>';
|
431 |
|
432 |
|
433 |
+
} elseif ( 'txt' == $this->config['feedType'] ) {
|
434 |
+
if ( empty($this->feedHeader) ) {
|
435 |
$this->process_txt_feed_header();
|
436 |
}
|
437 |
$this->process_txt_feed_body();
|
438 |
} else {
|
439 |
+
if ( empty($this->feedHeader) ) {
|
440 |
$this->process_csv_feed_header();
|
441 |
}
|
442 |
$this->process_csv_feed_body();
|
465 |
* @return bool
|
466 |
* @since 3.3.9
|
467 |
*/
|
468 |
+
protected function process_variation( $product ) {
|
|
|
469 |
// Apply variable and variation settings
|
470 |
+
if ( $product->is_type('variable') && $product->has_child() ) {
|
471 |
$this->pi++;
|
472 |
$variations = $product->get_visible_children();
|
473 |
+
if ( is_array($variations) && (sizeof($variations) > 0) ) {
|
474 |
+
if ( woo_feed_is_debugging_enabled() ) {
|
475 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Getting Variation Product(s) :: %s', implode(', ', $variations)));
|
476 |
}
|
477 |
$this->get_products($variations);
|
489 |
* @return void
|
490 |
* @since 3.3.9
|
491 |
*/
|
492 |
+
protected function process_attributes( $product ) {
|
|
|
493 |
// Get Product Attribute values by type and assign to product array
|
494 |
+
foreach ( $this->config['attributes'] as $attr_key => $attribute ) {
|
495 |
|
496 |
+
$merchant_attribute = isset($this->config['mattributes'][ $attr_key ]) ? $this->config['mattributes'][ $attr_key ] : '';
|
497 |
|
498 |
+
if ( $this->exclude_current_attribute($product, $merchant_attribute, $attribute) ) {
|
499 |
continue;
|
500 |
}
|
501 |
|
502 |
// Add Prefix and Suffix into Output
|
503 |
+
$prefix = $this->config['prefix'][ $attr_key ];
|
504 |
+
$suffix = $this->config['suffix'][ $attr_key ];
|
505 |
$merchant = $this->config['provider'];
|
506 |
$feedType = $this->config['feedType'];
|
507 |
|
508 |
+
if ( 'pattern' == $this->config['type'][ $attr_key ] ) {
|
509 |
+
$attributeValue = $this->config['default'][ $attr_key ];
|
510 |
} else { // Get Pattern value
|
511 |
$attributeValue = $this->getAttributeValueByType($product, $attribute);
|
512 |
}
|
513 |
|
514 |
// Format Output according to Output Type config.
|
515 |
+
if ( isset($this->config['output_type'][ $attr_key ]) ) {
|
516 |
+
$outputType = $this->config['output_type'][ $attr_key ];
|
517 |
+
$attributeValue = $this->format_output($attributeValue, $this->config['output_type'][ $attr_key ], $product, $attribute);
|
518 |
}
|
519 |
|
520 |
// Limit Output.
|
521 |
+
if ( isset($this->config['limit'][ $attr_key ]) ) {
|
522 |
+
$attributeValue = $this->crop_string($attributeValue, 0, $this->config['limit'][ $attr_key ]);
|
523 |
}
|
524 |
|
525 |
// Process prefix and suffix.
|
526 |
$attributeValue = $this->process_prefix_suffix($attributeValue, $prefix, $suffix, $attribute);
|
527 |
|
528 |
+
if ( 'xml' == $feedType ) {
|
529 |
|
530 |
// Replace XML Nodes according to merchant requirement.
|
531 |
$getReplacedAttribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
533 |
// XML does not support space in node. So replace Space with Underscore.
|
534 |
$getReplacedAttribute = str_replace(' ', '_', $getReplacedAttribute);
|
535 |
|
536 |
+
if ( ! empty($attributeValue) ) {
|
537 |
$attributeValue = trim($attributeValue);
|
538 |
}
|
539 |
|
540 |
// Add closing XML node if value is empty
|
541 |
+
if ( '' != $attributeValue ) {
|
542 |
// Add CDATA wrapper for XML feed to prevent XML error.
|
543 |
$attributeValue = woo_feed_add_cdata($merchant_attribute, $attributeValue, $merchant);
|
544 |
|
545 |
// TODO Move to proper place
|
546 |
// Replace Google Color attribute value according to requirements
|
547 |
+
if ( 'g:color' == $getReplacedAttribute ) {
|
548 |
$attributeValue = str_replace(', ', '/', $attributeValue);
|
549 |
}
|
550 |
|
558 |
$this->feedBody .= '<' . $getReplacedAttribute . '/>';
|
559 |
$this->feedBody .= "\n";
|
560 |
}
|
561 |
+
} elseif ( 'csv' == $feedType ) {
|
562 |
$merchant_attribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
563 |
$merchant_attribute = $this->processStringForCSV($merchant_attribute);
|
564 |
$attributeValue = $this->processStringForCSV($attributeValue);
|
565 |
+
} elseif ( 'txt' == $feedType ) {
|
566 |
$merchant_attribute = woo_feed_replace_to_merchant_attribute($merchant_attribute, $merchant, $feedType);
|
567 |
$merchant_attribute = $this->processStringForTXT($merchant_attribute);
|
568 |
$attributeValue = $this->processStringForTXT($attributeValue);
|
569 |
}
|
570 |
|
571 |
+
$this->products[ $this->pi ][ $merchant_attribute ] = $attributeValue;
|
572 |
}
|
573 |
}
|
574 |
|
582 |
* @since 3.3.9
|
583 |
*
|
584 |
*/
|
585 |
+
protected function exclude_from_loop( $product ) {
|
|
|
586 |
// For WP_Query check available product types
|
587 |
+
if ( 'wp' == $this->queryType && ! in_array($product->get_type(), $this->product_types) ) {
|
588 |
woo_feed_log_feed_process($this->config['filename'], sprintf('Skipping Product :: Invalid Post/Product Type : %s.', $product->get_type()));
|
589 |
return true;
|
590 |
}
|
591 |
|
592 |
// Skip for invalid products
|
593 |
+
if ( ! is_object($product) ) {
|
594 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Product data is not a valid WC_Product object.');
|
595 |
return true;
|
596 |
}
|
597 |
|
598 |
// Skip for invisible products
|
599 |
+
if ( ! $product->is_visible() ) {
|
600 |
woo_feed_log_feed_process($this->config['filename'], 'Skipping Product :: Product is not visible.');
|
601 |
return true;
|
602 |
}
|
617 |
* @since 3.3.9
|
618 |
*
|
619 |
*/
|
620 |
+
protected function exclude_current_attribute( $product, $merchant_attribute, $product_attribute, $feedType = 'xml' ) {
|
621 |
+
if ( empty($merchant_attribute) ) {
|
|
|
622 |
return true;
|
623 |
}
|
624 |
|
625 |
if (
|
626 |
$feedType == $this->config['feedType'] &&
|
627 |
in_array($this->config['provider'], array_keys($this->skipped_merchant_attributes)) &&
|
628 |
+
in_array($merchant_attribute, $this->skipped_merchant_attributes[ $this->config['provider'] ])
|
629 |
|
630 |
) {
|
631 |
return true;
|
632 |
}
|
633 |
|
634 |
+
if ( 'shopping_ads_excluded_country' !== $merchant_attribute && in_array($merchant_attribute, $this->processed_merchant_attributes) ) {
|
635 |
return true;
|
636 |
}
|
637 |
|
651 |
*
|
652 |
* @return string
|
653 |
*/
|
654 |
+
protected function crop_string( $string, $start = 0, $limit = null ) {
|
|
|
655 |
$limit = absint($limit);
|
656 |
+
if ( $limit > 0 ) {
|
657 |
$start = absint($start);
|
658 |
+
if ( strpos($string, '<![CDATA[') !== false ) {
|
659 |
+
$string = str_replace(array( '<![CDATA[', ']]>' ), array( '', '' ), $string);
|
660 |
$string = substr($string, $start, $limit);
|
661 |
$string = '<![CDATA[' . $string . ']]>';
|
662 |
} else {
|
675 |
* @since 3.2.0
|
676 |
*
|
677 |
*/
|
678 |
+
protected function process_for_merchant( $productObj, $index ) {
|
679 |
+
$product = $this->products[ $index ];
|
|
|
680 |
$merchantAttributes = $this->config['mattributes'];
|
681 |
|
682 |
// Format Shipping and Tax data for CSV and TXT feed only for google and facebook
|
683 |
+
if ( 'xml' != $this->config['feedType'] && in_array($this->config['provider'], [ 'google', 'facebook' ]) ) {
|
684 |
|
685 |
$shipping = array();
|
686 |
$tax = array();
|
687 |
$installment = array();
|
688 |
+
$product_detail = array();
|
689 |
$s = 0; // Shipping Index
|
690 |
$t = 0; // Tax Index
|
691 |
$i = 0; // Installment Index
|
703 |
'attribute_name',
|
704 |
'attribute_value',
|
705 |
);
|
706 |
+
foreach ( $this->products[ $this->pi ] as $attribute => $value ) {
|
707 |
+
if ( in_array($attribute, $shippingAttr) ) {
|
708 |
|
709 |
+
if ( 'tax_country' == $attribute ) {
|
710 |
$t++;
|
711 |
+
$tax[ $t ] .= $value . ':';
|
712 |
+
} elseif ( 'tax_region' == $attribute ) {
|
713 |
+
$tax[ $t ] .= $value . ':';
|
714 |
+
} elseif ( 'tax_rate' == $attribute ) {
|
715 |
+
$tax[ $t ] .= $value . ':';
|
716 |
+
} elseif ( 'tax_ship' == $attribute ) {
|
717 |
+
$tax[ $t ] .= $value . ':';
|
718 |
}
|
719 |
|
720 |
+
if ( 'shipping_country' == $attribute ) {
|
721 |
$s++;
|
722 |
+
$shipping[ $s ] .= $value . ':';
|
723 |
+
} elseif ( 'shipping_service' == $attribute ) {
|
724 |
+
$shipping[ $s ] .= $value . ':';
|
725 |
+
} elseif ( 'shipping_price' == $attribute ) {
|
726 |
+
$shipping[ $s ] .= $value . ':';
|
727 |
+
} elseif ( 'shipping_region' == $attribute ) {
|
728 |
+
$shipping[ $s ] .= $value . ':';
|
729 |
}
|
730 |
|
731 |
|
732 |
+
unset($this->products[ $this->pi ][ $attribute ]);
|
733 |
}
|
734 |
}
|
735 |
|
736 |
+
foreach ( $shipping as $key => $val ) {
|
737 |
+
$this->products[ $this->pi ]['shipping(country:region:service:price)'] = $val;
|
738 |
}
|
739 |
|
740 |
+
foreach ( $tax as $key => $val ) {
|
741 |
+
$this->products[ $this->pi ]['tax(country:region:rate:tax_ship)'] = $val;
|
742 |
}
|
743 |
}
|
744 |
|
745 |
+
if ( 'google' == $this->config['provider'] ) {
|
746 |
|
747 |
// Reformat Shipping attributes for google, facebook
|
748 |
$t = 0;
|
751 |
$shipping = '';
|
752 |
$sub = 0;
|
753 |
$subscription = '';
|
754 |
+
$product_detail = '';
|
755 |
+
$pd = 0;
|
756 |
+
if ( 'xml' == $this->config['feedType'] ) {
|
757 |
+
foreach ( $merchantAttributes as $key => $value ) {
|
758 |
|
759 |
+
if ( ! in_array($value, $this->google_shipping_tax) ) {
|
760 |
continue;
|
761 |
}
|
762 |
|
763 |
+
$prefix = $this->config['prefix'][ $key ];
|
764 |
+
$suffix = $this->config['suffix'][ $key ];
|
765 |
|
766 |
+
if ( 'pattern' == $this->config['type'][ $key ] ) {
|
767 |
+
$output = $this->config['default'][ $key ];
|
768 |
} else { // Get Pattern value.
|
769 |
+
$attribute = $this->config['attributes'][ $key ];
|
770 |
$output = $this->getAttributeValueByType($productObj, $attribute);
|
771 |
}
|
772 |
|
773 |
+
if ( false !== strpos($value, 'price') || false !== strpos($value, 'rate') ) {
|
774 |
$suffix = '' . $suffix;
|
775 |
}
|
776 |
|
777 |
|
778 |
$output = $prefix . $output . $suffix;
|
779 |
|
780 |
+
if ( 'shipping_country' == $value ) {
|
781 |
+
if ( 0 == $s ) {
|
782 |
$shipping .= '<g:shipping>';
|
783 |
$s = 1;
|
784 |
} else {
|
785 |
$shipping .= '</g:shipping>' . "\n";
|
786 |
$shipping .= '<g:shipping>';
|
787 |
}
|
788 |
+
} elseif ( ! in_array('shipping_country', $merchantAttributes) && 'shipping_price' == $value ) {
|
789 |
+
if ( 0 == $s ) {
|
790 |
$shipping .= '<g:shipping>';
|
791 |
$s = 1;
|
792 |
} else {
|
795 |
}
|
796 |
}
|
797 |
|
798 |
+
if ( 'shipping_country' == $value ) {
|
799 |
$shipping .= '<g:country>' . $output . '</g:country>' . "\n";
|
800 |
+
} elseif ( 'shipping_region' == $value ) {
|
801 |
$shipping .= '<g:region>' . $output . '</g:region>' . "\n";
|
802 |
+
} elseif ( 'shipping_service' == $value ) {
|
803 |
$shipping .= '<g:service>' . $output . '</g:service>' . "\n";
|
804 |
+
} elseif ( 'shipping_price' == $value ) {
|
805 |
$shipping .= '<g:price>' . $output . '</g:price>' . "\n";
|
806 |
+
} elseif ( 'tax_country' == $value ) {
|
807 |
+
if ( 0 == $t ) {
|
808 |
$tax .= '<g:tax>';
|
809 |
$t = 1;
|
810 |
} else {
|
812 |
$tax .= '<g:tax>';
|
813 |
}
|
814 |
$tax .= '<g:country>' . $output . '</g:country>' . "\n";
|
815 |
+
} elseif ( 'tax_region' == $value ) {
|
816 |
$tax .= '<g:region>' . $output . '</g:region>' . "\n";
|
817 |
+
} elseif ( 'tax_rate' == $value ) {
|
818 |
$tax .= '<g:rate>' . $output . '</g:rate>' . "\n";
|
819 |
+
} elseif ( 'tax_ship' == $value ) {
|
820 |
$tax .= '<g:tax_ship>' . $output . '</g:tax_ship>' . "\n";
|
821 |
}elseif ( 'subscription_period' == $value ) {
|
822 |
if ( 0 == $sub ) {
|
831 |
$subscription .= '<g:period_length>' . $output . '</g:period_length>' . "\n";
|
832 |
}elseif ( 'subscription_amount' == $value ) {
|
833 |
$subscription .= '<g:amount>' . $output . '</g:amount>' . "\n";
|
834 |
+
}elseif ( 'section_name' == $value ) {
|
835 |
+
if ( 0 == $pd ) {
|
836 |
$product_detail .= '<g:product_detail>';
|
837 |
$pd = 1;
|
838 |
} else {
|
839 |
$product_detail .= '</g:product_detail>' . "\n";
|
840 |
$product_detail .= '<g:product_detail>';
|
841 |
}
|
842 |
+
} elseif ( ! in_array('section_name', $merchantAttributes) && 'attribute_name' == $value ) {
|
843 |
+
if ( 0 == $pd ) {
|
844 |
$product_detail .= '<g:product_detail>';
|
845 |
$pd = 1;
|
846 |
} else {
|
858 |
}
|
859 |
}
|
860 |
|
861 |
+
if ( 1 == $pd ) {
|
862 |
$product_detail .= '</g:product_detail>';
|
863 |
}
|
864 |
|
865 |
+
if ( 1 == $s ) {
|
866 |
$shipping .= '</g:shipping>';
|
867 |
}
|
868 |
+
if ( 1 == $t ) {
|
869 |
$tax .= '</g:tax>';
|
870 |
}
|
871 |
|
877 |
$this->feedBody .= $tax;
|
878 |
$this->feedBody .= $product_detail;
|
879 |
|
880 |
+
if ( $productObj->is_type('subscription') ||
|
881 |
$productObj->is_type('variable-subscription') ||
|
882 |
+
$productObj->is_type('subscription_variation') ) {
|
883 |
$this->feedBody .= $subscription;
|
884 |
}
|
885 |
}
|
886 |
// ADD g:identifier_exists
|
887 |
+
$identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
|
888 |
$countIdentifier = 0;
|
889 |
+
if ( ! in_array('identifier_exists', $merchantAttributes) ) {
|
890 |
+
if ( count(array_intersect_key(array_flip($identifier), $product)) >= 2 ) {
|
891 |
// Any 2 required keys exist!
|
892 |
// @TODO Refactor with OR
|
893 |
+
if ( array_key_exists('brand', $product) && ! empty($product['brand']) ) {
|
894 |
$countIdentifier++;
|
895 |
}
|
896 |
+
if ( array_key_exists('upc', $product) && ! empty($product['upc']) ) {
|
897 |
$countIdentifier++;
|
898 |
}
|
899 |
+
if ( array_key_exists('sku', $product) && ! empty($product['sku']) ) {
|
900 |
$countIdentifier++;
|
901 |
}
|
902 |
+
if ( array_key_exists('mpn', $product) && ! empty($product['mpn']) ) {
|
903 |
$countIdentifier++;
|
904 |
}
|
905 |
+
if ( array_key_exists('gtin', $product) && ! empty($product['gtin']) ) {
|
906 |
$countIdentifier++;
|
907 |
}
|
908 |
}
|
909 |
|
910 |
+
if ( 'xml' == $this->config['feedType'] ) {
|
911 |
+
if ( $countIdentifier >= 2 ) {
|
912 |
$this->feedBody .= '<g:identifier_exists>yes</g:identifier_exists>';
|
913 |
} else {
|
914 |
$this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
|
915 |
}
|
916 |
} else {
|
917 |
+
if ( $countIdentifier >= 2 ) {
|
918 |
+
$this->products[ $this->pi ]['identifier exists'] = 'yes';
|
919 |
} else {
|
920 |
+
$this->products[ $this->pi ]['identifier exists'] = 'no';
|
921 |
}
|
922 |
}
|
923 |
}
|
928 |
* Get Query Type Settings
|
929 |
* @return string
|
930 |
*/
|
931 |
+
public function get_query_type() {
|
|
|
932 |
return $this->queryType;
|
933 |
}
|
934 |
|
935 |
+
public function get_product_types() {
|
|
|
936 |
return $this->product_types;
|
937 |
}
|
938 |
|
943 |
* @since 3.2.0
|
944 |
*
|
945 |
*/
|
946 |
+
protected function process_txt_feed_header() {
|
|
|
947 |
// Set Delimiter
|
948 |
+
if ( 'tab' == $this->config['delimiter'] ) {
|
949 |
$this->delimiter = "\t";
|
950 |
} else {
|
951 |
$this->delimiter = $this->config['delimiter'];
|
952 |
}
|
953 |
|
954 |
// Set Enclosure
|
955 |
+
if ( ! empty($this->config['enclosure']) ) {
|
956 |
$this->enclosure = $this->config['enclosure'];
|
957 |
+
if ( 'double' == $this->enclosure ) {
|
958 |
$this->enclosure = '"';
|
959 |
+
} elseif ( 'single' == $this->enclosure ) {
|
960 |
$this->enclosure = "'";
|
961 |
} else {
|
962 |
$this->enclosure = '';
|
966 |
}
|
967 |
|
968 |
$eol = PHP_EOL;
|
969 |
+
if ( 'trovaprezzi' === $this->config['provider'] ) {
|
970 |
$eol = '<endrecord>' . PHP_EOL;
|
971 |
}
|
972 |
|
973 |
+
$product = $this->products[ $this->pi ];
|
974 |
$headers = array_keys($product);
|
975 |
$this->feedHeader .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $headers) . $this->enclosure . $eol;
|
976 |
|
977 |
+
if ( 'google' === $this->config['provider'] ) {
|
978 |
+
$this->feedHeader = str_replace($this->google_product_highlights,'product highlight',$this->feedHeader);
|
979 |
+
$this->feedHeader = str_replace($this->google_additional_image,'additional image link',$this->feedHeader);
|
980 |
}
|
981 |
|
982 |
return $this->feedHeader;
|
989 |
* @since 3.2.0
|
990 |
*
|
991 |
*/
|
992 |
+
protected function process_txt_feed_body() {
|
993 |
+
$productInfo = array_values($this->products[ $this->pi ]);
|
|
|
994 |
$eol = PHP_EOL;
|
995 |
+
if ( 'trovaprezzi' === $this->config['provider'] ) {
|
996 |
$eol = '<endrecord>' . PHP_EOL;
|
997 |
}
|
998 |
$this->feedBody .= $this->enclosure . implode("$this->enclosure$this->delimiter$this->enclosure", $productInfo) . $this->enclosure . $eol;
|
1007 |
* @since 3.2.0
|
1008 |
*
|
1009 |
*/
|
1010 |
+
protected function process_csv_feed_header() {
|
|
|
1011 |
// Set Delimiter
|
1012 |
+
if ( 'tab' == $this->config['delimiter'] ) {
|
1013 |
$this->delimiter = "\t";
|
1014 |
} else {
|
1015 |
$this->delimiter = $this->config['delimiter'];
|
1016 |
}
|
1017 |
|
1018 |
// Set Enclosure
|
1019 |
+
if ( ! empty($this->config['enclosure']) ) {
|
1020 |
$this->enclosure = $this->config['enclosure'];
|
1021 |
+
if ( 'double' == $this->enclosure ) {
|
1022 |
$this->enclosure = '"';
|
1023 |
+
} elseif ( 'single' == $this->enclosure ) {
|
1024 |
$this->enclosure = "'";
|
1025 |
} else {
|
1026 |
$this->enclosure = '';
|
1029 |
$this->enclosure = '';
|
1030 |
}
|
1031 |
|
1032 |
+
$product = $this->products[ $this->pi ];
|
1033 |
$this->feedHeader = array_keys($product);
|
1034 |
|
1035 |
+
if ( 'google' === $this->config['provider'] ) {
|
1036 |
+
$this->feedHeader = str_replace($this->google_product_highlights,'product highlight',$this->feedHeader);
|
1037 |
+
$this->feedHeader = str_replace($this->google_additional_image,'additional image link',$this->feedHeader);
|
1038 |
}
|
1039 |
|
1040 |
return $this->feedHeader;
|
1045 |
* @return array
|
1046 |
* @since 3.2.0
|
1047 |
*/
|
1048 |
+
protected function process_csv_feed_body() {
|
1049 |
+
$product = $this->products[ $this->pi ];
|
|
|
1050 |
$this->feedBody[] = array_values($product);
|
1051 |
|
1052 |
return $this->feedBody;
|
1053 |
}
|
1054 |
|
1055 |
+
protected function process_xml_wrapper() {
|
|
|
1056 |
|
1057 |
$this->xml_wrapper = [
|
1058 |
'header' => '<?xml version="1.0" encoding="UTF-8" ?>' . PHP_EOL . '<' . $this->config['itemsWrapper'] . '>',
|
1061 |
$this->config['itemWrapper'] = str_replace(' ', '_', $this->config['itemWrapper']);
|
1062 |
$this->config['itemsWrapper'] = str_replace(' ', '_', $this->config['itemsWrapper']);
|
1063 |
|
1064 |
+
if ( file_exists(WOO_FEED_FREE_ADMIN_PATH . 'partials/templates/' . $this->config['provider'] . '.txt') ) {
|
1065 |
$txt = file_get_contents(WOO_FEED_FREE_ADMIN_PATH . 'partials/templates/' . $this->config['provider'] . '.txt');
|
1066 |
$txt = trim($txt);
|
1067 |
$txt = explode('{separator}', $txt);
|
1068 |
+
if ( 2 === count($txt) ) {
|
1069 |
$this->xml_wrapper['header'] = trim($txt[0]);
|
1070 |
$this->xml_wrapper['footer'] = trim($txt[1]);
|
1071 |
}
|
1072 |
}
|
1073 |
|
1074 |
+
if ( ! empty($this->config['extraHeader']) ) {
|
1075 |
$this->xml_wrapper['header'] .= PHP_EOL . $this->config['extraHeader'];
|
1076 |
}
|
1077 |
|
1083 |
$blog_email = get_bloginfo('admin_email'); // {BlogEmail}
|
1084 |
|
1085 |
$this->xml_wrapper['header'] = str_replace(
|
1086 |
+
[ '{DateTimeNow}', '{BlogName}', '{BlogURL}', '{BlogDescription}', '{BlogEmail}' ],
|
1087 |
+
[ $datetime_now, $blog_name, $blog_url, $blog_desc, $blog_email ],
|
1088 |
$this->xml_wrapper['header']
|
1089 |
);
|
1090 |
}
|
1094 |
* @return string
|
1095 |
* @since 3.2.0
|
1096 |
*/
|
1097 |
+
protected function process_xml_feed_header() {
|
|
|
1098 |
return $this->xml_wrapper['header'];
|
1099 |
}
|
1100 |
|
1103 |
* @return string
|
1104 |
* @since 3.2.0
|
1105 |
*/
|
1106 |
+
protected function process_xml_feed_footer() {
|
|
|
1107 |
return $this->xml_wrapper['footer'];
|
1108 |
}
|
1109 |
|
1116 |
* @since 3.2.0
|
1117 |
*
|
1118 |
*/
|
1119 |
+
protected function processStringForTXT( $string ) {
|
1120 |
+
if ( ! empty($string) ) {
|
|
|
1121 |
$string = html_entity_decode($string, ENT_HTML401 | ENT_QUOTES); // Convert any HTML entities
|
1122 |
|
1123 |
+
if ( stristr($string, '"') ) {
|
1124 |
$string = str_replace('"', '""', $string);
|
1125 |
}
|
1126 |
$string = str_replace("\n", ' ', $string);
|
1130 |
$string = stripslashes($string);
|
1131 |
|
1132 |
return $string;
|
1133 |
+
} elseif ( '0' == $string ) {
|
1134 |
return '0';
|
1135 |
} else {
|
1136 |
return '';
|
1146 |
* @since 3.2.0
|
1147 |
*
|
1148 |
*/
|
1149 |
+
protected function processStringForCSV( $string ) {
|
1150 |
+
if ( ! empty($string) ) {
|
|
|
1151 |
$string = str_replace("\n", ' ', $string);
|
1152 |
$string = str_replace("\r", ' ', $string);
|
1153 |
$string = trim($string);
|
1154 |
$string = stripslashes($string);
|
1155 |
|
1156 |
return $string;
|
1157 |
+
} elseif ( '0' == $string ) {
|
1158 |
return '0';
|
1159 |
} else {
|
1160 |
return '';
|
1171 |
* @since 3.2.0
|
1172 |
*
|
1173 |
*/
|
1174 |
+
protected function getAttributeValueByType( $product, $attribute ) {
|
|
|
1175 |
|
1176 |
+
if ( method_exists($this, $attribute) ) {
|
1177 |
+
$output = call_user_func_array(array( $this, $attribute ), array( $product ));
|
1178 |
+
} elseif ( false !== strpos($attribute, self::PRODUCT_ATTRIBUTE_PREFIX) ) {
|
1179 |
$attribute = str_replace(self::PRODUCT_ATTRIBUTE_PREFIX, '', $attribute);
|
1180 |
$output = $this->getProductAttribute($product, $attribute);
|
1181 |
+
} elseif ( false !== strpos($attribute, self::POST_META_PREFIX) ) {
|
1182 |
$attribute = str_replace(self::POST_META_PREFIX, '', $attribute);
|
1183 |
$output = $this->getProductMeta($product, $attribute);
|
1184 |
+
} elseif ( false !== strpos($attribute, self::PRODUCT_TAXONOMY_PREFIX) ) {
|
1185 |
$attribute = str_replace(self::PRODUCT_TAXONOMY_PREFIX, '', $attribute);
|
1186 |
$output = $this->getProductTaxonomy($product, $attribute);
|
1187 |
}elseif ( false !== strpos( $attribute, self::PRODUCT_CATEGORY_MAPPING_PREFIX ) ) {
|
1188 |
$id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
|
1189 |
$output = woo_feed_get_category_mapping_value( $attribute, $id );
|
1190 |
+
} elseif ( 'image_' == substr($attribute, 0, 6) ) {
|
1191 |
// For additional image method images() will be used with extra parameter - image number
|
1192 |
$imageKey = explode('_', $attribute);
|
1193 |
+
if ( ! isset($imageKey[1]) || (isset($imageKey[1]) && (empty($imageKey[1]) || ! is_numeric($imageKey[1]))) ) {
|
1194 |
$imageKey[1] = '';
|
1195 |
}
|
1196 |
+
$output = call_user_func_array(array( $this, 'images' ), array( $product, $imageKey[1] ));
|
1197 |
} else {
|
1198 |
// return the attribute so multiple attribute can be join with separator to make custom attribute.
|
1199 |
$output = $attribute;
|
1200 |
}
|
1201 |
|
1202 |
// Json encode if value is an array
|
1203 |
+
if ( is_array($output) ) {
|
1204 |
$output = wp_json_encode($output);
|
1205 |
}
|
1206 |
|
1251 |
* @return mixed
|
1252 |
* @since 3.2.0
|
1253 |
*/
|
1254 |
+
protected function id( $product ) {
|
|
|
1255 |
return $product->get_id();
|
1256 |
}
|
1257 |
|
1264 |
* @since 3.2.0
|
1265 |
*
|
1266 |
*/
|
1267 |
+
protected function title( $product ) {
|
|
|
1268 |
|
1269 |
return $this->remove_short_codes($product->get_name());
|
1270 |
}
|
1278 |
* @since 3.2.0
|
1279 |
*
|
1280 |
*/
|
1281 |
+
protected function yoast_wpseo_title( $product ) {
|
|
|
1282 |
$yoast_title = get_post_meta($product->get_id(), '_yoast_wpseo_title', true);
|
1283 |
+
if ( strpos($yoast_title, '%%') !== false ) {
|
1284 |
$title = strstr($yoast_title, '%%', true);
|
1285 |
+
if ( empty($title) ) {
|
1286 |
$title = get_the_title($product->get_id());
|
1287 |
}
|
1288 |
$wpseo_titles = get_option('wpseo_titles');
|
1289 |
|
1290 |
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
|
1291 |
+
if ( isset($wpseo_titles['separator']) && isset($sep_options[ $wpseo_titles['separator'] ]) ) {
|
1292 |
+
$sep = $sep_options[ $wpseo_titles['separator'] ];
|
1293 |
} else {
|
1294 |
$sep = '-'; //setting default separator if Admin didn't set it from backed
|
1295 |
}
|
1298 |
|
1299 |
$meta_title = $title . ' ' . $sep . ' ' . $site_title;
|
1300 |
|
1301 |
+
if ( ! empty($meta_title) ) {
|
1302 |
return $meta_title;
|
1303 |
}
|
1304 |
+
}elseif ( ! empty($yoast_title) ) {
|
1305 |
return $yoast_title;
|
1306 |
}
|
1307 |
|
1325 |
* @since 3.2.0
|
1326 |
*
|
1327 |
*/
|
1328 |
+
protected function _aioseop_title( $product ) {
|
|
|
1329 |
$title = '';
|
1330 |
+
if ( class_exists('All_in_One_SEO_Pack') ) {
|
1331 |
global $aioseop_options, $aiosp;
|
1332 |
+
if ( ! is_array($aioseop_options) ) {
|
1333 |
$aioseop_options = get_option('aioseop_options');
|
1334 |
}
|
1335 |
+
if ( ! ($aiosp instanceof All_in_One_SEO_Pack) ) {
|
1336 |
$aiosp = new All_in_One_SEO_Pack();
|
1337 |
}
|
1338 |
|
1339 |
+
if ( in_array('product', $aioseop_options['aiosp_cpostactive'], true) ) {
|
1340 |
+
if ( ! empty($aioseop_options['aiosp_rewrite_titles']) ) {
|
1341 |
$title = $aiosp->get_aioseop_title(get_post($product->get_id()));
|
1342 |
$title = $aiosp->apply_cf_fields($title);
|
1343 |
}
|
1344 |
$title = apply_filters('aioseop_title', $title);
|
1345 |
}
|
1346 |
}
|
1347 |
+
if ( ! empty($title) ) {
|
1348 |
return $title;
|
1349 |
}
|
1350 |
|
1360 |
* @since 3.2.0
|
1361 |
*
|
1362 |
*/
|
1363 |
+
protected function description( $product ) {
|
|
|
1364 |
|
1365 |
$description = $product->get_description();
|
1366 |
|
1367 |
// Get Variation Description
|
1368 |
+
if ( $product->is_type('variation') && empty($description) ) {
|
1369 |
$parent = wc_get_product($product->get_parent_id());
|
1370 |
$description = $parent->get_description();
|
1371 |
}
|
1372 |
$description = $this->remove_short_codes($description);
|
1373 |
|
1374 |
// Add variations attributes after description to prevent Facebook error
|
1375 |
+
if ( 'facebook' == $this->config['provider'] ) {
|
1376 |
$variationInfo = explode('-', $product->get_name());
|
1377 |
+
if ( isset($variationInfo[1]) ) {
|
1378 |
$extension = $variationInfo[1];
|
1379 |
} else {
|
1380 |
$extension = $product->get_id();
|
1394 |
* @since 3.2.0
|
1395 |
*
|
1396 |
*/
|
1397 |
+
protected function yoast_wpseo_metadesc( $product ) {
|
|
|
1398 |
$description = '';
|
1399 |
+
if ( class_exists('WPSEO_Frontend') ) {
|
1400 |
$description = wpseo_replace_vars(WPSEO_Meta::get_value('metadesc', $product->get_id()),
|
1401 |
get_post($product->get_id()));
|
1402 |
}
|
1403 |
+
if ( ! empty($description) ) {
|
1404 |
return $description;
|
1405 |
}
|
1406 |
|
1416 |
* @since 3.2.0
|
1417 |
*
|
1418 |
*/
|
1419 |
+
protected function _aioseop_description( $product ) {
|
|
|
1420 |
$description = '';
|
1421 |
+
if ( class_exists('All_in_One_SEO_Pack') ) {
|
1422 |
global $aioseop_options, $aiosp;
|
1423 |
+
if ( ! is_array($aioseop_options) ) {
|
1424 |
$aioseop_options = get_option('aioseop_options');
|
1425 |
}
|
1426 |
+
if ( ! ($aiosp instanceof All_in_One_SEO_Pack) ) {
|
1427 |
$aiosp = new All_in_One_SEO_Pack();
|
1428 |
}
|
1429 |
+
if ( in_array('product', $aioseop_options['aiosp_cpostactive'], true) ) {
|
1430 |
$description = $aiosp->get_main_description(get_post($product->get_id())); // Get the description.
|
1431 |
$description = $aiosp->trim_description($description);
|
1432 |
$description = apply_filters('aioseop_description_full',
|
1433 |
$aiosp->apply_description_format($description, get_post($product->get_id())));
|
1434 |
}
|
1435 |
}
|
1436 |
+
if ( ! empty($description) ) {
|
1437 |
return $description;
|
1438 |
}
|
1439 |
|
1449 |
* @since 3.2.0
|
1450 |
*
|
1451 |
*/
|
1452 |
+
protected function short_description( $product ) {
|
|
|
1453 |
|
1454 |
$short_description = $product->get_short_description();
|
1455 |
|
1456 |
// Get Variation Short Description
|
1457 |
+
if ( $product->is_type('variation') && empty($short_description) ) {
|
1458 |
$parent = wc_get_product($product->get_parent_id());
|
1459 |
$short_description = $parent->get_short_description();
|
1460 |
}
|
1505 |
* @return string
|
1506 |
*
|
1507 |
*/
|
1508 |
+
protected function primary_category( $product ) {
|
|
|
1509 |
$id = $product->get_id();
|
1510 |
+
if ( $product->is_type('variation') ) {
|
1511 |
$id = $product->get_parent_id();
|
1512 |
}
|
1513 |
$wpseo_primary_term = false;
|
1514 |
$main_category = '';
|
1515 |
+
if ( class_exists('WPSEO_Primary_Term') ) {
|
1516 |
$wpseo_primary_term = new WPSEO_Primary_Term('product_cat', $id);
|
1517 |
$main_category = $wpseo_primary_term->get_primary_term();
|
1518 |
$main_category = get_term($main_category, 'product_cat');
|
1519 |
}
|
1520 |
+
if ( ! ($wpseo_primary_term instanceof WPSEO_Primary_Term) || empty($main_category) ) {
|
1521 |
$term = wp_get_post_terms($id, 'product_cat');
|
1522 |
+
if ( ! is_wp_error($term) && ! empty($term) ) {
|
1523 |
$main_category = $term[0];
|
1524 |
}
|
1525 |
}
|
1535 |
* @return string
|
1536 |
*
|
1537 |
*/
|
1538 |
+
protected function primary_category_id( $product ) {
|
|
|
1539 |
$id = $product->get_id();
|
1540 |
+
if ( $product->is_type('variation') ) {
|
1541 |
$id = $product->get_parent_id();
|
1542 |
}
|
1543 |
$wpseo_primary_term = false;
|
1544 |
$main_category = '';
|
1545 |
+
if ( class_exists('WPSEO_Primary_Term') ) {
|
1546 |
$wpseo_primary_term = new WPSEO_Primary_Term('product_cat', $id);
|
1547 |
$main_category = $wpseo_primary_term->get_primary_term();
|
1548 |
$main_category = get_term($main_category, 'product_cat');
|
1549 |
}
|
1550 |
+
if ( ! ($wpseo_primary_term instanceof WPSEO_Primary_Term) || empty($main_category) ) {
|
1551 |
$term = wp_get_post_terms($id, 'product_cat');
|
1552 |
+
if ( ! is_wp_error($term) && ! empty($term) ) {
|
1553 |
$main_category = $term[0];
|
1554 |
}
|
1555 |
}
|
1568 |
$id = $product->get_id();
|
1569 |
$terms = get_the_terms( $id, 'product_cat' );
|
1570 |
$last_cat = ! empty($terms) && is_array($terms) ? end($terms) : [];
|
1571 |
+
$child_category = isset($last_cat->name) && ! empty($last_cat->name) ? $last_cat->name : '';
|
1572 |
|
1573 |
return $child_category;
|
1574 |
}
|
1596 |
* @since 3.2.0
|
1597 |
*
|
1598 |
*/
|
1599 |
+
protected function product_type( $product ) {
|
|
|
1600 |
$id = $product->get_id();
|
1601 |
+
if ( $product->is_type('variation') ) {
|
1602 |
$id = $product->get_parent_id();
|
1603 |
}
|
1604 |
|
1616 |
* @since 3.2.0
|
1617 |
*
|
1618 |
*/
|
1619 |
+
protected function link( $product ) {
|
|
|
1620 |
$utm = $this->config['campaign_parameters'];
|
1621 |
+
if ( ! empty($utm['utm_source']) && ! empty($utm['utm_medium']) && ! empty($utm['utm_campaign']) ) {
|
1622 |
$utm = [
|
1623 |
+
'utm_source' => $utm['utm_source'],
|
1624 |
+
'utm_medium' => $utm['utm_medium'],
|
1625 |
'utm_campaign' => $utm['utm_campaign'],
|
1626 |
+
'utm_term' => $utm['utm_term'],
|
1627 |
+
'utm_content' => $utm['utm_content'],
|
1628 |
];
|
1629 |
|
1630 |
return add_query_arg(array_filter($utm), $product->get_permalink());
|
1638 |
* @param WC_Product $product
|
1639 |
* @return mixed
|
1640 |
*/
|
1641 |
+
protected function canonical_link( $product ) {
|
1642 |
+
if ( $product->is_type('variation') ) {
|
1643 |
+
$product = wc_get_product($product->get_parent_id());
|
1644 |
return $product->get_permalink();
|
1645 |
}
|
1646 |
|
1656 |
* @since 3.2.0
|
1657 |
*
|
1658 |
*/
|
1659 |
+
protected function ex_link( $product ) {
|
1660 |
+
if ( $product->is_type('external') ) {
|
|
|
1661 |
return $product->get_product_url();
|
1662 |
}
|
1663 |
|
1673 |
* @since 3.2.0
|
1674 |
*
|
1675 |
*/
|
1676 |
+
protected function image( $product ) {
|
1677 |
+
if ( $product->is_type('variation') ) {
|
|
|
1678 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_id()),
|
1679 |
'single-post-thumbnail');
|
1680 |
+
if ( has_post_thumbnail($product->get_id()) && ! empty($getImage[0]) ) :
|
1681 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
1682 |
else :
|
1683 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_parent_id()),
|
1685 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
1686 |
endif;
|
1687 |
} else {
|
1688 |
+
if ( has_post_thumbnail($product->get_id()) ) :
|
1689 |
$getImage = wp_get_attachment_image_src(get_post_thumbnail_id($product->get_id()),
|
1690 |
'single-post-thumbnail');
|
1691 |
$image = woo_feed_get_formatted_url($getImage[0]);
|
1706 |
* @since 3.2.0
|
1707 |
*
|
1708 |
*/
|
1709 |
+
protected function feature_image( $product ) {
|
|
|
1710 |
return $this->image($product);
|
1711 |
}
|
1712 |
|
1720 |
* @since 3.2.0
|
1721 |
*
|
1722 |
*/
|
1723 |
+
protected function images( $product, $additionalImg = '' ) {
|
1724 |
+
if ( $product->is_type('variation') ) {
|
|
|
1725 |
// TODO Test Variation Images
|
1726 |
$imgUrls = $this->get_product_gallery(wc_get_product($product->get_parent_id()));
|
1727 |
} else {
|
1729 |
}
|
1730 |
|
1731 |
// Return Specific Additional Image URL
|
1732 |
+
if ( '' != $additionalImg ) {
|
1733 |
+
if ( array_key_exists($additionalImg, $imgUrls) ) {
|
1734 |
+
return $imgUrls[ $additionalImg ];
|
1735 |
} else {
|
1736 |
return '';
|
1737 |
}
|
1749 |
* @return string[]
|
1750 |
* @since 3.2.6
|
1751 |
*/
|
1752 |
+
protected function get_product_gallery( $product ) {
|
|
|
1753 |
$attachmentIds = $product->get_gallery_image_ids();
|
1754 |
$imgUrls = array();
|
1755 |
+
if ( $attachmentIds && is_array($attachmentIds) ) {
|
1756 |
$mKey = 1;
|
1757 |
+
foreach ( $attachmentIds as $attachmentId ) {
|
1758 |
+
$imgUrls[ $mKey ] = woo_feed_get_formatted_url(wp_get_attachment_url($attachmentId));
|
1759 |
$mKey++;
|
1760 |
}
|
1761 |
}
|
1772 |
* @since 3.2.0
|
1773 |
*
|
1774 |
*/
|
1775 |
+
protected function condition( $product ) {
|
|
|
1776 |
return apply_filters('woo_feed_product_condition', 'new', $product);
|
1777 |
}
|
1778 |
|
1785 |
* @since 3.2.0
|
1786 |
*
|
1787 |
*/
|
1788 |
+
protected function type( $product ) {
|
|
|
1789 |
return $product->get_type();
|
1790 |
}
|
1791 |
|
1798 |
* @since 3.2.0
|
1799 |
*
|
1800 |
*/
|
1801 |
+
protected function is_bundle( $product ) {
|
1802 |
+
if ( $product->is_type('bundle') || $product->is_type('yith_bundle') ) {
|
|
|
1803 |
return 'yes';
|
1804 |
}
|
1805 |
|
1815 |
* @since 3.2.0
|
1816 |
*
|
1817 |
*/
|
1818 |
+
protected function multipack( $product ) {
|
|
|
1819 |
$multi_pack = '';
|
1820 |
+
if ( $product->is_type('grouped') ) {
|
1821 |
+
$multi_pack = ( ! empty($product->get_children())) ? count($product->get_children()) : '';
|
1822 |
}
|
1823 |
|
1824 |
return $multi_pack;
|
1833 |
* @since 3.2.0
|
1834 |
*
|
1835 |
*/
|
1836 |
+
protected function visibility( $product ) {
|
|
|
1837 |
return $product->get_catalog_visibility();
|
1838 |
}
|
1839 |
|
1846 |
* @since 3.2.0
|
1847 |
*
|
1848 |
*/
|
1849 |
+
protected function rating_total( $product ) {
|
|
|
1850 |
return $product->get_rating_count();
|
1851 |
}
|
1852 |
|
1859 |
* @since 3.2.0
|
1860 |
*
|
1861 |
*/
|
1862 |
+
protected function rating_average( $product ) {
|
|
|
1863 |
return $product->get_average_rating();
|
1864 |
}
|
1865 |
|
1872 |
* @since 3.2.0
|
1873 |
*
|
1874 |
*/
|
1875 |
+
protected function tags( $product ) {
|
|
|
1876 |
$id = $product->get_id();
|
1877 |
+
if ( $product->is_type('variation') ) {
|
1878 |
$id = $product->get_parent_id();
|
1879 |
}
|
1880 |
|
1899 |
* @since 3.2.0
|
1900 |
*
|
1901 |
*/
|
1902 |
+
protected function item_group_id( $product ) {
|
|
|
1903 |
$id = $product->get_id();
|
1904 |
+
if ( $product->is_type('variation') ) {
|
1905 |
$id = $product->get_parent_id();
|
1906 |
}
|
1907 |
|
1917 |
* @since 3.2.0
|
1918 |
*
|
1919 |
*/
|
1920 |
+
protected function sku( $product ) {
|
|
|
1921 |
return $product->get_sku();
|
1922 |
}
|
1923 |
|
1930 |
* @since 3.2.0
|
1931 |
*
|
1932 |
*/
|
1933 |
+
protected function parent_sku( $product ) {
|
1934 |
+
if ( $product->is_type('variation') ) {
|
|
|
1935 |
$id = $product->get_parent_id();
|
1936 |
$parent = wc_get_product($id);
|
1937 |
|
1950 |
* @since 3.2.0
|
1951 |
*
|
1952 |
*/
|
1953 |
+
protected function availability( $product ) {
|
|
|
1954 |
$status = $product->get_stock_status();
|
1955 |
+
if ( 'instock' == $status ) {
|
1956 |
return 'in stock';
|
1957 |
+
} elseif ( 'outofstock' == $status ) {
|
1958 |
return 'out of stock';
|
1959 |
+
} elseif ( 'onbackorder' == $status ) {
|
1960 |
return 'on backorder';
|
1961 |
} else {
|
1962 |
return 'in stock';
|
1972 |
* @since 3.2.0
|
1973 |
*
|
1974 |
*/
|
1975 |
+
protected function quantity( $product ) {
|
1976 |
+
if ( $product->is_type('variable') && $product->has_child() ) {
|
|
|
1977 |
$visible_children = $product->get_visible_children();
|
1978 |
$qty = array();
|
1979 |
+
foreach ( $visible_children as $key => $child ) {
|
1980 |
$childQty = get_post_meta($child, '_stock', true);
|
1981 |
$qty[] = (int)$childQty + 0;
|
1982 |
}
|
1983 |
|
1984 |
+
if ( isset($this->config['variable_quantity']) ) {
|
1985 |
$vaQty = $this->config['variable_quantity'];
|
1986 |
+
if ( 'max' == $vaQty ) {
|
1987 |
return max($qty);
|
1988 |
+
} elseif ( 'min' == $vaQty ) {
|
1989 |
return min($qty);
|
1990 |
+
} elseif ( 'sum' == $vaQty ) {
|
1991 |
return array_sum($qty);
|
1992 |
+
} elseif ( 'first' == $vaQty ) {
|
1993 |
+
return ( (int)$qty[0]);
|
1994 |
}
|
1995 |
|
1996 |
return array_sum($qty);
|
2009 |
* @since 3.2.0
|
2010 |
*
|
2011 |
*/
|
2012 |
+
protected function sale_price_sdate( $product ) {
|
|
|
2013 |
$startDate = $product->get_date_on_sale_from();
|
2014 |
+
if ( is_object($startDate) ) {
|
2015 |
return $startDate->date_i18n();
|
2016 |
}
|
2017 |
|
2027 |
* @since 3.2.0
|
2028 |
*
|
2029 |
*/
|
2030 |
+
protected function sale_price_edate( $product ) {
|
|
|
2031 |
$endDate = $product->get_date_on_sale_to();
|
2032 |
+
if ( is_object($endDate) ) {
|
2033 |
return $endDate->date_i18n();
|
2034 |
}
|
2035 |
|
2045 |
* @since 3.2.0
|
2046 |
*
|
2047 |
*/
|
2048 |
+
protected function price( $product ) {
|
2049 |
+
if ( $product->is_type('variable') ) {
|
|
|
2050 |
return $this->getVariableProductPrice($product, 'regular_price');
|
2051 |
+
} elseif ( $product->is_type('grouped') ) {
|
2052 |
return $this->getGroupProductPrice($product,
|
2053 |
'regular'); // this calls self::price() so no need to use self::getWPMLPrice()
|
2054 |
} else {
|
2065 |
* @since 3.2.0
|
2066 |
*
|
2067 |
*/
|
2068 |
+
protected function current_price( $product ) {
|
2069 |
+
if ( $product->is_type('variable') ) {
|
|
|
2070 |
return $this->getVariableProductPrice($product, 'price');
|
2071 |
+
} elseif ( $product->is_type('grouped') ) {
|
2072 |
return $this->getGroupProductPrice($product, 'current');
|
2073 |
} else {
|
2074 |
return $product->get_price();
|
2084 |
* @since 3.2.0
|
2085 |
*
|
2086 |
*/
|
2087 |
+
protected function sale_price( $product ) {
|
2088 |
+
if ( $product->is_type('variable') ) {
|
|
|
2089 |
return $this->getVariableProductPrice($product, 'sale_price');
|
2090 |
+
} elseif ( $product->is_type('grouped') ) {
|
2091 |
return $this->getGroupProductPrice($product, 'sale');
|
2092 |
} else {
|
2093 |
$price = $product->get_sale_price();
|
2105 |
* @since 3.2.0
|
2106 |
*
|
2107 |
*/
|
2108 |
+
protected function price_with_tax( $product ) {
|
2109 |
+
if ( $product->is_type('variable') ) {
|
|
|
2110 |
return $this->getVariableProductPrice($product, 'regular_price', true);
|
2111 |
+
} elseif ( $product->is_type('grouped') ) {
|
2112 |
return $this->getGroupProductPrice($product, 'regular', true);
|
2113 |
} else {
|
2114 |
$price = $this->price($product);
|
2115 |
|
2116 |
// Get price with tax.
|
2117 |
+
return ($product->is_taxable() && ! empty($price)) ? $this->get_price_with_tax($product,
|
2118 |
$price) : $price;
|
2119 |
}
|
2120 |
}
|
2128 |
* @since 3.2.0
|
2129 |
*
|
2130 |
*/
|
2131 |
+
protected function current_price_with_tax( $product ) {
|
2132 |
+
if ( $product->is_type('variable') ) {
|
|
|
2133 |
return $this->getVariableProductPrice($product, 'current_price', true);
|
2134 |
+
} elseif ( $product->is_type('grouped') ) {
|
2135 |
return $this->getGroupProductPrice($product, 'current', true);
|
2136 |
} else {
|
2137 |
$price = $this->current_price($product);
|
2138 |
|
2139 |
// Get price with tax
|
2140 |
+
return ($product->is_taxable() && ! empty($price)) ? $this->get_price_with_tax($product,
|
2141 |
$price) : $price;
|
2142 |
}
|
2143 |
}
|
2151 |
* @since 3.2.0
|
2152 |
*
|
2153 |
*/
|
2154 |
+
protected function sale_price_with_tax( $product ) {
|
2155 |
+
if ( $product->is_type('variable') ) {
|
|
|
2156 |
return $this->getVariableProductPrice($product, 'sale_price', true);
|
2157 |
+
} elseif ( $product->is_type('grouped') ) {
|
2158 |
return $this->getGroupProductPrice($product, 'sale', true);
|
2159 |
} else {
|
2160 |
$price = $this->sale_price($product);
|
2161 |
+
if ( $product->is_taxable() && ! empty($price) ) {
|
2162 |
$price = $this->get_price_with_tax($product, $price);
|
2163 |
}
|
2164 |
|
2177 |
* @since 3.2.0
|
2178 |
*
|
2179 |
*/
|
2180 |
+
protected function getGroupProductPrice( $grouped, $type, $tax = false ) {
|
|
|
2181 |
$groupProductIds = $grouped->get_children();
|
2182 |
$sum = 0;
|
2183 |
+
if ( ! empty($groupProductIds) ) {
|
2184 |
+
foreach ( $groupProductIds as $id ) {
|
2185 |
$product = wc_get_product($id);
|
2186 |
|
2187 |
+
if ( ! is_object($product) ) {
|
2188 |
continue; // make sure that the product exists..
|
2189 |
}
|
2190 |
|
2191 |
+
if ( $tax ) {
|
2192 |
+
if ( 'regular' == $type ) {
|
2193 |
$regularPrice = $this->price_with_tax($product);
|
2194 |
$sum += (float)$regularPrice;
|
2195 |
+
} elseif ( 'current' == $type ) {
|
2196 |
$currentPrice = $this->current_price_with_tax($product);
|
2197 |
$sum += (float)$currentPrice;
|
2198 |
} else {
|
2200 |
$sum += (float)$salePrice;
|
2201 |
}
|
2202 |
} else {
|
2203 |
+
if ( 'regular' == $type ) {
|
2204 |
$regularPrice = $this->price($product);
|
2205 |
$sum += (float)$regularPrice;
|
2206 |
+
} elseif ( 'current' == $type ) {
|
2207 |
$currentPrice = $this->current_price($product);
|
2208 |
$sum += (float)$currentPrice;
|
2209 |
} else {
|
2214 |
}
|
2215 |
}
|
2216 |
|
2217 |
+
if ( 'sale' == $type ) {
|
2218 |
$sum = $sum > 0 ? $sum : '';
|
2219 |
}
|
2220 |
|
2232 |
* @since 3.2.0
|
2233 |
*
|
2234 |
*/
|
2235 |
+
protected function getVariableProductPrice( $variable, $type, $tax = false ) {
|
|
|
2236 |
$price = 0;
|
2237 |
+
if ( 'regular_price' == $type ) {
|
2238 |
$price = $variable->get_variation_regular_price();
|
2239 |
+
} elseif ( 'sale_price' == $type ) {
|
2240 |
$price = $variable->get_variation_sale_price();
|
2241 |
} else {
|
2242 |
$price = $variable->get_variation_price();
|
2243 |
}
|
2244 |
+
if ( true === $tax && $variable->is_taxable() ) {
|
2245 |
$price = $this->get_price_with_tax($variable, $price);
|
2246 |
}
|
2247 |
+
if ( 'sale_price' != $type ) {
|
2248 |
$price = $price > 0 ? $price : '';
|
2249 |
}
|
2250 |
|
2261 |
* @since 3.2.0
|
2262 |
*
|
2263 |
*/
|
2264 |
+
protected function get_price_with_tax( $product, $price ) {
|
2265 |
+
if ( woo_feed_wc_version_check(3.0) ) {
|
2266 |
+
return wc_get_price_including_tax($product, array( 'price' => $price ));
|
|
|
2267 |
} else {
|
2268 |
return $product->get_price_including_tax(1, $price);
|
2269 |
}
|
2278 |
* @since 3.2.0
|
2279 |
*
|
2280 |
*/
|
2281 |
+
protected function weight( $product ) {
|
|
|
2282 |
return $product->get_weight();
|
2283 |
}
|
2284 |
|
2291 |
* @since 3.2.0
|
2292 |
*
|
2293 |
*/
|
2294 |
+
protected function width( $product ) {
|
|
|
2295 |
return $product->get_width();
|
2296 |
}
|
2297 |
|
2304 |
* @since 3.2.0
|
2305 |
*
|
2306 |
*/
|
2307 |
+
protected function height( $product ) {
|
|
|
2308 |
return $product->get_height();
|
2309 |
}
|
2310 |
|
2317 |
* @since 3.2.0
|
2318 |
*
|
2319 |
*/
|
2320 |
+
protected function length( $product ) {
|
|
|
2321 |
return $product->get_length();
|
2322 |
}
|
2323 |
|
2330 |
* @since 3.2.0
|
2331 |
*
|
2332 |
*/
|
2333 |
+
protected function shipping_class( $product ) {
|
|
|
2334 |
return $product->get_shipping_class();
|
2335 |
}
|
2336 |
|
2343 |
* @since 3.2.0
|
2344 |
*
|
2345 |
*/
|
2346 |
+
protected function author_name( $product ) {
|
|
|
2347 |
$post = get_post($product->get_id());
|
2348 |
|
2349 |
return get_the_author_meta('user_login', $post->post_author);
|
2358 |
* @since 3.2.0
|
2359 |
*
|
2360 |
*/
|
2361 |
+
protected function author_email( $product ) {
|
|
|
2362 |
$post = get_post($product->get_id());
|
2363 |
|
2364 |
return get_the_author_meta('user_email', $post->post_author);
|
2373 |
* @since 3.2.0
|
2374 |
*
|
2375 |
*/
|
2376 |
+
protected function date_created( $product ) {
|
|
|
2377 |
return gmdate('Y-m-d', strtotime($product->get_date_created()));
|
2378 |
}
|
2379 |
|
2386 |
* @since 3.2.0
|
2387 |
*
|
2388 |
*/
|
2389 |
+
protected function date_updated( $product ) {
|
|
|
2390 |
return gmdate('Y-m-d', strtotime($product->get_date_modified()));
|
2391 |
}
|
2392 |
|
2395 |
* @param WC_Product $product Product object.
|
2396 |
* @return string
|
2397 |
*/
|
2398 |
+
protected function tax_class( $product ) {
|
2399 |
return $product->get_tax_class();
|
2400 |
}
|
2401 |
|
2404 |
* @param WC_Product $product Product object.
|
2405 |
* @return string
|
2406 |
*/
|
2407 |
+
protected function tax_status( $product ) {
|
2408 |
return $product->get_tax_status();
|
2409 |
}
|
2410 |
|
2413 |
* @param WC_Product $product Product object.
|
2414 |
* @return string
|
2415 |
*/
|
2416 |
+
protected function woo_feed_gtin( $product ) {
|
2417 |
+
$id = $product->get_id();
|
2418 |
+
$meta = 'woo_feed_gtin';
|
2419 |
+
if ( $product->is_type('variation') ) {
|
2420 |
+
$meta = 'woo_feed_gtin_var';
|
2421 |
}
|
2422 |
return $this->getProductMeta($product,$meta);
|
2423 |
}
|
2427 |
* @param WC_Product $product Product object.
|
2428 |
* @return string
|
2429 |
*/
|
2430 |
+
protected function woo_feed_mpn( $product ) {
|
2431 |
+
$id = $product->get_id();
|
2432 |
+
$meta = 'woo_feed_mpn';
|
2433 |
+
if ( $product->is_type('variation') ) {
|
2434 |
+
$meta = 'woo_feed_mpn_var';
|
2435 |
}
|
2436 |
return $this->getProductMeta($product,$meta);
|
2437 |
}
|
2441 |
* @param WC_Product $product Product object.
|
2442 |
* @return string
|
2443 |
*/
|
2444 |
+
protected function woo_feed_ean( $product ) {
|
2445 |
+
$id = $product->get_id();
|
2446 |
+
$meta = 'woo_feed_ean';
|
2447 |
+
if ( $product->is_type('variation') ) {
|
2448 |
+
$meta = 'woo_feed_ean_var';
|
2449 |
}
|
2450 |
return $this->getProductMeta($product,$meta);
|
2451 |
}
|
2459 |
* @since 3.2.0
|
2460 |
*
|
2461 |
*/
|
2462 |
+
protected function sale_price_effective_date( $product ) {
|
|
|
2463 |
$effective_date = '';
|
2464 |
$from = $this->sale_price_sdate($product);
|
2465 |
$to = $this->sale_price_edate($product);
|
2466 |
+
if ( ! empty($from) && ! empty($to) ) {
|
2467 |
$from = gmdate('c', strtotime($from));
|
2468 |
$to = gmdate('c', strtotime($to));
|
2469 |
|
2483 |
* @since 2.2.3
|
2484 |
*
|
2485 |
*/
|
2486 |
+
protected function getProductAttribute( $product, $attr ) {
|
|
|
2487 |
$id = $product->get_id();
|
2488 |
|
2489 |
+
if ( woo_feed_wc_version_check(3.2) ) {
|
2490 |
+
if ( woo_feed_wc_version_check(3.6) ) {
|
2491 |
$attr = str_replace('pa_', '', $attr);
|
2492 |
}
|
2493 |
$value = $product->get_attribute($attr);
|
2494 |
|
2495 |
return $value;
|
2496 |
} else {
|
2497 |
+
return implode(',', wc_get_product_terms($id, $attr, array( 'fields' => 'names' )));
|
2498 |
}
|
2499 |
}
|
2500 |
|
2508 |
* @since 2.2.3
|
2509 |
*
|
2510 |
*/
|
2511 |
+
protected function getProductMeta( $product, $meta ) {
|
|
|
2512 |
$value = get_post_meta($product->get_id(), $meta, true);
|
2513 |
// if empty get meta value of parent post
|
2514 |
+
if ( '' == $value && $product->get_parent_id() ) {
|
2515 |
$value = get_post_meta($product->get_parent_id(), $meta, true);
|
2516 |
}
|
2517 |
|
2527 |
* @since 3.2.0
|
2528 |
*
|
2529 |
*/
|
2530 |
+
public function filter_product( $product ) {
|
|
|
2531 |
return true;
|
2532 |
}
|
2533 |
|
2541 |
* @since 2.2.3
|
2542 |
*
|
2543 |
*/
|
2544 |
+
protected function getProductTaxonomy( $product, $taxonomy ) {
|
|
|
2545 |
$id = $product->get_id();
|
2546 |
+
if ( $product->is_type('variation') ) {
|
2547 |
$id = $product->get_parent_id();
|
2548 |
}
|
2549 |
|
2563 |
* @since 3.2.0
|
2564 |
*
|
2565 |
*/
|
2566 |
+
protected function price_format( $name, $conditionName, $result ) {
|
|
|
2567 |
$plus = '+';
|
2568 |
$minus = '-';
|
2569 |
$percent = '%';
|
2570 |
|
2571 |
+
if ( strpos($name, 'price') !== false ) {
|
2572 |
+
if ( strpos($result, $plus) !== false && strpos($result, $percent) !== false ) {
|
2573 |
$result = str_replace('+', '', $result);
|
2574 |
$result = str_replace('%', '', $result);
|
2575 |
+
if ( is_numeric($result) ) {
|
2576 |
$result = $conditionName + (($conditionName * $result) / 100);
|
2577 |
}
|
2578 |
+
} elseif ( strpos($result, $minus) !== false && strpos($result, $percent) !== false ) {
|
2579 |
$result = str_replace('-', '', $result);
|
2580 |
$result = str_replace('%', '', $result);
|
2581 |
+
if ( is_numeric($result) ) {
|
2582 |
$result = $conditionName - (($conditionName * $result) / 100);
|
2583 |
}
|
2584 |
+
} elseif ( strpos($result, $plus) !== false ) {
|
2585 |
$result = str_replace('+', '', $result);
|
2586 |
+
if ( is_numeric($result) ) {
|
2587 |
$result = ($conditionName + $result);
|
2588 |
}
|
2589 |
+
} elseif ( strpos($result, $minus) !== false ) {
|
2590 |
$result = str_replace('-', '', $result);
|
2591 |
+
if ( is_numeric($result) ) {
|
2592 |
$result = $conditionName - $result;
|
2593 |
}
|
2594 |
}
|
2609 |
* @since 3.2.0
|
2610 |
*
|
2611 |
*/
|
2612 |
+
protected function format_output( $output, $outputTypes, $product, $productAttribute ) {
|
2613 |
+
if ( ! empty($outputTypes) && is_array($outputTypes) ) {
|
|
|
2614 |
|
2615 |
// Format Output According to output type
|
2616 |
+
if ( in_array(2, $outputTypes) ) { // Strip Tags
|
2617 |
$output = wp_strip_all_tags(html_entity_decode($output));
|
2618 |
}
|
2619 |
|
2620 |
+
if ( in_array(3, $outputTypes) ) { // UTF-8 Encode
|
2621 |
$output = utf8_encode($output);
|
2622 |
}
|
2623 |
|
2624 |
+
if ( in_array(4, $outputTypes) ) { // htmlentities
|
2625 |
$output = htmlentities($output, ENT_QUOTES, 'UTF-8');
|
2626 |
}
|
2627 |
|
2628 |
+
if ( in_array(5, $outputTypes) ) { // Integer
|
2629 |
$output = intval($output);
|
2630 |
}
|
2631 |
|
2632 |
+
if ( in_array(6, $outputTypes) ) { // Format Price
|
2633 |
+
if ( ! empty($output) && $output > 0 ) {
|
2634 |
$output = (float)$output;
|
2635 |
$output = number_format($output, 2, '.', '');
|
2636 |
}
|
2637 |
}
|
2638 |
|
2639 |
+
if ( in_array(7, $outputTypes) ) { // Delete Space
|
2640 |
$output = trim($output);
|
2641 |
$output = preg_replace('!\s+!', ' ', $output);
|
2642 |
}
|
2643 |
|
2644 |
+
if ( in_array(9, $outputTypes) ) { // Remove Invalid Character
|
2645 |
$output = woo_feed_stripInvalidXml($output);
|
2646 |
}
|
2647 |
|
2648 |
+
if ( in_array(10, $outputTypes) ) { // Remove ShortCodes
|
2649 |
$output = $this->remove_short_codes($output);
|
2650 |
}
|
2651 |
|
2652 |
+
if ( in_array(11, $outputTypes) ) {
|
2653 |
$output = ucwords(strtolower($output));
|
2654 |
}
|
2655 |
|
2656 |
+
if ( in_array(12, $outputTypes) ) {
|
2657 |
$output = ucfirst(strtolower($output));
|
2658 |
}
|
2659 |
|
2660 |
+
if ( in_array(13, $outputTypes) ) {
|
2661 |
$output = strtoupper(strtolower($output));
|
2662 |
}
|
2663 |
|
2664 |
+
if ( in_array(14, $outputTypes) ) {
|
2665 |
$output = strtolower($output);
|
2666 |
}
|
2667 |
|
2668 |
+
if ( in_array(15, $outputTypes) ) {
|
2669 |
+
if ( 'http' == substr($output, 0, 4) ) {
|
2670 |
$output = str_replace('http://', 'https://', $output);
|
2671 |
}
|
2672 |
}
|
2673 |
|
2674 |
+
if ( in_array(16, $outputTypes) ) {
|
2675 |
+
if ( 'http' == substr($output, 0, 4) ) {
|
2676 |
$output = str_replace('https://', 'http://', $output);
|
2677 |
}
|
2678 |
}
|
2679 |
|
2680 |
+
if ( in_array(17, $outputTypes) ) { // only parent
|
2681 |
+
if ( $product->is_type('variation') ) {
|
2682 |
$id = $product->get_parent_id();
|
2683 |
$parentProduct = wc_get_product($id);
|
2684 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
2685 |
}
|
2686 |
}
|
2687 |
|
2688 |
+
if ( in_array(18, $outputTypes) ) { // child if parent empty
|
2689 |
+
if ( $product->is_type('variation') ) {
|
2690 |
$id = $product->get_parent_id();
|
2691 |
$parentProduct = wc_get_product($id);
|
2692 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
2693 |
+
if ( empty($output) ) {
|
2694 |
$output = $this->getAttributeValueByType($product, $productAttribute);
|
2695 |
}
|
2696 |
}
|
2697 |
}
|
2698 |
|
2699 |
+
if ( in_array(19, $outputTypes) ) { // parent if child empty
|
2700 |
+
if ( $product->is_type('variation') ) {
|
2701 |
$output = $this->getAttributeValueByType($product, $productAttribute);
|
2702 |
+
if ( empty($output) ) {
|
2703 |
$id = $product->get_parent_id();
|
2704 |
$parentProduct = wc_get_product($id);
|
2705 |
$output = $this->getAttributeValueByType($parentProduct, $productAttribute);
|
2707 |
}
|
2708 |
}
|
2709 |
|
2710 |
+
if ( in_array(8, $outputTypes) && ! empty($output) ) { // Add CDATA
|
2711 |
$output = '<![CDATA[' . $output . ']]>';
|
2712 |
}
|
2713 |
}
|
2727 |
* @since 3.2.0
|
2728 |
*
|
2729 |
*/
|
2730 |
+
public function process_prefix_suffix( $output, $prefix, $suffix, $attribute = '' ) {
|
|
|
2731 |
|
2732 |
+
if ( '' == $output ) {
|
2733 |
return $output;
|
2734 |
}
|
2735 |
|
2736 |
// Add Prefix before Output
|
2737 |
+
if ( '' != $prefix ) {
|
2738 |
$output = "$prefix" . $output;
|
2739 |
}
|
2740 |
|
2741 |
// Add Suffix after Output
|
2742 |
+
if ( '' !== $suffix ) {
|
2743 |
if (
|
2744 |
'price' == $attribute
|
2745 |
|| 'sale_price' == $attribute
|
2751 |
|| 'tax_rate' == $attribute
|
2752 |
) { // Add space before suffix if attribute contain price.
|
2753 |
$output = $output . ' ' . $suffix;
|
2754 |
+
} elseif ( substr($output, 0, 4) === 'http' ) {
|
2755 |
// Parse URL Parameters if available into suffix field
|
2756 |
$output = woo_feed_make_url_with_parameter($output, $suffix);
|
2757 |
|
2772 |
* @since 3.6.3
|
2773 |
*
|
2774 |
*/
|
2775 |
+
protected function subscription_period( $product ) {
|
2776 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
2777 |
return $this->getProductMeta($product,'_subscription_period');
|
2778 |
}
|
2787 |
* @since 3.6.3
|
2788 |
*
|
2789 |
*/
|
2790 |
+
protected function subscription_period_interval( $product ) {
|
2791 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
2792 |
return $this->getProductMeta($product,'_subscription_period_interval');
|
2793 |
}
|
2803 |
* @since 3.6.3
|
2804 |
*
|
2805 |
*/
|
2806 |
+
protected function subscription_amount( $product ) {
|
2807 |
return $this->price($product);
|
2808 |
}
|
2809 |
}
|
includes/cron-helper.php
CHANGED
@@ -70,11 +70,11 @@ if ( ! function_exists( 'woo_feed_cron_update_single_feed' ) ) {
|
|
70 |
*/
|
71 |
function woo_feed_cron_update_single_feed( $feedName ) {
|
72 |
global $wpdb;
|
73 |
-
if(is_array($feedName)){
|
74 |
-
$feedName
|
75 |
}
|
76 |
|
77 |
-
$cron_param_feedName
|
78 |
|
79 |
if ( woo_feed_is_debugging_enabled() ) {
|
80 |
woo_feed_delete_log( 'woo-feed-cron' );
|
@@ -128,7 +128,7 @@ if ( ! function_exists( 'woo_feed_cron_update_single_feed' ) ) {
|
|
128 |
|
129 |
add_action( 'woo_feed_after_update_config', function( $data, $feed_slug ) {
|
130 |
// Schedule Cron.
|
131 |
-
if(!wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ])){
|
132 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
133 |
}
|
134 |
|
@@ -136,7 +136,7 @@ add_action( 'woo_feed_after_update_config', function( $data, $feed_slug ) {
|
|
136 |
|
137 |
add_action( 'woo_feed_after_insert_config', function( $data, $feed_slug ) {
|
138 |
// Schedule Cron.
|
139 |
-
if(!wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ])){
|
140 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
141 |
}
|
142 |
|
70 |
*/
|
71 |
function woo_feed_cron_update_single_feed( $feedName ) {
|
72 |
global $wpdb;
|
73 |
+
if ( is_array($feedName) ) {
|
74 |
+
$feedName = $feedName[0];
|
75 |
}
|
76 |
|
77 |
+
$cron_param_feedName = $feedName;
|
78 |
|
79 |
if ( woo_feed_is_debugging_enabled() ) {
|
80 |
woo_feed_delete_log( 'woo-feed-cron' );
|
128 |
|
129 |
add_action( 'woo_feed_after_update_config', function( $data, $feed_slug ) {
|
130 |
// Schedule Cron.
|
131 |
+
if ( ! wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ]) ) {
|
132 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
133 |
}
|
134 |
|
136 |
|
137 |
add_action( 'woo_feed_after_insert_config', function( $data, $feed_slug ) {
|
138 |
// Schedule Cron.
|
139 |
+
if ( ! wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ]) ) {
|
140 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
141 |
}
|
142 |
|
includes/feeds/merchant_infos.php
CHANGED
@@ -386,5 +386,9 @@ return array(
|
|
386 |
'link' => 'https://sluzby.heureka.sk/napoveda/xml-feed/',
|
387 |
'feed_file_type' => array( 'XML' ),
|
388 |
),
|
|
|
|
|
|
|
|
|
389 |
);
|
390 |
// End of file merchant_infos.php
|
386 |
'link' => 'https://sluzby.heureka.sk/napoveda/xml-feed/',
|
387 |
'feed_file_type' => array( 'XML' ),
|
388 |
),
|
389 |
+
'moebel.de' => array(
|
390 |
+
'link' => 'https://feedonomics.com/supported-channels/moebel-de-feed-specifications/',
|
391 |
+
'feed_file_type' => array( 'XML', 'CSV', 'TXT' ),
|
392 |
+
),
|
393 |
);
|
394 |
// End of file merchant_infos.php
|
includes/feeds/merchant_templates.php
CHANGED
@@ -7639,5 +7639,15 @@ return array(
|
|
7639 |
'output_type' => array('1','1','1','1','1','1','6','1','1',),
|
7640 |
'limit' => array('','','','','','','','','',),
|
7641 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7642 |
);
|
7643 |
// End of file merchant_templates.php
|
7639 |
'output_type' => array('1','1','1','1','1','1','6','1','1',),
|
7640 |
'limit' => array('','','','','','','','','',),
|
7641 |
),
|
7642 |
+
'moebel.de' => array(
|
7643 |
+
'mattributes' => array('art_nr','art_name','art_beschreibung','art_url','art_img_url','art_price','art_kategorie','art_verfuegbarkeit',),
|
7644 |
+
'prefix' => array('','','','','','','','',),
|
7645 |
+
'type' => array('attribute','attribute','attribute','attribute','attribute','attribute','attribute','attribute',),
|
7646 |
+
'attributes' => array('id','title','description','link','image','price','product_type','availability',),
|
7647 |
+
'default' => array('','','','','','','','',),
|
7648 |
+
'suffix' => array('','','','','','','','',),
|
7649 |
+
'output_type' => array('1','1','1','1','1','1','1','1',),
|
7650 |
+
'limit' => array('','','','','','','','',),
|
7651 |
+
),
|
7652 |
);
|
7653 |
// End of file merchant_templates.php
|
includes/feeds/merchant_templates_override.php
CHANGED
@@ -14,11 +14,11 @@
|
|
14 |
* @param $feed_config
|
15 |
* @return string
|
16 |
*/
|
17 |
-
function woo_feed_spartoo_attribute_value_modify($attribute_value, $product, $feed_config){
|
18 |
-
if('spartoo.fi'
|
19 |
-
if('variation'
|
20 |
return "child";
|
21 |
-
}else{
|
22 |
return "parent";
|
23 |
}
|
24 |
}
|
@@ -34,25 +34,25 @@ add_filter('woo_feed_get_type_attribute','woo_feed_spartoo_attribute_value_modif
|
|
34 |
* @param $feed_config
|
35 |
* @return string
|
36 |
*/
|
37 |
-
function woo_feed_availability_attribute_value_modify($attribute_value, $product, $feed_config){
|
38 |
-
if('skroutz'
|
39 |
-
if('in stock'
|
40 |
return "Y";
|
41 |
-
}else{
|
42 |
return "N";
|
43 |
}
|
44 |
-
}elseif ('pricerunner'
|
45 |
-
if('in stock'
|
46 |
return "Yes";
|
47 |
-
}else{
|
48 |
return "No";
|
49 |
}
|
50 |
-
}elseif ('google'
|
51 |
-
||'pinterest'
|
52 |
-
if('on backorder'
|
53 |
return 'preorder';
|
54 |
}
|
55 |
-
}elseif('facebook'
|
56 |
return 'available for order';
|
57 |
}
|
58 |
return $attribute_value;
|
@@ -67,8 +67,8 @@ add_filter('woo_feed_get_availability_attribute','woo_feed_availability_attribut
|
|
67 |
* @param $feed_config
|
68 |
* @return string
|
69 |
*/
|
70 |
-
function woo_feed_get_bestprice_categoryPath_attribute_value_modify($attribute_value, $product, $feed_config){
|
71 |
-
$attribute_value=str_replace('>',', ',$attribute_value);
|
72 |
return $attribute_value;
|
73 |
}
|
74 |
add_filter('woo_feed_get_bestprice_product_type_attribute','woo_feed_get_bestprice_categoryPath_attribute_value_modify',10,3);
|
14 |
* @param $feed_config
|
15 |
* @return string
|
16 |
*/
|
17 |
+
function woo_feed_spartoo_attribute_value_modify( $attribute_value, $product, $feed_config ) {
|
18 |
+
if ( 'spartoo.fi' === $feed_config['provider'] ) {
|
19 |
+
if ( 'variation' === $attribute_value ) {
|
20 |
return "child";
|
21 |
+
}else {
|
22 |
return "parent";
|
23 |
}
|
24 |
}
|
34 |
* @param $feed_config
|
35 |
* @return string
|
36 |
*/
|
37 |
+
function woo_feed_availability_attribute_value_modify( $attribute_value, $product, $feed_config ) {
|
38 |
+
if ( 'skroutz' === $feed_config['provider'] || 'bestprice' === $feed_config['provider'] ) {
|
39 |
+
if ( 'in stock' === $attribute_value ) {
|
40 |
return "Y";
|
41 |
+
}else {
|
42 |
return "N";
|
43 |
}
|
44 |
+
}elseif ( 'pricerunner' === $feed_config['provider'] ) {
|
45 |
+
if ( 'in stock' === $attribute_value ) {
|
46 |
return "Yes";
|
47 |
+
}else {
|
48 |
return "No";
|
49 |
}
|
50 |
+
}elseif ( 'google' === $feed_config['provider']
|
51 |
+
|| 'pinterest' === $feed_config['provider'] ) {
|
52 |
+
if ( 'on backorder' === $attribute_value ) {
|
53 |
return 'preorder';
|
54 |
}
|
55 |
+
}elseif ( 'facebook' === $feed_config['provider'] && 'on backorder' === $attribute_value ) {
|
56 |
return 'available for order';
|
57 |
}
|
58 |
return $attribute_value;
|
67 |
* @param $feed_config
|
68 |
* @return string
|
69 |
*/
|
70 |
+
function woo_feed_get_bestprice_categoryPath_attribute_value_modify( $attribute_value, $product, $feed_config ) {
|
71 |
+
$attribute_value = str_replace('>',', ',$attribute_value);
|
72 |
return $attribute_value;
|
73 |
}
|
74 |
add_filter('woo_feed_get_bestprice_product_type_attribute','woo_feed_get_bestprice_categoryPath_attribute_value_modify',10,3);
|
includes/helper.php
CHANGED
@@ -427,11 +427,11 @@ if ( ! function_exists( 'woo_feed_get_default_brand' ) ) {
|
|
427 |
if ( false !== $url ) {
|
428 |
$url = wp_parse_url( $url );
|
429 |
if ( array_key_exists( 'host', $url ) ) {
|
430 |
-
if(strpos($url['host'], ".") !== false){
|
431 |
$arr = explode( '.', $url['host'] );
|
432 |
$brand = $arr[ count( $arr ) - 2 ];
|
433 |
$brand = ucfirst( $brand );
|
434 |
-
} else{
|
435 |
$brand = $url['host'];
|
436 |
$brand = ucfirst( $brand );
|
437 |
}
|
@@ -542,53 +542,53 @@ if ( ! function_exists( 'woo_feed_parse_feed_rules' ) ) {
|
|
542 |
$rules = [];
|
543 |
}
|
544 |
$defaults = [
|
545 |
-
'provider'
|
546 |
-
'filename'
|
547 |
-
'feedType'
|
548 |
-
'ftpenabled'
|
549 |
-
'ftporsftp'
|
550 |
-
'ftphost'
|
551 |
-
'ftpport'
|
552 |
-
'ftpuser'
|
553 |
-
'ftppassword'
|
554 |
-
'ftppath'
|
555 |
-
'ftpmode'
|
556 |
-
'is_variations'
|
557 |
-
'variable_price'
|
558 |
-
'variable_quantity'
|
559 |
-
'feedLanguage'
|
560 |
-
'feedCurrency'
|
561 |
-
'itemsWrapper'
|
562 |
-
'itemWrapper'
|
563 |
-
'delimiter'
|
564 |
-
'enclosure'
|
565 |
-
'extraHeader'
|
566 |
-
'vendors'
|
567 |
// Feed Config
|
568 |
-
'mattributes'
|
569 |
-
'prefix'
|
570 |
-
'type'
|
571 |
-
'attributes'
|
572 |
-
'default'
|
573 |
-
'suffix'
|
574 |
-
'output_type'
|
575 |
-
'limit'
|
576 |
// filters tab
|
577 |
-
'composite_price'
|
578 |
-
'product_ids'
|
579 |
-
'categories'
|
580 |
-
'post_status'
|
581 |
-
'filter_mode'
|
582 |
-
'campaign_parameters'
|
583 |
//'is_outOfStock' => 'y',
|
584 |
//'product_visibility' => 0,
|
585 |
// include hidden ? 1 yes 0 no
|
586 |
//'outofstock_visibility' => 1,
|
587 |
// override wc global option for out-of-stock product hidden from catalog? 1 yes 0 no
|
588 |
-
'ptitle_show'
|
589 |
-
'decimal_separator'
|
590 |
-
'thousand_separator'
|
591 |
-
'decimals'
|
592 |
];
|
593 |
$rules = wp_parse_args( $rules, $defaults );
|
594 |
$rules['filter_mode'] = wp_parse_args( $rules['filter_mode'],
|
@@ -1407,8 +1407,8 @@ if ( ! function_exists( 'woo_feed_delete_feed' ) ) {
|
|
1407 |
}
|
1408 |
|
1409 |
// Delete cron schedule.
|
1410 |
-
$feed_cron_param='wf_config' . $feed_name;
|
1411 |
-
wp_clear_scheduled_hook( 'woo_feed_update_single_feed',[$feed_cron_param]);
|
1412 |
|
1413 |
return $deleted;
|
1414 |
}
|
@@ -2378,11 +2378,6 @@ if ( ! function_exists( 'woo_feed_filter_parsed_rules' ) ) {
|
|
2378 |
$rules['itemsWrapper'] = 'channel';
|
2379 |
$rules['itemWrapper'] = 'item';
|
2380 |
}
|
2381 |
-
|
2382 |
-
if ( 'heureka.sk' === $provider ) {
|
2383 |
-
$rules['itemsWrapper'] = 'SHOP';
|
2384 |
-
$rules['itemWrapper'] = 'SHOPITEM';
|
2385 |
-
}
|
2386 |
}
|
2387 |
|
2388 |
return $rules;
|
@@ -2541,7 +2536,7 @@ if ( ! function_exists( 'woo_feed_get_category_mapping_value' ) ) {
|
|
2541 |
}
|
2542 |
|
2543 |
|
2544 |
-
if( ! function_exists( 'woo_feed_add_identifier_fields' ) ) {
|
2545 |
/**
|
2546 |
* Add Custom fields into product inventory tab for Unique Identifier (GTIN,MPN,EAN)
|
2547 |
*
|
@@ -2554,31 +2549,31 @@ if( ! function_exists( 'woo_feed_add_identifier_fields' ) ) {
|
|
2554 |
|
2555 |
//GTIN input field
|
2556 |
woocommerce_wp_text_input( array(
|
2557 |
-
'id'
|
2558 |
-
'value'
|
2559 |
-
'placeholder'
|
2560 |
-
'label'
|
2561 |
-
'desc_tip'
|
2562 |
'description' => esc_html( 'Set product GTIN code here.', 'woo-feed' ),
|
2563 |
) );
|
2564 |
|
2565 |
//MPN input field
|
2566 |
woocommerce_wp_text_input( array(
|
2567 |
-
'id'
|
2568 |
-
'value'
|
2569 |
-
'placeholder'
|
2570 |
-
'label'
|
2571 |
-
'desc_tip'
|
2572 |
'description' => esc_html( 'Set product MPN code here.', 'woo-feed' ),
|
2573 |
) );
|
2574 |
|
2575 |
//EAN input field
|
2576 |
woocommerce_wp_text_input( array(
|
2577 |
-
'id'
|
2578 |
-
'value'
|
2579 |
-
'placeholder'
|
2580 |
-
'label'
|
2581 |
-
'desc_tip'
|
2582 |
'description' => esc_html( 'Set product EAN code here.', 'woo-feed' ),
|
2583 |
) );
|
2584 |
|
@@ -2588,7 +2583,7 @@ if( ! function_exists( 'woo_feed_add_identifier_fields' ) ) {
|
|
2588 |
add_action( 'woocommerce_product_options_inventory_product_data', 'woo_feed_add_identifier_fields');
|
2589 |
}
|
2590 |
|
2591 |
-
if( ! function_exists( 'woo_feed_save_identifier_fields_data' ) ) {
|
2592 |
|
2593 |
/**
|
2594 |
* Updating custom fields data. (Unique Identifier (GTIN,MPN,EAN))
|
@@ -2600,21 +2595,21 @@ if( ! function_exists( 'woo_feed_save_identifier_fields_data' ) ) {
|
|
2600 |
function woo_feed_save_identifier_fields_data( $id, $post ) {
|
2601 |
|
2602 |
//save gtin fields value
|
2603 |
-
if( isset( $_POST['woo_feed_gtin'] ) && ! empty( $_POST['woo_feed_gtin'] ) ) {
|
2604 |
update_post_meta( $id, 'woo_feed_gtin', $_POST['woo_feed_gtin'] );
|
2605 |
} else {
|
2606 |
delete_post_meta( $id, 'woo_feed_gtin' );
|
2607 |
}
|
2608 |
|
2609 |
//save mpn fields value
|
2610 |
-
if( isset( $_POST['woo_feed_mpn'] ) && ! empty( $_POST['woo_feed_mpn'] ) ) {
|
2611 |
update_post_meta( $id, 'woo_feed_mpn', $_POST['woo_feed_mpn'] );
|
2612 |
} else {
|
2613 |
delete_post_meta( $id, 'woo_feed_mpn' );
|
2614 |
}
|
2615 |
|
2616 |
//save ean fields value
|
2617 |
-
if( isset( $_POST['woo_feed_ean'] ) && ! empty( $_POST['woo_feed_ean'] ) ) {
|
2618 |
update_post_meta( $id, 'woo_feed_ean', $_POST['woo_feed_ean'] );
|
2619 |
} else {
|
2620 |
delete_post_meta( $id, 'woo_feed_ean' );
|
@@ -2624,7 +2619,7 @@ if( ! function_exists( 'woo_feed_save_identifier_fields_data' ) ) {
|
|
2624 |
add_action( 'woocommerce_process_product_meta', 'woo_feed_save_identifier_fields_data', 10, 2 );
|
2625 |
}
|
2626 |
|
2627 |
-
if( ! function_exists( 'woo_feed_add_identifier_fields_for_variation' ) ) {
|
2628 |
|
2629 |
/**
|
2630 |
* Custom options in variation tab, here we are putting gtin, mpn, ean input fields in product variation tab
|
@@ -2670,26 +2665,26 @@ if( ! function_exists( 'woo_feed_add_identifier_fields_for_variation' ) ) {
|
|
2670 |
echo '<div class="woo-feed-variation-items">';
|
2671 |
//GTIN variation input field
|
2672 |
woocommerce_wp_text_input( array(
|
2673 |
-
'id'
|
2674 |
-
'value'
|
2675 |
-
'placeholder'
|
2676 |
-
'label'
|
2677 |
) );
|
2678 |
|
2679 |
//MPN variation input field
|
2680 |
woocommerce_wp_text_input( array(
|
2681 |
-
'id'
|
2682 |
-
'value'
|
2683 |
-
'placeholder'
|
2684 |
-
'label'
|
2685 |
) );
|
2686 |
|
2687 |
//EAN variation input field
|
2688 |
woocommerce_wp_text_input( array(
|
2689 |
-
'id'
|
2690 |
-
'value'
|
2691 |
-
'placeholder'
|
2692 |
-
'label'
|
2693 |
) );
|
2694 |
|
2695 |
echo '</div></div>';
|
@@ -2698,7 +2693,7 @@ if( ! function_exists( 'woo_feed_add_identifier_fields_for_variation' ) ) {
|
|
2698 |
add_action( 'woocommerce_product_after_variable_attributes', 'woo_feed_add_identifier_fields_for_variation', 10, 3 );
|
2699 |
}
|
2700 |
|
2701 |
-
if( ! function_exists( 'woo_feed_save_identifier_fields_data_for_variation' ) ) {
|
2702 |
|
2703 |
/**
|
2704 |
* Saving variation custom fields.
|
@@ -2711,20 +2706,20 @@ if( ! function_exists( 'woo_feed_save_identifier_fields_data_for_variation' ) )
|
|
2711 |
function woo_feed_save_identifier_fields_data_for_variation( $variation_id, $i ) {
|
2712 |
|
2713 |
//save gtin field
|
2714 |
-
if( isset($_POST['woo_feed_gtin_var'][$variation_id]) ) {
|
2715 |
-
$woo_feed_gtin_field = $_POST['woo_feed_gtin_var'][$variation_id];
|
2716 |
if ( isset( $woo_feed_gtin_field ) ) update_post_meta( $variation_id, 'woo_feed_gtin_var', esc_attr( $woo_feed_gtin_field ) );
|
2717 |
}
|
2718 |
|
2719 |
//save mpn field
|
2720 |
-
if( isset($_POST['woo_feed_mpn_var'][$variation_id]) ) {
|
2721 |
-
$woo_feed_mpn_field = $_POST['woo_feed_mpn_var'][$variation_id];
|
2722 |
if ( isset( $woo_feed_mpn_field ) ) update_post_meta( $variation_id, 'woo_feed_mpn_var', esc_attr( $woo_feed_mpn_field ) );
|
2723 |
}
|
2724 |
|
2725 |
//save ean field
|
2726 |
-
if( isset($_POST['woo_feed_ean_var'][$variation_id]) ) {
|
2727 |
-
$woo_feed_ean_field = $_POST['woo_feed_ean_var'][$variation_id];
|
2728 |
if ( isset( $woo_feed_ean_field ) ) update_post_meta( $variation_id, 'woo_feed_ean_var', esc_attr( $woo_feed_ean_field ) );
|
2729 |
}
|
2730 |
|
@@ -2733,7 +2728,7 @@ if( ! function_exists( 'woo_feed_save_identifier_fields_data_for_variation' ) )
|
|
2733 |
}
|
2734 |
|
2735 |
|
2736 |
-
if( ! function_exists( 'woo_feed_clear_cache_button' ) ) {
|
2737 |
/**
|
2738 |
* Clear cache button.
|
2739 |
*
|
@@ -2751,7 +2746,7 @@ if( ! function_exists( 'woo_feed_clear_cache_button' ) ) {
|
|
2751 |
}
|
2752 |
}
|
2753 |
|
2754 |
-
if( ! function_exists( 'woo_feed_clear_cache_data' ) ) {
|
2755 |
/**
|
2756 |
* Clear cache data.
|
2757 |
*
|
@@ -2762,18 +2757,17 @@ if( ! function_exists( 'woo_feed_clear_cache_data' ) ) {
|
|
2762 |
function woo_feed_clear_cache_data() {
|
2763 |
if ( isset( $_REQUEST['_ajax_clean_nonce'] ) ) {
|
2764 |
|
2765 |
-
if( wp_verify_nonce( sanitize_text_field( $_REQUEST['_ajax_clean_nonce'] ), 'clean_cache_nonce' ) ) {
|
2766 |
$data = [];
|
2767 |
|
2768 |
global $wpdb;
|
2769 |
$wpdb->query( "DELETE FROM $wpdb->options WHERE ({$wpdb->options}.option_name LIKE '_transient_timeout___woo_feed_cache_%') OR ({$wpdb->options}.option_name LIKE '_transient___woo_feed_cache_%')" ); // phpcs:ignore
|
2770 |
|
2771 |
-
$data = [ 'success' => true];
|
2772 |
|
2773 |
wp_send_json_success( $data );
|
2774 |
-
}
|
2775 |
-
|
2776 |
-
} else {
|
2777 |
wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
|
2778 |
}
|
2779 |
wp_die();
|
427 |
if ( false !== $url ) {
|
428 |
$url = wp_parse_url( $url );
|
429 |
if ( array_key_exists( 'host', $url ) ) {
|
430 |
+
if ( strpos($url['host'], ".") !== false ) {
|
431 |
$arr = explode( '.', $url['host'] );
|
432 |
$brand = $arr[ count( $arr ) - 2 ];
|
433 |
$brand = ucfirst( $brand );
|
434 |
+
} else {
|
435 |
$brand = $url['host'];
|
436 |
$brand = ucfirst( $brand );
|
437 |
}
|
542 |
$rules = [];
|
543 |
}
|
544 |
$defaults = [
|
545 |
+
'provider' => '',
|
546 |
+
'filename' => '',
|
547 |
+
'feedType' => '',
|
548 |
+
'ftpenabled' => 0,
|
549 |
+
'ftporsftp' => 'ftp',
|
550 |
+
'ftphost' => '',
|
551 |
+
'ftpport' => '21',
|
552 |
+
'ftpuser' => '',
|
553 |
+
'ftppassword' => '',
|
554 |
+
'ftppath' => '',
|
555 |
+
'ftpmode' => 'active',
|
556 |
+
'is_variations' => 'n',
|
557 |
+
'variable_price' => 'first',
|
558 |
+
'variable_quantity' => 'first',
|
559 |
+
'feedLanguage' => apply_filters( 'wpml_current_language', null ),
|
560 |
+
'feedCurrency' => get_woocommerce_currency(),
|
561 |
+
'itemsWrapper' => 'products',
|
562 |
+
'itemWrapper' => 'product',
|
563 |
+
'delimiter' => ',',
|
564 |
+
'enclosure' => 'double',
|
565 |
+
'extraHeader' => '',
|
566 |
+
'vendors' => [],
|
567 |
// Feed Config
|
568 |
+
'mattributes' => [], // merchant attributes
|
569 |
+
'prefix' => [], // prefixes
|
570 |
+
'type' => [], // value (attribute) types
|
571 |
+
'attributes' => [], // product attribute mappings
|
572 |
+
'default' => [], // default values (patterns) if value type set to pattern
|
573 |
+
'suffix' => [], // suffixes
|
574 |
+
'output_type' => [], // output type (output filter)
|
575 |
+
'limit' => [], // limit or command
|
576 |
// filters tab
|
577 |
+
'composite_price' => '',
|
578 |
+
'product_ids' => '',
|
579 |
+
'categories' => [],
|
580 |
+
'post_status' => [ 'publish' ],
|
581 |
+
'filter_mode' => [],
|
582 |
+
'campaign_parameters' => [],
|
583 |
//'is_outOfStock' => 'y',
|
584 |
//'product_visibility' => 0,
|
585 |
// include hidden ? 1 yes 0 no
|
586 |
//'outofstock_visibility' => 1,
|
587 |
// override wc global option for out-of-stock product hidden from catalog? 1 yes 0 no
|
588 |
+
'ptitle_show' => '',
|
589 |
+
'decimal_separator' => wc_get_price_decimal_separator(),
|
590 |
+
'thousand_separator' => wc_get_price_thousand_separator(),
|
591 |
+
'decimals' => wc_get_price_decimals(),
|
592 |
];
|
593 |
$rules = wp_parse_args( $rules, $defaults );
|
594 |
$rules['filter_mode'] = wp_parse_args( $rules['filter_mode'],
|
1407 |
}
|
1408 |
|
1409 |
// Delete cron schedule.
|
1410 |
+
$feed_cron_param = 'wf_config' . $feed_name;
|
1411 |
+
wp_clear_scheduled_hook( 'woo_feed_update_single_feed',[ $feed_cron_param ]);
|
1412 |
|
1413 |
return $deleted;
|
1414 |
}
|
2378 |
$rules['itemsWrapper'] = 'channel';
|
2379 |
$rules['itemWrapper'] = 'item';
|
2380 |
}
|
|
|
|
|
|
|
|
|
|
|
2381 |
}
|
2382 |
|
2383 |
return $rules;
|
2536 |
}
|
2537 |
|
2538 |
|
2539 |
+
if ( ! function_exists( 'woo_feed_add_identifier_fields' ) ) {
|
2540 |
/**
|
2541 |
* Add Custom fields into product inventory tab for Unique Identifier (GTIN,MPN,EAN)
|
2542 |
*
|
2549 |
|
2550 |
//GTIN input field
|
2551 |
woocommerce_wp_text_input( array(
|
2552 |
+
'id' => 'woo_feed_gtin',
|
2553 |
+
'value' => get_post_meta( get_the_ID(), 'woo_feed_gtin', true ),
|
2554 |
+
'placeholder' => esc_html( 'Set product GTIN', 'woo-feed' ),
|
2555 |
+
'label' => esc_html( 'GTIN', 'woo-feed' ),
|
2556 |
+
'desc_tip' => true,
|
2557 |
'description' => esc_html( 'Set product GTIN code here.', 'woo-feed' ),
|
2558 |
) );
|
2559 |
|
2560 |
//MPN input field
|
2561 |
woocommerce_wp_text_input( array(
|
2562 |
+
'id' => 'woo_feed_mpn',
|
2563 |
+
'value' => get_post_meta( get_the_ID(), 'woo_feed_mpn', true ),
|
2564 |
+
'placeholder' => esc_html( 'Set product MPN', 'woo-feed' ),
|
2565 |
+
'label' => esc_html( 'MPN', 'woo-feed' ),
|
2566 |
+
'desc_tip' => true,
|
2567 |
'description' => esc_html( 'Set product MPN code here.', 'woo-feed' ),
|
2568 |
) );
|
2569 |
|
2570 |
//EAN input field
|
2571 |
woocommerce_wp_text_input( array(
|
2572 |
+
'id' => 'woo_feed_ean',
|
2573 |
+
'value' => get_post_meta( get_the_ID(), 'woo_feed_ean', true ),
|
2574 |
+
'placeholder' => esc_html( 'Set product EAN', 'woo-feed' ),
|
2575 |
+
'label' => esc_html( 'EAN', 'woo-feed' ),
|
2576 |
+
'desc_tip' => true,
|
2577 |
'description' => esc_html( 'Set product EAN code here.', 'woo-feed' ),
|
2578 |
) );
|
2579 |
|
2583 |
add_action( 'woocommerce_product_options_inventory_product_data', 'woo_feed_add_identifier_fields');
|
2584 |
}
|
2585 |
|
2586 |
+
if ( ! function_exists( 'woo_feed_save_identifier_fields_data' ) ) {
|
2587 |
|
2588 |
/**
|
2589 |
* Updating custom fields data. (Unique Identifier (GTIN,MPN,EAN))
|
2595 |
function woo_feed_save_identifier_fields_data( $id, $post ) {
|
2596 |
|
2597 |
//save gtin fields value
|
2598 |
+
if ( isset( $_POST['woo_feed_gtin'] ) && ! empty( $_POST['woo_feed_gtin'] ) ) {
|
2599 |
update_post_meta( $id, 'woo_feed_gtin', $_POST['woo_feed_gtin'] );
|
2600 |
} else {
|
2601 |
delete_post_meta( $id, 'woo_feed_gtin' );
|
2602 |
}
|
2603 |
|
2604 |
//save mpn fields value
|
2605 |
+
if ( isset( $_POST['woo_feed_mpn'] ) && ! empty( $_POST['woo_feed_mpn'] ) ) {
|
2606 |
update_post_meta( $id, 'woo_feed_mpn', $_POST['woo_feed_mpn'] );
|
2607 |
} else {
|
2608 |
delete_post_meta( $id, 'woo_feed_mpn' );
|
2609 |
}
|
2610 |
|
2611 |
//save ean fields value
|
2612 |
+
if ( isset( $_POST['woo_feed_ean'] ) && ! empty( $_POST['woo_feed_ean'] ) ) {
|
2613 |
update_post_meta( $id, 'woo_feed_ean', $_POST['woo_feed_ean'] );
|
2614 |
} else {
|
2615 |
delete_post_meta( $id, 'woo_feed_ean' );
|
2619 |
add_action( 'woocommerce_process_product_meta', 'woo_feed_save_identifier_fields_data', 10, 2 );
|
2620 |
}
|
2621 |
|
2622 |
+
if ( ! function_exists( 'woo_feed_add_identifier_fields_for_variation' ) ) {
|
2623 |
|
2624 |
/**
|
2625 |
* Custom options in variation tab, here we are putting gtin, mpn, ean input fields in product variation tab
|
2665 |
echo '<div class="woo-feed-variation-items">';
|
2666 |
//GTIN variation input field
|
2667 |
woocommerce_wp_text_input( array(
|
2668 |
+
'id' => "woo_feed_gtin_var[$variation->ID]",
|
2669 |
+
'value' => get_post_meta( $variation->ID, "woo_feed_gtin_var", true ),
|
2670 |
+
'placeholder' => esc_html( 'Set product GTIN', 'woo-feed' ),
|
2671 |
+
'label' => esc_html( 'GTIN', 'woo-feed' ),
|
2672 |
) );
|
2673 |
|
2674 |
//MPN variation input field
|
2675 |
woocommerce_wp_text_input( array(
|
2676 |
+
'id' => "woo_feed_mpn_var[$variation->ID]",
|
2677 |
+
'value' => get_post_meta( $variation->ID, 'woo_feed_mpn_var', true ),
|
2678 |
+
'placeholder' => esc_html( 'Set product MPN', 'woo-feed' ),
|
2679 |
+
'label' => esc_html( 'MPN', 'woo-feed' ),
|
2680 |
) );
|
2681 |
|
2682 |
//EAN variation input field
|
2683 |
woocommerce_wp_text_input( array(
|
2684 |
+
'id' => "woo_feed_ean_var[$variation->ID]",
|
2685 |
+
'value' => get_post_meta( $variation->ID, 'woo_feed_ean_var', true ),
|
2686 |
+
'placeholder' => esc_html( 'Set product EAN', 'woo-feed' ),
|
2687 |
+
'label' => esc_html( 'EAN', 'woo-feed' ),
|
2688 |
) );
|
2689 |
|
2690 |
echo '</div></div>';
|
2693 |
add_action( 'woocommerce_product_after_variable_attributes', 'woo_feed_add_identifier_fields_for_variation', 10, 3 );
|
2694 |
}
|
2695 |
|
2696 |
+
if ( ! function_exists( 'woo_feed_save_identifier_fields_data_for_variation' ) ) {
|
2697 |
|
2698 |
/**
|
2699 |
* Saving variation custom fields.
|
2706 |
function woo_feed_save_identifier_fields_data_for_variation( $variation_id, $i ) {
|
2707 |
|
2708 |
//save gtin field
|
2709 |
+
if ( isset($_POST['woo_feed_gtin_var'][ $variation_id ]) ) {
|
2710 |
+
$woo_feed_gtin_field = $_POST['woo_feed_gtin_var'][ $variation_id ];
|
2711 |
if ( isset( $woo_feed_gtin_field ) ) update_post_meta( $variation_id, 'woo_feed_gtin_var', esc_attr( $woo_feed_gtin_field ) );
|
2712 |
}
|
2713 |
|
2714 |
//save mpn field
|
2715 |
+
if ( isset($_POST['woo_feed_mpn_var'][ $variation_id ]) ) {
|
2716 |
+
$woo_feed_mpn_field = $_POST['woo_feed_mpn_var'][ $variation_id ];
|
2717 |
if ( isset( $woo_feed_mpn_field ) ) update_post_meta( $variation_id, 'woo_feed_mpn_var', esc_attr( $woo_feed_mpn_field ) );
|
2718 |
}
|
2719 |
|
2720 |
//save ean field
|
2721 |
+
if ( isset($_POST['woo_feed_ean_var'][ $variation_id ]) ) {
|
2722 |
+
$woo_feed_ean_field = $_POST['woo_feed_ean_var'][ $variation_id ];
|
2723 |
if ( isset( $woo_feed_ean_field ) ) update_post_meta( $variation_id, 'woo_feed_ean_var', esc_attr( $woo_feed_ean_field ) );
|
2724 |
}
|
2725 |
|
2728 |
}
|
2729 |
|
2730 |
|
2731 |
+
if ( ! function_exists( 'woo_feed_clear_cache_button' ) ) {
|
2732 |
/**
|
2733 |
* Clear cache button.
|
2734 |
*
|
2746 |
}
|
2747 |
}
|
2748 |
|
2749 |
+
if ( ! function_exists( 'woo_feed_clear_cache_data' ) ) {
|
2750 |
/**
|
2751 |
* Clear cache data.
|
2752 |
*
|
2757 |
function woo_feed_clear_cache_data() {
|
2758 |
if ( isset( $_REQUEST['_ajax_clean_nonce'] ) ) {
|
2759 |
|
2760 |
+
if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['_ajax_clean_nonce'] ), 'clean_cache_nonce' ) ) {
|
2761 |
$data = [];
|
2762 |
|
2763 |
global $wpdb;
|
2764 |
$wpdb->query( "DELETE FROM $wpdb->options WHERE ({$wpdb->options}.option_name LIKE '_transient_timeout___woo_feed_cache_%') OR ({$wpdb->options}.option_name LIKE '_transient___woo_feed_cache_%')" ); // phpcs:ignore
|
2765 |
|
2766 |
+
$data = [ 'success' => true ];
|
2767 |
|
2768 |
wp_send_json_success( $data );
|
2769 |
+
}
|
2770 |
+
} else {
|
|
|
2771 |
wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
|
2772 |
}
|
2773 |
wp_die();
|
includes/widget.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
|
9 |
|
10 |
-
if(!function_exists('webappick_add_dashboard_widgets')){
|
11 |
/**
|
12 |
* Add a widget to the dashboard.
|
13 |
*
|
@@ -22,7 +22,7 @@ if(!function_exists('webappick_add_dashboard_widgets')){
|
|
22 |
add_action( 'wp_dashboard_setup', 'webappick_add_dashboard_widgets',1);
|
23 |
}
|
24 |
|
25 |
-
if(!function_exists('webappick_dashboard_widget_render')){
|
26 |
/**
|
27 |
* Function to get dashboard widget data.
|
28 |
*/
|
7 |
*/
|
8 |
|
9 |
|
10 |
+
if ( ! function_exists('webappick_add_dashboard_widgets') ) {
|
11 |
/**
|
12 |
* Add a widget to the dashboard.
|
13 |
*
|
22 |
add_action( 'wp_dashboard_setup', 'webappick_add_dashboard_widgets',1);
|
23 |
}
|
24 |
|
25 |
+
if ( ! function_exists('webappick_dashboard_widget_render') ) {
|
26 |
/**
|
27 |
* Function to get dashboard widget data.
|
28 |
*/
|
woo-feed.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
* Plugin URI: https://webappick.com/
|
12 |
* Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
|
13 |
*
|
14 |
-
* Version: 3.
|
15 |
* Author: WebAppick
|
16 |
* Author URI: https://webappick.com/
|
17 |
* License: GPL v2
|
@@ -39,7 +39,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
|
|
39 |
* @var string
|
40 |
* @since 3.1.6
|
41 |
*/
|
42 |
-
define( 'WOO_FEED_FREE_VERSION', '3.
|
43 |
}
|
44 |
|
45 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|
@@ -796,17 +796,17 @@ if ( ! function_exists( 'woo_feed_update_feed_status' ) ) {
|
|
796 |
wp_die();
|
797 |
}
|
798 |
|
799 |
-
$feedName=sanitize_text_field( $_POST['feedName'] );
|
800 |
if ( ! empty( $feedName ) ) {
|
801 |
$feedInfo = maybe_unserialize( get_option( $feedName ) );
|
802 |
$feedInfo['status'] = isset( $_POST['status'] ) && 1 == $_POST['status'] ? 1 : 0;
|
803 |
|
804 |
-
$feed_slug=str_replace('wf_feed_','wf_config',$feedName);
|
805 |
-
if(1
|
806 |
-
if(!wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ])){
|
807 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
808 |
}
|
809 |
-
}else{
|
810 |
wp_clear_scheduled_hook( 'woo_feed_update_single_feed',[ $feed_slug ]);
|
811 |
}
|
812 |
|
@@ -875,36 +875,35 @@ if ( ! function_exists( 'woo_feed_flash_cache_action' ) ) {
|
|
875 |
|
876 |
|
877 |
// Suggest other plugins of webappick.
|
878 |
-
if(!class_exists('webappick_suggest_plugin')){
|
879 |
class webappick_suggest_plugin
|
880 |
{
|
881 |
-
static function init()
|
882 |
-
|
883 |
-
|
884 |
-
add_filter('install_plugins_table_api_args_featured', array(__CLASS__, 'featured_plugins_tab'));
|
885 |
}
|
886 |
} // init
|
887 |
// add our plugins to recommended list
|
888 |
-
static function plugins_api_result($res, $action, $args) {
|
889 |
-
remove_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 1);
|
890 |
$res = self::add_plugin_favs('webappick-pdf-invoice-for-woocommerce', $res);
|
891 |
return $res;
|
892 |
} // plugins_api_result
|
893 |
// helper function for adding plugins to fav list
|
894 |
-
static function featured_plugins_tab($args) {
|
895 |
-
add_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 3);
|
896 |
return $args;
|
897 |
} // featured_plugins_tab
|
898 |
// add single plugin to list of favs
|
899 |
-
static function add_plugin_favs($plugin_slug, $res) {
|
900 |
-
if (!empty($res->plugins) && is_array($res->plugins)) {
|
901 |
-
foreach ($res->plugins as $plugin) {
|
902 |
-
if (is_object($plugin) && !empty($plugin->slug) && $plugin->slug == $plugin_slug) {
|
903 |
return $res;
|
904 |
}
|
905 |
} // foreach
|
906 |
}
|
907 |
-
if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
|
908 |
array_unshift($res->plugins, $plugin_info);
|
909 |
} else {
|
910 |
$plugin_info = plugins_api('plugin_information', array(
|
@@ -917,9 +916,9 @@ if(!class_exists('webappick_suggest_plugin')){
|
|
917 |
'active_installs' => true,
|
918 |
'icons' => true,
|
919 |
'short_description' => true,
|
920 |
-
)
|
921 |
));
|
922 |
-
if (!is_wp_error($plugin_info)) {
|
923 |
$res->plugins[] = $plugin_info;
|
924 |
set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
|
925 |
}
|
@@ -927,7 +926,7 @@ if(!class_exists('webappick_suggest_plugin')){
|
|
927 |
return $res;
|
928 |
} // add_plugin_favs
|
929 |
}
|
930 |
-
add_action('init', array('webappick_suggest_plugin', 'init'));
|
931 |
}
|
932 |
|
933 |
|
11 |
* Plugin URI: https://webappick.com/
|
12 |
* Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
|
13 |
*
|
14 |
+
* Version: 3.9.0
|
15 |
* Author: WebAppick
|
16 |
* Author URI: https://webappick.com/
|
17 |
* License: GPL v2
|
39 |
* @var string
|
40 |
* @since 3.1.6
|
41 |
*/
|
42 |
+
define( 'WOO_FEED_FREE_VERSION', '3.9.0' );
|
43 |
}
|
44 |
|
45 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|
796 |
wp_die();
|
797 |
}
|
798 |
|
799 |
+
$feedName = sanitize_text_field( $_POST['feedName'] );
|
800 |
if ( ! empty( $feedName ) ) {
|
801 |
$feedInfo = maybe_unserialize( get_option( $feedName ) );
|
802 |
$feedInfo['status'] = isset( $_POST['status'] ) && 1 == $_POST['status'] ? 1 : 0;
|
803 |
|
804 |
+
$feed_slug = str_replace('wf_feed_','wf_config',$feedName);
|
805 |
+
if ( 1 === $feedInfo['status'] ) {
|
806 |
+
if ( ! wp_next_scheduled('woo_feed_update_single_feed',[ $feed_slug ]) ) {
|
807 |
wp_schedule_event( time(), 'woo_feed_corn', 'woo_feed_update_single_feed', [ $feed_slug ] );
|
808 |
}
|
809 |
+
}else {
|
810 |
wp_clear_scheduled_hook( 'woo_feed_update_single_feed',[ $feed_slug ]);
|
811 |
}
|
812 |
|
875 |
|
876 |
|
877 |
// Suggest other plugins of webappick.
|
878 |
+
if ( ! class_exists('webappick_suggest_plugin') ) {
|
879 |
class webappick_suggest_plugin
|
880 |
{
|
881 |
+
static function init() {
|
882 |
+
if ( is_admin() ) {
|
883 |
+
add_filter('install_plugins_table_api_args_featured', array( __CLASS__, 'featured_plugins_tab' ));
|
|
|
884 |
}
|
885 |
} // init
|
886 |
// add our plugins to recommended list
|
887 |
+
static function plugins_api_result( $res, $action, $args ) {
|
888 |
+
remove_filter('plugins_api_result', array( __CLASS__, 'plugins_api_result' ), 10, 1);
|
889 |
$res = self::add_plugin_favs('webappick-pdf-invoice-for-woocommerce', $res);
|
890 |
return $res;
|
891 |
} // plugins_api_result
|
892 |
// helper function for adding plugins to fav list
|
893 |
+
static function featured_plugins_tab( $args ) {
|
894 |
+
add_filter('plugins_api_result', array( __CLASS__, 'plugins_api_result' ), 10, 3);
|
895 |
return $args;
|
896 |
} // featured_plugins_tab
|
897 |
// add single plugin to list of favs
|
898 |
+
static function add_plugin_favs( $plugin_slug, $res ) {
|
899 |
+
if ( ! empty($res->plugins) && is_array($res->plugins) ) {
|
900 |
+
foreach ( $res->plugins as $plugin ) {
|
901 |
+
if ( is_object($plugin) && ! empty($plugin->slug) && $plugin->slug == $plugin_slug ) {
|
902 |
return $res;
|
903 |
}
|
904 |
} // foreach
|
905 |
}
|
906 |
+
if ( $plugin_info = get_transient('wf-plugin-info-' . $plugin_slug) ) {
|
907 |
array_unshift($res->plugins, $plugin_info);
|
908 |
} else {
|
909 |
$plugin_info = plugins_api('plugin_information', array(
|
916 |
'active_installs' => true,
|
917 |
'icons' => true,
|
918 |
'short_description' => true,
|
919 |
+
),
|
920 |
));
|
921 |
+
if ( ! is_wp_error($plugin_info) ) {
|
922 |
$res->plugins[] = $plugin_info;
|
923 |
set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
|
924 |
}
|
926 |
return $res;
|
927 |
} // add_plugin_favs
|
928 |
}
|
929 |
+
add_action('init', array( 'webappick_suggest_plugin', 'init' ));
|
930 |
}
|
931 |
|
932 |
|