CTX Feed – WooCommerce Product Feed Manager Plugin - Version 4.3.16

Version Description

(2021-01-10) = * Added: Dynamic shipping and tax for Google, Facebook, Pinterest, Snapchat feed. * Added: Shipping cost attributes.

Download this release

Release Info

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

Code changes from version 4.3.15 to 4.3.16

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.15
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
 
@@ -308,6 +308,10 @@ Using pro version:
308
 
309
  == Changelog ==
310
 
 
 
 
 
311
  = 4.3.15 (2020-12-29) =
312
  * Fixed: Facebook pixel event issue solved.
313
 
8
  Requires at least: 3.6
9
  Tested Up To: 5.6
10
  Requires PHP: 5.6
11
+ Stable tag: 4.3.16
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.16 (2021-01-10) =
312
+ * Added: Dynamic shipping and tax for Google, Facebook, Pinterest, Snapchat feed.
313
+ * Added: Shipping cost attributes.
314
+
315
  = 4.3.15 (2020-12-29) =
316
  * Fixed: Facebook pixel event issue solved.
317
 
admin/partials/woo-feed-content-settings.php CHANGED
@@ -29,6 +29,17 @@ global $feedRules, $wooFeedDropDown, $merchant;
29
  </tr>
30
  </thead>
31
  <tbody>
 
 
 
 
 
 
 
 
 
 
 
32
  <tr>
33
  <th><label for="provider"><?php esc_html_e( 'Template', 'woo-feed' ); ?> <span class="requiredIn">*</span></label></th>
34
  <td>
29
  </tr>
30
  </thead>
31
  <tbody>
32
+ <tr>
33
+ <th><label for="feed_country"><?php esc_html_e( 'Country', 'woo-feed' ); ?> <span class="requiredIn">*</span></label></th>
34
+ <td>
35
+ <select wftitle="<?php esc_attr_e( 'Select a country', 'woo-feed' ); ?>" name="feed_country" id="feed_country" class="generalInput wfmasterTooltip" required>
36
+ <?php
37
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
38
+ echo $wooFeedDropDown->countriesDropdown( $feedRules['feed_country'] );
39
+ ?>
40
+ </select>
41
+ </td>
42
+ </tr>
43
  <tr>
44
  <th><label for="provider"><?php esc_html_e( 'Template', 'woo-feed' ); ?> <span class="requiredIn">*</span></label></th>
45
  <td>
admin/partials/woo-feed-settings.php CHANGED
@@ -147,6 +147,42 @@ $settings = woo_feed_get_options( 'all' );
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
  <?php do_action( 'woo_feed_after_settings_page_fields' ); ?>
152
  <tr>
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>
154
+ <label for="allow_all_shipping">
155
+ <select name="allow_all_shipping" id="allow_all_shipping">
156
+ <option value="no" <?php selected( $settings['allow_all_shipping'], 'no' ); ?>><?php esc_html_e( 'Disabled', 'woo-feed' ); ?></option>
157
+ <option value="yes" <?php selected( $settings['allow_all_shipping'], 'yes' ); ?>><?php esc_html_e( 'Enabled', 'woo-feed' ); ?></option>
158
+ </select>
159
+ </label>
160
+ <p class="description"><?php esc_html_e( 'Disables or Enables all shipping to feed', 'woo-feed' ); ?></p>
161
+ </td>
162
+ </tr>
163
+ <tr style="display: none;">
164
+ <th scope="row"><label for="only_free_shipping"><?php esc_html_e( 'Remove all other shipping classes when free shipping criteria are met (Google Shopping / Facebook only)', 'woo-feed' ); ?></label></th>
165
+ <td>
166
+ <label for="only_free_shipping">
167
+ <select name="only_free_shipping" id="only_free_shipping">
168
+ <option value="no" <?php selected( $settings['only_free_shipping'], 'no' ); ?>><?php esc_html_e( 'Disabled', 'woo-feed' ); ?></option>
169
+ <option value="yes" <?php selected( $settings['only_free_shipping'], 'yes' ); ?>><?php esc_html_e( 'Enabled', 'woo-feed' ); ?></option>
170
+ </select>
171
+ </label>
172
+ <p class="description"><?php esc_html_e( 'Disables or Enables all shipping when free shipping is exists', 'woo-feed' ); ?></p>
173
+ </td>
174
+ </tr>
175
+ <tr>
176
+ <th scope="row"><label for="only_local_pickup_shipping"><?php esc_html_e( 'Remove the local pickup shipping zone from feed (Google Shopping / Facebook only)', 'woo-feed' ); ?></label></th>
177
+ <td>
178
+ <label for="only_local_pickup_shipping">
179
+ <select name="only_local_pickup_shipping" id="only_local_pickup_shipping">
180
+ <option value="no" <?php selected( $settings['only_local_pickup_shipping'], 'no' ); ?>><?php esc_html_e( 'Disabled', 'woo-feed' ); ?></option>
181
+ <option value="yes" <?php selected( $settings['only_local_pickup_shipping'], 'yes' ); ?>><?php esc_html_e( 'Enabled', 'woo-feed' ); ?></option>
182
+ </select>
183
+ </label>
184
+ <p class="description"><?php esc_html_e( 'Disables or Enables all shipping when local pickup shipping is exists', 'woo-feed' ); ?></p>
185
+ </td>
186
  </tr>
187
  <?php do_action( 'woo_feed_after_settings_page_fields' ); ?>
188
  <tr>
includes/class-woo-feed.php CHANGED
@@ -143,6 +143,11 @@ class Woo_Feed {
143
  * The class is a FTP library
144
  */
145
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-ftp.php';
 
 
 
 
 
146
 
147
  /**
148
  * The class responsible for save feed
143
  * The class is a FTP library
144
  */
145
  require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-ftp.php';
146
+
147
+ /**
148
+ * The class is a shipping calculation library
149
+ */
150
+ require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-shipping.php';
151
 
152
  /**
153
  * The class responsible for save feed
includes/classes/class-woo-feed-default-attributes.php CHANGED
@@ -73,15 +73,12 @@ class Woo_Feed_Default_Attributes {
73
  'tax_rate' => array( 'g:tax_rate', true ),
74
  'tax_ship' => array( 'g:tax_ship', true ),
75
  'tax_category' => array( 'g:tax_category', true ),
 
76
  'weight' => array( 'g:shipping_weight', false ),
77
  'length' => array( 'g:shipping_length', false ),
78
  'width' => array( 'g:shipping_width', false ),
79
  'height' => array( 'g:shipping_height', false ),
80
  'shipping_label' => array( 'g:shipping_label', false ),
81
- 'shipping_country' => array( 'g:shipping_country', false ),
82
- 'shipping_service' => array( 'g:shipping_service', false ),
83
- 'shipping_price' => array( 'g:shipping_price', false ),
84
- 'shipping_region' => array( 'g:shipping_region', false ),
85
  'multipack' => array( 'g:multipack', true ),
86
  'is_bundle' => array( 'g:is_bundle', true ),
87
  'adult' => array( 'g:adult', true ),
@@ -194,11 +191,8 @@ class Woo_Feed_Default_Attributes {
194
  'size_type' => array( 'size type', true ),
195
  'size_system' => array( 'size system', true ),
196
  'tax' => array( 'tax', true ),
197
- 'tax_country' => array( 'tax country', true ),
198
- 'tax_region' => array( 'tax region', true ),
199
- 'tax_rate' => array( 'tax rate', true ),
200
- 'tax_ship' => array( 'tax ship', true ),
201
  'tax_category' => array( 'tax category', true ),
 
202
  'weight' => array( 'shipping weight', false ),
203
  'length' => array( 'shipping length', false ),
204
  'width' => array( 'shipping width', false ),
@@ -660,10 +654,7 @@ class Woo_Feed_Default_Attributes {
660
  'tax_rate' => 'Tax Rate[tax_rate]',
661
  'tax_ship' => 'Tax Ship[tax_ship]',
662
  'tax_category' => 'Tax[tax_category]',
663
- 'shipping_country' => 'Shipping Country',
664
- 'shipping_region' => 'Shipping Region',
665
- 'shipping_service' => 'Shipping Service',
666
- 'shipping_price' => 'Shipping Price',
667
  'weight' => 'Shipping Weight[shipping_weight]',
668
  'length' => 'Shipping Length[shipping_length]',
669
  'width' => 'Shipping Width[shipping_width]',
73
  'tax_rate' => array( 'g:tax_rate', true ),
74
  'tax_ship' => array( 'g:tax_ship', true ),
75
  'tax_category' => array( 'g:tax_category', true ),
76
+ 'shipping' => array( 'g:shipping', true ),
77
  'weight' => array( 'g:shipping_weight', false ),
78
  'length' => array( 'g:shipping_length', false ),
79
  'width' => array( 'g:shipping_width', false ),
80
  'height' => array( 'g:shipping_height', false ),
81
  'shipping_label' => array( 'g:shipping_label', false ),
 
 
 
 
82
  'multipack' => array( 'g:multipack', true ),
83
  'is_bundle' => array( 'g:is_bundle', true ),
84
  'adult' => array( 'g:adult', true ),
191
  'size_type' => array( 'size type', true ),
192
  'size_system' => array( 'size system', true ),
193
  'tax' => array( 'tax', true ),
 
 
 
 
194
  'tax_category' => array( 'tax category', true ),
195
+ 'shipping' => array( 'shipping', true ),
196
  'weight' => array( 'shipping weight', false ),
197
  'length' => array( 'shipping length', false ),
198
  'width' => array( 'shipping width', false ),
654
  'tax_rate' => 'Tax Rate[tax_rate]',
655
  'tax_ship' => 'Tax Ship[tax_ship]',
656
  'tax_category' => 'Tax[tax_category]',
657
+ 'shipping' => 'Shipping',
 
 
 
658
  'weight' => 'Shipping Weight[shipping_weight]',
659
  'length' => 'Shipping Length[shipping_length]',
660
  'width' => 'Shipping Width[shipping_width]',
includes/classes/class-woo-feed-dropdown.php CHANGED
@@ -55,6 +55,21 @@ class Woo_Feed_Dropdown {
55
  }
56
  return $options;
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  /**
60
  * @param int|int[] $selected
@@ -207,6 +222,8 @@ class Woo_Feed_Dropdown {
207
  'width' => esc_html__( 'Width', 'woo-feed' ),
208
  'height' => esc_html__( 'Height', 'woo-feed' ),
209
  'length' => esc_html__( 'Length', 'woo-feed' ),
 
 
210
  'shipping_class' => esc_html__( 'Shipping Class', 'woo-feed' ),
211
  'type' => esc_html__( 'Product Type', 'woo-feed' ),
212
  'variation_type' => esc_html__( 'Variation Type', 'woo-feed' ),
@@ -220,6 +237,7 @@ class Woo_Feed_Dropdown {
220
  'author_email' => esc_html__( 'Author Email', 'woo-feed' ),
221
  'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
222
  'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
 
223
  'tax_class' => esc_html__( 'Tax Class', 'woo-feed' ),
224
  'tax_status' => esc_html__( 'Tax Status', 'woo-feed' ),
225
  'woo_feed_gtin' => esc_html__( 'GTIN', 'woo-feed' ),
55
  }
56
  return $options;
57
  }
58
+
59
+ /**
60
+ * Dropdown of Country List
61
+ *
62
+ * @param string $selected
63
+ *
64
+ * @return string
65
+ */
66
+ public function countriesDropdown( $selected = '' ) {
67
+ $options = $this->get_cached_dropdown( 'countriesDropdown', $selected );
68
+ if ( false === $options ) {
69
+ $options = $this->cache_dropdown( 'countriesDropdown', woo_feed_countries(), $selected );
70
+ }
71
+ return $options;
72
+ }
73
 
74
  /**
75
  * @param int|int[] $selected
222
  'width' => esc_html__( 'Width', 'woo-feed' ),
223
  'height' => esc_html__( 'Height', 'woo-feed' ),
224
  'length' => esc_html__( 'Length', 'woo-feed' ),
225
+ 'shipping' => esc_html__( 'Shipping (Google Format)', 'woo-feed' ),
226
+ 'shipping_cost' => esc_html__( 'Shipping Cost', 'woo-feed' ),
227
  'shipping_class' => esc_html__( 'Shipping Class', 'woo-feed' ),
228
  'type' => esc_html__( 'Product Type', 'woo-feed' ),
229
  'variation_type' => esc_html__( 'Variation Type', 'woo-feed' ),
237
  'author_email' => esc_html__( 'Author Email', 'woo-feed' ),
238
  'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
239
  'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
240
+ 'tax' => esc_html__( 'Tax', 'woo-feed' ),
241
  'tax_class' => esc_html__( 'Tax Class', 'woo-feed' ),
242
  'tax_status' => esc_html__( 'Tax Status', 'woo-feed' ),
243
  'woo_feed_gtin' => esc_html__( 'GTIN', 'woo-feed' ),
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -593,7 +593,33 @@ class Woo_Feed_Products_v3
593
  $getReplacedAttribute = trim($getReplacedAttribute, 'g:');
594
  }
595
  }
596
- $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  }
598
 
599
  $this->feedBody .= "\n";
@@ -2705,6 +2731,40 @@ class Woo_Feed_Products_v3
2705
  return $product->get_length();
2706
  }
2707
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2708
  /**
2709
  * Get Product Shipping Class
2710
  *
@@ -2774,6 +2834,75 @@ class Woo_Feed_Products_v3
2774
  return gmdate('Y-m-d', strtotime($product->get_date_modified()));
2775
  }
2776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2777
  /**
2778
  * Get Product Tax class
2779
  * @param WC_Product $product Product object.
593
  $getReplacedAttribute = trim($getReplacedAttribute, 'g:');
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 . '>';
614
+ }
615
+
616
+ $this->feedBody .= "\n";
617
+ }else {
618
+ // Strip slash from output
619
+ $attributeValue = stripslashes( $attributeValue );
620
+ $this->feedBody .= '<' . $getReplacedAttribute . '>' . "$attributeValue" . '</' . $getReplacedAttribute . '>';
621
+ $this->feedBody .= "\n";
622
+ }
623
  }
624
 
625
  $this->feedBody .= "\n";
2731
  return $product->get_length();
2732
  }
2733
 
2734
+ /**
2735
+ * Get Product Shipping
2736
+ *
2737
+ * @param WC_Product $product
2738
+ *
2739
+ * @return mixed
2740
+ * @since 4.3.16
2741
+ * @author Nazrul Islam Nayan
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
+ }
2749
+
2750
+ return $feedBody;
2751
+
2752
+ }
2753
+
2754
+ /**
2755
+ * Get Product Shipping Cost
2756
+ *
2757
+ * @param WC_Product $product
2758
+ *
2759
+ * @return mixed
2760
+ * @since 5.1.20
2761
+ * @author Nazrul Islam Nayan
2762
+ */
2763
+ protected function shipping_cost( $product ) {
2764
+ $shipping_obj = new Woo_Feed_Shipping($product, $this->config);
2765
+ return $shipping_obj->get_lowest_shipping_price();
2766
+ }
2767
+
2768
  /**
2769
  * Get Product Shipping Class
2770
  *
2834
  return gmdate('Y-m-d', strtotime($product->get_date_modified()));
2835
  }
2836
 
2837
+ /**
2838
+ * Get Product Tax
2839
+ *
2840
+ * @param WC_Product $product Product object.
2841
+ * @return mixed
2842
+ * @since 5.1.20
2843
+ * @author Nazrul Islam Nayan
2844
+ */
2845
+ protected function tax( $product ) {
2846
+ $feedBody = '';
2847
+ if( in_array($this->config['provider'], ['google', 'facebook', 'pinterest', 'bing', 'snapchat'] ) ) {
2848
+ $get_tax_rates = new Woo_Feed_Shipping($product, $this->config);
2849
+ $tax_rates = $get_tax_rates->get_tax_rates();
2850
+
2851
+ if( "xml" === $this->config['feedType'] ) {
2852
+ if( isset($tax_rates) && is_array($tax_rates) ) {
2853
+ $tax_label = "g:tax";
2854
+ $feedBody .= "<$tax_label>"; //start tax label
2855
+ $i = 0;
2856
+ $len = count($tax_rates);
2857
+
2858
+ foreach( $tax_rates as $k => $tax_item ) {
2859
+ $tax_child = '';
2860
+ foreach( $tax_item as $tax_item_attr => $tax_value ) {
2861
+ $tax_child .= '<' . $tax_item_attr . '>' . "$tax_value" . '</' . $tax_item_attr . '>';
2862
+ $tax_child = stripslashes( $tax_child );
2863
+ }
2864
+
2865
+ // when loop is in last ride skip inserting labels, as it insert label with empty value
2866
+ $feedBody .= "$tax_child";
2867
+ if( isset($tax_child) && !empty($tax_child) && $i !== $len - 1 ) {
2868
+ $feedBody .= "</$tax_label>";
2869
+ $feedBody .= "\n";
2870
+ $feedBody .= "<$tax_label>";
2871
+ }
2872
+
2873
+ unset($tax_child); //unset for not to join all item together
2874
+ $i++;
2875
+ }
2876
+
2877
+ $feedBody .= "</$tax_label>"; //end tax label
2878
+ $feedBody .= "\n";
2879
+
2880
+ }
2881
+ }elseif( in_array($this->config['feedType'], ['csv', 'tsv', 'xls']) ) {
2882
+ if( isset($tax_rates) && is_array($tax_rates) ) {
2883
+ foreach( $tax_rates as $k => $tax_item ) {
2884
+ $tax_child = '';
2885
+ foreach( $tax_item as $tax_item_attr => $tax_value ) {
2886
+ if( "postal_code" !== $tax_item_attr ) {
2887
+ $tax_value = !empty($tax_value) ? $tax_value : '';
2888
+ $tax_child .= $tax_value . ":";
2889
+ }
2890
+ }
2891
+ $tax_child = trim( $tax_child, ":" );
2892
+
2893
+ //add separator for multiple tax
2894
+ $feedBody .= $tax_child . '||';
2895
+ }
2896
+
2897
+ //trim last extra sign
2898
+ $feedBody = trim($feedBody, '||');
2899
+ }
2900
+ }
2901
+ }
2902
+
2903
+ return $feedBody;
2904
+ }
2905
+
2906
  /**
2907
  * Get Product Tax class
2908
  * @param WC_Product $product Product object.
includes/classes/class-woo-feed-shipping.php ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Woo_Feed_Shipping {
3
+ /**
4
+ * @var WC_Product $product Contain product object.
5
+ */
6
+ private $product;
7
+
8
+ /**
9
+ * @var array $settings Contain plugin setting.
10
+ */
11
+ private $settings;
12
+
13
+ /**
14
+ * @var string $currency Currency sign like `USD`, `EUR`.
15
+ */
16
+ private $currency;
17
+
18
+ /**
19
+ * @var string $class_cost_id Shipping class cost id.
20
+ */
21
+ private $class_cost_id;
22
+ /**
23
+ * @var array $shipping_zones Contain Shipping Zone info.
24
+ */
25
+ private $shipping_zones;
26
+ /**
27
+ * @var string $country
28
+ */
29
+ private $feed_country;
30
+ /**
31
+ * @var array $config Contain feed configuration.
32
+ */
33
+ private $config;
34
+
35
+ public function __construct( $product, $feed_config ) {
36
+ $this->config = $feed_config;
37
+ $this->product = $product;
38
+ $this->class_cost_id = $this->set_shipping_class_id();
39
+ $this->shipping_zones = $this->set_shipping_zone();
40
+ $this->feed_country = $this->set_country();
41
+ $this->settings = woo_feed_get_options( 'all' );
42
+ $this->currency = $this->get_currency();
43
+ }
44
+
45
+
46
+ private function set_country() {
47
+ return $this->config['feed_country'];
48
+ }
49
+
50
+ /**
51
+ * Get current feed currency.
52
+ *
53
+ * @since 5.2.0
54
+ * @author Nazrul Islam Nayan
55
+ * @return string $currency feed currency
56
+ */
57
+ private function get_currency() {
58
+ $currency = '';
59
+ $mattributes = $this->config['mattributes'];
60
+ $price_index = array_search('price', $mattributes);
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
+ }
76
+
77
+ return $currency;
78
+ }
79
+
80
+ private function set_shipping_class_id() {
81
+ $class_cost_id = "class_cost_" . $this->product->get_shipping_class_id();
82
+ if ( $class_cost_id == "class_cost_0" ) {
83
+ return 'no_class_cost';
84
+ }
85
+
86
+ return $class_cost_id;
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;
94
+ }
95
+
96
+ /**
97
+ * Get shipping information.
98
+ *
99
+ * @since 5.2.0
100
+ * @return array $shipping_info shipping information
101
+ */
102
+ public function get_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
110
+ $shipping['country'] = $zone_type->code;
111
+ } elseif ( $zone_type->type == "code" ) {
112
+ // This is a country shipping zone
113
+ $shipping['country'] = $zone_type->code;
114
+ } elseif ( $zone_type->type == "state" ) {
115
+ // This is a state shipping zone, split of country
116
+ $zone_explode = explode( ":", $zone_type->code );
117
+ $shipping['country'] = $zone_explode[0];
118
+
119
+ //TODO Adding a region is only allowed for these countries
120
+ $region_countries = array( 'US', 'JP', 'AU' );
121
+ $shipping['region'] = $zone_explode[1];
122
+
123
+ } elseif ( $zone_type->type == "postcode" ) {
124
+ // Create an array of postal codes so we can loop over it later
125
+ $zone_type->code = str_replace( "...", "-", $zone_type->code );
126
+ $shipping['postal_code'] = $zone_type->code;
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
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+
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
+ }
150
+
151
+
152
+ foreach ( $shipping_methods as $method ) {
153
+ if ( 'yes' === $method->enabled ) {
154
+
155
+ //when only_free_shipping is enabled and shipping is not free shipping then skip the shipping method
156
+ // if( isset($this->settings) && is_array($this->settings) ) {
157
+ // if( array_key_exists('only_free_shipping', $this->settings) ) {
158
+ // $only_free_shipping = $this->settings['only_free_shipping'];
159
+ // if( empty($only_free_shipping) || 'yes' === $only_free_shipping ) {
160
+ // if ( "free_shipping" !== $method->id ) {
161
+ // unset( $shipping );
162
+ // continue;
163
+ // }
164
+ // }
165
+ // }
166
+ // }
167
+
168
+ // if ($method->id == "free_shipping") {
169
+ // $minimum_fee = $method->min_amount;
170
+ //
171
+ // // Set type to double otherwise the >= doesn't work
172
+ // settype($minimum_fee, "double");
173
+ //
174
+ // // Only Free Shipping when product price is over or equal to minimum order fee
175
+ // if ($this->product->get_price() >= $minimum_fee) {
176
+ // $shipping['free'] = "yes";
177
+ // } else {
178
+ // // There are no free shipping requirements
179
+ // if ($method->requires === "") {
180
+ // $shipping['free'] = "yes";
181
+ // } else {
182
+ // // No Free Shipping Allowed for this product
183
+ // //unset($zone_details);
184
+ // unset($shipping['service']);
185
+ // unset($shipping['price']);
186
+ // unset($shipping);
187
+ // }
188
+ // }
189
+ // }
190
+
191
+
192
+ if ( empty( $shipping['country'] ) ) {
193
+ $shipping['service'] = $zone['zone_name'] . " " . $method->title;
194
+ } else {
195
+ $shipping['service'] = $zone['zone_name'] . " " . $method->title . " " . $shipping['country'];
196
+ }
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
+
223
+ return $shipping_info;
224
+ }
225
+
226
+
227
+ /**
228
+ * Get shipping cost.
229
+ *
230
+ * @param $shipping array shipping information
231
+ *
232
+ * @since 5.2.0
233
+ * @return mixed $shipping_cost shipping cost
234
+ */
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.
242
+ include_once WC_ABSPATH . 'includes/wc-cart-functions.php';
243
+ include_once WC_ABSPATH . 'includes/class-wc-cart.php';
244
+
245
+ wc_load_cart();
246
+ global $woocommerce;
247
+
248
+ // Make sure to empty the cart again
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
+
262
+ $woocommerce->cart->add_to_cart( $this->product->get_id(), 1 );
263
+
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();
274
+
275
+ return $shipping_cost;
276
+ }
277
+
278
+ /**
279
+ * Get lowest shipping price.
280
+ *
281
+ * @since 5.2.0
282
+ * @author Nazrul Islam Nayan
283
+ * @return mixed
284
+ */
285
+ public function get_lowest_shipping_price() {
286
+ return min( wp_list_pluck( $this->get_shipping(), 'price' ) );
287
+ }
288
+
289
+ /**
290
+ * Get highest shipping price.
291
+ *
292
+ * @since 5.2.0
293
+ * @author Nazrul Islam Nayan
294
+ * @return mixed
295
+ */
296
+ public function get_highest_shipping_price() {
297
+ return max( wp_list_pluck( $this->get_shipping(), 'price' ) );
298
+ }
299
+
300
+ /**
301
+ * Get first shipping price.
302
+ *
303
+ * @since 5.2.0
304
+ * @author Nazrul Islam Nayan
305
+ * @return mixed
306
+ */
307
+ public function get_first_shipping_price() {
308
+ $shipping_prices = wp_list_pluck( $this->get_shipping(), 'price' );
309
+
310
+ return reset( $shipping_prices );
311
+ }
312
+
313
+ /**
314
+ * Get google shipping feed structure for XML/CSV feed type.
315
+ *
316
+ * @since 5.2.0
317
+ * @author Nazrul Islam Nayan
318
+ * @return string $feedBody shipping feed structure
319
+ */
320
+ public function get_google_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
+
339
+ $shipping_child .= '<' . $shipping_item_attr . '>' . $shipping_value . '</' . $shipping_item_attr . '>';
340
+ $shipping_child = stripslashes( $shipping_child );
341
+ }
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>";
349
+ }
350
+
351
+ unset($shipping_child); //unset for not to join all item together
352
+ $i++;
353
+ }
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
+ }
373
+ $shipping_child = trim( $shipping_child, ":" );
374
+
375
+ //add separator for multiple shipping method
376
+ $feedBody .= $shipping_child . '||';
377
+ }
378
+
379
+ //trim last extra sign
380
+ $feedBody = trim($feedBody, '||');
381
+ }
382
+ }
383
+
384
+ return $feedBody;
385
+ }
386
+
387
+
388
+ /**
389
+ * Get google tax feed structure for XML/CSV feed type.
390
+ *
391
+ * @since 5.2.0
392
+ * @author Nazrul Islam Nayan
393
+ * @return string $feedBody tax feed structure
394
+ */
395
+ public function get_google_tax() {
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
+ $tax_child .= '<' . $tax_item_attr . '>' . "$tax_value" . '</' . $tax_item_attr . '>';
410
+ $tax_child = stripslashes( $tax_child );
411
+ }
412
+
413
+ // Strip slash from output
414
+ // when loop is in last ride skip inserting labels, as it insert label with empty value
415
+ $feedBody .= "$tax_child";
416
+ if( isset($tax_child) && !empty($tax_child) && $i !== $len - 1 ) {
417
+ $feedBody .= "</$tax_label>";
418
+ $feedBody .= "\n";
419
+ $feedBody .= "<$tax_label>";
420
+ }
421
+
422
+ unset($tax_child); //unset for not to join all item together
423
+ $i++;
424
+ }
425
+
426
+ $feedBody .= "</$tax_label>"; //end tax label
427
+ $feedBody .= "\n";
428
+
429
+ }
430
+ }elseif( in_array($this->config['feedType'], ['csv', 'tsv', 'xls']) ) {
431
+ if( isset($tax_rates) && is_array($tax_rates) ) {
432
+ foreach( $tax_rates as $k => $tax_item ) {
433
+ $tax_child = '';
434
+ foreach( $tax_item as $tax_item_attr => $tax_value ) {
435
+ if( "postal_code" !== $tax_item_attr ) {
436
+ $tax_value = !empty($tax_value) ? $tax_value : '';
437
+ $tax_child .= $tax_value . ":";
438
+ }
439
+ }
440
+ $tax_child = trim( $tax_child, ":" );
441
+
442
+ //add separator for multiple tax
443
+ $feedBody .= $tax_child . '||';
444
+ }
445
+
446
+ //trim last extra sign
447
+ $feedBody = trim($feedBody, '||');
448
+ }
449
+ }
450
+
451
+ return $feedBody;
452
+ }
453
+
454
+ /**
455
+ * Get tax rates.
456
+ *
457
+ * @since 5.2.0
458
+ * @return mixed
459
+ */
460
+ public function get_tax_rates() {
461
+ // Skip if product is not taxable.
462
+ if (!$this->product->is_taxable()) {
463
+ return "";
464
+ }
465
+
466
+ $all_tax_rates = [];
467
+ $formatted_rates = [];
468
+
469
+ // Retrieve all tax classes.
470
+ $tax_classes = WC_Tax::get_tax_classes();
471
+
472
+ // Make sure "Standard rate" (empty class name) is present.
473
+ if (!in_array('', $tax_classes)) {
474
+ array_unshift($tax_classes, '');
475
+ }
476
+
477
+ // For each tax class, get all rates.
478
+ foreach ($tax_classes as $tax_class) {
479
+ $taxes = WC_Tax::get_rates_for_tax_class($tax_class);
480
+ $all_tax_rates = array_merge($all_tax_rates, $taxes);
481
+ }
482
+
483
+ if (!empty($all_tax_rates)) {
484
+ foreach ($all_tax_rates as $rate_key => $rate) {
485
+ $formatted_rates[$rate_key]['country'] = $rate->tax_rate_country;
486
+ $formatted_rates[$rate_key]['region'] = $rate->tax_rate_state;
487
+ $formatted_rates[$rate_key]['rate'] = $rate->tax_rate;
488
+ $formatted_rates[$rate_key]['tax_ship'] = ($rate->tax_rate_shipping) ? 'yes' : 'no';
489
+ }
490
+ }
491
+
492
+ return $formatted_rates;
493
+ }
494
+ }
includes/helper.php CHANGED
@@ -2063,6 +2063,10 @@ if ( ! function_exists( 'woo_feed_add_cdata' ) ) {
2063
  return "$attributeValue";
2064
  }
2065
 
 
 
 
 
2066
  if ( strpos( $attributeValue, '<![CDATA[' ) !== false ) {
2067
  return "$attributeValue";
2068
  }
@@ -2123,6 +2127,9 @@ if ( ! function_exists( 'woo_feed_get_options' ) ) {
2123
  'disable_brand' => 'enable',
2124
  'disable_pixel' => 'enable',
2125
  'pixel_id' => '',
 
 
 
2126
  ];
2127
 
2128
  /**
@@ -2226,6 +2233,29 @@ if ( ! function_exists( 'woo_feed_save_options' ) ) {
2226
  }
2227
  unset( $args['unset'] );
2228
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2229
  if ( ! empty( $args ) ) {
2230
  foreach ( $args as $key => $value ) {
2231
  if ( has_filter( "woo_feed_save_{$key}_option" ) ) {
@@ -3513,4 +3543,270 @@ if( ! function_exists( 'woo_feed_filter_dropdown_attributes' ) ) {
3513
  add_filter('woo_feed_filter_dropdown_attributes', 'woo_feed_filter_dropdown_attributes', 2, 10);
3514
  }
3515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3516
  // End of file helper.php.
2063
  return "$attributeValue";
2064
  }
2065
 
2066
+ if ( "shipping" === $pluginAttribute || "tax" === $pluginAttribute ) {
2067
+ return "$attributeValue";
2068
+ }
2069
+
2070
  if ( strpos( $attributeValue, '<![CDATA[' ) !== false ) {
2071
  return "$attributeValue";
2072
  }
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',
2133
  ];
2134
 
2135
  /**
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' ) ) ) {
2239
+ $data['allow_all_shipping'] = in_array( $_data['allow_all_shipping'], array( 'yes', 'no' ) ) ? $_data['allow_all_shipping'] : $defaults['allow_all_shipping'];
2240
+ }
2241
+ unset( $args['allow_all_shipping'] );
2242
+ }
2243
+
2244
+ if ( array_key_exists( 'only_free_shipping', $args ) ) {
2245
+ $data['only_free_shipping'] = strtolower( $args['only_free_shipping'] );
2246
+ if ( ! in_array( $data['only_free_shipping'], array( 'yes', 'no' ) ) ) {
2247
+ $data['only_free_shipping'] = in_array( $_data['only_free_shipping'], array( 'yes', 'no' ) ) ? $_data['only_free_shipping'] : $defaults['only_free_shipping'];
2248
+ }
2249
+ unset( $args['only_free_shipping'] );
2250
+ }
2251
+
2252
+ if ( array_key_exists( 'only_local_pickup_shipping', $args ) ) {
2253
+ $data['only_local_pickup_shipping'] = strtolower( $args['only_local_pickup_shipping'] );
2254
+ if ( ! in_array( $data['only_local_pickup_shipping'], array( 'yes', 'no' ) ) ) {
2255
+ $data['only_local_pickup_shipping'] = in_array( $_data['only_local_pickup_shipping'], array( 'yes', 'no' ) ) ? $_data['only_local_pickup_shipping'] : $defaults['only_local_pickup_shipping'];
2256
+ }
2257
+ unset( $args['only_local_pickup_shipping'] );
2258
+ }
2259
  if ( ! empty( $args ) ) {
2260
  foreach ( $args as $key => $value ) {
2261
  if ( has_filter( "woo_feed_save_{$key}_option" ) ) {
3543
  add_filter('woo_feed_filter_dropdown_attributes', 'woo_feed_filter_dropdown_attributes', 2, 10);
3544
  }
3545
 
3546
+
3547
+ if ( ! function_exists( 'woo_feed_countries' ) ) {
3548
+ /**
3549
+ * Woo Feed Country List
3550
+ *
3551
+ * @author Nazrul Islam Nayan
3552
+ * @updated 10-01-2021
3553
+ *
3554
+ * @since 4.3.16
3555
+ * @return array
3556
+ */
3557
+
3558
+ function woo_feed_countries() {
3559
+
3560
+ return array(
3561
+ 'AF' => 'Afghanistan',
3562
+ 'AX' => 'Aland Islands',
3563
+ 'AL' => 'Albania',
3564
+ 'DZ' => 'Algeria',
3565
+ 'AS' => 'American Samoa',
3566
+ 'AD' => 'Andorra',
3567
+ 'AO' => 'Angola',
3568
+ 'AI' => 'Anguilla',
3569
+ 'AQ' => 'Antarctica',
3570
+ 'AG' => 'Antigua and Barbuda',
3571
+ 'AR' => 'Argentina',
3572
+ 'AM' => 'Armenia',
3573
+ 'AW' => 'Aruba',
3574
+ 'AU' => 'Australia',
3575
+ 'AT' => 'Austria',
3576
+ 'AZ' => 'Azerbaijan',
3577
+ 'BS' => 'Bahamas the',
3578
+ 'BH' => 'Bahrain',
3579
+ 'BD' => 'Bangladesh',
3580
+ 'BB' => 'Barbados',
3581
+ 'BY' => 'Belarus',
3582
+ 'BE' => 'Belgium',
3583
+ 'BZ' => 'Belize',
3584
+ 'BJ' => 'Benin',
3585
+ 'BM' => 'Bermuda',
3586
+ 'BT' => 'Bhutan',
3587
+ 'BO' => 'Bolivia',
3588
+ 'BA' => 'Bosnia and Herzegovina',
3589
+ 'BW' => 'Botswana',
3590
+ 'BV' => 'Bouvet Island (Bouvetoya)',
3591
+ 'BR' => 'Brazil',
3592
+ 'IO' => 'British Indian Ocean Territory (Chagos Archipelago)',
3593
+ 'VG' => 'British Virgin Islands',
3594
+ 'BN' => 'Brunei Darussalam',
3595
+ 'BG' => 'Bulgaria',
3596
+ 'BF' => 'Burkina Faso',
3597
+ 'BI' => 'Burundi',
3598
+ 'KH' => 'Cambodia',
3599
+ 'CM' => 'Cameroon',
3600
+ 'CA' => 'Canada',
3601
+ 'CV' => 'Cape Verde',
3602
+ 'KY' => 'Cayman Islands',
3603
+ 'CF' => 'Central African Republic',
3604
+ 'TD' => 'Chad',
3605
+ 'CL' => 'Chile',
3606
+ 'CN' => 'China',
3607
+ 'CX' => 'Christmas Island',
3608
+ 'CC' => 'Cocos (Keeling) Islands',
3609
+ 'CO' => 'Colombia',
3610
+ 'KM' => 'Comoros the',
3611
+ 'CD' => 'Congo',
3612
+ 'CG' => 'Congo the',
3613
+ 'CK' => 'Cook Islands',
3614
+ 'CR' => 'Costa Rica',
3615
+ 'CI' => 'Cote d\'Ivoire',
3616
+ 'HR' => 'Croatia',
3617
+ 'CU' => 'Cuba',
3618
+ 'CY' => 'Cyprus',
3619
+ 'CZ' => 'Czech Republic',
3620
+ 'DK' => 'Denmark',
3621
+ 'DJ' => 'Djibouti',
3622
+ 'DM' => 'Dominica',
3623
+ 'DO' => 'Dominican Republic',
3624
+ 'EC' => 'Ecuador',
3625
+ 'EG' => 'Egypt',
3626
+ 'SV' => 'El Salvador',
3627
+ 'GQ' => 'Equatorial Guinea',
3628
+ 'ER' => 'Eritrea',
3629
+ 'EE' => 'Estonia',
3630
+ 'ET' => 'Ethiopia',
3631
+ 'FO' => 'Faroe Islands',
3632
+ 'FK' => 'Falkland Islands (Malvinas)',
3633
+ 'FJ' => 'Fiji the Fiji Islands',
3634
+ 'FI' => 'Finland',
3635
+ 'FR' => 'France',
3636
+ 'GF' => 'French Guiana',
3637
+ 'PF' => 'French Polynesia',
3638
+ 'TF' => 'French Southern Territories',
3639
+ 'GA' => 'Gabon',
3640
+ 'GM' => 'Gambia the',
3641
+ 'GE' => 'Georgia',
3642
+ 'DE' => 'Germany',
3643
+ 'GH' => 'Ghana',
3644
+ 'GI' => 'Gibraltar',
3645
+ 'GR' => 'Greece',
3646
+ 'GL' => 'Greenland',
3647
+ 'GD' => 'Grenada',
3648
+ 'GP' => 'Guadeloupe',
3649
+ 'GU' => 'Guam',
3650
+ 'GT' => 'Guatemala',
3651
+ 'GG' => 'Guernsey',
3652
+ 'GN' => 'Guinea',
3653
+ 'GW' => 'Guinea-Bissau',
3654
+ 'GY' => 'Guyana',
3655
+ 'HT' => 'Haiti',
3656
+ 'HM' => 'Heard Island and McDonald Islands',
3657
+ 'VA' => 'Holy See (Vatican City State)',
3658
+ 'HN' => 'Honduras',
3659
+ 'HK' => 'Hong Kong',
3660
+ 'HU' => 'Hungary',
3661
+ 'IS' => 'Iceland',
3662
+ 'IN' => 'India',
3663
+ 'ID' => 'Indonesia',
3664
+ 'IR' => 'Iran',
3665
+ 'IQ' => 'Iraq',
3666
+ 'IE' => 'Ireland',
3667
+ 'IM' => 'Isle of Man',
3668
+ 'IL' => 'Israel',
3669
+ 'IT' => 'Italy',
3670
+ 'JM' => 'Jamaica',
3671
+ 'JP' => 'Japan',
3672
+ 'JE' => 'Jersey',
3673
+ 'JO' => 'Jordan',
3674
+ 'KZ' => 'Kazakhstan',
3675
+ 'KE' => 'Kenya',
3676
+ 'KI' => 'Kiribati',
3677
+ 'KP' => 'Korea',
3678
+ 'KR' => 'Korea',
3679
+ 'KW' => 'Kuwait',
3680
+ 'KG' => 'Kyrgyz Republic',
3681
+ 'LA' => 'Lao',
3682
+ 'LV' => 'Latvia',
3683
+ 'LB' => 'Lebanon',
3684
+ 'LS' => 'Lesotho',
3685
+ 'LR' => 'Liberia',
3686
+ 'LY' => 'Libyan Arab Jamahiriya',
3687
+ 'LI' => 'Liechtenstein',
3688
+ 'LT' => 'Lithuania',
3689
+ 'LU' => 'Luxembourg',
3690
+ 'MO' => 'Macao',
3691
+ 'MK' => 'Macedonia',
3692
+ 'MG' => 'Madagascar',
3693
+ 'MW' => 'Malawi',
3694
+ 'MY' => 'Malaysia',
3695
+ 'MV' => 'Maldives',
3696
+ 'ML' => 'Mali',
3697
+ 'MT' => 'Malta',
3698
+ 'MH' => 'Marshall Islands',
3699
+ 'MQ' => 'Martinique',
3700
+ 'MR' => 'Mauritania',
3701
+ 'MU' => 'Mauritius',
3702
+ 'YT' => 'Mayotte',
3703
+ 'MX' => 'Mexico',
3704
+ 'FM' => 'Micronesia',
3705
+ 'MD' => 'Moldova',
3706
+ 'MC' => 'Monaco',
3707
+ 'MN' => 'Mongolia',
3708
+ 'ME' => 'Montenegro',
3709
+ 'MS' => 'Montserrat',
3710
+ 'MA' => 'Morocco',
3711
+ 'MZ' => 'Mozambique',
3712
+ 'MM' => 'Myanmar',
3713
+ 'NA' => 'Namibia',
3714
+ 'NR' => 'Nauru',
3715
+ 'NP' => 'Nepal',
3716
+ 'AN' => 'Netherlands Antilles',
3717
+ 'NL' => 'Netherlands',
3718
+ 'NC' => 'New Caledonia',
3719
+ 'NZ' => 'New Zealand',
3720
+ 'NI' => 'Nicaragua',
3721
+ 'NE' => 'Niger',
3722
+ 'NG' => 'Nigeria',
3723
+ 'NU' => 'Niue',
3724
+ 'NF' => 'Norfolk Island',
3725
+ 'MP' => 'Northern Mariana Islands',
3726
+ 'NO' => 'Norway',
3727
+ 'OM' => 'Oman',
3728
+ 'PK' => 'Pakistan',
3729
+ 'PW' => 'Palau',
3730
+ 'PS' => 'Palestinian Territory',
3731
+ 'PA' => 'Panama',
3732
+ 'PG' => 'Papua New Guinea',
3733
+ 'PY' => 'Paraguay',
3734
+ 'PE' => 'Peru',
3735
+ 'PH' => 'Philippines',
3736
+ 'PN' => 'Pitcairn Islands',
3737
+ 'PL' => 'Poland',
3738
+ 'PT' => 'Portugal, Portuguese Republic',
3739
+ 'PR' => 'Puerto Rico',
3740
+ 'QA' => 'Qatar',
3741
+ 'RE' => 'Reunion',
3742
+ 'RO' => 'Romania',
3743
+ 'RU' => 'Russian Federation',
3744
+ 'RW' => 'Rwanda',
3745
+ 'BL' => 'Saint Barthelemy',
3746
+ 'SH' => 'Saint Helena',
3747
+ 'KN' => 'Saint Kitts and Nevis',
3748
+ 'LC' => 'Saint Lucia',
3749
+ 'MF' => 'Saint Martin',
3750
+ 'PM' => 'Saint Pierre and Miquelon',
3751
+ 'VC' => 'Saint Vincent and the Grenadines',
3752
+ 'WS' => 'Samoa',
3753
+ 'SM' => 'San Marino',
3754
+ 'ST' => 'Sao Tome and Principe',
3755
+ 'SA' => 'Saudi Arabia',
3756
+ 'SN' => 'Senegal',
3757
+ 'RS' => 'Serbia',
3758
+ 'SC' => 'Seychelles',
3759
+ 'SL' => 'Sierra Leone',
3760
+ 'SG' => 'Singapore',
3761
+ 'SK' => 'Slovakia (Slovak Republic)',
3762
+ 'SI' => 'Slovenia',
3763
+ 'SB' => 'Solomon Islands',
3764
+ 'SO' => 'Somalia, Somali Republic',
3765
+ 'ZA' => 'South Africa',
3766
+ 'GS' => 'South Georgia and the South Sandwich Islands',
3767
+ 'ES' => 'Spain',
3768
+ 'LK' => 'Sri Lanka',
3769
+ 'SD' => 'Sudan',
3770
+ 'SR' => 'Suriname',
3771
+ 'SJ' => 'Svalbard & Jan Mayen Islands',
3772
+ 'SZ' => 'Swaziland',
3773
+ 'SE' => 'Sweden',
3774
+ 'CH' => 'Switzerland',
3775
+ 'SY' => 'Syrian Arab Republic',
3776
+ 'TW' => 'Taiwan',
3777
+ 'TJ' => 'Tajikistan',
3778
+ 'TZ' => 'Tanzania',
3779
+ 'TH' => 'Thailand',
3780
+ 'TL' => 'Timor-Leste',
3781
+ 'TG' => 'Togo',
3782
+ 'TK' => 'Tokelau',
3783
+ 'TO' => 'Tonga',
3784
+ 'TT' => 'Trinidad and Tobago',
3785
+ 'TN' => 'Tunisia',
3786
+ 'TR' => 'Turkey',
3787
+ 'TM' => 'Turkmenistan',
3788
+ 'TC' => 'Turks and Caicos Islands',
3789
+ 'TV' => 'Tuvalu',
3790
+ 'UG' => 'Uganda',
3791
+ 'UA' => 'Ukraine',
3792
+ 'AE' => 'United Arab Emirates',
3793
+ 'GB' => 'United Kingdom',
3794
+ 'US' => 'United States',
3795
+ 'UM' => 'United States Minor Outlying Islands',
3796
+ 'VI' => 'United States Virgin Islands',
3797
+ 'UY' => 'Uruguay, Eastern Republic of',
3798
+ 'UZ' => 'Uzbekistan',
3799
+ 'VU' => 'Vanuatu',
3800
+ 'VE' => 'Venezuela',
3801
+ 'VN' => 'Vietnam',
3802
+ 'WF' => 'Wallis and Futuna',
3803
+ 'EH' => 'Western Sahara',
3804
+ 'YE' => 'Yemen',
3805
+ 'ZM' => 'Zambia',
3806
+ 'ZW' => 'Zimbabwe'
3807
+ );
3808
+
3809
+ }
3810
+ }
3811
+
3812
  // 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.15
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.15' );
42
  }
43
 
44
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
@@ -858,6 +858,9 @@ if ( ! function_exists( 'woo_feed_config_feed' ) ) {
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
  ];
862
 
863
  woo_feed_save_options( $data );
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.16
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.16' );
42
  }
43
 
44
  if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
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'] ) : '',
864
  ];
865
 
866
  woo_feed_save_options( $data );