CTX Feed – WooCommerce Product Feed Manager Plugin - Version 4.3.19

Version Description

(2021-01-18) = * Fixed: Uncaught error get_title issue solved.

Download this release

Release Info

Developer wahid0003
Plugin Icon 128x128 CTX Feed – WooCommerce Product Feed Manager Plugin
Version 4.3.19
Comparing to
See all releases

Code changes from version 4.3.18 to 4.3.19

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.18
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
 
@@ -308,6 +308,9 @@ Using pro version:
308
 
309
  == Changelog ==
310
 
 
 
 
311
  = 4.3.18 (2021-01-12) =
312
  * Tweak: Removing cache during plugin deactivation.
313
  * Tweak: Attribute positioning for yoast, rankmath, all in one seo plugin.
8
  Requires at least: 3.6
9
  Tested Up To: 5.6
10
  Requires PHP: 5.6
11
+ Stable tag: 4.3.19
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.19 (2021-01-18) =
312
+ * Fixed: Uncaught error get_title issue solved.
313
+
314
  = 4.3.18 (2021-01-12) =
315
  * Tweak: Removing cache during plugin deactivation.
316
  * Tweak: Attribute positioning for yoast, rankmath, all in one seo plugin.
admin/partials/woo-feed-edit-config.php CHANGED
@@ -87,7 +87,7 @@ if ( ! defined( 'ABSPATH' ) ) {
87
  </select>
88
  </td>
89
  <td>
90
- <input type="text" name="limit[<?php echo esc_attr( $k ); ?>]" value="<?php echo esc_attr( $limit[ $k ] ); ?>" autocomplete="off" class="wf_ps"/>
91
  </td>
92
  <td>
93
  <i class="delRow dashicons dashicons-trash"></i>
87
  </select>
88
  </td>
89
  <td>
90
+ <input type="text" readonly name="limit[<?php echo esc_attr( $k ); ?>]" value="<?php echo esc_attr( $limit[ $k ] ); ?>" autocomplete="off" class="wf_ps"/>
91
  </td>
92
  <td>
93
  <i class="delRow dashicons dashicons-trash"></i>
admin/partials/woo-feed-settings.php CHANGED
@@ -129,25 +129,25 @@ $settings = woo_feed_get_options( 'all' );
129
  <p class="description"><?php esc_html_e( 'Disables or Enables Brand', 'woo-feed' ); ?></p>
130
  </td>
131
  </tr>
132
- <tr>
133
- <td><label for="disable_pixel"><?php _e( 'Disable/Enable Facebook Pixel', 'woo-feed' ); ?></label></td>
134
- <td>
135
- <label for="disable_pixel">
136
- <select name="disable_pixel" id="disable_pixel">
137
- <option value="disable"<?php selected( $settings['disable_pixel'], 'disable' ); ?>><?php esc_html_e( 'Disabled', 'woo-feed' ); ?></option>
138
- <option value="enable"<?php selected( $settings['disable_pixel'], 'enable' ); ?>><?php esc_html_e( 'Enabled', 'woo-feed' ); ?></option>
139
- </select>
140
- </label>
141
- <p class="description"><?php esc_html_e( 'Disables or Enables Facebook Pixel ID’s for Variation', 'woo-feed' ); ?></p>
142
- </td>
143
- </tr>
144
- <tr>
145
- <th scope="row"><label for="pixel_id"><?php _e( 'Facebook Pixel Content ID’s for Variation', 'woo-feed' ); ?></label></th>
146
- <td>
147
- <input class="regular-text" type="number" min="1" name="pixel_id" id="pixel_id" value="<?php echo esc_attr( $settings['pixel_id'] ); ?>">
148
- <p class="description"><?php _e( 'Insert your Facebook Pixel ID', 'woo-feed' ); ?></p>
149
- </td>
150
- </tr>
151
  <tr>
152
  <th scope="row"><label for="allow_all_shipping"><?php esc_html_e( 'Add shipping costs for all countries to feed (Google Shopping / Facebook only)', 'woo-feed' ); ?></label></th>
153
  <td>
129
  <p class="description"><?php esc_html_e( 'Disables or Enables Brand', 'woo-feed' ); ?></p>
130
  </td>
131
  </tr>
132
+ <!-- <tr>-->
133
+ <!-- <td><label for="disable_pixel">--><?php //_e( 'Disable/Enable Facebook Pixel', 'woo-feed' ); ?><!--</label></td>-->
134
+ <!-- <td>-->
135
+ <!-- <label for="disable_pixel">-->
136
+ <!-- <select name="disable_pixel" id="disable_pixel">-->
137
+ <!-- <option value="disable"--><?php //selected( $settings['disable_pixel'], 'disable' ); ?><!-->--><?php //esc_html_e( 'Disabled', 'woo-feed' ); ?><!--</option>-->
138
+ <!-- <option value="enable"--><?php //selected( $settings['disable_pixel'], 'enable' ); ?><!-->--><?php //esc_html_e( 'Enabled', 'woo-feed' ); ?><!--</option>-->
139
+ <!-- </select>-->
140
+ <!-- </label>-->
141
+ <!-- <p class="description">--><?php //esc_html_e( 'Disables or Enables Facebook Pixel ID’s for Variation', 'woo-feed' ); ?><!--</p>-->
142
+ <!-- </td>-->
143
+ <!-- </tr>-->
144
+ <!-- <tr>-->
145
+ <!-- <th scope="row"><label for="pixel_id">--><?php //_e( 'Facebook Pixel Content ID’s for Variation', 'woo-feed' ); ?><!--</label></th>-->
146
+ <!-- <td>-->
147
+ <!-- <input class="regular-text" type="number" min="1" name="pixel_id" id="pixel_id" value="--><?php //echo esc_attr( $settings['pixel_id'] ); ?><!--">-->
148
+ <!-- <p class="description">--><?php //_e( 'Insert your Facebook Pixel ID', 'woo-feed' ); ?><!--</p>-->
149
+ <!-- </td>-->
150
+ <!-- </tr>-->
151
  <tr>
152
  <th scope="row"><label for="allow_all_shipping"><?php esc_html_e( 'Add shipping costs for all countries to feed (Google Shopping / Facebook only)', 'woo-feed' ); ?></label></th>
153
  <td>
admin/partials/woo-feed-status.php CHANGED
@@ -59,7 +59,7 @@
59
  </table>
60
  </div>
61
  <?php
62
- if( isset( $_POST['woo-feed-test-options-submit'] ) ) {
63
  $option_name = sanitize_text_field($_POST['woo-feed-test-options']);
64
 
65
  $get_option_val = maybe_unserialize(get_option($option_name));
59
  </table>
60
  </div>
61
  <?php
62
+ if ( isset( $_POST['woo-feed-test-options-submit'] ) ) {
63
  $option_name = sanitize_text_field($_POST['woo-feed-test-options']);
64
 
65
  $get_option_val = maybe_unserialize(get_option($option_name));
includes/classes/class-woo-feed-dropdown.php CHANGED
@@ -248,7 +248,7 @@ class Woo_Feed_Dropdown {
248
 
249
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
250
  //add all_in_one_seo_pack title array in the dropdown
251
- if( in_array( 'title', array_keys($attributes) ) ) {
252
  $search_key = 'title';
253
  $aioseop_title = [
254
  '_aioseop_title' => esc_html__( 'Title [All in One SEO]', 'woo-feed' ),
@@ -258,24 +258,23 @@ class Woo_Feed_Dropdown {
258
  }
259
 
260
  //add all_in_one_seo_pack description array in the dropdown
261
- if( in_array( 'description', array_keys($attributes) ) ) {
262
  $search_key = 'description';
263
  $aioseop_description = [
264
  '_aioseop_description' => esc_html__( 'Description [All in One SEO]', 'woo-feed' ),
265
  ];
266
 
267
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $aioseop_description );
268
- }
269
-
270
- }
271
 
272
 
273
  if ( class_exists( 'WPSEO_Frontend' ) ) {
274
  //add yoast title array in the dropdown
275
  $search_key = in_array( '_aioseop_title', array_keys($attributes) ) ? '_aioseop_title' : 'title';
276
  $yoast_title = [
277
- 'yoast_wpseo_title' => esc_html__( 'Title [Yoast SEO]', 'woo-feed' ),
278
- ];
279
 
280
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $yoast_title );
281
 
@@ -291,9 +290,9 @@ class Woo_Feed_Dropdown {
291
  if ( class_exists( 'RankMath' ) ) {
292
 
293
  //add rankmath title array in the dropdown
294
- if( in_array( 'yoast_wpseo_title', array_keys($attributes) ) ) {
295
  $search_key = 'yoast_wpseo_title';
296
- }elseif( in_array( '_aioseop_title', array_keys($attributes) ) ) {
297
  $search_key = '_aioseop_title';
298
  }else {
299
  $search_key = 'title';
@@ -305,9 +304,9 @@ class Woo_Feed_Dropdown {
305
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $rankmath_title );
306
 
307
  //add rankmath description array in the dropdown
308
- if( in_array( 'yoast_wpseo_metadesc', array_keys($attributes) ) ) {
309
  $search_key = 'yoast_wpseo_metadesc';
310
- }elseif( in_array( '_aioseop_description', array_keys($attributes) ) ) {
311
  $search_key = '_aioseop_description';
312
  }else {
313
  $search_key = 'description';
@@ -319,7 +318,7 @@ class Woo_Feed_Dropdown {
319
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $rankmath_description );
320
 
321
  //add rankmath canonical_url array in the dropdown
322
- if( in_array( 'canonical_link', array_keys($attributes) ) ) {
323
  $search_key = 'canonical_link';
324
  $rankmath_canonical_link = [
325
  'rank_math_canonical_url' => esc_html__( 'Rank Math Canonical URL [Rank Math SEO]', 'woo-feed' ),
@@ -642,7 +641,7 @@ class Woo_Feed_Dropdown {
642
  * @return string
643
  */
644
  public function google_shopping_actionAttributesDropdown( $selected = '' ) {
645
- return $this->googleAttributesDropdown( $selected, ['google_shopping_action'] );
646
  }
647
 
648
 
@@ -672,7 +671,7 @@ class Woo_Feed_Dropdown {
672
  * @return string
673
  */
674
  public function facebookAttributesDropdown( $selected = '' ) {
675
- return $this->googleAttributesDropdown( $selected, ['facebook'] );
676
  }
677
 
678
  /**
@@ -684,7 +683,7 @@ class Woo_Feed_Dropdown {
684
  * @return string
685
  */
686
  public function pinterestAttributesDropdown( $selected = '' ) {
687
- return $this->googleAttributesDropdown( $selected, ['pinterest'] );
688
  }
689
 
690
  /**
@@ -714,7 +713,7 @@ class Woo_Feed_Dropdown {
714
  * @return string
715
  */
716
  public function adrollAttributesDropdown( $selected = '' ) {
717
- return $this->googleAttributesDropdown( $selected, ['adroll'] );
718
  }
719
 
720
  /**
248
 
249
  if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
250
  //add all_in_one_seo_pack title array in the dropdown
251
+ if ( in_array( 'title', array_keys($attributes) ) ) {
252
  $search_key = 'title';
253
  $aioseop_title = [
254
  '_aioseop_title' => esc_html__( 'Title [All in One SEO]', 'woo-feed' ),
258
  }
259
 
260
  //add all_in_one_seo_pack description array in the dropdown
261
+ if ( in_array( 'description', array_keys($attributes) ) ) {
262
  $search_key = 'description';
263
  $aioseop_description = [
264
  '_aioseop_description' => esc_html__( 'Description [All in One SEO]', 'woo-feed' ),
265
  ];
266
 
267
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $aioseop_description );
268
+ }
269
+ }
 
270
 
271
 
272
  if ( class_exists( 'WPSEO_Frontend' ) ) {
273
  //add yoast title array in the dropdown
274
  $search_key = in_array( '_aioseop_title', array_keys($attributes) ) ? '_aioseop_title' : 'title';
275
  $yoast_title = [
276
+ 'yoast_wpseo_title' => esc_html__( 'Title [Yoast SEO]', 'woo-feed' ),
277
+ ];
278
 
279
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $yoast_title );
280
 
290
  if ( class_exists( 'RankMath' ) ) {
291
 
292
  //add rankmath title array in the dropdown
293
+ if ( in_array( 'yoast_wpseo_title', array_keys($attributes) ) ) {
294
  $search_key = 'yoast_wpseo_title';
295
+ }elseif ( in_array( '_aioseop_title', array_keys($attributes) ) ) {
296
  $search_key = '_aioseop_title';
297
  }else {
298
  $search_key = 'title';
304
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $rankmath_title );
305
 
306
  //add rankmath description array in the dropdown
307
+ if ( in_array( 'yoast_wpseo_metadesc', array_keys($attributes) ) ) {
308
  $search_key = 'yoast_wpseo_metadesc';
309
+ }elseif ( in_array( '_aioseop_description', array_keys($attributes) ) ) {
310
  $search_key = '_aioseop_description';
311
  }else {
312
  $search_key = 'description';
318
  $attributes = woo_feed_positioning_attribute_value( $attributes, $search_key, $rankmath_description );
319
 
320
  //add rankmath canonical_url array in the dropdown
321
+ if ( in_array( 'canonical_link', array_keys($attributes) ) ) {
322
  $search_key = 'canonical_link';
323
  $rankmath_canonical_link = [
324
  'rank_math_canonical_url' => esc_html__( 'Rank Math Canonical URL [Rank Math SEO]', 'woo-feed' ),
641
  * @return string
642
  */
643
  public function google_shopping_actionAttributesDropdown( $selected = '' ) {
644
+ return $this->googleAttributesDropdown( $selected, [ 'google_shopping_action' ] );
645
  }
646
 
647
 
671
  * @return string
672
  */
673
  public function facebookAttributesDropdown( $selected = '' ) {
674
+ return $this->googleAttributesDropdown( $selected, [ 'facebook' ] );
675
  }
676
 
677
  /**
683
  * @return string
684
  */
685
  public function pinterestAttributesDropdown( $selected = '' ) {
686
+ return $this->googleAttributesDropdown( $selected, [ 'pinterest' ] );
687
  }
688
 
689
  /**
713
  * @return string
714
  */
715
  public function adrollAttributesDropdown( $selected = '' ) {
716
+ return $this->googleAttributesDropdown( $selected, [ 'adroll' ] );
717
  }
718
 
719
  /**
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -189,12 +189,12 @@ class Woo_Feed_Products_v3
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',
@@ -204,7 +204,7 @@ class Woo_Feed_Products_v3
204
  'tax_region',
205
  'tax_rate',
206
  'tax_ship',
207
- )
208
  );
209
 
210
  /**
@@ -594,20 +594,20 @@ class Woo_Feed_Products_v3
594
  }
595
  }
596
 
597
- if( "shipping" === $merchant_attribute && in_array($merchant, ['google', 'facebook', 'bing', 'pinterest', 'snapchat']) ) {
598
  // Strip slash from output
599
  $attributeValue = stripslashes( $attributeValue );
600
- if( strpos($attributeValue, 'g:shipping') > 0 ) {
601
  $this->feedBody .= $attributeValue;
602
  }else {
603
  $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
604
  }
605
  $this->feedBody .= "\n";
606
- }elseif( "tax" === $merchant_attribute && in_array($merchant, ['google', 'facebook', 'bing', 'pinterest', 'snapchat']) ) {
607
  // Strip slash from output
608
  $attributeValue = stripslashes( $attributeValue );
609
 
610
- if( strpos($attributeValue, 'g:tax') > 0 ) {
611
  $this->feedBody .= $attributeValue;
612
  }else {
613
  $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
@@ -812,14 +812,14 @@ class Woo_Feed_Products_v3
812
  $sub = 0;
813
  $subscription = '';
814
  $ins = 0; // Installment Index
815
- $installment ="";
816
  $product_detail = '';
817
  $pd = 0;
818
 
819
 
820
  // Format Shipping and Tax data for CSV and TXT feed only for google and facebook
821
 
822
- if ( 'xml' != $this->config['feedType'] && in_array( $this->config['provider'], array( 'google', 'facebook','bing','snapchat','pinterest') ) ) {
823
  foreach ( $merchantAttributes as $key => $value ) {
824
 
825
  if ( ! in_array( $value, $this->google_shipping_tax ) ) {
@@ -827,36 +827,36 @@ class Woo_Feed_Products_v3
827
  }
828
 
829
  # Get value by attribute type with prefix & suffix
830
- $output=$this->process_for_merchant_get_value($productObj,$key);
831
 
832
  if ( 'tax_country' == $value ) {
833
  $t++;
834
- $tax.= $output;
835
  }
836
  if ( 'tax_region' == $value ) {
837
- $tax.= ':'.$output;
838
  }
839
  if ( 'tax_rate' == $value ) {
840
- $tax.= ':'.$output;
841
  }
842
  if ( 'tax_ship' == $value ) {
843
- $tax.= ':'.$output;
844
  }
845
 
846
 
847
  if ( 'shipping_country' == $value ) {
848
  $s++;
849
- $shipping.= $output;
850
  }
851
  if ( 'shipping_region' == $value ) {
852
- $shipping.= ':'.$output;
853
- }else if('shipping_postal_code' == $value){
854
- $shipping.= ':'.$output;
855
  }
856
  if ( 'shipping_service' == $value ) {
857
- $shipping.= ':'.$output;
858
  } if ( 'shipping_price' == $value ) {
859
- $shipping.= ':'.$output;
860
  }
861
 
862
  if ( 'section_name' == $value ) {
@@ -917,7 +917,7 @@ class Woo_Feed_Products_v3
917
  }
918
 
919
 
920
- if ( in_array( $this->config['provider'], array( 'google', 'facebook','snapchat','bing','pinterest') ) ) {
921
 
922
 
923
  // Reformat Shipping attributes for google, facebook
@@ -930,7 +930,7 @@ class Woo_Feed_Products_v3
930
 
931
 
932
  # Get value by attribute type with prefix & suffix
933
- $output=$this->process_for_merchant_get_value($productObj,$key);
934
 
935
 
936
  if ( 'shipping_country' == $value ) {
@@ -1094,22 +1094,22 @@ class Woo_Feed_Products_v3
1094
  $this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
1095
  }
1096
  } else {
1097
- $identifier_exists='identifier exists';
1098
- if(in_array( $this->config['provider'], array( 'bing','pinterest') )){
1099
- $identifier_exists='identifier_exists';
1100
  }
1101
 
1102
  if ( $countIdentifier >= 2 ) {
1103
- $this->products[ $this->pi ][$identifier_exists] = 'yes';
1104
  } else {
1105
- $this->products[ $this->pi ][$identifier_exists] = 'no';
1106
  }
1107
  }
1108
  }
1109
  }
1110
  }
1111
 
1112
- private function process_for_merchant_get_value($productObj,$key){
1113
  $prefix = $this->config['prefix'][ $key ];
1114
  $suffix = $this->config['suffix'][ $key ];
1115
  $attribute = $this->config['attributes'][ $key ];
@@ -1117,14 +1117,14 @@ class Woo_Feed_Products_v3
1117
 
1118
  if ( 'pattern' == $this->config['type'][ $key ] ) {// Get Pattern value.
1119
  $output = $this->config['default'][ $key ];
1120
- $output=$this->apply_filters_to_attribute_value($output,$productObj,$attribute,$merchant_attribute);
1121
  } else {
1122
  $output = $this->getAttributeValueByType( $productObj, $attribute, $merchant_attribute );
1123
  }
1124
 
1125
- $output=$this->format_output($output,$this->config['output_type'],$productObj,$attribute,$merchant_attribute);
1126
 
1127
- $output=$this->process_prefix_suffix( $output, $prefix, $suffix, $attribute = '' );
1128
 
1129
  return $output;
1130
  }
@@ -1511,8 +1511,8 @@ class Woo_Feed_Products_v3
1511
  * @return mixed
1512
  */
1513
  protected function parent_title( $product ) {
1514
- if( $product->is_type( 'variation' ) ) {
1515
- $product=wc_get_product($product->get_parent_id());
1516
  $title = $this->title($product);
1517
  }else {
1518
  $title = $this->title($product);
@@ -2002,8 +2002,8 @@ class Woo_Feed_Products_v3
2002
  * @return string
2003
  */
2004
  protected function parent_link( $product ) {
2005
- if( $product->is_type( 'variation' ) ) {
2006
- $product=wc_get_product($product->get_parent_id());
2007
  $link = $this->link($product);
2008
  }else {
2009
  $link = $this->link($product);
@@ -2310,7 +2310,7 @@ class Woo_Feed_Products_v3
2310
  * @return string
2311
  */
2312
  protected function sku_id( $product ) {
2313
- $sku = !empty($product->get_sku()) ? $product->get_sku() . '_' : '';
2314
 
2315
  return $sku . $product->get_id();
2316
  }
@@ -2367,8 +2367,8 @@ class Woo_Feed_Products_v3
2367
  * @return string
2368
  */
2369
  protected function add_to_cart_link( $product ) {
2370
- $url=$this->link($product);
2371
- $suffix='add-to-cart=' . $product->get_id();
2372
 
2373
  return woo_feed_make_url_with_parameter($url,$suffix);
2374
  }
@@ -2742,7 +2742,7 @@ class Woo_Feed_Products_v3
2742
  */
2743
  protected function shipping( $product ) {
2744
  $feedBody = '';
2745
- if( in_array($this->config['provider'], ['google', 'facebook', 'pinterest', 'bing', 'snapchat'] ) ) {
2746
  $get_shipping = new Woo_Feed_Shipping($product, $this->config);
2747
  $feedBody .= $get_shipping->get_google_shipping();
2748
  }
@@ -2844,7 +2844,7 @@ class Woo_Feed_Products_v3
2844
  */
2845
  protected function tax( $product ) {
2846
  $feedBody = '';
2847
- if( in_array($this->config['provider'], ['google', 'facebook', 'pinterest', 'bing', 'snapchat'] ) ) {
2848
  $shipping_obj = new Woo_Feed_Shipping($product, $this->config);
2849
  $feedBody .= $shipping_obj->get_google_tax();
2850
  }
@@ -3175,7 +3175,7 @@ class Woo_Feed_Products_v3
3175
  }
3176
  }
3177
 
3178
- if ( in_array( 8, $outputTypes ) && ! empty( $output ) && 'xml'===$this->config['feedType']) { // Add CDATA
3179
  $output = '<![CDATA[' . $output . ']]>';
3180
  }
3181
  }
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',
204
  'tax_region',
205
  'tax_rate',
206
  'tax_ship',
207
+ ),
208
  );
209
 
210
  /**
594
  }
595
  }
596
 
597
+ if ( "shipping" === $merchant_attribute && in_array($merchant, [ 'google', 'facebook', 'bing', 'pinterest', 'snapchat' ]) ) {
598
  // Strip slash from output
599
  $attributeValue = stripslashes( $attributeValue );
600
+ if ( strpos($attributeValue, 'g:shipping') > 0 ) {
601
  $this->feedBody .= $attributeValue;
602
  }else {
603
  $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
604
  }
605
  $this->feedBody .= "\n";
606
+ }elseif ( "tax" === $merchant_attribute && in_array($merchant, [ 'google', 'facebook', 'bing', 'pinterest', 'snapchat' ]) ) {
607
  // Strip slash from output
608
  $attributeValue = stripslashes( $attributeValue );
609
 
610
+ if ( strpos($attributeValue, 'g:tax') > 0 ) {
611
  $this->feedBody .= $attributeValue;
612
  }else {
613
  $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
812
  $sub = 0;
813
  $subscription = '';
814
  $ins = 0; // Installment Index
815
+ $installment = "";
816
  $product_detail = '';
817
  $pd = 0;
818
 
819
 
820
  // Format Shipping and Tax data for CSV and TXT feed only for google and facebook
821
 
822
+ if ( 'xml' != $this->config['feedType'] && in_array( $this->config['provider'], array( 'google', 'facebook', 'bing', 'snapchat', 'pinterest' ) ) ) {
823
  foreach ( $merchantAttributes as $key => $value ) {
824
 
825
  if ( ! in_array( $value, $this->google_shipping_tax ) ) {
827
  }
828
 
829
  # Get value by attribute type with prefix & suffix
830
+ $output = $this->process_for_merchant_get_value($productObj,$key);
831
 
832
  if ( 'tax_country' == $value ) {
833
  $t++;
834
+ $tax .= $output;
835
  }
836
  if ( 'tax_region' == $value ) {
837
+ $tax .= ':'.$output;
838
  }
839
  if ( 'tax_rate' == $value ) {
840
+ $tax .= ':'.$output;
841
  }
842
  if ( 'tax_ship' == $value ) {
843
+ $tax .= ':'.$output;
844
  }
845
 
846
 
847
  if ( 'shipping_country' == $value ) {
848
  $s++;
849
+ $shipping .= $output;
850
  }
851
  if ( 'shipping_region' == $value ) {
852
+ $shipping .= ':'.$output;
853
+ }else if ( 'shipping_postal_code' == $value ) {
854
+ $shipping .= ':'.$output;
855
  }
856
  if ( 'shipping_service' == $value ) {
857
+ $shipping .= ':'.$output;
858
  } if ( 'shipping_price' == $value ) {
859
+ $shipping .= ':'.$output;
860
  }
861
 
862
  if ( 'section_name' == $value ) {
917
  }
918
 
919
 
920
+ if ( in_array( $this->config['provider'], array( 'google', 'facebook', 'snapchat', 'bing', 'pinterest' ) ) ) {
921
 
922
 
923
  // Reformat Shipping attributes for google, facebook
930
 
931
 
932
  # Get value by attribute type with prefix & suffix
933
+ $output = $this->process_for_merchant_get_value($productObj,$key);
934
 
935
 
936
  if ( 'shipping_country' == $value ) {
1094
  $this->feedBody .= '<g:identifier_exists>no</g:identifier_exists>';
1095
  }
1096
  } else {
1097
+ $identifier_exists = 'identifier exists';
1098
+ if ( in_array( $this->config['provider'], array( 'bing', 'pinterest' ) ) ) {
1099
+ $identifier_exists = 'identifier_exists';
1100
  }
1101
 
1102
  if ( $countIdentifier >= 2 ) {
1103
+ $this->products[ $this->pi ][ $identifier_exists ] = 'yes';
1104
  } else {
1105
+ $this->products[ $this->pi ][ $identifier_exists ] = 'no';
1106
  }
1107
  }
1108
  }
1109
  }
1110
  }
1111
 
1112
+ private function process_for_merchant_get_value( $productObj,$key ) {
1113
  $prefix = $this->config['prefix'][ $key ];
1114
  $suffix = $this->config['suffix'][ $key ];
1115
  $attribute = $this->config['attributes'][ $key ];
1117
 
1118
  if ( 'pattern' == $this->config['type'][ $key ] ) {// Get Pattern value.
1119
  $output = $this->config['default'][ $key ];
1120
+ $output = $this->apply_filters_to_attribute_value($output,$productObj,$attribute,$merchant_attribute);
1121
  } else {
1122
  $output = $this->getAttributeValueByType( $productObj, $attribute, $merchant_attribute );
1123
  }
1124
 
1125
+ $output = $this->format_output($output,$this->config['output_type'],$productObj,$attribute,$merchant_attribute);
1126
 
1127
+ $output = $this->process_prefix_suffix( $output, $prefix, $suffix, $attribute = '' );
1128
 
1129
  return $output;
1130
  }
1511
  * @return mixed
1512
  */
1513
  protected function parent_title( $product ) {
1514
+ if ( $product->is_type( 'variation' ) ) {
1515
+ $product = wc_get_product($product->get_parent_id());
1516
  $title = $this->title($product);
1517
  }else {
1518
  $title = $this->title($product);
2002
  * @return string
2003
  */
2004
  protected function parent_link( $product ) {
2005
+ if ( $product->is_type( 'variation' ) ) {
2006
+ $product = wc_get_product($product->get_parent_id());
2007
  $link = $this->link($product);
2008
  }else {
2009
  $link = $this->link($product);
2310
  * @return string
2311
  */
2312
  protected function sku_id( $product ) {
2313
+ $sku = ! empty($product->get_sku()) ? $product->get_sku() . '_' : '';
2314
 
2315
  return $sku . $product->get_id();
2316
  }
2367
  * @return string
2368
  */
2369
  protected function add_to_cart_link( $product ) {
2370
+ $url = $this->link($product);
2371
+ $suffix = 'add-to-cart=' . $product->get_id();
2372
 
2373
  return woo_feed_make_url_with_parameter($url,$suffix);
2374
  }
2742
  */
2743
  protected function shipping( $product ) {
2744
  $feedBody = '';
2745
+ if ( in_array($this->config['provider'], [ 'google', 'facebook', 'pinterest', 'bing', 'snapchat' ] ) ) {
2746
  $get_shipping = new Woo_Feed_Shipping($product, $this->config);
2747
  $feedBody .= $get_shipping->get_google_shipping();
2748
  }
2844
  */
2845
  protected function tax( $product ) {
2846
  $feedBody = '';
2847
+ if ( in_array($this->config['provider'], [ 'google', 'facebook', 'pinterest', 'bing', 'snapchat' ] ) ) {
2848
  $shipping_obj = new Woo_Feed_Shipping($product, $this->config);
2849
  $feedBody .= $shipping_obj->get_google_tax();
2850
  }
3175
  }
3176
  }
3177
 
3178
+ if ( in_array( 8, $outputTypes ) && ! empty( $output ) && 'xml' === $this->config['feedType'] ) { // Add CDATA
3179
  $output = '<![CDATA[' . $output . ']]>';
3180
  }
3181
  }
includes/classes/class-woo-feed-shipping.php CHANGED
@@ -61,15 +61,15 @@ class Woo_Feed_Shipping {
61
  $sale_price_index = array_search('sale_price', $mattributes);
62
 
63
  //when feedCurrency is set to feed config setting, bring it or look at the prices suffix values.
64
- if( isset($this->config['feedCurrency']) ) {
65
  $currency = $this->config['feedCurrency'];
66
  }else {
67
- if( isset($price_index) && !empty($price_index) ) {
68
- $currency = $this->config['suffix'][$price_index];
69
 
70
  //when price attribute's suffix value is empty, check and bring sale_price attribute's suffix value if exists.
71
- if( empty($currency) && !empty($sale_price_index) ) {
72
- $currency = $this->config['suffix'][$sale_price_index];
73
  }
74
  }
75
  }
@@ -87,7 +87,7 @@ class Woo_Feed_Shipping {
87
  }
88
 
89
  public function set_shipping_zone() {
90
- if( class_exists( 'WC_Shipping_Zones' ) ) {
91
  return WC_Shipping_Zones::get_zones();
92
  }
93
  return false;
@@ -103,7 +103,7 @@ class Woo_Feed_Shipping {
103
  $shipping_info = [];
104
 
105
  foreach ( $this->shipping_zones as $zone ) {
106
- $shipping=[];
107
  foreach ( $zone['zone_locations'] as $zone_type ) {
108
  if ( $zone_type->type == "country" ) {
109
  // This is a country shipping zone
@@ -127,11 +127,11 @@ class Woo_Feed_Shipping {
127
  }
128
 
129
  //when allow_all_shipping is disabled and feed country doesn't match shipping country then skip the shipping method
130
- if( isset($this->settings) && is_array($this->settings) ) {
131
- if( array_key_exists('allow_all_shipping', $this->settings) ) {
132
  $all_country_shipping = $this->settings['allow_all_shipping'];
133
- if( !empty($all_country_shipping) && 'no' === $all_country_shipping ) {
134
- if ( $shipping['country'] !== $this->feed_country ) {
135
  unset($shipping);
136
  continue 2;
137
  }
@@ -143,7 +143,7 @@ class Woo_Feed_Shipping {
143
  $shipping_methods = $zone['shipping_methods'];
144
 
145
  // Continue loop if no shipping method defined.
146
- if(empty($shipping_methods)){
147
  unset($shipping);
148
  continue 2;
149
  }
@@ -197,26 +197,26 @@ class Woo_Feed_Shipping {
197
 
198
  //when only_local_pickup_shipping is disabled then skip the local pickup method
199
  if ( $method->id === "local_pickup" ) {
200
- if( isset($this->settings) && is_array($this->settings) ) {
201
- if( array_key_exists('only_local_pickup_shipping', $this->settings) ) {
202
  $allow_local_pickup = $this->settings['only_local_pickup_shipping'];
203
- if( !empty($allow_local_pickup) && 'no' === $allow_local_pickup ) {
204
  unset( $shipping );
205
  continue 3;
206
  }
207
  }
208
  }
209
  }
210
- }else{
211
  unset( $shipping );
212
  continue 3;
213
  }
214
 
215
  $shipping_cost = $this->get_shipping_cost($shipping);
216
- $shipping['price'] = (string) $shipping_cost;
217
 
218
  }
219
- $shipping_info[]=$shipping;
220
  }
221
  }
222
 
@@ -235,7 +235,7 @@ class Woo_Feed_Shipping {
235
  private function get_shipping_cost( $shipping ) {
236
  // Set shipping cost
237
  $shipping_cost = 0;
238
- $tax=0;
239
  defined( 'WC_ABSPATH' ) || exit;
240
 
241
  // Load cart functions which are loaded only on the front-end.
@@ -249,13 +249,13 @@ class Woo_Feed_Shipping {
249
  $woocommerce->cart->empty_cart();
250
 
251
  // Set Shipping Country.
252
- if(isset($shipping['country']) and !empty($shipping['country'])){
253
  $woocommerce->customer->set_shipping_country( $shipping['country'] );
254
  }
255
  // Set Shipping Region.
256
- if(isset($shipping['region']) and !empty($shipping['region'])){
257
  $woocommerce->customer->set_shipping_state( $shipping['region'] );
258
- }else{
259
  $woocommerce->customer->set_shipping_state("");
260
  }
261
 
@@ -264,10 +264,10 @@ class Woo_Feed_Shipping {
264
  // Read cart and get shipping costs
265
  foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
266
  $shipping_cost = $woocommerce->cart->get_shipping_total();
267
- $tax=$woocommerce->cart->get_shipping_tax();
268
  }
269
 
270
- $shipping_cost=$shipping_cost+$tax;
271
 
272
  // Make sure to empty the cart again
273
  $woocommerce->cart->empty_cart();
@@ -321,18 +321,18 @@ class Woo_Feed_Shipping {
321
  $shipping_arr = $this->get_shipping();
322
  $feedBody = "";
323
 
324
- if( "xml" === $this->config['feedType'] ) {
325
  $shipping_label = 'g:shipping';
326
 
327
- if( isset($shipping_arr) && is_array($shipping_arr) ) {
328
  $feedBody .= "<$shipping_label>"; //start shipping label
329
  $i = 0;
330
  $len = count($shipping_arr);
331
 
332
- foreach( $shipping_arr as $k => $shipping_item ) {
333
  $shipping_child = '';
334
- foreach( $shipping_item as $shipping_item_attr => $shipping_value ) {
335
- if( "price" === $shipping_item_attr ) {
336
  $shipping_value = $shipping_value . ' ' . $this->currency;
337
  }
338
 
@@ -342,7 +342,7 @@ class Woo_Feed_Shipping {
342
 
343
  // when loop is in last ride skip inserting labels, as it insert label with empty value
344
  $feedBody .= "$shipping_child";
345
- if( isset($shipping_child) && !empty($shipping_child) && $i !== $len - 1 ) {
346
  $feedBody .= "</$shipping_label>";
347
  $feedBody .= "\n";
348
  $feedBody .= "<$shipping_label>";
@@ -354,19 +354,18 @@ class Woo_Feed_Shipping {
354
 
355
  $feedBody .= "</$shipping_label>"; //end shipping label
356
  $feedBody .= "\n";
357
- }
358
-
359
- }elseif( in_array($this->config['feedType'], ['csv', 'tsv', 'xls']) ) {
360
 
361
- if( isset($shipping_arr) && is_array($shipping_arr) ) {
362
- foreach( $shipping_arr as $k => $shipping_item ) {
363
  $shipping_child = '';
364
- foreach( $shipping_item as $shipping_item_attr => $shipping_value ) {
365
- if( "price" === $shipping_item_attr ) {
366
  $shipping_value = $shipping_value . ' ' . $this->currency;
367
  }
368
 
369
- if( "postal_code" !== $shipping_item_attr ) {
370
  $shipping_child .= $shipping_value . ":";
371
  }
372
  }
@@ -396,17 +395,17 @@ class Woo_Feed_Shipping {
396
  $feedBody = "";
397
  $tax_rates = $this->get_tax_rates();
398
 
399
- if( "xml" === $this->config['feedType'] ) {
400
- if( isset($tax_rates) && is_array($tax_rates) ) {
401
  $tax_label = "g:tax";
402
  $feedBody .= "<$tax_label>"; //start tax label
403
  $i = 0;
404
  $len = count($tax_rates);
405
 
406
- foreach( $tax_rates as $k => $tax_item ) {
407
  $tax_child = '';
408
- foreach( $tax_item as $tax_item_attr => $tax_value ) {
409
- if( "rate" === $tax_item_attr ) {
410
  $tax_value = $tax_value . ' ' . $this->currency;
411
  }
412
 
@@ -417,7 +416,7 @@ class Woo_Feed_Shipping {
417
  // Strip slash from output
418
  // when loop is in last ride skip inserting labels, as it insert label with empty value
419
  $feedBody .= "$tax_child";
420
- if( isset($tax_child) && !empty($tax_child) && $i !== $len - 1 ) {
421
  $feedBody .= "</$tax_label>";
422
  $feedBody .= "\n";
423
  $feedBody .= "<$tax_label>";
@@ -431,17 +430,17 @@ class Woo_Feed_Shipping {
431
  $feedBody .= "\n";
432
 
433
  }
434
- }elseif( in_array($this->config['feedType'], ['csv', 'tsv', 'xls']) ) {
435
- if( isset($tax_rates) && is_array($tax_rates) ) {
436
- foreach( $tax_rates as $k => $tax_item ) {
437
  $tax_child = '';
438
- foreach( $tax_item as $tax_item_attr => $tax_value ) {
439
- if( "rate" === $tax_item_attr ) {
440
  $tax_value = $tax_value . ' ' . $this->currency;
441
  }
442
 
443
- if( "postal_code" !== $tax_item_attr ) {
444
- $tax_value = !empty($tax_value) ? $tax_value : '';
445
  $tax_child .= $tax_value . ":";
446
  }
447
  }
@@ -467,7 +466,7 @@ class Woo_Feed_Shipping {
467
  */
468
  public function get_tax_rates() {
469
  // Skip if product is not taxable.
470
- if (!$this->product->is_taxable()) {
471
  return "";
472
  }
473
 
@@ -478,22 +477,22 @@ class Woo_Feed_Shipping {
478
  $tax_classes = WC_Tax::get_tax_classes();
479
 
480
  // Make sure "Standard rate" (empty class name) is present.
481
- if (!in_array('', $tax_classes)) {
482
  array_unshift($tax_classes, '');
483
  }
484
 
485
  // For each tax class, get all rates.
486
- foreach ($tax_classes as $tax_class) {
487
  $taxes = WC_Tax::get_rates_for_tax_class($tax_class);
488
  $all_tax_rates = array_merge($all_tax_rates, $taxes);
489
  }
490
 
491
- if (!empty($all_tax_rates)) {
492
- foreach ($all_tax_rates as $rate_key => $rate) {
493
- $formatted_rates[$rate_key]['country'] = $rate->tax_rate_country;
494
- $formatted_rates[$rate_key]['region'] = $rate->tax_rate_state;
495
- $formatted_rates[$rate_key]['rate'] = $rate->tax_rate;
496
- $formatted_rates[$rate_key]['tax_ship'] = ($rate->tax_rate_shipping) ? 'yes' : 'no';
497
  }
498
  }
499
 
61
  $sale_price_index = array_search('sale_price', $mattributes);
62
 
63
  //when feedCurrency is set to feed config setting, bring it or look at the prices suffix values.
64
+ if ( isset($this->config['feedCurrency']) ) {
65
  $currency = $this->config['feedCurrency'];
66
  }else {
67
+ if ( isset($price_index) && ! empty($price_index) ) {
68
+ $currency = $this->config['suffix'][ $price_index ];
69
 
70
  //when price attribute's suffix value is empty, check and bring sale_price attribute's suffix value if exists.
71
+ if ( empty($currency) && ! empty($sale_price_index) ) {
72
+ $currency = $this->config['suffix'][ $sale_price_index ];
73
  }
74
  }
75
  }
87
  }
88
 
89
  public function set_shipping_zone() {
90
+ if ( class_exists( 'WC_Shipping_Zones' ) ) {
91
  return WC_Shipping_Zones::get_zones();
92
  }
93
  return false;
103
  $shipping_info = [];
104
 
105
  foreach ( $this->shipping_zones as $zone ) {
106
+ $shipping = [];
107
  foreach ( $zone['zone_locations'] as $zone_type ) {
108
  if ( $zone_type->type == "country" ) {
109
  // This is a country shipping zone
127
  }
128
 
129
  //when allow_all_shipping is disabled and feed country doesn't match shipping country then skip the shipping method
130
+ if ( isset($this->settings) && is_array($this->settings) ) {
131
+ if ( array_key_exists('allow_all_shipping', $this->settings) ) {
132
  $all_country_shipping = $this->settings['allow_all_shipping'];
133
+ if ( ! empty($all_country_shipping) && 'no' === $all_country_shipping ) {
134
+ if ( $shipping['country'] !== $this->feed_country ) {
135
  unset($shipping);
136
  continue 2;
137
  }
143
  $shipping_methods = $zone['shipping_methods'];
144
 
145
  // Continue loop if no shipping method defined.
146
+ if ( empty($shipping_methods) ) {
147
  unset($shipping);
148
  continue 2;
149
  }
197
 
198
  //when only_local_pickup_shipping is disabled then skip the local pickup method
199
  if ( $method->id === "local_pickup" ) {
200
+ if ( isset($this->settings) && is_array($this->settings) ) {
201
+ if ( array_key_exists('only_local_pickup_shipping', $this->settings) ) {
202
  $allow_local_pickup = $this->settings['only_local_pickup_shipping'];
203
+ if ( ! empty($allow_local_pickup) && 'no' === $allow_local_pickup ) {
204
  unset( $shipping );
205
  continue 3;
206
  }
207
  }
208
  }
209
  }
210
+ }else {
211
  unset( $shipping );
212
  continue 3;
213
  }
214
 
215
  $shipping_cost = $this->get_shipping_cost($shipping);
216
+ $shipping['price'] = (string) $shipping_cost;
217
 
218
  }
219
+ $shipping_info[] = $shipping;
220
  }
221
  }
222
 
235
  private function get_shipping_cost( $shipping ) {
236
  // Set shipping cost
237
  $shipping_cost = 0;
238
+ $tax = 0;
239
  defined( 'WC_ABSPATH' ) || exit;
240
 
241
  // Load cart functions which are loaded only on the front-end.
249
  $woocommerce->cart->empty_cart();
250
 
251
  // Set Shipping Country.
252
+ if ( isset($shipping['country']) and ! empty($shipping['country']) ) {
253
  $woocommerce->customer->set_shipping_country( $shipping['country'] );
254
  }
255
  // Set Shipping Region.
256
+ if ( isset($shipping['region']) and ! empty($shipping['region']) ) {
257
  $woocommerce->customer->set_shipping_state( $shipping['region'] );
258
+ }else {
259
  $woocommerce->customer->set_shipping_state("");
260
  }
261
 
264
  // Read cart and get shipping costs
265
  foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
266
  $shipping_cost = $woocommerce->cart->get_shipping_total();
267
+ $tax = $woocommerce->cart->get_shipping_tax();
268
  }
269
 
270
+ $shipping_cost = $shipping_cost + $tax;
271
 
272
  // Make sure to empty the cart again
273
  $woocommerce->cart->empty_cart();
321
  $shipping_arr = $this->get_shipping();
322
  $feedBody = "";
323
 
324
+ if ( "xml" === $this->config['feedType'] ) {
325
  $shipping_label = 'g:shipping';
326
 
327
+ if ( isset($shipping_arr) && is_array($shipping_arr) ) {
328
  $feedBody .= "<$shipping_label>"; //start shipping label
329
  $i = 0;
330
  $len = count($shipping_arr);
331
 
332
+ foreach ( $shipping_arr as $k => $shipping_item ) {
333
  $shipping_child = '';
334
+ foreach ( $shipping_item as $shipping_item_attr => $shipping_value ) {
335
+ if ( "price" === $shipping_item_attr ) {
336
  $shipping_value = $shipping_value . ' ' . $this->currency;
337
  }
338
 
342
 
343
  // when loop is in last ride skip inserting labels, as it insert label with empty value
344
  $feedBody .= "$shipping_child";
345
+ if ( isset($shipping_child) && ! empty($shipping_child) && $i !== $len - 1 ) {
346
  $feedBody .= "</$shipping_label>";
347
  $feedBody .= "\n";
348
  $feedBody .= "<$shipping_label>";
354
 
355
  $feedBody .= "</$shipping_label>"; //end shipping label
356
  $feedBody .= "\n";
357
+ }
358
+ }elseif ( in_array($this->config['feedType'], [ 'csv', 'tsv', 'xls' ]) ) {
 
359
 
360
+ if ( isset($shipping_arr) && is_array($shipping_arr) ) {
361
+ foreach ( $shipping_arr as $k => $shipping_item ) {
362
  $shipping_child = '';
363
+ foreach ( $shipping_item as $shipping_item_attr => $shipping_value ) {
364
+ if ( "price" === $shipping_item_attr ) {
365
  $shipping_value = $shipping_value . ' ' . $this->currency;
366
  }
367
 
368
+ if ( "postal_code" !== $shipping_item_attr ) {
369
  $shipping_child .= $shipping_value . ":";
370
  }
371
  }
395
  $feedBody = "";
396
  $tax_rates = $this->get_tax_rates();
397
 
398
+ if ( "xml" === $this->config['feedType'] ) {
399
+ if ( isset($tax_rates) && is_array($tax_rates) ) {
400
  $tax_label = "g:tax";
401
  $feedBody .= "<$tax_label>"; //start tax label
402
  $i = 0;
403
  $len = count($tax_rates);
404
 
405
+ foreach ( $tax_rates as $k => $tax_item ) {
406
  $tax_child = '';
407
+ foreach ( $tax_item as $tax_item_attr => $tax_value ) {
408
+ if ( "rate" === $tax_item_attr ) {
409
  $tax_value = $tax_value . ' ' . $this->currency;
410
  }
411
 
416
  // Strip slash from output
417
  // when loop is in last ride skip inserting labels, as it insert label with empty value
418
  $feedBody .= "$tax_child";
419
+ if ( isset($tax_child) && ! empty($tax_child) && $i !== $len - 1 ) {
420
  $feedBody .= "</$tax_label>";
421
  $feedBody .= "\n";
422
  $feedBody .= "<$tax_label>";
430
  $feedBody .= "\n";
431
 
432
  }
433
+ }elseif ( in_array($this->config['feedType'], [ 'csv', 'tsv', 'xls' ]) ) {
434
+ if ( isset($tax_rates) && is_array($tax_rates) ) {
435
+ foreach ( $tax_rates as $k => $tax_item ) {
436
  $tax_child = '';
437
+ foreach ( $tax_item as $tax_item_attr => $tax_value ) {
438
+ if ( "rate" === $tax_item_attr ) {
439
  $tax_value = $tax_value . ' ' . $this->currency;
440
  }
441
 
442
+ if ( "postal_code" !== $tax_item_attr ) {
443
+ $tax_value = ! empty($tax_value) ? $tax_value : '';
444
  $tax_child .= $tax_value . ":";
445
  }
446
  }
466
  */
467
  public function get_tax_rates() {
468
  // Skip if product is not taxable.
469
+ if ( ! $this->product->is_taxable() ) {
470
  return "";
471
  }
472
 
477
  $tax_classes = WC_Tax::get_tax_classes();
478
 
479
  // Make sure "Standard rate" (empty class name) is present.
480
+ if ( ! in_array('', $tax_classes) ) {
481
  array_unshift($tax_classes, '');
482
  }
483
 
484
  // For each tax class, get all rates.
485
+ foreach ( $tax_classes as $tax_class ) {
486
  $taxes = WC_Tax::get_rates_for_tax_class($tax_class);
487
  $all_tax_rates = array_merge($all_tax_rates, $taxes);
488
  }
489
 
490
+ if ( ! empty($all_tax_rates) ) {
491
+ foreach ( $all_tax_rates as $rate_key => $rate ) {
492
+ $formatted_rates[ $rate_key ]['country'] = $rate->tax_rate_country;
493
+ $formatted_rates[ $rate_key ]['region'] = $rate->tax_rate_state;
494
+ $formatted_rates[ $rate_key ]['rate'] = $rate->tax_rate;
495
+ $formatted_rates[ $rate_key ]['tax_ship'] = ($rate->tax_rate_shipping) ? 'yes' : 'no';
496
  }
497
  }
498
 
includes/helper.php CHANGED
@@ -2059,11 +2059,11 @@ if ( ! function_exists( 'woo_feed_add_cdata' ) ) {
2059
  * @return string
2060
  */
2061
  function woo_feed_add_cdata( $pluginAttribute, $attributeValue, $merchant, $feed_type ) {
2062
- if("xml"!==$feed_type){
2063
  return "$attributeValue";
2064
  }
2065
 
2066
- if ( "shipping" === $pluginAttribute || "tax" === $pluginAttribute ) {
2067
  return "$attributeValue";
2068
  }
2069
 
@@ -2125,8 +2125,8 @@ if ( ! function_exists( 'woo_feed_get_options' ) ) {
2125
  'overridden_structured_data' => 'on',
2126
  'disable_mpn' => 'enable',
2127
  'disable_brand' => 'enable',
2128
- 'disable_pixel' => 'enable',
2129
- 'pixel_id' => '',
2130
  'allow_all_shipping' => 'no',
2131
  'only_free_shipping' => 'yes',
2132
  'only_local_pickup_shipping' => 'no',
@@ -2219,20 +2219,20 @@ if ( ! function_exists( 'woo_feed_save_options' ) ) {
2219
  }
2220
  unset( $args['disable_brand'] );
2221
  }
2222
- if ( array_key_exists( 'disable_pixel', $args ) ) {
2223
- $data['disable_pixel'] = strtolower( $args['disable_pixel'] );
2224
- if ( ! in_array( $data['disable_pixel'], array( 'enable', 'disable' ) ) ) {
2225
- $data['disable_pixel'] = in_array( $_data['disable_pixel'], array( 'enable', 'disable' ) ) ? $_data['disable_pixel'] : $defaults['disable_pixel'];
2226
- }
2227
- unset( $args['disable_pixel'] );
2228
- }
2229
- if ( array_key_exists( 'pixel_id', $args ) ) {
2230
- $data['pixel_id'] = absint( $args['pixel_id'] );
2231
- if ( $data['pixel_id'] <= 0 ) {
2232
- $data['pixel_id'] = $_data['pixel_id'] > 0 ? $_data['pixel_id'] : $defaults['pixel_id'];
2233
- }
2234
- unset( $args['unset'] );
2235
- }
2236
  if ( array_key_exists( 'allow_all_shipping', $args ) ) {
2237
  $data['allow_all_shipping'] = strtolower( $args['allow_all_shipping'] );
2238
  if ( ! in_array( $data['allow_all_shipping'], array( 'yes', 'no' ) ) ) {
@@ -3118,7 +3118,7 @@ if ( ! function_exists( 'woo_feed_brand_taxonomy' ) ) {
3118
  $settings = woo_feed_get_options( 'all' );
3119
  $disable_brand = $settings['disable_brand'];
3120
 
3121
- if ( $disable_brand == 'disable' ) {
3122
  return false;
3123
  }
3124
 
@@ -3220,7 +3220,7 @@ if ( ! function_exists( 'woo_feed_product_structured_data' ) ) {
3220
  */
3221
  function woo_feed_product_structured_data() {
3222
 
3223
- if (is_product()) {
3224
  global $post;
3225
  $product = wc_get_product( $post->ID );
3226
 
@@ -3415,7 +3415,7 @@ if ( ! function_exists( 'woo_feed_pixel_script' ) ) {
3415
  // Product Tracking
3416
  if ( is_product() ) {
3417
  $product = wc_get_product( $post->ID );
3418
- if($product instanceof WC_Product) {
3419
  $product_price = $product->get_price();
3420
  $view_type .= "fbq('track', 'ViewContent', {
3421
  content_name: '$post->post_title',
@@ -3434,9 +3434,9 @@ if ( ! function_exists( 'woo_feed_pixel_script' ) ) {
3434
  global $wp_query;
3435
  if ( ! empty( $wp_query->query_vars['order-received'] ) ) {
3436
  $order = wc_get_order($wp_query->query_vars['order-received'] );
3437
- if($order instanceof WC_Order){
3438
  $price = $order->get_total();
3439
- $currency=$order->get_currency();
3440
  $view_type .= "fbq('track', 'Purchase', {
3441
  value: '$price',
3442
  currency: '$currency'
@@ -3468,7 +3468,7 @@ if ( ! function_exists( 'woo_feed_pixel_script' ) ) {
3468
  <?php
3469
  }
3470
  }
3471
- add_action('wp_head', 'woo_feed_pixel_script');
3472
  }
3473
 
3474
  if ( ! function_exists('woo_feed_addtocart' ) ) {
@@ -3486,7 +3486,7 @@ if ( ! function_exists('woo_feed_addtocart' ) ) {
3486
  if ( isset( $_REQUEST['add-to-cart'] ) ) {
3487
  $product_id = ! empty( $_REQUEST['add-to-cart'] ) ? $_REQUEST['add-to-cart'] : "";
3488
  $product = wc_get_product( (int)$product_id );
3489
- if($product instanceof WC_Product){
3490
  $product_name = $product->get_title();
3491
  $product_id = $product->get_id();
3492
  $product_price = $product->get_price();
@@ -3506,10 +3506,10 @@ if ( ! function_exists('woo_feed_addtocart' ) ) {
3506
  }
3507
  }
3508
  }
3509
- add_action( 'wp_head', 'woo_feed_addtocart' );
3510
  }
3511
 
3512
- if( ! function_exists( 'woo_feed_filter_dropdown_attributes' ) ) {
3513
  /**
3514
  * Woo Feed Filter Dropdown Attributes
3515
  *
@@ -3523,15 +3523,15 @@ if( ! function_exists( 'woo_feed_filter_dropdown_attributes' ) ) {
3523
  * @return array $filtered_attributes
3524
  *
3525
  */
3526
- function woo_feed_filter_dropdown_attributes($default_attr, $merchants) {
3527
  $filtered_attributes = $default_attr;
3528
 
3529
  //filtering attributes for pinterest merchant
3530
- if( in_array('pinterest', $merchants) ) {
3531
- if( isset($default_attr['ads_redirect']) ) {
3532
- if(array_key_exists( 'ads_redirect', $default_attr)) {
3533
  $keys = array_keys($default_attr);
3534
- $keys[array_search('ads_redirect', $keys)] = 'ads_link';
3535
  $filtered_attributes = array_combine($keys, $default_attr);
3536
  $filtered_attributes['ads_link'] = 'Ads Link[ads_link]';
3537
  }
@@ -3803,7 +3803,7 @@ if ( ! function_exists( 'woo_feed_countries' ) ) {
3803
  'EH' => 'Western Sahara',
3804
  'YE' => 'Yemen',
3805
  'ZM' => 'Zambia',
3806
- 'ZW' => 'Zimbabwe'
3807
  );
3808
 
3809
  }
@@ -3824,7 +3824,7 @@ if ( ! function_exists( 'woo_feed_positioning_attribute_value' ) ) {
3824
  * @since 4.3.18
3825
  * @return array $array
3826
  */
3827
- function woo_feed_positioning_attribute_value($array, $key, $input_array ){
3828
  $keys = array_keys( $array );
3829
  $index = array_search( $key, $keys, true );
3830
  $pos = false === $index ? count( $array ) : $index + 1;
2059
  * @return string
2060
  */
2061
  function woo_feed_add_cdata( $pluginAttribute, $attributeValue, $merchant, $feed_type ) {
2062
+ if ( "xml" !== $feed_type ) {
2063
  return "$attributeValue";
2064
  }
2065
 
2066
+ if ( "shipping" === $pluginAttribute || "tax" === $pluginAttribute ) {
2067
  return "$attributeValue";
2068
  }
2069
 
2125
  'overridden_structured_data' => 'on',
2126
  'disable_mpn' => 'enable',
2127
  'disable_brand' => 'enable',
2128
+ /*'disable_pixel' => 'enable',
2129
+ 'pixel_id' => '',*/
2130
  'allow_all_shipping' => 'no',
2131
  'only_free_shipping' => 'yes',
2132
  'only_local_pickup_shipping' => 'no',
2219
  }
2220
  unset( $args['disable_brand'] );
2221
  }
2222
+ // if ( array_key_exists( 'disable_pixel', $args ) ) {
2223
+ // $data['disable_pixel'] = strtolower( $args['disable_pixel'] );
2224
+ // if ( ! in_array( $data['disable_pixel'], array( 'enable', 'disable' ) ) ) {
2225
+ // $data['disable_pixel'] = in_array( $_data['disable_pixel'], array( 'enable', 'disable' ) ) ? $_data['disable_pixel'] : $defaults['disable_pixel'];
2226
+ // }
2227
+ // unset( $args['disable_pixel'] );
2228
+ // }
2229
+ // if ( array_key_exists( 'pixel_id', $args ) ) {
2230
+ // $data['pixel_id'] = absint( $args['pixel_id'] );
2231
+ // if ( $data['pixel_id'] <= 0 ) {
2232
+ // $data['pixel_id'] = $_data['pixel_id'] > 0 ? $_data['pixel_id'] : $defaults['pixel_id'];
2233
+ // }
2234
+ // unset( $args['unset'] );
2235
+ // }
2236
  if ( array_key_exists( 'allow_all_shipping', $args ) ) {
2237
  $data['allow_all_shipping'] = strtolower( $args['allow_all_shipping'] );
2238
  if ( ! in_array( $data['allow_all_shipping'], array( 'yes', 'no' ) ) ) {
3118
  $settings = woo_feed_get_options( 'all' );
3119
  $disable_brand = $settings['disable_brand'];
3120
 
3121
+ if ( $disable_brand == 'disable' ) {
3122
  return false;
3123
  }
3124
 
3220
  */
3221
  function woo_feed_product_structured_data() {
3222
 
3223
+ if ( is_product() ) {
3224
  global $post;
3225
  $product = wc_get_product( $post->ID );
3226
 
3415
  // Product Tracking
3416
  if ( is_product() ) {
3417
  $product = wc_get_product( $post->ID );
3418
+ if ( $product instanceof WC_Product ) {
3419
  $product_price = $product->get_price();
3420
  $view_type .= "fbq('track', 'ViewContent', {
3421
  content_name: '$post->post_title',
3434
  global $wp_query;
3435
  if ( ! empty( $wp_query->query_vars['order-received'] ) ) {
3436
  $order = wc_get_order($wp_query->query_vars['order-received'] );
3437
+ if ( $order instanceof WC_Order ) {
3438
  $price = $order->get_total();
3439
+ $currency = $order->get_currency();
3440
  $view_type .= "fbq('track', 'Purchase', {
3441
  value: '$price',
3442
  currency: '$currency'
3468
  <?php
3469
  }
3470
  }
3471
+ //add_action('wp_head', 'woo_feed_pixel_script');
3472
  }
3473
 
3474
  if ( ! function_exists('woo_feed_addtocart' ) ) {
3486
  if ( isset( $_REQUEST['add-to-cart'] ) ) {
3487
  $product_id = ! empty( $_REQUEST['add-to-cart'] ) ? $_REQUEST['add-to-cart'] : "";
3488
  $product = wc_get_product( (int)$product_id );
3489
+ if ( $product instanceof WC_Product ) {
3490
  $product_name = $product->get_title();
3491
  $product_id = $product->get_id();
3492
  $product_price = $product->get_price();
3506
  }
3507
  }
3508
  }
3509
+ //add_action( 'wp_head', 'woo_feed_addtocart' );
3510
  }
3511
 
3512
+ if ( ! function_exists( 'woo_feed_filter_dropdown_attributes' ) ) {
3513
  /**
3514
  * Woo Feed Filter Dropdown Attributes
3515
  *
3523
  * @return array $filtered_attributes
3524
  *
3525
  */
3526
+ function woo_feed_filter_dropdown_attributes( $default_attr, $merchants ) {
3527
  $filtered_attributes = $default_attr;
3528
 
3529
  //filtering attributes for pinterest merchant
3530
+ if ( in_array('pinterest', $merchants) ) {
3531
+ if ( isset($default_attr['ads_redirect']) ) {
3532
+ if ( array_key_exists( 'ads_redirect', $default_attr) ) {
3533
  $keys = array_keys($default_attr);
3534
+ $keys[ array_search('ads_redirect', $keys) ] = 'ads_link';
3535
  $filtered_attributes = array_combine($keys, $default_attr);
3536
  $filtered_attributes['ads_link'] = 'Ads Link[ads_link]';
3537
  }
3803
  'EH' => 'Western Sahara',
3804
  'YE' => 'Yemen',
3805
  'ZM' => 'Zambia',
3806
+ 'ZW' => 'Zimbabwe',
3807
  );
3808
 
3809
  }
3824
  * @since 4.3.18
3825
  * @return array $array
3826
  */
3827
+ function woo_feed_positioning_attribute_value( $array, $key, $input_array ) {
3828
  $keys = array_keys( $array );
3829
  $index = array_search( $key, $keys, true );
3830
  $pos = false === $index ? count( $array ) : $index + 1;
includes/log-helper.php CHANGED
@@ -36,7 +36,7 @@ if ( ! function_exists( 'woo_feed_get_logger' ) ) {
36
  return $logger;
37
  }
38
 
39
- if( !class_exists('WC_Logger') ) {
40
  return $logger;
41
  }
42
 
36
  return $logger;
37
  }
38
 
39
+ if ( ! class_exists('WC_Logger') ) {
40
  return $logger;
41
  }
42
 
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.18
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.18' );
42
  }
43
 
44
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
@@ -856,8 +856,8 @@ if ( ! function_exists( 'woo_feed_config_feed' ) ) {
856
  'overridden_structured_data' => isset( $_POST['overridden_structured_data'] ) ? sanitize_text_field( $_POST['overridden_structured_data'] ) : '',
857
  'disable_mpn' => isset( $_POST['disable_mpn'] ) ? sanitize_text_field( $_POST['disable_mpn'] ) : '',
858
  'disable_brand' => isset( $_POST['disable_brand'] ) ? sanitize_text_field( $_POST['disable_brand'] ) : '',
859
- 'disable_pixel' => isset( $_POST['disable_pixel'] ) ? sanitize_text_field( $_POST['disable_pixel'] ) : '',
860
- 'pixel_id' => isset( $_POST['pixel_id'] ) ? sanitize_text_field( $_POST['pixel_id'] ) : '',
861
  'allow_all_shipping' => isset( $_POST['allow_all_shipping'] ) ? sanitize_text_field( $_POST['allow_all_shipping'] ) : '',
862
  'only_free_shipping' => isset( $_POST['only_free_shipping'] ) ? sanitize_text_field( $_POST['only_free_shipping'] ) : '',
863
  'only_local_pickup_shipping' => isset( $_POST['only_local_pickup_shipping'] ) ? sanitize_text_field( $_POST['only_local_pickup_shipping'] ) : '',
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.19
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.19' );
42
  }
43
 
44
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
856
  'overridden_structured_data' => isset( $_POST['overridden_structured_data'] ) ? sanitize_text_field( $_POST['overridden_structured_data'] ) : '',
857
  'disable_mpn' => isset( $_POST['disable_mpn'] ) ? sanitize_text_field( $_POST['disable_mpn'] ) : '',
858
  'disable_brand' => isset( $_POST['disable_brand'] ) ? sanitize_text_field( $_POST['disable_brand'] ) : '',
859
+ /* 'disable_pixel' => isset( $_POST['disable_pixel'] ) ? sanitize_text_field( $_POST['disable_pixel'] ) : '',
860
+ 'pixel_id' => isset( $_POST['pixel_id'] ) ? sanitize_text_field( $_POST['pixel_id'] ) : '',*/
861
  'allow_all_shipping' => isset( $_POST['allow_all_shipping'] ) ? sanitize_text_field( $_POST['allow_all_shipping'] ) : '',
862
  'only_free_shipping' => isset( $_POST['only_free_shipping'] ) ? sanitize_text_field( $_POST['only_free_shipping'] ) : '',
863
  'only_local_pickup_shipping' => isset( $_POST['only_local_pickup_shipping'] ) ? sanitize_text_field( $_POST['only_local_pickup_shipping'] ) : '',