Version Description
(2020-12-23) = * Added: Google shipping, identifier, tax attribute rule. * Added: Bing shipping, identifier, tax attribute rule. * Added: Pinterest ads_link attribute.
Download this release
Release Info
Developer | wahid0003 |
Plugin | CTX Feed – WooCommerce Product Feed Manager Plugin |
Version | 4.3.11 |
Comparing to | |
See all releases |
Code changes from version 4.3.10 to 4.3.11
- README.txt +6 -1
- admin/partials/templates/facebook.txt +10 -0
- admin/partials/templates/google.txt +10 -0
- admin/partials/templates/pinterest.txt +10 -0
- includes/classes/class-woo-feed-default-attributes.php +16 -14
- includes/classes/class-woo-feed-dropdown.php +9 -7
- includes/classes/class-woo-feed-products-v3.php +197 -117
- includes/feeds/class-woo-feed-custom.php +0 -167
- includes/feeds/class-woo-feed-facebook.php +3 -400
- includes/feeds/class-woo-feed-google.php +4 -488
- includes/feeds/class-woo-feed-pinterest.php +3 -495
- includes/feeds/merchant_templates.php +8 -8
- includes/helper.php +34 -0
- woo-feed.php +2 -2
README.txt
CHANGED
@@ -8,7 +8,7 @@ Google Product Review feed, product variations, rakuteen, shopping, skroutz, TSV
|
|
8 |
Requires at least: 3.6
|
9 |
Tested Up To: 5.6
|
10 |
Requires PHP: 5.6
|
11 |
-
Stable tag: 4.3.
|
12 |
License: GPLv2 or later
|
13 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
|
@@ -308,6 +308,11 @@ Using pro version:
|
|
308 |
|
309 |
== Changelog ==
|
310 |
|
|
|
|
|
|
|
|
|
|
|
311 |
= 4.3.10 (2020-12-22) =
|
312 |
* Fixed: Brand disable/enable option.
|
313 |
|
8 |
Requires at least: 3.6
|
9 |
Tested Up To: 5.6
|
10 |
Requires PHP: 5.6
|
11 |
+
Stable tag: 4.3.11
|
12 |
License: GPLv2 or later
|
13 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
|
308 |
|
309 |
== Changelog ==
|
310 |
|
311 |
+
= 4.3.11 (2020-12-23) =
|
312 |
+
* Added: Google shipping, identifier, tax attribute rule.
|
313 |
+
* Added: Bing shipping, identifier, tax attribute rule.
|
314 |
+
* Added: Pinterest ads_link attribute.
|
315 |
+
|
316 |
= 4.3.10 (2020-12-22) =
|
317 |
* Fixed: Brand disable/enable option.
|
318 |
|
admin/partials/templates/facebook.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0" version="2.0">
|
2 |
+
<channel>
|
3 |
+
<title>
|
4 |
+
<![CDATA[ {BlogName} ]]>
|
5 |
+
</title>
|
6 |
+
<link><![CDATA[ {BlogURL} ]]></link>
|
7 |
+
<description><![CDATA[ {BlogDescription} ]]></description>
|
8 |
+
{separator}
|
9 |
+
</channel>
|
10 |
+
</rss>
|
admin/partials/templates/google.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0" version="2.0">
|
2 |
+
<channel>
|
3 |
+
<title>
|
4 |
+
<![CDATA[ {BlogName} ]]>
|
5 |
+
</title>
|
6 |
+
<link><![CDATA[ {BlogURL} ]]></link>
|
7 |
+
<description><![CDATA[ {BlogDescription} ]]></description>
|
8 |
+
{separator}
|
9 |
+
</channel>
|
10 |
+
</rss>
|
admin/partials/templates/pinterest.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0" version="2.0">
|
2 |
+
<channel>
|
3 |
+
<title>
|
4 |
+
<![CDATA[ {BlogName} ]]>
|
5 |
+
</title>
|
6 |
+
<link><![CDATA[ {BlogURL} ]]></link>
|
7 |
+
<description><![CDATA[ {BlogDescription} ]]></description>
|
8 |
+
{separator}
|
9 |
+
</channel>
|
10 |
+
</rss>
|
includes/classes/class-woo-feed-default-attributes.php
CHANGED
@@ -18,8 +18,8 @@ class Woo_Feed_Default_Attributes {
|
|
18 |
public $googleXMLAttribute
|
19 |
= array(
|
20 |
'id' => array( 'g:id', false ),
|
21 |
-
'title' => array( 'title', true ),
|
22 |
-
'description' => array( 'description', true ),
|
23 |
'link' => array( 'link', true ),
|
24 |
'canonical_link' => array( 'g:canonical_link', true ),
|
25 |
'mobile_link' => array( 'mobile_link', true ),
|
@@ -486,16 +486,16 @@ class Woo_Feed_Default_Attributes {
|
|
486 |
'current_category' => array( 'google_product_category', true ),
|
487 |
'image' => array( 'image_link', true ),
|
488 |
'images' => array( 'additional_image_link', true ),
|
489 |
-
'images_1' => array( '
|
490 |
-
'images_2' => array( '
|
491 |
-
'images_3' => array( '
|
492 |
-
'images_4' => array( '
|
493 |
-
'images_5' => array( '
|
494 |
-
'images_6' => array( '
|
495 |
-
'images_7' => array( '
|
496 |
-
'images_8' => array( '
|
497 |
-
'images_9' => array( '
|
498 |
-
'images_10' => array( '
|
499 |
'condition' => array( 'condition', false ),
|
500 |
'availability' => array( 'availability', false ),
|
501 |
'availability_date' => array( 'availability_date', false ),
|
@@ -506,7 +506,7 @@ class Woo_Feed_Default_Attributes {
|
|
506 |
'brand' => array( 'brand', true ),
|
507 |
'sku' => array( 'mpn', true ),
|
508 |
'upc' => array( 'gtin', true ),
|
509 |
-
'identifier_exists' => array( '
|
510 |
'item_group_id' => array( 'item_group_id', false ),
|
511 |
'color' => array( 'color', true ),
|
512 |
'gender' => array( 'gender', true ),
|
@@ -786,7 +786,9 @@ class Woo_Feed_Default_Attributes {
|
|
786 |
'price' => 'Product Price[price]',
|
787 |
'description' => 'Product Description[description]',
|
788 |
'image_link' => 'Image[image_link]',
|
789 |
-
'
|
|
|
|
|
790 |
'gtin' => 'GTIN[gtin]',
|
791 |
'mpn' => 'MPN[mpn]',
|
792 |
'brand' => 'Brand[brand]',
|
18 |
public $googleXMLAttribute
|
19 |
= array(
|
20 |
'id' => array( 'g:id', false ),
|
21 |
+
'title' => array( 'g:title', true ),
|
22 |
+
'description' => array( 'g:description', true ),
|
23 |
'link' => array( 'link', true ),
|
24 |
'canonical_link' => array( 'g:canonical_link', true ),
|
25 |
'mobile_link' => array( 'mobile_link', true ),
|
486 |
'current_category' => array( 'google_product_category', true ),
|
487 |
'image' => array( 'image_link', true ),
|
488 |
'images' => array( 'additional_image_link', true ),
|
489 |
+
'images_1' => array( 'additional_image_link', true ),
|
490 |
+
'images_2' => array( 'additional_image_link', true ),
|
491 |
+
'images_3' => array( 'additional_image_link', true ),
|
492 |
+
'images_4' => array( 'additional_image_link', true ),
|
493 |
+
'images_5' => array( 'additional_image_link', true ),
|
494 |
+
'images_6' => array( 'additional_image_link', true ),
|
495 |
+
'images_7' => array( 'additional_image_link', true ),
|
496 |
+
'images_8' => array( 'additional_image_link', true ),
|
497 |
+
'images_9' => array( 'additional_image_link', true ),
|
498 |
+
'images_10' => array( 'additional_image_link', true ),
|
499 |
'condition' => array( 'condition', false ),
|
500 |
'availability' => array( 'availability', false ),
|
501 |
'availability_date' => array( 'availability_date', false ),
|
506 |
'brand' => array( 'brand', true ),
|
507 |
'sku' => array( 'mpn', true ),
|
508 |
'upc' => array( 'gtin', true ),
|
509 |
+
'identifier_exists' => array( 'identifier_exists', true ),
|
510 |
'item_group_id' => array( 'item_group_id', false ),
|
511 |
'color' => array( 'color', true ),
|
512 |
'gender' => array( 'gender', true ),
|
786 |
'price' => 'Product Price[price]',
|
787 |
'description' => 'Product Description[description]',
|
788 |
'image_link' => 'Image[image_link]',
|
789 |
+
'shipping_country' => 'Shipping Country[shipping]',
|
790 |
+
'shipping_service' => 'Shipping Service[shipping]',
|
791 |
+
'shipping_price' => 'Shipping Price[shipping]',
|
792 |
'gtin' => 'GTIN[gtin]',
|
793 |
'mpn' => 'MPN[mpn]',
|
794 |
'brand' => 'Brand[brand]',
|
includes/classes/class-woo-feed-dropdown.php
CHANGED
@@ -403,15 +403,17 @@ class Woo_Feed_Dropdown {
|
|
403 |
* Dropdown of Google Attribute List
|
404 |
*
|
405 |
* @param string $selected
|
|
|
406 |
*
|
407 |
* @return string
|
408 |
*/
|
409 |
-
public function googleAttributesDropdown( $selected = '' ) {
|
410 |
$options = $this->get_cached_dropdown( 'googleAttributesDropdown', $selected );
|
411 |
|
412 |
if ( false === $options ) {
|
413 |
-
|
414 |
-
|
|
|
415 |
}
|
416 |
return $options;
|
417 |
}
|
@@ -561,7 +563,7 @@ class Woo_Feed_Dropdown {
|
|
561 |
* @return string
|
562 |
*/
|
563 |
public function google_shopping_actionAttributesDropdown( $selected = '' ) {
|
564 |
-
|
565 |
}
|
566 |
|
567 |
|
@@ -591,7 +593,7 @@ class Woo_Feed_Dropdown {
|
|
591 |
* @return string
|
592 |
*/
|
593 |
public function facebookAttributesDropdown( $selected = '' ) {
|
594 |
-
|
595 |
}
|
596 |
|
597 |
/**
|
@@ -603,7 +605,7 @@ class Woo_Feed_Dropdown {
|
|
603 |
* @return string
|
604 |
*/
|
605 |
public function pinterestAttributesDropdown( $selected = '' ) {
|
606 |
-
|
607 |
}
|
608 |
|
609 |
/**
|
@@ -633,7 +635,7 @@ class Woo_Feed_Dropdown {
|
|
633 |
* @return string
|
634 |
*/
|
635 |
public function adrollAttributesDropdown( $selected = '' ) {
|
636 |
-
|
637 |
}
|
638 |
|
639 |
/**
|
403 |
* Dropdown of Google Attribute List
|
404 |
*
|
405 |
* @param string $selected
|
406 |
+
* @param array $merchants
|
407 |
*
|
408 |
* @return string
|
409 |
*/
|
410 |
+
public function googleAttributesDropdown( $selected = '', $merchants = [] ) {
|
411 |
$options = $this->get_cached_dropdown( 'googleAttributesDropdown', $selected );
|
412 |
|
413 |
if ( false === $options ) {
|
414 |
+
$attributes_obj = new Woo_Feed_Default_Attributes();
|
415 |
+
$attributes = apply_filters( 'woo_feed_filter_dropdown_attributes', $attributes_obj->googleAttributes(), $merchants );
|
416 |
+
return $this->cache_dropdown( 'googleAttributesDropdown', $attributes, $selected );
|
417 |
}
|
418 |
return $options;
|
419 |
}
|
563 |
* @return string
|
564 |
*/
|
565 |
public function google_shopping_actionAttributesDropdown( $selected = '' ) {
|
566 |
+
return $this->googleAttributesDropdown( $selected, ['google_shopping_action'] );
|
567 |
}
|
568 |
|
569 |
|
593 |
* @return string
|
594 |
*/
|
595 |
public function facebookAttributesDropdown( $selected = '' ) {
|
596 |
+
return $this->googleAttributesDropdown( $selected, ['facebook'] );
|
597 |
}
|
598 |
|
599 |
/**
|
605 |
* @return string
|
606 |
*/
|
607 |
public function pinterestAttributesDropdown( $selected = '' ) {
|
608 |
+
return $this->googleAttributesDropdown( $selected, ['pinterest'] );
|
609 |
}
|
610 |
|
611 |
/**
|
635 |
* @return string
|
636 |
*/
|
637 |
public function adrollAttributesDropdown( $selected = '' ) {
|
638 |
+
return $this->googleAttributesDropdown( $selected, ['adroll'] );
|
639 |
}
|
640 |
|
641 |
/**
|
includes/classes/class-woo-feed-products-v3.php
CHANGED
@@ -114,9 +114,15 @@ class Woo_Feed_Products_v3
|
|
114 |
* Google shipping tax attributes
|
115 |
* @var array
|
116 |
*/
|
|
|
|
|
|
|
|
|
|
|
117 |
protected $google_shipping_tax = array(
|
118 |
'shipping_country',
|
119 |
'shipping_region',
|
|
|
120 |
'shipping_service',
|
121 |
'shipping_price',
|
122 |
'tax_country',
|
@@ -139,14 +145,17 @@ class Woo_Feed_Products_v3
|
|
139 |
*/
|
140 |
protected $xml_wrapper = [];
|
141 |
|
|
|
142 |
/**
|
143 |
* Attribute to skip in attribute loop for processing separately
|
|
|
144 |
* @var array
|
145 |
*/
|
146 |
protected $skipped_merchant_attributes = array(
|
147 |
'google' => array(
|
148 |
'shipping_country',
|
149 |
'shipping_region',
|
|
|
150 |
'shipping_service',
|
151 |
'shipping_price',
|
152 |
'tax_country',
|
@@ -180,6 +189,22 @@ class Woo_Feed_Products_v3
|
|
180 |
'attribute_name',
|
181 |
'attribute_value',
|
182 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
);
|
184 |
|
185 |
/**
|
@@ -409,6 +434,7 @@ class Woo_Feed_Products_v3
|
|
409 |
|
410 |
// reset processed attribute list before loop
|
411 |
$this->processed_merchant_attributes = [];
|
|
|
412 |
// Process attribute values
|
413 |
$this->process_attributes($product);
|
414 |
|
@@ -693,12 +719,12 @@ class Woo_Feed_Products_v3
|
|
693 |
*
|
694 |
*/
|
695 |
protected function exclude_current_attribute( $product, $merchant_attribute, $product_attribute, $feedType = 'xml' ) {
|
|
|
696 |
if ( empty($merchant_attribute) ) {
|
697 |
return true;
|
698 |
}
|
699 |
|
700 |
if (
|
701 |
-
$feedType == $this->config['feedType'] &&
|
702 |
in_array($this->config['provider'], array_keys($this->skipped_merchant_attributes)) &&
|
703 |
in_array($merchant_attribute, $this->skipped_merchant_attributes[ $this->config['provider'] ])
|
704 |
|
@@ -744,131 +770,155 @@ class Woo_Feed_Products_v3
|
|
744 |
/**
|
745 |
* Process feed data according to merchant uncommon requirements like Google
|
746 |
*
|
747 |
-
* @param $productObj WC_Product
|
748 |
-
* @param $index
|
749 |
*
|
750 |
* @since 3.2.0
|
751 |
-
*
|
752 |
*/
|
753 |
protected function process_for_merchant( $productObj, $index ) {
|
754 |
-
$product
|
755 |
$merchantAttributes = $this->config['mattributes'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
756 |
|
757 |
// Format Shipping and Tax data for CSV and TXT feed only for google and facebook
|
758 |
-
if ( 'xml' != $this->config['feedType'] && in_array($this->config['provider'], [ 'google', 'facebook' ]) ) {
|
759 |
-
|
760 |
-
$shipping = array();
|
761 |
-
$tax = array();
|
762 |
-
$installment = array();
|
763 |
-
$product_detail = array();
|
764 |
-
$s = 0; // Shipping Index
|
765 |
-
$t = 0; // Tax Index
|
766 |
-
$i = 0; // Installment Index
|
767 |
-
$pd = 0; // Product details Index
|
768 |
-
$shippingAttr = array(
|
769 |
-
'shipping_country',
|
770 |
-
'shipping_service',
|
771 |
-
'shipping_price',
|
772 |
-
'shipping_region',
|
773 |
-
'tax_country',
|
774 |
-
'tax_region',
|
775 |
-
'tax_rate',
|
776 |
-
'tax_ship',
|
777 |
-
'section_name',
|
778 |
-
'attribute_name',
|
779 |
-
'attribute_value',
|
780 |
-
);
|
781 |
-
foreach ( $this->products[ $this->pi ] as $attribute => $value ) {
|
782 |
-
$trim_attribute_array = explode(" ", $attribute);
|
783 |
-
$csv_attribute = implode("_", $trim_attribute_array);
|
784 |
-
if ( in_array($csv_attribute, $shippingAttr) ) {
|
785 |
-
if ( 'tax_country' == $csv_attribute ) {
|
786 |
-
$t++;
|
787 |
-
$tax[ $t ] .= $value . ':';
|
788 |
-
} elseif ( 'tax_region' == $csv_attribute ) {
|
789 |
-
$tax[ $t ] .= $value . ':';
|
790 |
-
} elseif ( 'tax_rate' == $csv_attribute ) {
|
791 |
-
$tax[ $t ] .= $value . ':';
|
792 |
-
} elseif ( 'tax_ship' == $csv_attribute ) {
|
793 |
-
$tax[ $t ] .= $value . ':';
|
794 |
-
}
|
795 |
|
|
|
|
|
796 |
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
808 |
|
809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
}
|
812 |
|
813 |
-
|
814 |
-
$this->products[ $this->pi ][
|
|
|
|
|
|
|
815 |
}
|
816 |
|
817 |
-
|
818 |
-
$this->products[ $this->pi ][
|
|
|
|
|
|
|
|
|
|
|
819 |
}
|
820 |
}
|
821 |
|
822 |
-
if ( 'google' == $this->config['provider'] ) {
|
823 |
|
824 |
-
|
825 |
-
|
826 |
-
$tax = '';
|
827 |
-
$s = 0; // Shipping
|
828 |
-
$shipping = '';
|
829 |
-
$sub = 0; // Subscription Index
|
830 |
-
$subscription = '';
|
831 |
-
$ins = 0; // Installment Index
|
832 |
-
$installment = "";
|
833 |
-
$product_detail = '';
|
834 |
-
$pd = 0;
|
835 |
|
|
|
836 |
if ( 'xml' == $this->config['feedType'] ) {
|
837 |
foreach ( $merchantAttributes as $key => $value ) {
|
838 |
|
839 |
-
if ( ! in_array($value, $this->google_shipping_tax) ) {
|
840 |
continue;
|
841 |
}
|
842 |
|
843 |
-
$prefix = $this->config['prefix'][ $key ];
|
844 |
-
$suffix = $this->config['suffix'][ $key ];
|
845 |
|
846 |
-
|
847 |
-
$
|
848 |
|
849 |
-
if ( 'pattern' == $this->config['type'][ $key ] ) {
|
850 |
-
$output = $this->config['default'][ $key ];
|
851 |
-
$output = $this->apply_filters_to_attribute_value($output,$productObj,$attribute,$merchant_attribute);
|
852 |
-
} else { // Get Pattern value.
|
853 |
-
$output = $this->getAttributeValueByType($productObj, $attribute, $merchant_attribute);
|
854 |
-
}
|
855 |
-
|
856 |
-
$output = $this->format_output($output,$this->config['output_type'],$productObj,$attribute,$merchant_attribute);
|
857 |
-
|
858 |
-
$output = $this->process_prefix_suffix( $output, $prefix, $suffix, $attribute = '' );
|
859 |
|
860 |
if ( 'shipping_country' == $value ) {
|
861 |
if ( 0 == $s ) {
|
862 |
$shipping .= '<g:shipping>';
|
863 |
-
$s
|
864 |
} else {
|
865 |
$shipping .= '</g:shipping>' . "\n";
|
866 |
$shipping .= '<g:shipping>';
|
867 |
}
|
868 |
-
} elseif ( ! in_array('shipping_country', $merchantAttributes) && 'shipping_price' == $value ) {
|
869 |
if ( 0 == $s ) {
|
870 |
$shipping .= '<g:shipping>';
|
871 |
-
$s
|
872 |
} else {
|
873 |
$shipping .= '</g:shipping>' . "\n";
|
874 |
$shipping .= '<g:shipping>';
|
@@ -879,14 +929,18 @@ class Woo_Feed_Products_v3
|
|
879 |
$shipping .= '<g:country>' . $output . '</g:country>' . "\n";
|
880 |
} elseif ( 'shipping_region' == $value ) {
|
881 |
$shipping .= '<g:region>' . $output . '</g:region>' . "\n";
|
|
|
|
|
882 |
} elseif ( 'shipping_service' == $value ) {
|
883 |
$shipping .= '<g:service>' . $output . '</g:service>' . "\n";
|
|
|
|
|
884 |
} elseif ( 'shipping_price' == $value ) {
|
885 |
$shipping .= '<g:price>' . $output . '</g:price>' . "\n";
|
886 |
} elseif ( 'tax_country' == $value ) {
|
887 |
if ( 0 == $t ) {
|
888 |
$tax .= '<g:tax>';
|
889 |
-
$t
|
890 |
} else {
|
891 |
$tax .= '</g:tax>' . "\n";
|
892 |
$tax .= '<g:tax>';
|
@@ -898,31 +952,33 @@ class Woo_Feed_Products_v3
|
|
898 |
$tax .= '<g:rate>' . $output . '</g:rate>' . "\n";
|
899 |
} elseif ( 'tax_ship' == $value ) {
|
900 |
$tax .= '<g:tax_ship>' . $output . '</g:tax_ship>' . "\n";
|
901 |
-
}elseif ( 'subscription_period'
|
902 |
if ( 0 == $sub ) {
|
903 |
$subscription .= '<g:subscription_cost>';
|
904 |
-
$sub
|
905 |
} else {
|
906 |
$subscription .= '</g:subscription_cost>' . "\n";
|
907 |
$subscription .= '<g:subscription_cost>';
|
908 |
}
|
909 |
$subscription .= '<g:period>' . $output . '</g:period>' . "\n";
|
910 |
-
}elseif ( 'subscription_period_length' == $value ) {
|
911 |
$subscription .= '<g:period_length>' . $output . '</g:period_length>' . "\n";
|
912 |
-
}elseif ( 'subscription_amount' == $value ) {
|
913 |
$subscription .= '<g:amount>' . $output . '</g:amount>' . "\n";
|
914 |
-
}
|
|
|
|
|
915 |
if ( 0 == $pd ) {
|
916 |
$product_detail .= '<g:product_detail>';
|
917 |
-
$pd
|
918 |
} else {
|
919 |
$product_detail .= '</g:product_detail>' . "\n";
|
920 |
$product_detail .= '<g:product_detail>';
|
921 |
}
|
922 |
-
} elseif ( ! in_array('section_name', $merchantAttributes) && 'attribute_name' == $value ) {
|
923 |
if ( 0 == $pd ) {
|
924 |
$product_detail .= '<g:product_detail>';
|
925 |
-
$pd
|
926 |
} else {
|
927 |
$product_detail .= '</g:product_detail>' . "\n";
|
928 |
$product_detail .= '<g:product_detail>';
|
@@ -931,9 +987,9 @@ class Woo_Feed_Products_v3
|
|
931 |
|
932 |
if ( 'section_name' == $value ) {
|
933 |
$product_detail .= '<g:section_name>' . $output . '</g:section_name>' . "\n";
|
934 |
-
}elseif ( 'attribute_name' == $value ) {
|
935 |
$product_detail .= '<g:attribute_name>' . $output . '</g:attribute_name>' . "\n";
|
936 |
-
}elseif ( 'attribute_value' == $value ) {
|
937 |
$product_detail .= '<g:attribute_value>' . $output . '</g:attribute_value>' . "\n";
|
938 |
}
|
939 |
|
@@ -975,34 +1031,33 @@ class Woo_Feed_Products_v3
|
|
975 |
$this->feedBody .= $product_detail;
|
976 |
$this->feedBody .= $installment;
|
977 |
|
978 |
-
|
979 |
-
|
980 |
-
$productObj->is_type('
|
981 |
-
$productObj->is_type('subscription_variation') ) {
|
982 |
$this->feedBody .= $subscription;
|
983 |
}
|
984 |
}
|
985 |
// ADD g:identifier_exists
|
986 |
-
$identifier
|
987 |
$countIdentifier = 0;
|
988 |
-
if ( ! in_array('identifier_exists', $merchantAttributes) ) {
|
989 |
-
if ( count(array_intersect_key(array_flip($identifier), $product)) >= 2 ) {
|
990 |
// Any 2 required keys exist!
|
991 |
// @TODO Refactor with OR
|
992 |
-
if ( array_key_exists('brand', $product) && ! empty($product['brand']) ) {
|
993 |
-
$countIdentifier++;
|
994 |
}
|
995 |
-
if ( array_key_exists('upc', $product) && ! empty($product['upc']) ) {
|
996 |
-
$countIdentifier++;
|
997 |
}
|
998 |
-
if ( array_key_exists('sku', $product) && ! empty($product['sku']) ) {
|
999 |
-
$countIdentifier++;
|
1000 |
}
|
1001 |
-
if ( array_key_exists('mpn', $product) && ! empty($product['mpn']) ) {
|
1002 |
-
$countIdentifier++;
|
1003 |
}
|
1004 |
-
if ( array_key_exists('gtin', $product) && ! empty($product['gtin']) ) {
|
1005 |
-
$countIdentifier++;
|
1006 |
}
|
1007 |
}
|
1008 |
|
@@ -1013,16 +1068,41 @@ class Woo_Feed_Products_v3
|
|
1013 |
$this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
|
1014 |
}
|
1015 |
} else {
|
|
|
|
|
|
|
|
|
|
|
1016 |
if ( $countIdentifier >= 2 ) {
|
1017 |
-
$this->products[ $this->pi ][
|
1018 |
} else {
|
1019 |
-
$this->products[ $this->pi ][
|
1020 |
}
|
1021 |
}
|
1022 |
}
|
1023 |
}
|
1024 |
}
|
1025 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1026 |
/**
|
1027 |
* Get Query Type Settings
|
1028 |
* @return string
|
114 |
* Google shipping tax attributes
|
115 |
* @var array
|
116 |
*/
|
117 |
+
/**
|
118 |
+
* Google shipping tax attributes
|
119 |
+
*
|
120 |
+
* @var array
|
121 |
+
*/
|
122 |
protected $google_shipping_tax = array(
|
123 |
'shipping_country',
|
124 |
'shipping_region',
|
125 |
+
'shipping_postal_code',
|
126 |
'shipping_service',
|
127 |
'shipping_price',
|
128 |
'tax_country',
|
145 |
*/
|
146 |
protected $xml_wrapper = [];
|
147 |
|
148 |
+
|
149 |
/**
|
150 |
* Attribute to skip in attribute loop for processing separately
|
151 |
+
*
|
152 |
* @var array
|
153 |
*/
|
154 |
protected $skipped_merchant_attributes = array(
|
155 |
'google' => array(
|
156 |
'shipping_country',
|
157 |
'shipping_region',
|
158 |
+
'shipping_postal_code',
|
159 |
'shipping_service',
|
160 |
'shipping_price',
|
161 |
'tax_country',
|
189 |
'attribute_name',
|
190 |
'attribute_value',
|
191 |
),
|
192 |
+
'bing'=>array(
|
193 |
+
'shipping_country',
|
194 |
+
'shipping_service',
|
195 |
+
'shipping_price',
|
196 |
+
),
|
197 |
+
'pinterest'=>array(
|
198 |
+
'shipping_country',
|
199 |
+
'shipping_service',
|
200 |
+
'shipping_price',
|
201 |
+
'shipping_region',
|
202 |
+
'shipping_postal_code',
|
203 |
+
'tax_country',
|
204 |
+
'tax_region',
|
205 |
+
'tax_rate',
|
206 |
+
'tax_ship',
|
207 |
+
)
|
208 |
);
|
209 |
|
210 |
/**
|
434 |
|
435 |
// reset processed attribute list before loop
|
436 |
$this->processed_merchant_attributes = [];
|
437 |
+
|
438 |
// Process attribute values
|
439 |
$this->process_attributes($product);
|
440 |
|
719 |
*
|
720 |
*/
|
721 |
protected function exclude_current_attribute( $product, $merchant_attribute, $product_attribute, $feedType = 'xml' ) {
|
722 |
+
|
723 |
if ( empty($merchant_attribute) ) {
|
724 |
return true;
|
725 |
}
|
726 |
|
727 |
if (
|
|
|
728 |
in_array($this->config['provider'], array_keys($this->skipped_merchant_attributes)) &&
|
729 |
in_array($merchant_attribute, $this->skipped_merchant_attributes[ $this->config['provider'] ])
|
730 |
|
770 |
/**
|
771 |
* Process feed data according to merchant uncommon requirements like Google
|
772 |
*
|
773 |
+
* @param object $productObj WC_Product
|
774 |
+
* @param int $index Product Index
|
775 |
*
|
776 |
* @since 3.2.0
|
|
|
777 |
*/
|
778 |
protected function process_for_merchant( $productObj, $index ) {
|
779 |
+
$product = $this->products[ $index ];
|
780 |
$merchantAttributes = $this->config['mattributes'];
|
781 |
+
$s = 0; // Shipping Index
|
782 |
+
$i = 0; // Installment Index
|
783 |
+
$t = 0; // Tax Index
|
784 |
+
$tax = '';
|
785 |
+
$shipping = '';
|
786 |
+
$sub = 0;
|
787 |
+
$subscription = '';
|
788 |
+
$ins = 0; // Installment Index
|
789 |
+
$installment ="";
|
790 |
+
$product_detail = '';
|
791 |
+
$pd = 0;
|
792 |
+
|
793 |
|
794 |
// Format Shipping and Tax data for CSV and TXT feed only for google and facebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
795 |
|
796 |
+
if ( 'xml' != $this->config['feedType'] && in_array( $this->config['provider'], array( 'google', 'facebook','bing','snapchat','pinterest') ) ) {
|
797 |
+
foreach ( $merchantAttributes as $key => $value ) {
|
798 |
|
799 |
+
if ( ! in_array( $value, $this->google_shipping_tax ) ) {
|
800 |
+
continue;
|
801 |
+
}
|
802 |
+
|
803 |
+
# Get value by attribute type with prefix & suffix
|
804 |
+
$output=$this->process_for_merchant_get_value($productObj,$key);
|
805 |
+
|
806 |
+
if ( 'tax_country' == $value ) {
|
807 |
+
$t++;
|
808 |
+
$tax.= $output;
|
809 |
+
}
|
810 |
+
if ( 'tax_region' == $value ) {
|
811 |
+
$tax.= ':'.$output;
|
812 |
+
}
|
813 |
+
if ( 'tax_rate' == $value ) {
|
814 |
+
$tax.= ':'.$output;
|
815 |
+
}
|
816 |
+
if ( 'tax_ship' == $value ) {
|
817 |
+
$tax.= ':'.$output;
|
818 |
+
}
|
819 |
+
|
820 |
+
|
821 |
+
if ( 'shipping_country' == $value ) {
|
822 |
+
$s++;
|
823 |
+
$shipping.= $output;
|
824 |
+
}
|
825 |
+
if ( 'shipping_region' == $value ) {
|
826 |
+
$shipping.= ':'.$output;
|
827 |
+
}else if('shipping_postal_code' == $value){
|
828 |
+
$shipping.= ':'.$output;
|
829 |
+
}
|
830 |
+
if ( 'shipping_service' == $value ) {
|
831 |
+
$shipping.= ':'.$output;
|
832 |
+
} if ( 'shipping_price' == $value ) {
|
833 |
+
$shipping.= ':'.$output;
|
834 |
+
}
|
835 |
+
|
836 |
+
if ( 'section_name' == $value ) {
|
837 |
+
$pd++;
|
838 |
+
$product_detail .= $output;
|
839 |
+
}
|
840 |
+
if ( 'attribute_name' == $value ) {
|
841 |
+
$product_detail .= ':'.$output;
|
842 |
+
}
|
843 |
+
if ( 'attribute_value' == $value ) {
|
844 |
+
$product_detail .= ':'.$output;
|
845 |
+
}
|
846 |
|
847 |
+
if ( 'installment_months' == $value ) {
|
848 |
+
$ins++;
|
849 |
+
$installment .= $output;
|
850 |
+
}
|
851 |
+
if ( 'installment_amount' == $value ) {
|
852 |
+
$installment .= ':'.$output;
|
853 |
+
}
|
854 |
|
855 |
+
if ( 'subscription_period' == $value ) {
|
856 |
+
$sub++;
|
857 |
+
$subscription .= $output;
|
858 |
+
}
|
859 |
+
if ( 'subscription_period_length' == $value ) {
|
860 |
+
$subscription .= ':'.$output;
|
861 |
+
}
|
862 |
+
if ( 'subscription_amount' == $value ) {
|
863 |
+
$subscription .= ':'.$output;
|
864 |
}
|
865 |
+
|
866 |
+
// echo "<pre>";print_r($this->products[ $this->pi ]);die();
|
867 |
+
|
868 |
+
// unset($this->products[ $this->pi ][$value]);
|
869 |
+
|
870 |
+
}
|
871 |
+
|
872 |
+
if ( 0 < $pd ) {
|
873 |
+
$this->products[ $this->pi ]["product detail"] = $product_detail;
|
874 |
}
|
875 |
|
876 |
+
if ( 0 < $s ) {
|
877 |
+
$this->products[ $this->pi ]["shipping"] = $shipping;
|
878 |
+
}
|
879 |
+
if ( 0 < $t ) {
|
880 |
+
$this->products[ $this->pi ]["tax"] = $tax;
|
881 |
}
|
882 |
|
883 |
+
if ( 0 < $sub ) {
|
884 |
+
$this->products[ $this->pi ]["subscription cost"] = $subscription;
|
885 |
+
|
886 |
+
}
|
887 |
+
|
888 |
+
if ( 0 < $ins ) {
|
889 |
+
$this->products[ $this->pi ]["installment"] = $installment;
|
890 |
}
|
891 |
}
|
892 |
|
|
|
893 |
|
894 |
+
if ( in_array( $this->config['provider'], array( 'google', 'facebook','snapchat','bing','pinterest') ) ) {
|
895 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
896 |
|
897 |
+
// Reformat Shipping attributes for google, facebook
|
898 |
if ( 'xml' == $this->config['feedType'] ) {
|
899 |
foreach ( $merchantAttributes as $key => $value ) {
|
900 |
|
901 |
+
if ( ! in_array( $value, $this->google_shipping_tax ) ) {
|
902 |
continue;
|
903 |
}
|
904 |
|
|
|
|
|
905 |
|
906 |
+
# Get value by attribute type with prefix & suffix
|
907 |
+
$output=$this->process_for_merchant_get_value($productObj,$key);
|
908 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
|
910 |
if ( 'shipping_country' == $value ) {
|
911 |
if ( 0 == $s ) {
|
912 |
$shipping .= '<g:shipping>';
|
913 |
+
$s = 1;
|
914 |
} else {
|
915 |
$shipping .= '</g:shipping>' . "\n";
|
916 |
$shipping .= '<g:shipping>';
|
917 |
}
|
918 |
+
} elseif ( ! in_array( 'shipping_country', $merchantAttributes ) && 'shipping_price' == $value ) {
|
919 |
if ( 0 == $s ) {
|
920 |
$shipping .= '<g:shipping>';
|
921 |
+
$s = 1;
|
922 |
} else {
|
923 |
$shipping .= '</g:shipping>' . "\n";
|
924 |
$shipping .= '<g:shipping>';
|
929 |
$shipping .= '<g:country>' . $output . '</g:country>' . "\n";
|
930 |
} elseif ( 'shipping_region' == $value ) {
|
931 |
$shipping .= '<g:region>' . $output . '</g:region>' . "\n";
|
932 |
+
}elseif ( 'shipping_region' == $value ) {
|
933 |
+
$shipping .= '<g:region>' . $output . '</g:region>' . "\n";
|
934 |
} elseif ( 'shipping_service' == $value ) {
|
935 |
$shipping .= '<g:service>' . $output . '</g:service>' . "\n";
|
936 |
+
}elseif ( 'shipping_postal_code' == $value ) {
|
937 |
+
$shipping .= '<g:postal_code>' . $output . '</g:postal_code>' . "\n";
|
938 |
} elseif ( 'shipping_price' == $value ) {
|
939 |
$shipping .= '<g:price>' . $output . '</g:price>' . "\n";
|
940 |
} elseif ( 'tax_country' == $value ) {
|
941 |
if ( 0 == $t ) {
|
942 |
$tax .= '<g:tax>';
|
943 |
+
$t = 1;
|
944 |
} else {
|
945 |
$tax .= '</g:tax>' . "\n";
|
946 |
$tax .= '<g:tax>';
|
952 |
$tax .= '<g:rate>' . $output . '</g:rate>' . "\n";
|
953 |
} elseif ( 'tax_ship' == $value ) {
|
954 |
$tax .= '<g:tax_ship>' . $output . '</g:tax_ship>' . "\n";
|
955 |
+
} elseif ( 'subscription_period' == $value ) {
|
956 |
if ( 0 == $sub ) {
|
957 |
$subscription .= '<g:subscription_cost>';
|
958 |
+
$sub = 1;
|
959 |
} else {
|
960 |
$subscription .= '</g:subscription_cost>' . "\n";
|
961 |
$subscription .= '<g:subscription_cost>';
|
962 |
}
|
963 |
$subscription .= '<g:period>' . $output . '</g:period>' . "\n";
|
964 |
+
} elseif ( 'subscription_period_length' == $value ) {
|
965 |
$subscription .= '<g:period_length>' . $output . '</g:period_length>' . "\n";
|
966 |
+
} elseif ( 'subscription_amount' == $value ) {
|
967 |
$subscription .= '<g:amount>' . $output . '</g:amount>' . "\n";
|
968 |
+
}
|
969 |
+
|
970 |
+
if ( 'section_name' == $value ) {
|
971 |
if ( 0 == $pd ) {
|
972 |
$product_detail .= '<g:product_detail>';
|
973 |
+
$pd = 1;
|
974 |
} else {
|
975 |
$product_detail .= '</g:product_detail>' . "\n";
|
976 |
$product_detail .= '<g:product_detail>';
|
977 |
}
|
978 |
+
} elseif ( ! in_array( 'section_name', $merchantAttributes ) && 'attribute_name' == $value ) {
|
979 |
if ( 0 == $pd ) {
|
980 |
$product_detail .= '<g:product_detail>';
|
981 |
+
$pd = 1;
|
982 |
} else {
|
983 |
$product_detail .= '</g:product_detail>' . "\n";
|
984 |
$product_detail .= '<g:product_detail>';
|
987 |
|
988 |
if ( 'section_name' == $value ) {
|
989 |
$product_detail .= '<g:section_name>' . $output . '</g:section_name>' . "\n";
|
990 |
+
} elseif ( 'attribute_name' == $value ) {
|
991 |
$product_detail .= '<g:attribute_name>' . $output . '</g:attribute_name>' . "\n";
|
992 |
+
} elseif ( 'attribute_value' == $value ) {
|
993 |
$product_detail .= '<g:attribute_value>' . $output . '</g:attribute_value>' . "\n";
|
994 |
}
|
995 |
|
1031 |
$this->feedBody .= $product_detail;
|
1032 |
$this->feedBody .= $installment;
|
1033 |
|
1034 |
+
if ( $productObj->is_type( 'subscription' ) ||
|
1035 |
+
$productObj->is_type( 'variable-subscription' ) ||
|
1036 |
+
$productObj->is_type( 'subscription_variation' ) ) {
|
|
|
1037 |
$this->feedBody .= $subscription;
|
1038 |
}
|
1039 |
}
|
1040 |
// ADD g:identifier_exists
|
1041 |
+
$identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
|
1042 |
$countIdentifier = 0;
|
1043 |
+
if ( ! in_array( 'identifier_exists', $merchantAttributes ) ) {
|
1044 |
+
if ( count( array_intersect_key( array_flip( $identifier ), $product ) ) >= 2 ) {
|
1045 |
// Any 2 required keys exist!
|
1046 |
// @TODO Refactor with OR
|
1047 |
+
if ( array_key_exists( 'brand', $product ) && ! empty( $product['brand'] ) ) {
|
1048 |
+
$countIdentifier ++;
|
1049 |
}
|
1050 |
+
if ( array_key_exists( 'upc', $product ) && ! empty( $product['upc'] ) ) {
|
1051 |
+
$countIdentifier ++;
|
1052 |
}
|
1053 |
+
if ( array_key_exists( 'sku', $product ) && ! empty( $product['sku'] ) ) {
|
1054 |
+
$countIdentifier ++;
|
1055 |
}
|
1056 |
+
if ( array_key_exists( 'mpn', $product ) && ! empty( $product['mpn'] ) ) {
|
1057 |
+
$countIdentifier ++;
|
1058 |
}
|
1059 |
+
if ( array_key_exists( 'gtin', $product ) && ! empty( $product['gtin'] ) ) {
|
1060 |
+
$countIdentifier ++;
|
1061 |
}
|
1062 |
}
|
1063 |
|
1068 |
$this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
|
1069 |
}
|
1070 |
} else {
|
1071 |
+
$identifier_exists='identifier exists';
|
1072 |
+
if(in_array( $this->config['provider'], array( 'bing','pinterest') )){
|
1073 |
+
$identifier_exists='identifier_exists';
|
1074 |
+
}
|
1075 |
+
|
1076 |
if ( $countIdentifier >= 2 ) {
|
1077 |
+
$this->products[ $this->pi ][$identifier_exists] = 'yes';
|
1078 |
} else {
|
1079 |
+
$this->products[ $this->pi ][$identifier_exists] = 'no';
|
1080 |
}
|
1081 |
}
|
1082 |
}
|
1083 |
}
|
1084 |
}
|
1085 |
|
1086 |
+
private function process_for_merchant_get_value($productObj,$key){
|
1087 |
+
$prefix = $this->config['prefix'][ $key ];
|
1088 |
+
$suffix = $this->config['suffix'][ $key ];
|
1089 |
+
$attribute = $this->config['attributes'][ $key ];
|
1090 |
+
$merchant_attribute = $this->config['mattributes'][ $key ];
|
1091 |
+
|
1092 |
+
if ( 'pattern' == $this->config['type'][ $key ] ) {// Get Pattern value.
|
1093 |
+
$output = $this->config['default'][ $key ];
|
1094 |
+
$output=$this->apply_filters_to_attribute_value($output,$productObj,$attribute,$merchant_attribute);
|
1095 |
+
} else {
|
1096 |
+
$output = $this->getAttributeValueByType( $productObj, $attribute, $merchant_attribute );
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
$output=$this->format_output($output,$this->config['output_type'],$productObj,$attribute,$merchant_attribute);
|
1100 |
+
|
1101 |
+
$output=$this->process_prefix_suffix( $output, $prefix, $suffix, $attribute = '' );
|
1102 |
+
|
1103 |
+
return $output;
|
1104 |
+
}
|
1105 |
+
|
1106 |
/**
|
1107 |
* Get Query Type Settings
|
1108 |
* @return string
|
includes/feeds/class-woo-feed-custom.php
CHANGED
@@ -54,58 +54,6 @@ class Woo_Feed_Custom {
|
|
54 |
}
|
55 |
$this->products->get_products($feedRule['productIds']);
|
56 |
$this->rules = $feedRule;
|
57 |
-
|
58 |
-
// $products = new Woo_Feed_Products();
|
59 |
-
// $limit =isset($feedRule['Limit'])?esc_html($feedRule['Limit']):'';
|
60 |
-
// $offset = isset($feedRule['Offset'])?esc_html($feedRule['Offset']):'';
|
61 |
-
// $categories = isset($feedRule['categories']) ? $feedRule['categories']: '';
|
62 |
-
// $storeProducts = $products->woo_feed_get_visible_product($limit, $offset,$categories,$feedRule);
|
63 |
-
// $feedRule=$products->feedRule;
|
64 |
-
// $engine = new WF_Engine($storeProducts,$feedRule);
|
65 |
-
// $this->products = $engine->mapProductsByRules();
|
66 |
-
// $this->rules = $feedRule;
|
67 |
-
// if ($feedRule['feedType'] == 'xml') {
|
68 |
-
// $this->mapAttributeForXML();
|
69 |
-
// }
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Prepare Feed For XML Output
|
74 |
-
*
|
75 |
-
*/
|
76 |
-
public function mapAttributeForXML() {
|
77 |
-
if ( $this->products ) {
|
78 |
-
foreach ( $this->products as $no => $product ) {
|
79 |
-
foreach ( $product as $key => $value ) {
|
80 |
-
$this->products[ $no ][ $key ] = $this->formatXMLLine($key, $value);
|
81 |
-
}
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Format and Make the XML node for the Feed
|
88 |
-
*
|
89 |
-
* @param $attribute
|
90 |
-
* @param $value
|
91 |
-
* @param string $space
|
92 |
-
* @return string
|
93 |
-
*/
|
94 |
-
function formatXMLLine( $attribute, $value, $space = '' ) {
|
95 |
-
$attribute = str_replace( ' ', '_', $attribute );
|
96 |
-
// Make child node for XML
|
97 |
-
if ( ! empty( $value ) )
|
98 |
-
$value = trim( $value );
|
99 |
-
if ( false === strpos($value, '<![CDATA[' ) && 'http' == substr(trim($value), 0, 4) ) {
|
100 |
-
$value = "<![CDATA[$value]]>";
|
101 |
-
} elseif ( false === strpos( $value, '<![CDATA[' ) && ! is_numeric( trim( $value ) ) && ! empty( $value ) ) {
|
102 |
-
$value = "<![CDATA[$value]]>";
|
103 |
-
}
|
104 |
-
if ( 'myshopping.com.au' == $this->rules['provider'] && 'Category' == $attribute ) {
|
105 |
-
return "$space<$attribute xml:space=\"preserve\">$value</$attribute>";
|
106 |
-
}
|
107 |
-
return "
|
108 |
-
$space<$attribute>$value</$attribute>";
|
109 |
}
|
110 |
|
111 |
/**
|
@@ -147,119 +95,4 @@ class Woo_Feed_Custom {
|
|
147 |
);
|
148 |
return $feed;
|
149 |
}
|
150 |
-
|
151 |
-
public function get_header( $engine ) {
|
152 |
-
$datetime_now = date('Y-m-d H:i:s', strtotime( current_time( 'mysql' ) ) );
|
153 |
-
if ( 'fruugo.au' == $this->rules['provider'] ) {
|
154 |
-
$fruugo_au = "<products version=\"1.0\" standalone=\"yes\">
|
155 |
-
<datetime>$datetime_now</datetime>
|
156 |
-
<title>" . get_bloginfo('name') . '</title>
|
157 |
-
<link>' . get_bloginfo('url') . '</link>
|
158 |
-
<description>' . get_bloginfo('description') . '</description>';
|
159 |
-
return $fruugo_au;
|
160 |
-
} elseif ( 'zap.co.il' == $this->rules['provider'] ) {
|
161 |
-
$zap = "<STORE>
|
162 |
-
<datetime>$datetime_now</datetime>
|
163 |
-
<title>" . get_bloginfo('name') . '</title>
|
164 |
-
<link>' . get_bloginfo('url') . '</link>
|
165 |
-
<description>' . get_bloginfo('description') . '</description>
|
166 |
-
<agency>' . get_bloginfo('name') . '</agency>
|
167 |
-
<email>' . get_bloginfo('admin_email') . '</email>';
|
168 |
-
return $zap;
|
169 |
-
} elseif ( 'myshopping.com.au' == $this->rules['provider'] ) {
|
170 |
-
return '<productset>';
|
171 |
-
} elseif ( 'stylight.com' == $this->rules['provider'] ) {
|
172 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
173 |
-
<datetime>$datetime_now</datetime>
|
174 |
-
<title>" . get_bloginfo('name') . '</title>
|
175 |
-
<link>' . get_bloginfo('url') . '</link>
|
176 |
-
<description>' . get_bloginfo('description') . '</description>';
|
177 |
-
} elseif ( 'nextad' == $this->rules['provider'] ) {
|
178 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
179 |
-
<datetime>$datetime_now</datetime>
|
180 |
-
<title>" . get_bloginfo('name') . '</title>
|
181 |
-
<link>' . get_bloginfo('url') . '</link>
|
182 |
-
<description>' . get_bloginfo('description') . '</description>';
|
183 |
-
} elseif ( 'skinflint.co.uk' == $this->rules['provider'] ) {
|
184 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
185 |
-
<datetime>$datetime_now</datetime>
|
186 |
-
<title>" . get_bloginfo('name') . '</title>
|
187 |
-
<link>' . get_bloginfo('url') . '</link>
|
188 |
-
<description>' . get_bloginfo('description') . '</description>';
|
189 |
-
} elseif ( 'comparer.be' == $this->rules['provider'] ) {
|
190 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
191 |
-
<datetime>$datetime_now</datetime>
|
192 |
-
<title>" . get_bloginfo('name') . '</title>
|
193 |
-
<link>' . get_bloginfo('url') . '</link>
|
194 |
-
<description>' . get_bloginfo('description') . '</description>';
|
195 |
-
} elseif ( 'dooyoo' == $this->rules['provider'] ) {
|
196 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
197 |
-
<datetime>$datetime_now</datetime>
|
198 |
-
<title>" . get_bloginfo('name') . '</title>
|
199 |
-
<link>' . get_bloginfo('url') . '</link>
|
200 |
-
<description>' . get_bloginfo('description') . '</description>';
|
201 |
-
} elseif ( 'hintaseuranta.fi' == $this->rules['provider'] ) {
|
202 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
203 |
-
<datetime>$datetime_now</datetime>
|
204 |
-
<title>" . get_bloginfo('name') . '</title>
|
205 |
-
<link>' . get_bloginfo('url') . '</link>
|
206 |
-
<description>' . get_bloginfo('description') . '</description>';
|
207 |
-
} elseif ( 'incurvy' == $this->rules['provider'] ) {
|
208 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
209 |
-
<datetime>$datetime_now</datetime>
|
210 |
-
<title>" . get_bloginfo('name') . '</title>
|
211 |
-
<link>' . get_bloginfo('url') . '</link>
|
212 |
-
<description>' . get_bloginfo('description') . '</description>';
|
213 |
-
} elseif ( 'kijiji.ca' == $this->rules['provider'] ) {
|
214 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
215 |
-
<datetime>$datetime_now</datetime>
|
216 |
-
<title>" . get_bloginfo('name') . '</title>
|
217 |
-
<link>' . get_bloginfo('url') . '</link>
|
218 |
-
<description>' . get_bloginfo('description') . '</description>';
|
219 |
-
} elseif ( 'marktplaats.nl' == $this->rules['provider'] ) {
|
220 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
221 |
-
<datetime>$datetime_now</datetime>
|
222 |
-
<title>" . get_bloginfo('name') . '</title>
|
223 |
-
<link>' . get_bloginfo('url') . '</link>
|
224 |
-
<description>' . get_bloginfo('description') . '</description>';
|
225 |
-
} elseif ( 'rakuten.de' == $this->rules['provider'] ) {
|
226 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
227 |
-
<datetime>$datetime_now</datetime>
|
228 |
-
<title>" . get_bloginfo('name') . '</title>
|
229 |
-
<link>' . get_bloginfo('url') . '</link>
|
230 |
-
<description>' . get_bloginfo('description') . '</description>';
|
231 |
-
} elseif ( 'shopalike.fr' == $this->rules['provider'] ) {
|
232 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
233 |
-
<datetime>$datetime_now</datetime>
|
234 |
-
<title>" . get_bloginfo('name') . '</title>
|
235 |
-
<link>' . get_bloginfo('url') . '</link>
|
236 |
-
<description>' . get_bloginfo('description') . '</description>';
|
237 |
-
} elseif ( 'spartoo.fi' == $this->rules['provider'] ) {
|
238 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
239 |
-
<datetime>$datetime_now</datetime>
|
240 |
-
<title>" . get_bloginfo('name') . '</title>
|
241 |
-
<link>' . get_bloginfo('url') . '</link>
|
242 |
-
<description>' . get_bloginfo('description') . '</description>';
|
243 |
-
} elseif ( 'webmarchand' == $this->rules['provider'] ) {
|
244 |
-
return "<products version=\"1.0\" standalone=\"yes\">
|
245 |
-
<datetime>$datetime_now</datetime>
|
246 |
-
<title>" . get_bloginfo('name') . '</title>
|
247 |
-
<link>' . get_bloginfo('url') . '</link>
|
248 |
-
<description>' . get_bloginfo('description') . '</description>';
|
249 |
-
} else {
|
250 |
-
return $engine->get_xml_feed_header();
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
public function get_footer( $engine ) {
|
255 |
-
if ( in_array($this->rules['provider'], [ 'fruugo.au', 'stylight.com', 'nextad', 'skinflint.co.uk', 'comparer.be', 'dooyoo', 'hintaseuranta.fi', 'incurvy', 'kijiji.ca', 'marktplaats.nl', 'rakuten.de', 'shopalike.fr', 'spartoo.fi', 'webmarchand' ]) ) {
|
256 |
-
return '</products>';
|
257 |
-
} elseif ( 'zap.co.il' == $this->rules['provider'] ) {
|
258 |
-
return '</STORE>';
|
259 |
-
} elseif ( 'myshopping.com.au' == $this->rules['provider'] ) {
|
260 |
-
return '</productset>';
|
261 |
-
} else {
|
262 |
-
return $engine->get_xml_feed_footer();
|
263 |
-
}
|
264 |
-
}
|
265 |
}
|
54 |
}
|
55 |
$this->products->get_products($feedRule['productIds']);
|
56 |
$this->rules = $feedRule;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
/**
|
95 |
);
|
96 |
return $feed;
|
97 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
includes/feeds/class-woo-feed-facebook.php
CHANGED
@@ -105,9 +105,9 @@ class Woo_Feed_Facebook {
|
|
105 |
if ( 'xml' == $this->rules['feedType'] ) {
|
106 |
// return $this->get_feed($this->products);
|
107 |
$feed = array(
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
);
|
112 |
|
113 |
return $feed;
|
@@ -140,401 +140,4 @@ class Woo_Feed_Facebook {
|
|
140 |
|
141 |
return $feed;
|
142 |
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Configure merchant attributes for XML feed
|
146 |
-
*/
|
147 |
-
public function mapAttributeForXML() {
|
148 |
-
|
149 |
-
$googleXMLAttribute = array(
|
150 |
-
'id' => array( 'g:id', false ),
|
151 |
-
'title' => array( 'g:title', true ),
|
152 |
-
'description' => array( 'g:description', true ),
|
153 |
-
'link' => array( 'g:link', true ),
|
154 |
-
'mobile_link' => array( 'g:mobile_link', true ),
|
155 |
-
'product_type' => array( 'g:product_type', true ),
|
156 |
-
'current_category' => array( 'g:google_product_category', true ),
|
157 |
-
'image' => array( 'g:image_link', true ),
|
158 |
-
'images' => array( 'g:additional_image_link', false ),
|
159 |
-
'images_1' => array( 'g:additional_image_link_1', true ),
|
160 |
-
'images_2' => array( 'g:additional_image_link_2', true ),
|
161 |
-
'images_3' => array( 'g:additional_image_link_3', true ),
|
162 |
-
'images_4' => array( 'g:additional_image_link_4', true ),
|
163 |
-
'images_5' => array( 'g:additional_image_link_5', true ),
|
164 |
-
'images_6' => array( 'g:additional_image_link_6', true ),
|
165 |
-
'images_7' => array( 'g:additional_image_link_7', true ),
|
166 |
-
'images_8' => array( 'g:additional_image_link_8', true ),
|
167 |
-
'images_9' => array( 'g:additional_image_link_9', true ),
|
168 |
-
'images_10' => array( 'g:additional_image_link_10', true ),
|
169 |
-
'condition' => array( 'g:condition', false ),
|
170 |
-
'availability' => array( 'g:availability', false ),
|
171 |
-
'inventory' => array( 'g:inventory', false ),
|
172 |
-
'override' => array( 'g:override', false ),
|
173 |
-
'price' => array( 'g:price', true ),
|
174 |
-
'sale_price' => array( 'g:sale_price', true ),
|
175 |
-
'sale_price_effective_date' => array( 'g:sale_price_effective_date', true ),
|
176 |
-
'brand' => array( 'g:brand', true ),
|
177 |
-
'sku' => array( 'g:mpn', true ),
|
178 |
-
'upc' => array( 'g:gtin', true ),
|
179 |
-
'identifier_exists' => array( 'g:identifier_exists', true ),
|
180 |
-
'item_group_id' => array( 'g:item_group_id', false ),
|
181 |
-
'color' => array( 'g:color', true ),
|
182 |
-
'gender' => array( 'g:gender', true ),
|
183 |
-
'age_group' => array( 'g:age_group', true ),
|
184 |
-
'material' => array( 'g:material', true ),
|
185 |
-
'pattern' => array( 'g:pattern', true ),
|
186 |
-
'size' => array( 'g:size', true ),
|
187 |
-
'size_type' => array( 'g:size_type', true ),
|
188 |
-
'size_system' => array( 'g:size_system', true ),
|
189 |
-
'tax' => array( 'tax', true ),
|
190 |
-
'weight' => array( 'g:shipping_weight', false ),
|
191 |
-
'length' => array( 'g:shipping_length', false ),
|
192 |
-
'width' => array( 'g:shipping_width', false ),
|
193 |
-
'height' => array( 'g:shipping_height', false ),
|
194 |
-
'shipping_label' => array( 'g:shipping_label', false ),
|
195 |
-
'shipping_country' => array( 'g:shipping_country', false ),
|
196 |
-
'shipping_service' => array( 'g:shipping_service', false ),
|
197 |
-
'shipping_price' => array( 'g:shipping_price', false ),
|
198 |
-
'shipping_region' => array( 'g:shipping_region', false ),
|
199 |
-
'multipack' => array( 'g:multipack', true ),
|
200 |
-
'is_bundle' => array( 'g:is_bundle', true ),
|
201 |
-
'adult' => array( 'g:adult', true ),
|
202 |
-
'adwords_redirect' => array( 'g:adwords_redirect', true ),
|
203 |
-
'custom_label_0' => array( 'g:custom_label_0', true ),
|
204 |
-
'custom_label_1' => array( 'g:custom_label_1', true ),
|
205 |
-
'custom_label_2' => array( 'g:custom_label_2', true ),
|
206 |
-
'custom_label_3' => array( 'g:custom_label_3', true ),
|
207 |
-
'custom_label_4' => array( 'g:custom_label_4', true ),
|
208 |
-
'excluded_destination' => array( 'g:excluded_destination', true ),
|
209 |
-
'expiration_date' => array( 'g:expiration_date', true ),
|
210 |
-
'unit_pricing_measure' => array( 'g:unit_pricing_measure', true ),
|
211 |
-
'unit_pricing_base_measure' => array( 'g:unit_pricing_base_measure', true ),
|
212 |
-
'energy_efficiency_class' => array( 'g:energy_efficiency_class', true ),
|
213 |
-
'loyalty_points' => array( 'g:loyalty_points', true ),
|
214 |
-
'installment' => array( 'g:installment', true ),
|
215 |
-
'promotion_id' => array( 'g:promotion_id', true ),
|
216 |
-
'cost_of_goods_sold' => array( 'g:cost_of_goods_sold', true ),
|
217 |
-
'availability_date' => array( 'g:availability_date', true ),
|
218 |
-
'tax_category' => array( 'g:tax_category', true ),
|
219 |
-
'included_destination' => array( 'g:included_destination', true ),
|
220 |
-
);
|
221 |
-
|
222 |
-
if ( ! empty( $this->products ) ) {
|
223 |
-
foreach ( $this->products as $no => $product ) {
|
224 |
-
foreach ( $product as $key => $value ) {
|
225 |
-
$this->mapAttribute( $no,
|
226 |
-
$key,
|
227 |
-
$googleXMLAttribute[ $key ][0],
|
228 |
-
$value,
|
229 |
-
$googleXMLAttribute[ $key ][0] );
|
230 |
-
}
|
231 |
-
$this->process_google_shipping_attribute_for_xml( $no );
|
232 |
-
}
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Configure merchant attributes for XML feed
|
238 |
-
*/
|
239 |
-
public function mapAttributeForCSVTXT() {
|
240 |
-
// Basic product information
|
241 |
-
$googleCSVTXTAttribute = array(
|
242 |
-
'id' => array( 'id', false ),
|
243 |
-
'title' => array( 'title', true ),
|
244 |
-
'description' => array( 'description', true ),
|
245 |
-
'link' => array( 'link', true ),
|
246 |
-
'mobile_link' => array( 'mobile_link', true ),
|
247 |
-
'product_type' => array( 'product type', true ),
|
248 |
-
'current_category' => array( 'google product category', true ),
|
249 |
-
'image' => array( 'image link', true ),
|
250 |
-
'images' => array( 'additional image link', true ),
|
251 |
-
'images_1' => array( 'additional image link 1', true ),
|
252 |
-
'images_2' => array( 'additional image link 2', true ),
|
253 |
-
'images_3' => array( 'additional image link 3', true ),
|
254 |
-
'images_4' => array( 'additional image link 4', true ),
|
255 |
-
'images_5' => array( 'additional image link 5', true ),
|
256 |
-
'images_6' => array( 'additional image link 6', true ),
|
257 |
-
'images_7' => array( 'additional image link 7', true ),
|
258 |
-
'images_8' => array( 'additional image link 8', true ),
|
259 |
-
'images_9' => array( 'additional image link 9', true ),
|
260 |
-
'images_10' => array( 'additional image link 10', true ),
|
261 |
-
'condition' => array( 'condition', false ),
|
262 |
-
'availability' => array( 'availability', false ),
|
263 |
-
'inventory' => array( 'inventory', false ),
|
264 |
-
'override' => array( 'override', false ),
|
265 |
-
'price' => array( 'price', true ),
|
266 |
-
'sale_price' => array( 'sale price', true ),
|
267 |
-
'sale_price_effective_date' => array( 'sale price effective date', true ),
|
268 |
-
'brand' => array( 'brand', true ),
|
269 |
-
'sku' => array( 'mpn', true ),
|
270 |
-
'upc' => array( 'gtin', true ),
|
271 |
-
'identifier_exists' => array( 'identifier exists', true ),
|
272 |
-
'item_group_id' => array( 'item group id', false ),
|
273 |
-
'color' => array( 'color', true ),
|
274 |
-
'gender' => array( 'gender', true ),
|
275 |
-
'age_group' => array( 'age group', true ),
|
276 |
-
'material' => array( 'material', true ),
|
277 |
-
'pattern' => array( 'pattern', true ),
|
278 |
-
'size' => array( 'size', true ),
|
279 |
-
'size_type' => array( 'size type', true ),
|
280 |
-
'size_system' => array( 'size system', true ),
|
281 |
-
'tax' => array( 'tax', true ),
|
282 |
-
'weight' => array( 'shipping weight', false ),
|
283 |
-
'length' => array( 'shipping length', false ),
|
284 |
-
'width' => array( 'shipping width', false ),
|
285 |
-
'height' => array( 'shipping height', false ),
|
286 |
-
'shipping_label' => array( 'shipping label', false ),
|
287 |
-
'shipping_country' => array( 'shipping country', false ),
|
288 |
-
'shipping_service' => array( 'shipping service', false ),
|
289 |
-
'shipping_price' => array( 'shipping price', false ),
|
290 |
-
'shipping_region' => array( 'shipping region', false ),
|
291 |
-
'multipack' => array( 'multipack', true ),
|
292 |
-
'is_bundle' => array( 'is bundle', true ),
|
293 |
-
'adult' => array( 'adult', true ),
|
294 |
-
'adwords_redirect' => array( 'adwords redirect', true ),
|
295 |
-
'custom_label_0' => array( 'custom label 0', true ),
|
296 |
-
'custom_label_1' => array( 'custom label 1', true ),
|
297 |
-
'custom_label_2' => array( 'custom label 2', true ),
|
298 |
-
'custom_label_3' => array( 'custom label 3', true ),
|
299 |
-
'custom_label_4' => array( 'custom label 4', true ),
|
300 |
-
'excluded_destination' => array( 'excluded destination', true ),
|
301 |
-
'expiration_date' => array( 'expiration date', true ),
|
302 |
-
'unit_pricing_measure' => array( 'unit pricing measure', true ),
|
303 |
-
'unit_pricing_base_measure' => array( 'unit pricing base measure', true ),
|
304 |
-
'energy_efficiency_class' => array( 'energy efficiency class', true ),
|
305 |
-
'loyalty_points' => array( 'loyalty points', true ),
|
306 |
-
'installment' => array( 'installment', true ),
|
307 |
-
'promotion_id' => array( 'promotion id', true ),
|
308 |
-
'cost_of_goods_sold' => array( 'cost of goods sold', true ),
|
309 |
-
'availability_date' => array( 'availability date', true ),
|
310 |
-
'tax_category' => array( 'tax category', true ),
|
311 |
-
'included_destination' => array( 'included destination', true ),
|
312 |
-
);
|
313 |
-
|
314 |
-
if ( ! empty( $this->products ) ) {
|
315 |
-
foreach ( $this->products as $no => $product ) {
|
316 |
-
foreach ( $product as $key => $value ) {
|
317 |
-
$this->mapAttribute( $no,
|
318 |
-
$key,
|
319 |
-
str_replace( ' ', '_', $googleCSVTXTAttribute[ $key ][0] ),
|
320 |
-
$value,
|
321 |
-
$googleCSVTXTAttribute[ $key ][0] );
|
322 |
-
}
|
323 |
-
$this->process_google_shipping_attribute_for_CSVTXT( $no );
|
324 |
-
}
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
/**
|
329 |
-
* Map to google attribute
|
330 |
-
*
|
331 |
-
* @param string|int $no
|
332 |
-
* @param string|int $from
|
333 |
-
* @param string|int $to
|
334 |
-
* @param mixed $value
|
335 |
-
* @param bool $cdata
|
336 |
-
*
|
337 |
-
* @return array|string
|
338 |
-
*/
|
339 |
-
public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
|
340 |
-
unset( $this->products[ $no ][ $from ] );
|
341 |
-
if ( 'xml' == $this->rules['feedType'] ) {
|
342 |
-
return $this->products[ $no ][ $to ] = $this->formatXMLLine( $to, $value, $cdata );
|
343 |
-
} else {
|
344 |
-
return $this->products[ $no ][ $to ] = $value;
|
345 |
-
}
|
346 |
-
}
|
347 |
-
|
348 |
-
|
349 |
-
public function process_google_shipping_attribute_for_xml(
|
350 |
-
$no
|
351 |
-
) {
|
352 |
-
$shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
|
353 |
-
$shippingAttr = array();
|
354 |
-
$products = $this->products[ $no ];
|
355 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
356 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
357 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
358 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
359 |
-
}
|
360 |
-
}
|
361 |
-
if ( count( $shippingAttr ) ) {
|
362 |
-
$str = '';
|
363 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
364 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
365 |
-
$str .= str_replace( 'shipping_', '', $valueAttr );
|
366 |
-
}
|
367 |
-
}
|
368 |
-
|
369 |
-
return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine( 'g:shipping', $str, false );
|
370 |
-
}
|
371 |
-
|
372 |
-
return false;
|
373 |
-
}
|
374 |
-
|
375 |
-
public function process_google_shipping_attribute_for_CSVTXT(
|
376 |
-
$no
|
377 |
-
) {
|
378 |
-
$shipping = array( 'shipping_country', 'shipping_service', 'shipping_price', 'shipping_region' );
|
379 |
-
$shippingAttr = array();
|
380 |
-
$products = $this->products[ $no ];
|
381 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
382 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
383 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
384 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
385 |
-
}
|
386 |
-
}
|
387 |
-
if ( count( $shippingAttr ) ) {
|
388 |
-
$str = '';
|
389 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
390 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
391 |
-
$country = ( 'shipping_country' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
392 |
-
$country = ( 'shipping_region' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
393 |
-
$service = ( 'shipping_service' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
394 |
-
$price = ( 'shipping_price' == $keyAttr ) ? $str .= $valueAttr : '';
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace( ' : ', ':', $str );
|
399 |
-
}
|
400 |
-
|
401 |
-
return false;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Make xml node
|
406 |
-
*
|
407 |
-
* @param string $attribute Attribute Name
|
408 |
-
* @param string $value Attribute Value
|
409 |
-
* @param bool $cdata
|
410 |
-
* @param string $space
|
411 |
-
*
|
412 |
-
* @return string
|
413 |
-
*/
|
414 |
-
function formatXMLLine( $attribute, $value, $cdata, $space = '' ) {
|
415 |
-
// Make single XML node
|
416 |
-
if ( ! empty( $value ) ) {
|
417 |
-
$value = trim( $value );
|
418 |
-
}
|
419 |
-
if ( gettype( $value ) == 'array' ) {
|
420 |
-
$value = wp_json_encode( $value );
|
421 |
-
}
|
422 |
-
if ( false === strpos( $value, '<![CDATA[' ) && 'http' === substr( trim( $value ), 0, 4 ) ) {
|
423 |
-
$value = "<![CDATA[$value]]>";
|
424 |
-
} elseif ( false === strpos( $value, '<![CDATA[' ) && true === $cdata && ! empty( $value ) ) {
|
425 |
-
$value = "<![CDATA[$value]]>";
|
426 |
-
} elseif ( $cdata ) {
|
427 |
-
if ( ! empty( $value ) ) {
|
428 |
-
$value = "<![CDATA[$value]]>";
|
429 |
-
}
|
430 |
-
}
|
431 |
-
|
432 |
-
if ( 'g:additional_image_link' == substr( $attribute, 0, 23 ) ) {
|
433 |
-
$attribute = 'g:additional_image_link';
|
434 |
-
}
|
435 |
-
|
436 |
-
return "$space<$attribute>$value</$attribute>";
|
437 |
-
}
|
438 |
-
|
439 |
-
|
440 |
-
/**
|
441 |
-
* Make XML Feed Header
|
442 |
-
* @return string
|
443 |
-
*/
|
444 |
-
public function get_xml_feed_header() {
|
445 |
-
$output = '<?xml version="1.0" encoding="UTF-8" ?>
|
446 |
-
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
|
447 |
-
<channel>
|
448 |
-
<title><![CDATA[' . html_entity_decode( get_option( 'blogname' ) ) . ']]></title>
|
449 |
-
<link><![CDATA[' . site_url() . ']]></link>
|
450 |
-
<description><![CDATA[' . html_entity_decode( get_option( 'blogdescription' ) ) . ']]></description>';
|
451 |
-
|
452 |
-
return $output;
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Make XML Feed
|
457 |
-
* @param array $items items.
|
458 |
-
* @return string
|
459 |
-
*/
|
460 |
-
public function get_xml_feed_body( $items ) {
|
461 |
-
$feed = '';
|
462 |
-
// $feed .= $this->get_feed_header();
|
463 |
-
$feed .= "\n";
|
464 |
-
if ( $items ) {
|
465 |
-
foreach ( $items as $item => $products ) {
|
466 |
-
$feed .= ' <' . $this->feedWrapper . '>';
|
467 |
-
foreach ( $products as $key => $value ) {
|
468 |
-
if ( ! empty( $value ) ) {
|
469 |
-
$feed .= $value;
|
470 |
-
}
|
471 |
-
}
|
472 |
-
$feed .= "\n </" . $this->feedWrapper . ">\n";
|
473 |
-
}
|
474 |
-
|
475 |
-
// $feed .= $this->get_feed_footer();
|
476 |
-
|
477 |
-
return $feed;
|
478 |
-
}
|
479 |
-
|
480 |
-
return false;
|
481 |
-
}
|
482 |
-
|
483 |
-
/**
|
484 |
-
* Make XML Feed Footer
|
485 |
-
* @return string
|
486 |
-
*/
|
487 |
-
public function get_xml_feed_footer() {
|
488 |
-
$footer = ' </channel>
|
489 |
-
</rss>';
|
490 |
-
|
491 |
-
return $footer;
|
492 |
-
}
|
493 |
-
|
494 |
-
/**
|
495 |
-
* Short Products
|
496 |
-
* @return array
|
497 |
-
*/
|
498 |
-
public function short_products() {
|
499 |
-
if ( $this->products ) {
|
500 |
-
update_option( 'wpf_progress', esc_html__('Shorting Products', 'woo-feed' ), false );
|
501 |
-
sleep( 1 );
|
502 |
-
$array = array();
|
503 |
-
$ij = 0;
|
504 |
-
foreach ( $this->products as $key => $item ) {
|
505 |
-
$array[ $ij ] = $item;
|
506 |
-
unset( $this->products[ $key ] );
|
507 |
-
$ij ++;
|
508 |
-
}
|
509 |
-
|
510 |
-
return $this->products = $array;
|
511 |
-
}
|
512 |
-
|
513 |
-
return $this->products;
|
514 |
-
}
|
515 |
-
|
516 |
-
/**
|
517 |
-
* Responsible to make CSV feed
|
518 |
-
* @return string
|
519 |
-
*/
|
520 |
-
public function get_csv_feed() {
|
521 |
-
if ( $this->products ) {
|
522 |
-
$headers = array_keys( $this->products[0] );
|
523 |
-
$feed[] = $headers;
|
524 |
-
foreach ( $this->products as $no => $product ) {
|
525 |
-
$row = array();
|
526 |
-
foreach ( $headers as $key => $header ) {
|
527 |
-
if ( strpos( $header, 'additional image link' ) !== false ) {
|
528 |
-
$header = 'additional image link';
|
529 |
-
}
|
530 |
-
$row[] = isset( $product[ $header ] ) ? $product[ $header ] : '';
|
531 |
-
}
|
532 |
-
$feed[] = $row;
|
533 |
-
}
|
534 |
-
|
535 |
-
return $feed;
|
536 |
-
}
|
537 |
-
|
538 |
-
return false;
|
539 |
-
}
|
540 |
}
|
105 |
if ( 'xml' == $this->rules['feedType'] ) {
|
106 |
// return $this->get_feed($this->products);
|
107 |
$feed = array(
|
108 |
+
'body' => $this->products->feedBody,
|
109 |
+
'header' => $this->products->feedHeader,
|
110 |
+
'footer' => $this->products->feedFooter,
|
111 |
);
|
112 |
|
113 |
return $feed;
|
140 |
|
141 |
return $feed;
|
142 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
}
|
includes/feeds/class-woo-feed-google.php
CHANGED
@@ -104,8 +104,8 @@ class Woo_Feed_Google {
|
|
104 |
if ( 'xml' == $this->rules['feedType'] ) {
|
105 |
$feed = array(
|
106 |
'body' => $this->products->feedBody,
|
107 |
-
'header' => $this->
|
108 |
-
'footer' => $this->
|
109 |
);
|
110 |
|
111 |
return $feed;
|
@@ -135,490 +135,6 @@ class Woo_Feed_Google {
|
|
135 |
return $feed;
|
136 |
}
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
*/
|
141 |
-
public function mapAttributeForXML() {
|
142 |
-
|
143 |
-
$googleXMLAttribute = array(
|
144 |
-
'id' => array( 'g:id', false ),
|
145 |
-
'title' => array( 'title', true ),
|
146 |
-
'description' => array( 'description', true ),
|
147 |
-
'link' => array( 'link', true ),
|
148 |
-
'mobile_link' => array( 'mobile_link', true ),
|
149 |
-
'product_type' => array( 'g:product_type', true ),
|
150 |
-
'current_category' => array( 'g:google_product_category', true ),
|
151 |
-
'image' => array( 'g:image_link', true ),
|
152 |
-
'images' => array( 'g:additional_image_link', false ),
|
153 |
-
'images_1' => array( 'g:additional_image_link_1', true ),
|
154 |
-
'images_2' => array( 'g:additional_image_link_2', true ),
|
155 |
-
'images_3' => array( 'g:additional_image_link_3', true ),
|
156 |
-
'images_4' => array( 'g:additional_image_link_4', true ),
|
157 |
-
'images_5' => array( 'g:additional_image_link_5', true ),
|
158 |
-
'images_6' => array( 'g:additional_image_link_6', true ),
|
159 |
-
'images_7' => array( 'g:additional_image_link_7', true ),
|
160 |
-
'images_8' => array( 'g:additional_image_link_8', true ),
|
161 |
-
'images_9' => array( 'g:additional_image_link_9', true ),
|
162 |
-
'images_10' => array( 'g:additional_image_link_10', true ),
|
163 |
-
'condition' => array( 'g:condition', false ),
|
164 |
-
'availability' => array( 'g:availability', false ),
|
165 |
-
'availability_date' => array( 'g:availability_date', false ),
|
166 |
-
'inventory' => array( 'g:inventory', false ),
|
167 |
-
'price' => array( 'g:price', true ),
|
168 |
-
'sale_price' => array( 'g:sale_price', true ),
|
169 |
-
'sale_price_effective_date' => array( 'g:sale_price_effective_date', true ),
|
170 |
-
'brand' => array( 'g:brand', true ),
|
171 |
-
'sku' => array( 'g:mpn', true ),
|
172 |
-
'upc' => array( 'g:gtin', true ),
|
173 |
-
'identifier_exists' => array( 'g:identifier_exists', true ),
|
174 |
-
'item_group_id' => array( 'g:item_group_id', false ),
|
175 |
-
'color' => array( 'g:color', true ),
|
176 |
-
'gender' => array( 'g:gender', true ),
|
177 |
-
'age_group' => array( 'g:age_group', true ),
|
178 |
-
'material' => array( 'g:material', true ),
|
179 |
-
'pattern' => array( 'g:pattern', true ),
|
180 |
-
'size' => array( 'g:size', true ),
|
181 |
-
'size_type' => array( 'g:size_type', true ),
|
182 |
-
'size_system' => array( 'g:size_system', true ),
|
183 |
-
'tax' => array( 'tax', true ),
|
184 |
-
'tax_country' => array( 'g:tax_country', true ),
|
185 |
-
'tax_region' => array( 'g:tax_region', true ),
|
186 |
-
'tax_rate' => array( 'g:tax_rate', true ),
|
187 |
-
'tax_ship' => array( 'g:tax_ship', true ),
|
188 |
-
'tax_category' => array( 'g:tax_category', true ),
|
189 |
-
'weight' => array( 'g:shipping_weight', false ),
|
190 |
-
'length' => array( 'g:shipping_length', false ),
|
191 |
-
'width' => array( 'g:shipping_width', false ),
|
192 |
-
'height' => array( 'g:shipping_height', false ),
|
193 |
-
'shipping_label' => array( 'g:shipping_label', false ),
|
194 |
-
'shipping_country' => array( 'g:shipping_country', false ),
|
195 |
-
'shipping_service' => array( 'g:shipping_service', false ),
|
196 |
-
'shipping_price' => array( 'g:shipping_price', false ),
|
197 |
-
'shipping_region' => array( 'g:shipping_region', false ),
|
198 |
-
'multipack' => array( 'g:multipack', true ),
|
199 |
-
'is_bundle' => array( 'g:is_bundle', true ),
|
200 |
-
'adult' => array( 'g:adult', true ),
|
201 |
-
'adwords_redirect' => array( 'g:adwords_redirect', true ),
|
202 |
-
'custom_label_0' => array( 'g:custom_label_0', true ),
|
203 |
-
'custom_label_1' => array( 'g:custom_label_1', true ),
|
204 |
-
'custom_label_2' => array( 'g:custom_label_2', true ),
|
205 |
-
'custom_label_3' => array( 'g:custom_label_3', true ),
|
206 |
-
'custom_label_4' => array( 'g:custom_label_4', true ),
|
207 |
-
'excluded_destination' => array( 'g:excluded_destination', true ),
|
208 |
-
'included_destination' => array( 'g:included_destination', true ),
|
209 |
-
'expiration_date' => array( 'g:expiration_date', true ),
|
210 |
-
'unit_pricing_measure' => array( 'g:unit_pricing_measure', true ),
|
211 |
-
'unit_pricing_base_measure' => array( 'g:unit_pricing_base_measure', true ),
|
212 |
-
'energy_efficiency_class' => array( 'g:energy_efficiency_class', true ),
|
213 |
-
'loyalty_points' => array( 'g:loyalty_points', true ),
|
214 |
-
'installment' => array( 'g:installment', true ),
|
215 |
-
'promotion_id' => array( 'g:promotion_id', true ),
|
216 |
-
'cost_of_goods_sold' => array( 'g:cost_of_goods_sold', true ),
|
217 |
-
);
|
218 |
-
|
219 |
-
if ( ! empty( $this->products ) ) {
|
220 |
-
foreach ( $this->products as $no => $product ) {
|
221 |
-
$this->identifier_status_add( $no );
|
222 |
-
foreach ( $product as $key => $value ) {
|
223 |
-
$this->mapAttribute( $no,
|
224 |
-
$key,
|
225 |
-
$googleXMLAttribute[ $key ][0],
|
226 |
-
$value,
|
227 |
-
$googleXMLAttribute[ $key ][0] );
|
228 |
-
}
|
229 |
-
|
230 |
-
$this->process_google_shipping_attribute_for_xml( $no );
|
231 |
-
$this->process_google_tax_attribute_for_xml( $no );
|
232 |
-
}
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Configure merchant attributes for XML feed
|
238 |
-
*/
|
239 |
-
public function mapAttributeForCSVTXT() {
|
240 |
-
// Basic product information
|
241 |
-
$googleCSVTXTAttribute = array(
|
242 |
-
'id' => array( 'id', false ),
|
243 |
-
'title' => array( 'title', true ),
|
244 |
-
'description' => array( 'description', true ),
|
245 |
-
'link' => array( 'link', true ),
|
246 |
-
'mobile_link' => array( 'mobile_link', true ),
|
247 |
-
'product_type' => array( 'product type', true ),
|
248 |
-
'current_category' => array( 'google product category', true ),
|
249 |
-
'image' => array( 'image link', true ),
|
250 |
-
'images' => array( 'additional image link', true ),
|
251 |
-
'images_1' => array( 'additional image link 1', true ),
|
252 |
-
'images_2' => array( 'additional image link 2', true ),
|
253 |
-
'images_3' => array( 'additional image link 3', true ),
|
254 |
-
'images_4' => array( 'additional image link 4', true ),
|
255 |
-
'images_5' => array( 'additional image link 5', true ),
|
256 |
-
'images_6' => array( 'additional image link 6', true ),
|
257 |
-
'images_7' => array( 'additional image link 7', true ),
|
258 |
-
'images_8' => array( 'additional image link 8', true ),
|
259 |
-
'images_9' => array( 'additional image link 9', true ),
|
260 |
-
'images_10' => array( 'additional image link 10', true ),
|
261 |
-
'condition' => array( 'condition', false ),
|
262 |
-
'availability' => array( 'availability', false ),
|
263 |
-
'availability_date' => array( 'availability date', false ),
|
264 |
-
'inventory' => array( 'inventory', false ),
|
265 |
-
'price' => array( 'price', true ),
|
266 |
-
'sale_price' => array( 'sale price', true ),
|
267 |
-
'sale_price_effective_date' => array( 'sale price effective date', true ),
|
268 |
-
'brand' => array( 'brand', true ),
|
269 |
-
'sku' => array( 'mpn', true ),
|
270 |
-
'upc' => array( 'gtin', true ),
|
271 |
-
'identifier_exists' => array( 'identifier exists', true ),
|
272 |
-
'item_group_id' => array( 'item group id', false ),
|
273 |
-
'color' => array( 'color', true ),
|
274 |
-
'gender' => array( 'gender', true ),
|
275 |
-
'age_group' => array( 'age group', true ),
|
276 |
-
'material' => array( 'material', true ),
|
277 |
-
'pattern' => array( 'pattern', true ),
|
278 |
-
'size' => array( 'size', true ),
|
279 |
-
'size_type' => array( 'size type', true ),
|
280 |
-
'size_system' => array( 'size system', true ),
|
281 |
-
'tax' => array( 'tax', true ),
|
282 |
-
'tax_country' => array( 'tax country', true ),
|
283 |
-
'tax_region' => array( 'tax region', true ),
|
284 |
-
'tax_rate' => array( 'tax rate', true ),
|
285 |
-
'tax_ship' => array( 'tax ship', true ),
|
286 |
-
'tax_category' => array( 'tax category', true ),
|
287 |
-
'weight' => array( 'shipping weight', false ),
|
288 |
-
'length' => array( 'shipping length', false ),
|
289 |
-
'width' => array( 'shipping width', false ),
|
290 |
-
'height' => array( 'shipping height', false ),
|
291 |
-
'shipping_label' => array( 'shipping label', false ),
|
292 |
-
'shipping_country' => array( 'shipping country', false ),
|
293 |
-
'shipping_service' => array( 'shipping service', false ),
|
294 |
-
'shipping_price' => array( 'shipping price', false ),
|
295 |
-
'shipping_region' => array( 'shipping region', false ),
|
296 |
-
'multipack' => array( 'multipack', true ),
|
297 |
-
'is_bundle' => array( 'is bundle', true ),
|
298 |
-
'adult' => array( 'adult', true ),
|
299 |
-
'adwords_redirect' => array( 'adwords redirect', true ),
|
300 |
-
'custom_label_0' => array( 'custom label 0', true ),
|
301 |
-
'custom_label_1' => array( 'custom label 1', true ),
|
302 |
-
'custom_label_2' => array( 'custom label 2', true ),
|
303 |
-
'custom_label_3' => array( 'custom label 3', true ),
|
304 |
-
'custom_label_4' => array( 'custom label 4', true ),
|
305 |
-
'excluded_destination' => array( 'excluded destination', true ),
|
306 |
-
'included_destination' => array( 'included destination', true ),
|
307 |
-
'expiration_date' => array( 'expiration date', true ),
|
308 |
-
'unit_pricing_measure' => array( 'unit pricing measure', true ),
|
309 |
-
'unit_pricing_base_measure' => array( 'unit pricing base measure', true ),
|
310 |
-
'energy_efficiency_class' => array( 'energy efficiency class', true ),
|
311 |
-
'loyalty_points' => array( 'loyalty points', true ),
|
312 |
-
'installment' => array( 'installment', true ),
|
313 |
-
'promotion_id' => array( 'promotion id', true ),
|
314 |
-
'cost_of_goods_sold' => array( 'cost of goods sold', true ),
|
315 |
-
);
|
316 |
-
|
317 |
-
if ( ! empty( $this->products ) ) {
|
318 |
-
foreach ( $this->products as $no => $product ) {
|
319 |
-
foreach ( $product as $key => $value ) {
|
320 |
-
$this->mapAttribute( $no,
|
321 |
-
$key,
|
322 |
-
$googleCSVTXTAttribute[ $key ][0],
|
323 |
-
$value,
|
324 |
-
$googleCSVTXTAttribute[ $key ][0] );
|
325 |
-
}
|
326 |
-
$this->process_google_shipping_attribute_for_CSVTXT( $no );
|
327 |
-
$this->process_google_tax_attribute_for_CSVTXT( $no );
|
328 |
-
}
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Map to google attribute
|
334 |
-
*
|
335 |
-
* @param $no
|
336 |
-
* @param $from
|
337 |
-
* @param $to
|
338 |
-
* @param $value
|
339 |
-
* @param bool $cdata
|
340 |
-
*
|
341 |
-
* @return array|string
|
342 |
-
*/
|
343 |
-
public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
|
344 |
-
unset( $this->products[ $no ][ $from ] );
|
345 |
-
if ( 'g:color' == $to ) {
|
346 |
-
$value = str_replace( ',', '/', $value );
|
347 |
-
}
|
348 |
-
if ( 'xml' == $this->rules['feedType'] ) {
|
349 |
-
return $this->products[ $no ][ $to ] = $this->formatXMLLine( $to, $value, $cdata );
|
350 |
-
} else {
|
351 |
-
return $this->products[ $no ][ $to ] = $value;
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
public function identifier_status_add( $no ) {
|
356 |
-
$identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
|
357 |
-
$product = $this->products[ $no ];
|
358 |
-
|
359 |
-
if ( ! array_key_exists( 'g:identifier_exists', $product ) ) {
|
360 |
-
if ( count( array_intersect_key( array_flip( $identifier ), $product ) ) >= 2 ) {
|
361 |
-
// Any 2 required keys exist!
|
362 |
-
$countIdentifier = 0;
|
363 |
-
if ( array_key_exists( 'brand', $product ) && ! empty( $product['brand'] ) ) {
|
364 |
-
$countIdentifier ++;
|
365 |
-
}
|
366 |
-
if ( array_key_exists( 'upc', $product ) && ! empty( $product['upc'] ) ) {
|
367 |
-
$countIdentifier ++;
|
368 |
-
}
|
369 |
-
if ( array_key_exists( 'sku', $product ) && ! empty( $product['sku'] ) ) {
|
370 |
-
$countIdentifier ++;
|
371 |
-
}
|
372 |
-
if ( array_key_exists( 'mpn', $product ) && ! empty( $product['mpn'] ) ) {
|
373 |
-
$countIdentifier ++;
|
374 |
-
}
|
375 |
-
if ( array_key_exists( 'gtin', $product ) && ! empty( $product['gtin'] ) ) {
|
376 |
-
$countIdentifier ++;
|
377 |
-
}
|
378 |
-
if ( $countIdentifier >= 2 ) {
|
379 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
380 |
-
'yes',
|
381 |
-
$cdata = true );
|
382 |
-
} else {
|
383 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
384 |
-
'no',
|
385 |
-
$cdata = true );
|
386 |
-
}
|
387 |
-
} else {
|
388 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
389 |
-
'no',
|
390 |
-
$cdata = true );
|
391 |
-
}
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
|
396 |
-
public function process_google_shipping_attribute_for_xml(
|
397 |
-
$no
|
398 |
-
) {
|
399 |
-
$shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
|
400 |
-
$shippingAttr = array();
|
401 |
-
$products = $this->products[ $no ];
|
402 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
403 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
404 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
405 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
406 |
-
}
|
407 |
-
}
|
408 |
-
if ( count( $shippingAttr ) ) {
|
409 |
-
$str = '';
|
410 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
411 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
412 |
-
$str .= str_replace( 'shipping_', '', $valueAttr );
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine( 'g:shipping', $str, false );
|
417 |
-
}
|
418 |
-
|
419 |
-
return false;
|
420 |
-
}
|
421 |
-
|
422 |
-
public function process_google_tax_attribute_for_xml(
|
423 |
-
$no
|
424 |
-
) {
|
425 |
-
$tax = array( 'g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship' );
|
426 |
-
$taxAttr = array();
|
427 |
-
$products = $this->products[ $no ];
|
428 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
429 |
-
if ( in_array( $keyAttr, $tax ) ) {
|
430 |
-
array_push( $taxAttr, array( $keyAttr => $valueAttr ) );
|
431 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
432 |
-
}
|
433 |
-
}
|
434 |
-
if ( count( $taxAttr ) ) {
|
435 |
-
$str = '';
|
436 |
-
foreach ( $taxAttr as $key => $attributes ) {
|
437 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
438 |
-
// if($keyAttr != "g:tax_ship")
|
439 |
-
// {
|
440 |
-
$str .= str_replace( 'tax_', '', $valueAttr );
|
441 |
-
$str = str_replace( 'ship', 'tax_ship', $str );
|
442 |
-
// }
|
443 |
-
// else
|
444 |
-
// {
|
445 |
-
// $str .= $valueAttr;
|
446 |
-
// }
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
return $this->products[ $no ]['g:tax'] = $this->formatXMLLine( 'g:tax', $str, false );
|
451 |
-
}
|
452 |
-
|
453 |
-
return false;
|
454 |
-
}
|
455 |
-
|
456 |
-
public function process_google_shipping_attribute_for_CSVTXT(
|
457 |
-
$no
|
458 |
-
) {
|
459 |
-
$shipping = array( 'shipping country', 'shipping service', 'shipping price', 'shipping region' );
|
460 |
-
$shippingAttr = array();
|
461 |
-
$products = $this->products[ $no ];
|
462 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
463 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
464 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
465 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
466 |
-
}
|
467 |
-
}
|
468 |
-
if ( count( $shippingAttr ) ) {
|
469 |
-
$str = '';
|
470 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
471 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
472 |
-
$country = ( 'shipping country' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
473 |
-
$service = ( 'shipping service' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
474 |
-
$price = ( 'shipping price' == $keyAttr ) ? $str .= $valueAttr : '';
|
475 |
-
$region = ( 'shipping region' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
476 |
-
}
|
477 |
-
}
|
478 |
-
|
479 |
-
return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace( ' : ', ':', $str );
|
480 |
-
}
|
481 |
-
|
482 |
-
return false;
|
483 |
-
}
|
484 |
-
|
485 |
-
public function process_google_tax_attribute_for_CSVTXT(
|
486 |
-
$no
|
487 |
-
) {
|
488 |
-
$tax = array( 'tax country', 'tax region', 'tax rate', 'tax ship' );
|
489 |
-
$taxAttr = array();
|
490 |
-
$products = $this->products[ $no ];
|
491 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
492 |
-
if ( in_array( $keyAttr, $tax ) ) {
|
493 |
-
array_push( $taxAttr, array( $keyAttr => $valueAttr ) );
|
494 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
495 |
-
}
|
496 |
-
}
|
497 |
-
if ( count( $taxAttr ) ) {
|
498 |
-
$str = '';
|
499 |
-
foreach ( $taxAttr as $key => $attributes ) {
|
500 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
501 |
-
$country = ( 'tax country' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
502 |
-
$region = ( 'tax region' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
503 |
-
$rate = ( 'tax rate' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
504 |
-
$ship = ( 'tax ship' == $keyAttr ) ? $str .= $valueAttr : '';
|
505 |
-
}
|
506 |
-
}
|
507 |
-
|
508 |
-
return $this->products[ $no ]['tax(country:region:rate:tax_ship)'] = str_replace( ' : ', ':', $str );
|
509 |
-
}
|
510 |
-
|
511 |
-
return false;
|
512 |
-
}
|
513 |
-
|
514 |
-
function formatXMLLine( $attribute, $value, $cdata, $space = '' ) {
|
515 |
-
// Make single XML node
|
516 |
-
if ( ! empty( $value ) ) {
|
517 |
-
$value = trim( $value );
|
518 |
-
}
|
519 |
-
if ( 'array' === gettype( $value ) ) {
|
520 |
-
$value = wp_json_encode( $value );
|
521 |
-
}
|
522 |
-
if ( false === strpos( $value, '<![CDATA[' ) && 'http' == substr( trim( $value ), 0, 4 ) ) {
|
523 |
-
$value = "<![CDATA[$value]]>";
|
524 |
-
} elseif ( false === strpos( $value, '<![CDATA[' ) && true === $cdata && ! empty( $value ) ) {
|
525 |
-
$value = "<![CDATA[$value]]>";
|
526 |
-
} elseif ( $cdata ) {
|
527 |
-
if ( ! empty( $value ) ) {
|
528 |
-
$value = "<![CDATA[$value]]>";
|
529 |
-
}
|
530 |
-
}
|
531 |
-
if ( substr( $attribute, 0, 23 ) == 'g:additional_image_link' ) {
|
532 |
-
$attribute = 'g:additional_image_link';
|
533 |
-
}
|
534 |
-
|
535 |
-
return "$space<$attribute>$value</$attribute>";
|
536 |
-
}
|
537 |
-
|
538 |
-
|
539 |
-
public function get_xml_feed_header() {
|
540 |
-
$output = '<?xml version="1.0" encoding="UTF-8" ?>
|
541 |
-
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
|
542 |
-
<channel>
|
543 |
-
<title><![CDATA[' . html_entity_decode( get_option( 'blogname' ) ) . ']]></title>
|
544 |
-
<link><![CDATA[' . site_url() . ']]></link>
|
545 |
-
<description><![CDATA[' . html_entity_decode( get_option( 'blogdescription' ) ) . ']]></description>';
|
546 |
-
|
547 |
-
return $output;
|
548 |
-
}
|
549 |
-
|
550 |
-
public function get_xml_feed(
|
551 |
-
$items
|
552 |
-
) {
|
553 |
-
$feed = '';
|
554 |
-
// $feed .= $this->get_feed_header();
|
555 |
-
$feed .= "\n";
|
556 |
-
if ( $items ) {
|
557 |
-
foreach ( $items as $item => $products ) {
|
558 |
-
$feed .= ' <' . $this->feedWrapper . '>';
|
559 |
-
foreach ( $products as $key => $value ) {
|
560 |
-
if ( ! empty( $value ) ) {
|
561 |
-
$feed .= $value;
|
562 |
-
}
|
563 |
-
}
|
564 |
-
$feed .= "\n </" . $this->feedWrapper . ">\n";
|
565 |
-
}
|
566 |
-
|
567 |
-
// $feed .= $this->get_feed_footer();
|
568 |
-
|
569 |
-
return $feed;
|
570 |
-
}
|
571 |
-
|
572 |
-
return false;
|
573 |
-
}
|
574 |
-
|
575 |
-
public function get_xml_feed_footer() {
|
576 |
-
$footer = ' </channel>
|
577 |
-
</rss>';
|
578 |
-
|
579 |
-
return $footer;
|
580 |
-
}
|
581 |
-
|
582 |
-
public function short_products() {
|
583 |
-
if ( $this->products ) {
|
584 |
-
update_option( 'wpf_progress', esc_html__( 'Shorting Products', 'woo-feed' ), false );
|
585 |
-
sleep( 1 );
|
586 |
-
$array = array();
|
587 |
-
$ij = 0;
|
588 |
-
foreach ( $this->products as $key => $item ) {
|
589 |
-
$array[ $ij ] = $item;
|
590 |
-
unset( $this->products[ $key ] );
|
591 |
-
$ij ++;
|
592 |
-
}
|
593 |
-
|
594 |
-
return $this->products = $array;
|
595 |
-
}
|
596 |
-
|
597 |
-
return $this->products;
|
598 |
-
}
|
599 |
-
|
600 |
-
/**
|
601 |
-
* Responsible to make CSV feed
|
602 |
-
* @return string
|
603 |
-
*/
|
604 |
-
public function get_csv_feed() {
|
605 |
-
if ( $this->products ) {
|
606 |
-
$headers = array_keys( $this->products[0] );
|
607 |
-
$feed[] = $headers;
|
608 |
-
foreach ( $this->products as $no => $product ) {
|
609 |
-
$row = array();
|
610 |
-
foreach ( $headers as $key => $header ) {
|
611 |
-
if ( strpos( $header, 'additional image link' ) !== false ) {
|
612 |
-
$header = 'additional image link';
|
613 |
-
}
|
614 |
-
$row[] = isset( $product[ $header ] ) ? $product[ $header ] : '';
|
615 |
-
}
|
616 |
-
$feed[] = $row;
|
617 |
-
}
|
618 |
-
|
619 |
-
return $feed;
|
620 |
-
}
|
621 |
-
|
622 |
-
return false;
|
623 |
-
}
|
624 |
}
|
104 |
if ( 'xml' == $this->rules['feedType'] ) {
|
105 |
$feed = array(
|
106 |
'body' => $this->products->feedBody,
|
107 |
+
'header' => $this->products->feedHeader,
|
108 |
+
'footer' => $this->products->feedFooter,
|
109 |
);
|
110 |
|
111 |
return $feed;
|
135 |
return $feed;
|
136 |
}
|
137 |
|
138 |
+
|
139 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
includes/feeds/class-woo-feed-pinterest.php
CHANGED
@@ -104,9 +104,9 @@ class Woo_Feed_Pinterest {
|
|
104 |
if ( 'xml' == $this->rules['feedType'] ) {
|
105 |
// return $this->get_feed($this->products);
|
106 |
$feed = array(
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
);
|
111 |
|
112 |
return $feed;
|
@@ -139,496 +139,4 @@ class Woo_Feed_Pinterest {
|
|
139 |
|
140 |
return $feed;
|
141 |
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Configure merchant attributes for XML feed
|
145 |
-
*/
|
146 |
-
public function mapAttributeForXML() {
|
147 |
-
|
148 |
-
$googleXMLAttribute = array(
|
149 |
-
'id' => array( 'g:id', false ),
|
150 |
-
'title' => array( 'title', true ),
|
151 |
-
'description' => array( 'description', true ),
|
152 |
-
'link' => array( 'link', true ),
|
153 |
-
'mobile_link' => array( 'mobile_link', true ),
|
154 |
-
'product_type' => array( 'g:product_type', true ),
|
155 |
-
'current_category' => array( 'g:google_product_category', true ),
|
156 |
-
'image' => array( 'g:image_link', true ),
|
157 |
-
'images' => array( 'g:additional_image_link', false ),
|
158 |
-
'images_1' => array( 'g:additional_image_link_1', true ),
|
159 |
-
'images_2' => array( 'g:additional_image_link_2', true ),
|
160 |
-
'images_3' => array( 'g:additional_image_link_3', true ),
|
161 |
-
'images_4' => array( 'g:additional_image_link_4', true ),
|
162 |
-
'images_5' => array( 'g:additional_image_link_5', true ),
|
163 |
-
'images_6' => array( 'g:additional_image_link_6', true ),
|
164 |
-
'images_7' => array( 'g:additional_image_link_7', true ),
|
165 |
-
'images_8' => array( 'g:additional_image_link_8', true ),
|
166 |
-
'images_9' => array( 'g:additional_image_link_9', true ),
|
167 |
-
'images_10' => array( 'g:additional_image_link_10', true ),
|
168 |
-
'condition' => array( 'g:condition', false ),
|
169 |
-
'availability' => array( 'g:availability', false ),
|
170 |
-
'availability_date' => array( 'g:availability_date', false ),
|
171 |
-
'inventory' => array( 'g:inventory', false ),
|
172 |
-
'price' => array( 'g:price', true ),
|
173 |
-
'sale_price' => array( 'g:sale_price', true ),
|
174 |
-
'sale_price_effective_date' => array( 'g:sale_price_effective_date', true ),
|
175 |
-
'brand' => array( 'g:brand', true ),
|
176 |
-
'sku' => array( 'g:mpn', true ),
|
177 |
-
'upc' => array( 'g:gtin', true ),
|
178 |
-
'identifier_exists' => array( 'g:identifier_exists', true ),
|
179 |
-
'item_group_id' => array( 'g:item_group_id', false ),
|
180 |
-
'color' => array( 'g:color', true ),
|
181 |
-
'gender' => array( 'g:gender', true ),
|
182 |
-
'age_group' => array( 'g:age_group', true ),
|
183 |
-
'material' => array( 'g:material', true ),
|
184 |
-
'pattern' => array( 'g:pattern', true ),
|
185 |
-
'size' => array( 'g:size', true ),
|
186 |
-
'size_type' => array( 'g:size_type', true ),
|
187 |
-
'size_system' => array( 'g:size_system', true ),
|
188 |
-
'tax' => array( 'tax', true ),
|
189 |
-
'tax_country' => array( 'g:tax_country', true ),
|
190 |
-
'tax_region' => array( 'g:tax_region', true ),
|
191 |
-
'tax_rate' => array( 'g:tax_rate', true ),
|
192 |
-
'tax_ship' => array( 'g:tax_ship', true ),
|
193 |
-
'tax_category' => array( 'g:tax_category', true ),
|
194 |
-
'weight' => array( 'g:shipping_weight', false ),
|
195 |
-
'length' => array( 'g:shipping_length', false ),
|
196 |
-
'width' => array( 'g:shipping_width', false ),
|
197 |
-
'height' => array( 'g:shipping_height', false ),
|
198 |
-
'shipping_label' => array( 'g:shipping_label', false ),
|
199 |
-
'shipping_country' => array( 'g:shipping_country', false ),
|
200 |
-
'shipping_service' => array( 'g:shipping_service', false ),
|
201 |
-
'shipping_price' => array( 'g:shipping_price', false ),
|
202 |
-
'shipping_region' => array( 'g:shipping_region', false ),
|
203 |
-
'multipack' => array( 'g:multipack', true ),
|
204 |
-
'is_bundle' => array( 'g:is_bundle', true ),
|
205 |
-
'adult' => array( 'g:adult', true ),
|
206 |
-
'adwords_redirect' => array( 'g:adwords_redirect', true ),
|
207 |
-
'custom_label_0' => array( 'g:custom_label_0', true ),
|
208 |
-
'custom_label_1' => array( 'g:custom_label_1', true ),
|
209 |
-
'custom_label_2' => array( 'g:custom_label_2', true ),
|
210 |
-
'custom_label_3' => array( 'g:custom_label_3', true ),
|
211 |
-
'custom_label_4' => array( 'g:custom_label_4', true ),
|
212 |
-
'excluded_destination' => array( 'g:excluded_destination', true ),
|
213 |
-
'included_destination' => array( 'g:included_destination', true ),
|
214 |
-
'expiration_date' => array( 'g:expiration_date', true ),
|
215 |
-
'unit_pricing_measure' => array( 'g:unit_pricing_measure', true ),
|
216 |
-
'unit_pricing_base_measure' => array( 'g:unit_pricing_base_measure', true ),
|
217 |
-
'energy_efficiency_class' => array( 'g:energy_efficiency_class', true ),
|
218 |
-
'loyalty_points' => array( 'g:loyalty_points', true ),
|
219 |
-
'installment' => array( 'g:installment', true ),
|
220 |
-
'promotion_id' => array( 'g:promotion_id', true ),
|
221 |
-
'cost_of_goods_sold' => array( 'g:cost_of_goods_sold', true ),
|
222 |
-
);
|
223 |
-
|
224 |
-
if ( ! empty( $this->products ) ) {
|
225 |
-
foreach ( $this->products as $no => $product ) {
|
226 |
-
$this->identifier_status_add( $no );
|
227 |
-
foreach ( $product as $key => $value ) {
|
228 |
-
$this->mapAttribute( $no,
|
229 |
-
$key,
|
230 |
-
$googleXMLAttribute[ $key ][0],
|
231 |
-
$value,
|
232 |
-
$googleXMLAttribute[ $key ][0] );
|
233 |
-
}
|
234 |
-
|
235 |
-
$this->process_google_shipping_attribute_for_xml( $no );
|
236 |
-
$this->process_google_tax_attribute_for_xml( $no );
|
237 |
-
}
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Configure merchant attributes for XML feed
|
243 |
-
*/
|
244 |
-
public function mapAttributeForCSVTXT() {
|
245 |
-
// Basic product information
|
246 |
-
$googleCSVTXTAttribute = array(
|
247 |
-
'id' => array( 'id', false ),
|
248 |
-
'title' => array( 'title', true ),
|
249 |
-
'description' => array( 'description', true ),
|
250 |
-
'link' => array( 'link', true ),
|
251 |
-
'mobile_link' => array( 'mobile_link', true ),
|
252 |
-
'product_type' => array( 'product_type', true ),
|
253 |
-
'current_category' => array( 'google_product_category', true ),
|
254 |
-
'image' => array( 'image_link', true ),
|
255 |
-
'images' => array( 'additional_image_link', true ),
|
256 |
-
'images_1' => array( 'additional_image_link_1', true ),
|
257 |
-
'images_2' => array( 'additional_image_link_2', true ),
|
258 |
-
'images_3' => array( 'additional_image_link_3', true ),
|
259 |
-
'images_4' => array( 'additional_image_link_4', true ),
|
260 |
-
'images_5' => array( 'additional_image_link_5', true ),
|
261 |
-
'images_6' => array( 'additional_image_link_6', true ),
|
262 |
-
'images_7' => array( 'additional_image_link_7', true ),
|
263 |
-
'images_8' => array( 'additional_image_link_8', true ),
|
264 |
-
'images_9' => array( 'additional_image_link_9', true ),
|
265 |
-
'images_10' => array( 'additional_image_link_10', true ),
|
266 |
-
'condition' => array( 'condition', false ),
|
267 |
-
'availability' => array( 'availability', false ),
|
268 |
-
'availability_date' => array( 'availability_date', false ),
|
269 |
-
'inventory' => array( 'inventory', false ),
|
270 |
-
'price' => array( 'price', true ),
|
271 |
-
'sale_price' => array( 'sale_price', true ),
|
272 |
-
'sale_price_effective_date' => array( 'sale_price_effective_date', true ),
|
273 |
-
'brand' => array( 'brand', true ),
|
274 |
-
'sku' => array( 'mpn', true ),
|
275 |
-
'upc' => array( 'gtin', true ),
|
276 |
-
'identifier_exists' => array( 'identifier exists', true ),
|
277 |
-
'item_group_id' => array( 'item_group_id', false ),
|
278 |
-
'color' => array( 'color', true ),
|
279 |
-
'gender' => array( 'gender', true ),
|
280 |
-
'age_group' => array( 'age_group', true ),
|
281 |
-
'material' => array( 'material', true ),
|
282 |
-
'pattern' => array( 'pattern', true ),
|
283 |
-
'size' => array( 'size', true ),
|
284 |
-
'size_type' => array( 'size_type', true ),
|
285 |
-
'size_system' => array( 'size_system', true ),
|
286 |
-
'tax' => array( 'tax', true ),
|
287 |
-
'tax_country' => array( 'tax_country', true ),
|
288 |
-
'tax_region' => array( 'tax_region', true ),
|
289 |
-
'tax_rate' => array( 'tax_rate', true ),
|
290 |
-
'tax_ship' => array( 'tax_ship', true ),
|
291 |
-
'tax_category' => array( 'tax_category', true ),
|
292 |
-
'weight' => array( 'shipping_weight', false ),
|
293 |
-
'length' => array( 'shipping_length', false ),
|
294 |
-
'width' => array( 'shipping_width', false ),
|
295 |
-
'height' => array( 'shipping_height', false ),
|
296 |
-
'shipping_label' => array( 'shipping_label', false ),
|
297 |
-
'shipping_country' => array( 'shipping_country', false ),
|
298 |
-
'shipping_service' => array( 'shipping_service', false ),
|
299 |
-
'shipping_price' => array( 'shipping_price', false ),
|
300 |
-
'shipping_region' => array( 'shipping_region', false ),
|
301 |
-
'multipack' => array( 'multipack', true ),
|
302 |
-
'is_bundle' => array( 'is_bundle', true ),
|
303 |
-
'adult' => array( 'adult', true ),
|
304 |
-
'adwords_redirect' => array( 'adwords_redirect', true ),
|
305 |
-
'custom_label_0' => array( 'custom_label_0', true ),
|
306 |
-
'custom_label_1' => array( 'custom_label_1', true ),
|
307 |
-
'custom_label_2' => array( 'custom_label_2', true ),
|
308 |
-
'custom_label_3' => array( 'custom_label_3', true ),
|
309 |
-
'custom_label_4' => array( 'custom_label_4', true ),
|
310 |
-
'excluded_destination' => array( 'excluded_destination', true ),
|
311 |
-
'included_destination' => array( 'included_destination', true ),
|
312 |
-
'expiration_date' => array( 'expiration_date', true ),
|
313 |
-
'unit_pricing_measure' => array( 'unit_pricing_measure', true ),
|
314 |
-
'unit_pricing_base_measure' => array( 'unit_pricing_base_measure', true ),
|
315 |
-
'energy_efficiency_class' => array( 'energy_efficiency_class', true ),
|
316 |
-
'loyalty_points' => array( 'loyalty_points', true ),
|
317 |
-
'installment' => array( 'installment', true ),
|
318 |
-
'promotion_id' => array( 'promotion_id', true ),
|
319 |
-
'cost_of_goods_sold' => array( 'cost_of_goods_sold', true ),
|
320 |
-
);
|
321 |
-
|
322 |
-
if ( ! empty( $this->products ) ) {
|
323 |
-
foreach ( $this->products as $no => $product ) {
|
324 |
-
foreach ( $product as $key => $value ) {
|
325 |
-
$this->mapAttribute( $no,
|
326 |
-
$key,
|
327 |
-
$googleCSVTXTAttribute[ $key ][0],
|
328 |
-
$value,
|
329 |
-
$googleCSVTXTAttribute[ $key ][0] );
|
330 |
-
}
|
331 |
-
$this->process_google_shipping_attribute_for_CSVTXT( $no );
|
332 |
-
$this->process_google_tax_attribute_for_CSVTXT( $no );
|
333 |
-
}
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Map to google attribute
|
339 |
-
*
|
340 |
-
* @param $no
|
341 |
-
* @param $from
|
342 |
-
* @param $to
|
343 |
-
* @param $value
|
344 |
-
* @param bool $cdata
|
345 |
-
*
|
346 |
-
* @return array|string
|
347 |
-
*/
|
348 |
-
public function mapAttribute( $no, $from, $to, $value, $cdata = false ) {
|
349 |
-
unset( $this->products[ $no ][ $from ] );
|
350 |
-
if ( 'g:color' == $to ) {
|
351 |
-
$value = str_replace( ',', '/', $value );
|
352 |
-
}
|
353 |
-
if ( 'xml' == $this->rules['feedType'] ) {
|
354 |
-
return $this->products[ $no ][ $to ] = $this->formatXMLLine( $to, $value, $cdata );
|
355 |
-
} else {
|
356 |
-
return $this->products[ $no ][ $to ] = $value;
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
public function identifier_status_add( $no ) {
|
361 |
-
$identifier = array( 'brand', 'upc', 'sku', 'mpn', 'gtin' );
|
362 |
-
$product = $this->products[ $no ];
|
363 |
-
|
364 |
-
if ( ! array_key_exists( 'g:identifier_exists', $product ) ) {
|
365 |
-
if ( count( array_intersect_key( array_flip( $identifier ), $product ) ) >= 2 ) {
|
366 |
-
// Any 2 required keys exist!
|
367 |
-
$countIdentifier = 0;
|
368 |
-
if ( array_key_exists( 'brand', $product ) && ! empty( $product['brand'] ) ) {
|
369 |
-
$countIdentifier ++;
|
370 |
-
}
|
371 |
-
if ( array_key_exists( 'upc', $product ) && ! empty( $product['upc'] ) ) {
|
372 |
-
$countIdentifier ++;
|
373 |
-
}
|
374 |
-
if ( array_key_exists( 'sku', $product ) && ! empty( $product['sku'] ) ) {
|
375 |
-
$countIdentifier ++;
|
376 |
-
}
|
377 |
-
if ( array_key_exists( 'mpn', $product ) && ! empty( $product['mpn'] ) ) {
|
378 |
-
$countIdentifier ++;
|
379 |
-
}
|
380 |
-
if ( array_key_exists( 'gtin', $product ) && ! empty( $product['gtin'] ) ) {
|
381 |
-
$countIdentifier ++;
|
382 |
-
}
|
383 |
-
if ( $countIdentifier >= 2 ) {
|
384 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
385 |
-
'yes',
|
386 |
-
$cdata = true );
|
387 |
-
} else {
|
388 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
389 |
-
'no',
|
390 |
-
$cdata = true );
|
391 |
-
}
|
392 |
-
} else {
|
393 |
-
$this->products[ $no ]['g:identifier_exists'] = $this->formatXMLLine( 'g:identifier_exists',
|
394 |
-
'no',
|
395 |
-
$cdata = true );
|
396 |
-
}
|
397 |
-
}
|
398 |
-
}
|
399 |
-
|
400 |
-
|
401 |
-
public function process_google_shipping_attribute_for_xml(
|
402 |
-
$no
|
403 |
-
) {
|
404 |
-
$shipping = array( 'g:shipping_country', 'g:shipping_service', 'g:shipping_price', 'g:shipping_region' );
|
405 |
-
$shippingAttr = array();
|
406 |
-
$products = $this->products[ $no ];
|
407 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
408 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
409 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
410 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
if ( count( $shippingAttr ) ) {
|
414 |
-
$str = '';
|
415 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
416 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
417 |
-
$str .= str_replace( 'shipping_', '', $valueAttr );
|
418 |
-
}
|
419 |
-
}
|
420 |
-
|
421 |
-
return $this->products[ $no ]['g:shipping'] = $this->formatXMLLine( 'g:shipping', $str, false );
|
422 |
-
}
|
423 |
-
|
424 |
-
return false;
|
425 |
-
}
|
426 |
-
|
427 |
-
public function process_google_tax_attribute_for_xml(
|
428 |
-
$no
|
429 |
-
) {
|
430 |
-
$tax = array( 'g:tax_country', 'g:tax_region', 'g:tax_rate', 'g:tax_ship' );
|
431 |
-
$taxAttr = array();
|
432 |
-
$products = $this->products[ $no ];
|
433 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
434 |
-
if ( in_array( $keyAttr, $tax ) ) {
|
435 |
-
array_push( $taxAttr, array( $keyAttr => $valueAttr ) );
|
436 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
437 |
-
}
|
438 |
-
}
|
439 |
-
if ( count( $taxAttr ) ) {
|
440 |
-
$str = '';
|
441 |
-
foreach ( $taxAttr as $key => $attributes ) {
|
442 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
443 |
-
// if($keyAttr != "g:tax_ship")
|
444 |
-
// {
|
445 |
-
$str .= str_replace( 'tax_', '', $valueAttr );
|
446 |
-
$str = str_replace( 'ship', 'tax_ship', $str );
|
447 |
-
// }
|
448 |
-
// else
|
449 |
-
// {
|
450 |
-
// $str .= $valueAttr;
|
451 |
-
// }
|
452 |
-
}
|
453 |
-
}
|
454 |
-
|
455 |
-
return $this->products[ $no ]['g:tax'] = $this->formatXMLLine( 'g:tax', $str, false );
|
456 |
-
}
|
457 |
-
|
458 |
-
return false;
|
459 |
-
}
|
460 |
-
|
461 |
-
public function process_google_shipping_attribute_for_CSVTXT(
|
462 |
-
$no
|
463 |
-
) {
|
464 |
-
$shipping = array( 'shipping country', 'shipping service', 'shipping price', 'shipping region' );
|
465 |
-
$shippingAttr = array();
|
466 |
-
$products = $this->products[ $no ];
|
467 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
468 |
-
if ( in_array( $keyAttr, $shipping ) ) {
|
469 |
-
array_push( $shippingAttr, array( $keyAttr => $valueAttr ) );
|
470 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
471 |
-
}
|
472 |
-
}
|
473 |
-
if ( count( $shippingAttr ) ) {
|
474 |
-
$str = '';
|
475 |
-
foreach ( $shippingAttr as $key => $attributes ) {
|
476 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
477 |
-
$country = ( 'shipping country' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
478 |
-
$service = ( 'shipping service' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
479 |
-
$price = ( 'shipping price' == $keyAttr ) ? $str .= $valueAttr : '';
|
480 |
-
$region = ( 'shipping region' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
return $this->products[ $no ]['shipping(country:region:service:price)'] = str_replace( ' : ', ':', $str );
|
485 |
-
}
|
486 |
-
|
487 |
-
return false;
|
488 |
-
}
|
489 |
-
|
490 |
-
public function process_google_tax_attribute_for_CSVTXT( $no ) {
|
491 |
-
$tax = array( 'tax country', 'tax region', 'tax rate', 'tax ship' );
|
492 |
-
$taxAttr = array();
|
493 |
-
$products = $this->products[ $no ];
|
494 |
-
foreach ( $products as $keyAttr => $valueAttr ) {
|
495 |
-
if ( in_array( $keyAttr, $tax ) ) {
|
496 |
-
array_push( $taxAttr, array( $keyAttr => $valueAttr ) );
|
497 |
-
unset( $this->products[ $no ][ $keyAttr ] );
|
498 |
-
}
|
499 |
-
}
|
500 |
-
if ( count( $taxAttr ) ) {
|
501 |
-
$str = '';
|
502 |
-
foreach ( $taxAttr as $key => $attributes ) {
|
503 |
-
foreach ( $attributes as $keyAttr => $valueAttr ) {
|
504 |
-
$country = ( 'tax country' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
505 |
-
$region = ( 'tax region' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
506 |
-
$rate = ( 'tax rate' == $keyAttr ) ? $str .= $valueAttr . ':' : '';
|
507 |
-
$ship = ( 'tax ship' == $keyAttr ) ? $str .= $valueAttr : '';
|
508 |
-
}
|
509 |
-
}
|
510 |
-
|
511 |
-
return $this->products[ $no ]['tax(country:region:rate:tax_ship)'] = str_replace( ' : ', ':', $str );
|
512 |
-
}
|
513 |
-
|
514 |
-
return false;
|
515 |
-
}
|
516 |
-
|
517 |
-
function formatXMLLine( $attribute, $value, $cdata, $space = '' ) {
|
518 |
-
// Make single XML node
|
519 |
-
if ( ! empty( $value ) ) {
|
520 |
-
$value = trim( $value );
|
521 |
-
}
|
522 |
-
if ( 'array' == gettype( $value ) ) {
|
523 |
-
$value = wp_json_encode( $value );
|
524 |
-
}
|
525 |
-
if ( false === strpos( $value, '<![CDATA[' ) && 'http' == substr( trim( $value ), 0, 4 ) ) {
|
526 |
-
$value = "<![CDATA[$value]]>";
|
527 |
-
} elseif ( false === strpos( $value, '<![CDATA[' ) && true === $cdata && ! empty( $value ) ) {
|
528 |
-
$value = "<![CDATA[$value]]>";
|
529 |
-
} elseif ( $cdata ) {
|
530 |
-
if ( ! empty( $value ) ) {
|
531 |
-
$value = "<![CDATA[$value]]>";
|
532 |
-
}
|
533 |
-
}
|
534 |
-
if ( 'g:additional_image_link' === substr( $attribute, 0, 23 ) ) {
|
535 |
-
$attribute = 'g:additional_image_link';
|
536 |
-
}
|
537 |
-
|
538 |
-
return "$space<$attribute>$value</$attribute>";
|
539 |
-
}
|
540 |
-
|
541 |
-
|
542 |
-
public function get_xml_feed_header() {
|
543 |
-
$last_update_date = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
|
544 |
-
|
545 |
-
if ( 'pinterest_rss' === $this->rules['provider'] ) {
|
546 |
-
$header_line = '<rss content="http://purl.org/rss/1.0/modules/content/" wfw="http://wellformedweb.org/CommentAPI/" dc="http://purl.org/dc/elements/1.1/" sy="http://purl.org/rss/1.0/modules/syndication/" slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">';
|
547 |
-
$extra_lines = '<lastBuildDate>'. $last_update_date .'</lastBuildDate><generator>WooCommerce Product Feed by Webappick</generator>';
|
548 |
-
}else {
|
549 |
-
$header_line = '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">';
|
550 |
-
$extra_lines = '';
|
551 |
-
}
|
552 |
-
|
553 |
-
$output = '<?xml version="1.0" encoding="UTF-8" ?>' . $header_line . '
|
554 |
-
<channel>
|
555 |
-
<title><![CDATA[' . html_entity_decode( get_option( 'blogname' ) ) . ']]></title>
|
556 |
-
<link><![CDATA[' . site_url() . ']]></link>
|
557 |
-
<description><![CDATA[' . html_entity_decode( get_option( 'blogdescription' ) ) . ']]></description>' . $extra_lines;
|
558 |
-
|
559 |
-
return $output;
|
560 |
-
}
|
561 |
-
|
562 |
-
public function get_xml_feed( $items ) {
|
563 |
-
$feed = '';
|
564 |
-
// $feed .= $this->get_feed_header();
|
565 |
-
$feed .= "\n";
|
566 |
-
if ( $items ) {
|
567 |
-
foreach ( $items as $item => $products ) {
|
568 |
-
$feed .= ' <' . $this->feedWrapper . '>';
|
569 |
-
foreach ( $products as $key => $value ) {
|
570 |
-
if ( ! empty( $value ) ) {
|
571 |
-
$feed .= $value;
|
572 |
-
}
|
573 |
-
}
|
574 |
-
$feed .= "\n </" . $this->feedWrapper . ">\n";
|
575 |
-
}
|
576 |
-
|
577 |
-
// $feed .= $this->get_feed_footer();
|
578 |
-
|
579 |
-
return $feed;
|
580 |
-
}
|
581 |
-
|
582 |
-
return false;
|
583 |
-
}
|
584 |
-
|
585 |
-
public function get_xml_feed_footer() {
|
586 |
-
$footer = ' </channel>
|
587 |
-
</rss>';
|
588 |
-
|
589 |
-
return $footer;
|
590 |
-
}
|
591 |
-
|
592 |
-
public function short_products() {
|
593 |
-
if ( $this->products ) {
|
594 |
-
update_option( 'wpf_progress', esc_html__( 'Shorting Products', 'woo-feed' ), false );
|
595 |
-
sleep( 1 );
|
596 |
-
$array = array();
|
597 |
-
$ij = 0;
|
598 |
-
foreach ( $this->products as $key => $item ) {
|
599 |
-
$array[ $ij ] = $item;
|
600 |
-
unset( $this->products[ $key ] );
|
601 |
-
$ij ++;
|
602 |
-
}
|
603 |
-
|
604 |
-
return $this->products = $array;
|
605 |
-
}
|
606 |
-
|
607 |
-
return $this->products;
|
608 |
-
}
|
609 |
-
|
610 |
-
/**
|
611 |
-
* Responsible to make CSV feed
|
612 |
-
* @return string
|
613 |
-
*/
|
614 |
-
public function get_csv_feed() {
|
615 |
-
if ( $this->products ) {
|
616 |
-
$headers = array_keys( $this->products[0] );
|
617 |
-
$feed[] = $headers;
|
618 |
-
foreach ( $this->products as $no => $product ) {
|
619 |
-
$row = array();
|
620 |
-
foreach ( $headers as $key => $header ) {
|
621 |
-
if ( false !== strpos( $header, 'additional_image_link' ) ) {
|
622 |
-
$header = 'additional_image_link';
|
623 |
-
}
|
624 |
-
$row[] = isset( $product[ $header ] ) ? $product[ $header ] : '';
|
625 |
-
}
|
626 |
-
$feed[] = $row;
|
627 |
-
}
|
628 |
-
|
629 |
-
return $feed;
|
630 |
-
}
|
631 |
-
|
632 |
-
return false;
|
633 |
-
}
|
634 |
}
|
104 |
if ( 'xml' == $this->rules['feedType'] ) {
|
105 |
// return $this->get_feed($this->products);
|
106 |
$feed = array(
|
107 |
+
'body' => $this->products->feedBody,
|
108 |
+
'header' => $this->products->feedHeader,
|
109 |
+
'footer' => $this->products->feedFooter,
|
110 |
);
|
111 |
|
112 |
return $feed;
|
139 |
|
140 |
return $feed;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
includes/feeds/merchant_templates.php
CHANGED
@@ -2676,14 +2676,14 @@ return array(
|
|
2676 |
'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
|
2677 |
),
|
2678 |
'bing' => array(
|
2679 |
-
'mattributes' => array('id','title','link','price','description','image_link','
|
2680 |
-
'prefix' => array('','','','','','','','','','','','','',
|
2681 |
-
'type' => array('attribute','attribute','attribute','attribute','attribute','attribute','attribute','attribute','
|
2682 |
-
'attributes' => array('id','title','link','price','description','image','
|
2683 |
-
'default' => array('','','','','','','','','','','','','',
|
2684 |
-
'suffix' => array('','','','','','','','','','','','','',
|
2685 |
-
'output_type' => array('1','1','1','6','1','1','1','1','1','1','1','1','1',
|
2686 |
-
'limit' => array('','','','','','','','','','','','','',
|
2687 |
),
|
2688 |
'bing_local_inventory' => array(
|
2689 |
'mattributes' => array('store_code','itemid','quantity','weeks_of_supply','pick_up_method','pick_up_sla',),
|
2676 |
'limit' => array( '', '', '', '', '', '', '', '', '', '', '', '' ),
|
2677 |
),
|
2678 |
'bing' => array(
|
2679 |
+
'mattributes' => array('id','title','link','price','description','image_link','gtin','mpn','brand','product_type','product_category','availability','item_group_id',),
|
2680 |
+
'prefix' => array('','','','','','','','','','','','','',),
|
2681 |
+
'type' => array('attribute','attribute','attribute','attribute','attribute','attribute','attribute','attribute','pattern','attribute','pattern','attribute','attribute',),
|
2682 |
+
'attributes' => array('id','title','link','price','description','image','woo_feed_gtin','sku','','product_type','','availability','item_group_id',),
|
2683 |
+
'default' => array('','','','','','','','','','','','','',),
|
2684 |
+
'suffix' => array('','','','','','','','','','','','','',),
|
2685 |
+
'output_type' => array('1','1','1','6','1','1','1','1','1','1','1','1','1',),
|
2686 |
+
'limit' => array('','','','','','','','','','','','','',),
|
2687 |
),
|
2688 |
'bing_local_inventory' => array(
|
2689 |
'mattributes' => array('store_code','itemid','quantity','weeks_of_supply','pick_up_method','pick_up_sla',),
|
includes/helper.php
CHANGED
@@ -3469,4 +3469,38 @@ if ( ! function_exists('woo_feed_addtocart' ) ) {
|
|
3469 |
add_action( 'wp_head', 'woo_feed_addtocart' );
|
3470 |
}
|
3471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3472 |
// End of file helper.php.
|
3469 |
add_action( 'wp_head', 'woo_feed_addtocart' );
|
3470 |
}
|
3471 |
|
3472 |
+
if( ! function_exists( 'woo_feed_filter_dropdown_attributes' ) ) {
|
3473 |
+
/**
|
3474 |
+
* Woo Feed Filter Dropdown Attributes
|
3475 |
+
*
|
3476 |
+
* @param array $default_attr default attributes
|
3477 |
+
* @param array $merchants merchant names
|
3478 |
+
*
|
3479 |
+
* @since 4.3.11
|
3480 |
+
* @author Nazrul Islam Nayan
|
3481 |
+
* @updated 23-12-2020
|
3482 |
+
*
|
3483 |
+
* @return array $filtered_attributes
|
3484 |
+
*
|
3485 |
+
*/
|
3486 |
+
function woo_feed_filter_dropdown_attributes($default_attr, $merchants) {
|
3487 |
+
$filtered_attributes = $default_attr;
|
3488 |
+
|
3489 |
+
//filtering attributes for pinterest merchant
|
3490 |
+
if( in_array('pinterest', $merchants) ) {
|
3491 |
+
if( isset($default_attr['ads_redirect']) ) {
|
3492 |
+
if(array_key_exists( 'ads_redirect', $default_attr)) {
|
3493 |
+
$keys = array_keys($default_attr);
|
3494 |
+
$keys[array_search('ads_redirect', $keys)] = 'ads_link';
|
3495 |
+
$filtered_attributes = array_combine($keys, $default_attr);
|
3496 |
+
$filtered_attributes['ads_link'] = 'Ads Link[ads_link]';
|
3497 |
+
}
|
3498 |
+
}
|
3499 |
+
}
|
3500 |
+
|
3501 |
+
return $filtered_attributes;
|
3502 |
+
}
|
3503 |
+
add_filter('woo_feed_filter_dropdown_attributes', 'woo_feed_filter_dropdown_attributes', 2, 10);
|
3504 |
+
}
|
3505 |
+
|
3506 |
// End of file helper.php.
|
woo-feed.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
* Plugin Name: WooCommerce Product Feed
|
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 |
-
* Version: 4.3.
|
14 |
* Author: WebAppick
|
15 |
* Author URI: https://webappick.com/
|
16 |
* License: GPL v2
|
@@ -38,7 +38,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
|
|
38 |
* @var string
|
39 |
* @since 3.1.6
|
40 |
*/
|
41 |
-
define( 'WOO_FEED_FREE_VERSION', '4.3.
|
42 |
}
|
43 |
|
44 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|
10 |
* Plugin Name: WooCommerce Product Feed
|
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 |
+
* Version: 4.3.11
|
14 |
* Author: WebAppick
|
15 |
* Author URI: https://webappick.com/
|
16 |
* License: GPL v2
|
38 |
* @var string
|
39 |
* @since 3.1.6
|
40 |
*/
|
41 |
+
define( 'WOO_FEED_FREE_VERSION', '4.3.11' );
|
42 |
}
|
43 |
|
44 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|