CTX Feed – WooCommerce Product Feed Manager Plugin - Version 2.2.5

Version Description

Download this release

Release Info

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

Code changes from version 2.1.29 to 2.2.5

README.txt CHANGED
@@ -1,23 +1,25 @@
1
  === WooCommerce Product Feed : Google Shopping,Facebook Product Ad,eBay and Many More ===
2
  Contributors: wahid0003
3
  Donate link: https://webappick.com
4
- Tags:woocommerce,Google Merchant Feed,facebook product feed,eBay,bing,pricegrabber,nextag,pricerunner,kelkoo,feed,woocommerce feed,woocommerce product feed, txt export, csv export, xml export,woocommerce export,product export, newegg,rakuten,houzz,godatafeed,pricefalls,google merchant,google shopping,sell,sears,variation export,shareasale,etsy,Buy,Getprice,LeGuide,Twenga,Beslist,Kieskeurig,HotLine,Yandex.Market,product variation,connexity,Commission Junction,channel advisor,dealtime,shopbot,shopzilla,yahoo,Getprice,Gimme,Junglee,Myshopping,Priceme,Shopmania,Wine-searcher
5
  Requires at least: 3.6
6
  Tested up to: 4.9
7
- Stable tag: 2.1.28
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Get Real Buyer and Boost Your Sell by Uploading your Products to 100+ Shopping Engines Like Google Merchant,Facebook,PriceSpy,eBay,Idealo.
12
 
13
  == Description ==
14
 
15
- **WooCommerce Product Feed** generate product feed or data feed to Sync your products with your merchant center like Google Shopping,Facebook Product Ads,Idealo.de, shopbot.ca etc. The main target of this plugin is to generate product feed, automatically update product information into feed file according to given schedule and sync your product to different shopping engines via HTTP or FTP so that real buyer can get your product into shopping engines like Google Shopping, pricegrabber, pricerunner, nextag,ebay and many more.<br/><br/> Compatible with WooCommerce 3.0+
16
  <blockquote>
17
  <h4>Free version support unlimited feed with up to 2000 products including variations.</h4>
18
  <br/>
19
  <h4><b><a target="_blank" href="http://webappick.com/plugin/woocommerce-product-feed-pro/">Premium Version</a></b> have some additional awesome features which are not included into free version</h4>
20
  <br/>
 
 
21
  </blockquote>
22
  **WHAT IS PRODUCT FEED?**
23
 
@@ -266,6 +268,26 @@ Using pro version:
266
 
267
  == Changelog ==
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  = 2.1.29(2018-01-09) =
270
  * Added: Bonanza, Real, LeGuide and Crowdfox template added
271
 
1
  === WooCommerce Product Feed : Google Shopping,Facebook Product Ad,eBay and Many More ===
2
  Contributors: wahid0003
3
  Donate link: https://webappick.com
4
+ Tags:woocommerce,Google Merchant Feed,Facebook product feed,eBay,Bing,pricegrabber,nextag,pricerunner,kelkoo,feed,woocommerce feed,woocommerce product feed, txt export, csv export, xml export,woocommerce export,product export, newegg,rakuten,houzz,godatafeed,pricefalls,google merchant,google shopping,sell,sears,variation export,shareasale,etsy,Buy,Getprice,LeGuide,Twenga,Beslist,Kieskeurig,HotLine,Yandex.Market,product variation,connexity,Commission Junction,channel advisor,dealtime,shopbot,shopzilla,yahoo,Getprice,Gimme,Junglee,Myshopping,Priceme,Shopmania,Wine-searcher
5
  Requires at least: 3.6
6
  Tested up to: 4.9
7
+ Stable tag: 4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Get Real Buyer and Boost Your Sell by Uploading your Products to 100+ Shopping Engines Like Google Merchant,Facebook,Bing,eBay,Amazon.
12
 
13
  == Description ==
14
 
15
+ **WooCommerce Product Feed** generate product feed or data feed to Sync your products with your merchant center like Google Shopping,Facebook Product Ads,Bing Ads, eBay, Amazon etc. The main target of this plugin is to generate product feed, automatically update product information into feed file according to given schedule and sync your product to different shopping engines via HTTP or FTP so that real buyer can get your product into shopping engines like Google Shopping, pricegrabber, pricerunner, nextag,ebay and many more.<br/><br/> Compatible with WooCommerce 3.0+
16
  <blockquote>
17
  <h4>Free version support unlimited feed with up to 2000 products including variations.</h4>
18
  <br/>
19
  <h4><b><a target="_blank" href="http://webappick.com/plugin/woocommerce-product-feed-pro/">Premium Version</a></b> have some additional awesome features which are not included into free version</h4>
20
  <br/>
21
+ <h4><b>Premium version also support WooCommerce <a target="_blank" href="https://woocommerce.com/products/composite-products/">Composite</a> and <a target="_blank" href="https://woocommerce.com/products/product-bundles/">Bundle</a></b> Products</h4>
22
+ <br/>
23
  </blockquote>
24
  **WHAT IS PRODUCT FEED?**
25
 
268
 
269
  == Changelog ==
270
 
271
+ = 2.2.5(2018-02-05) =
272
+ * Fixed: Variations description issue
273
+ * Fixed: Remove shortcodes Automatically
274
+
275
+ = 2.2.4(2018-02-01) =
276
+ * Auto Remove ShortCodes from Product Description
277
+
278
+ = 2.2.3(2018-01-30) =
279
+ * Fixed: Variations description issue
280
+ * Added: Remove shortcodes function modified
281
+
282
+ = 2.2.2(2018-01-26) =
283
+ * removed variations for facebook
284
+
285
+ = 2.2.1(2018-01-25) =
286
+ * product variation issue fixed
287
+
288
+ = 2.2.0(2018-01-25) =
289
+ * WC 3.1+ compatibility extended
290
+
291
  = 2.1.29(2018-01-09) =
292
  * Added: Bonanza, Real, LeGuide and Crowdfox template added
293
 
admin/partials/woo-feed-pro-vs-free.php CHANGED
@@ -150,6 +150,7 @@
150
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b> &nbsp;&nbsp; (2000 Products Only)</td>
151
  <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
152
  </tr>
 
153
  <tr>
154
  <td><b>Product Filtering by Id,SKU, Title, Category and Others Attributes.</b></td>
155
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
@@ -175,6 +176,16 @@
175
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
176
  <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
177
  </tr>
 
 
 
 
 
 
 
 
 
 
178
  <tr>
179
  <td><b>Remove Variation Products</b></td>
180
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
150
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b> &nbsp;&nbsp; (2000 Products Only)</td>
151
  <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
152
  </tr>
153
+
154
  <tr>
155
  <td><b>Product Filtering by Id,SKU, Title, Category and Others Attributes.</b></td>
156
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
176
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
177
  <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
178
  </tr>
179
+ <tr>
180
+ <td><b>WooCommerce Composite Products</b></td>
181
+ <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-no"></span></b></td>
182
+ <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
183
+ </tr>
184
+ <tr>
185
+ <td><b>WooCommerce Bundle Products</b></td>
186
+ <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-no"></span></b></td>
187
+ <td style="text-align: center;"><b><span style="font-size: 25px;color: green;" class="dashicons dashicons-yes"></span></b></td>
188
+ </tr>
189
  <tr>
190
  <td><b>Remove Variation Products</b></td>
191
  <td style="text-align: center;"><b><span style="font-size: 25px;color:red;" class="dashicons dashicons-no"></span></b></td>
includes/class-woo-feed.php CHANGED
@@ -69,9 +69,8 @@ class Woo_Feed
69
  */
70
  public function __construct()
71
  {
72
-
73
  $this->woo_feed = 'woo-feed';
74
- $this->version = '2.1.29';
75
 
76
  $this->load_dependencies();
77
  $this->set_locale();
69
  */
70
  public function __construct()
71
  {
 
72
  $this->woo_feed = 'woo-feed';
73
+ $this->version = '2.2.5';
74
 
75
  $this->load_dependencies();
76
  $this->set_locale();
includes/classes/class-woo-feed-engine.php CHANGED
@@ -65,11 +65,13 @@ class WF_Engine
65
  * @access private
66
  */
67
  public $csvFeedHeader;
 
68
 
69
  public function __construct($Products, $rules)
70
  {
71
  $this->rules = $rules;
72
  $this->storeProducts = $Products;
 
73
  }
74
 
75
  public function stripInvalidXml($value) {
@@ -113,7 +115,6 @@ class WF_Engine
113
 
114
  # Map Merchant Attributes and Woo Attributes
115
  $countAttr = 0;
116
- update_option('wpf_progress', 'Mapping Attributes');
117
 
118
  if (!empty($merchantAttributes)) {
119
  foreach ($merchantAttributes as $key => $attr) {
@@ -150,23 +151,21 @@ class WF_Engine
150
  if (!empty($this->storeProducts)) {
151
  if (!empty($wf_attr) || !empty($wf_cattr)) {
152
  foreach ($this->storeProducts as $key => $value) {
153
- if ($value['type'] == 'variation') {
154
- $id = $value['item_group_id'];
155
- } else {
156
- $id = $value['id'];
157
- }
158
 
159
  # Get Woo Attributes
160
  if (!empty($wf_attr)) {
161
  foreach ($wf_attr as $attr_key => $attr_value) {
162
- $this->storeProducts[$key][$attr_value] = implode(',', wc_get_product_terms($id, str_replace("wf_attr_", "", $attr_value), array('fields' => 'names')));
 
163
  }
164
  }
165
 
166
  # Get Custom Attributes
167
  if (!empty($wf_cattr)) {
168
  foreach ($wf_cattr as $cattr_key => $cattr_value) {
169
- $this->storeProducts[$key][$cattr_value] = $productClass->getAttributeValue($value['id'], str_replace("wf_cattr_", "", $cattr_value));
170
  }
171
  }
172
  }
@@ -204,7 +203,8 @@ class WF_Engine
204
  $output=$this->stripInvalidXml($output);
205
  //$output = preg_replace( '/[^[:print:]]/',' ',$output);
206
  }else if($value22 == 10){
207
- $output=preg_replace("/\[[^]]+\]/","",$output);
 
208
  }
209
  }
210
  }
@@ -284,7 +284,8 @@ class WF_Engine
284
  $output=$this->stripInvalidXml($output);
285
  //$output = preg_replace( '/[^[:print:]]/',' ',$output);
286
  }else if($value22 == 10){
287
- $output=preg_replace("/\[[^]]+\]/","",$output);
 
288
  }
289
  }
290
  }
@@ -305,7 +306,7 @@ class WF_Engine
305
  $output = $this->make_url_with_parameter($rules['prefix'],$output,$rules['suffix']);
306
  }else{
307
  if($attr=='price'){
308
- $suffix=!empty($rules['suffix'])?trim($rules['suffix']):$rules['suffix'];
309
  $output = $rules['prefix'].$output." ".$suffix;
310
  }else{
311
  $output = $rules['prefix'].$output.$rules['suffix'];
@@ -354,21 +355,11 @@ class WF_Engine
354
  }
355
  }
356
 
357
- # Reindex product array key
358
- if (!empty($this->products)) {
359
-
360
- $array = array();
361
- $ij = 0;
362
- foreach ($this->products as $key => $item) {
363
- $array[$ij] = $item;
364
- unset($this->products[$key]);
365
- $ij++;
366
- }
367
- return $this->products = $array;
368
- }
369
- return $this->products;
370
  }
371
 
 
 
372
  /**
373
  * Make proper URL using parameters
374
  * @param $prefix
@@ -536,11 +527,6 @@ class WF_Engine
536
  public function processStringForTXT($string){
537
  if(!empty($string)){
538
  $string = html_entity_decode( $string, ENT_HTML401 | ENT_QUOTES ); // Convert any HTML entities
539
- // $string = iconv(
540
- // 'UTF-8',
541
- // 'ASCII//TRANSLIT',
542
- // $string
543
- // );
544
 
545
  if (stristr( $string,'"' ) ) {
546
  $string = str_replace( '"', '""', $string );
@@ -595,7 +581,7 @@ class WF_Engine
595
  $feed[]=explode(',',$header);
596
  }
597
  }
598
- $headers = array_keys($this->storeProducts[0]);
599
  $feed[] = $headers;
600
  foreach ($this->storeProducts as $no => $product) {
601
  $row = array();
@@ -636,7 +622,7 @@ class WF_Engine
636
  $feed[]=explode(',',$header);
637
  }
638
  }
639
- $headers = array_keys($this->storeProducts[0]);
640
  $this->csvFeedHeader = $headers;
641
  foreach ($this->storeProducts as $no => $product) {
642
  $row = array();
65
  * @access private
66
  */
67
  public $csvFeedHeader;
68
+ public $productClass;
69
 
70
  public function __construct($Products, $rules)
71
  {
72
  $this->rules = $rules;
73
  $this->storeProducts = $Products;
74
+ $this->productClass = new Woo_Feed_Products();
75
  }
76
 
77
  public function stripInvalidXml($value) {
115
 
116
  # Map Merchant Attributes and Woo Attributes
117
  $countAttr = 0;
 
118
 
119
  if (!empty($merchantAttributes)) {
120
  foreach ($merchantAttributes as $key => $attr) {
151
  if (!empty($this->storeProducts)) {
152
  if (!empty($wf_attr) || !empty($wf_cattr)) {
153
  foreach ($this->storeProducts as $key => $value) {
154
+
155
+ $id = $value['id'];
 
 
 
156
 
157
  # Get Woo Attributes
158
  if (!empty($wf_attr)) {
159
  foreach ($wf_attr as $attr_key => $attr_value) {
160
+ //$this->storeProducts[$key][$attr_value] = implode(',', wc_get_product_terms($id, str_replace("wf_attr_", "", $attr_value), array('fields' => 'names')));
161
+ $this->storeProducts[$key][$attr_value] = $this->productClass->getProductAttribute($id,$attr_value);
162
  }
163
  }
164
 
165
  # Get Custom Attributes
166
  if (!empty($wf_cattr)) {
167
  foreach ($wf_cattr as $cattr_key => $cattr_value) {
168
+ $this->storeProducts[$key][$cattr_value] = $this->productClass->getProductMeta($id,$cattr_value);
169
  }
170
  }
171
  }
203
  $output=$this->stripInvalidXml($output);
204
  //$output = preg_replace( '/[^[:print:]]/',' ',$output);
205
  }else if($value22 == 10){
206
+ //$output=preg_replace("/\[[^]]+\]/","",$output);
207
+ $output=$this->productClass->remove_short_codes($output);
208
  }
209
  }
210
  }
284
  $output=$this->stripInvalidXml($output);
285
  //$output = preg_replace( '/[^[:print:]]/',' ',$output);
286
  }else if($value22 == 10){
287
+ //$output=preg_replace("/\[[^]]+\]/","",$output);
288
+ $output=$this->productClass->remove_short_codes($output);
289
  }
290
  }
291
  }
306
  $output = $this->make_url_with_parameter($rules['prefix'],$output,$rules['suffix']);
307
  }else{
308
  if($attr=='price'){
309
+ $suffix=!empty($rules['suffix'])?trim($rules['suffix']):$rules['suffix'];
310
  $output = $rules['prefix'].$output." ".$suffix;
311
  }else{
312
  $output = $rules['prefix'].$output.$rules['suffix'];
355
  }
356
  }
357
 
358
+ return $this->products;
 
 
 
 
 
 
 
 
 
 
 
 
359
  }
360
 
361
+
362
+
363
  /**
364
  * Make proper URL using parameters
365
  * @param $prefix
527
  public function processStringForTXT($string){
528
  if(!empty($string)){
529
  $string = html_entity_decode( $string, ENT_HTML401 | ENT_QUOTES ); // Convert any HTML entities
 
 
 
 
 
530
 
531
  if (stristr( $string,'"' ) ) {
532
  $string = str_replace( '"', '""', $string );
581
  $feed[]=explode(',',$header);
582
  }
583
  }
584
+ $headers = array_keys($this->storeProducts[key($this->storeProducts)]);
585
  $feed[] = $headers;
586
  foreach ($this->storeProducts as $no => $product) {
587
  $row = array();
622
  $feed[]=explode(',',$header);
623
  }
624
  }
625
+ $headers = array_keys($this->storeProducts[key($this->storeProducts)]);
626
  $this->csvFeedHeader = $headers;
627
  foreach ($this->storeProducts as $no => $product) {
628
  $row = array();
includes/classes/class-woo-feed-products.php CHANGED
@@ -66,6 +66,661 @@ class Woo_Feed_Products
66
 
67
  public $feedRule;
68
  public $idExist=array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  /**
70
  * Get WooCommerce Product
71
  * @param string $feedRule
@@ -73,579 +728,609 @@ class Woo_Feed_Products
73
  */
74
  public function woo_feed_get_visible_product($feedRule="")
75
  {
76
- try{
77
-
78
- if(!empty($feedRule)){
79
- $this->feedRule=$feedRule;
80
- }
81
- $limit = !empty($feedRule['Limit']) && is_numeric($feedRule['Limit']) ? absint($feedRule['Limit']) : '2000';
82
- $offset = !empty($feedRule['Offset']) && is_numeric($feedRule['Offset']) ? absint($feedRule['Offset']) : '0';
83
-
84
- if($offset=='0'){
85
- delete_option("wf_check_duplicate");
86
- }
87
- $getIDs=get_option("wf_check_duplicate");
88
- $arg=array(
89
- 'post_type' => array('product', 'product_variation'),
90
- 'post_status' => 'publish',
91
- 'posts_per_page' => $limit,
92
- 'orderby' => 'date',
93
- 'order' => 'desc',
94
- 'fields' => 'ids',
95
- 'offset' => $offset,
96
- 'cache_results' => false,
97
- 'update_post_term_cache' => false,
98
- 'update_post_meta_cache' => false,
99
- );
100
-
101
-
102
- # Query Database for products
103
- $loop = new WP_Query($arg);
104
-
105
- $i = 0;
106
-
107
- while ($loop->have_posts()) : $loop->the_post();
108
-
109
- $this->childID = get_the_ID();
110
- $this->parentID = (wp_get_post_parent_id($this->childID))?wp_get_post_parent_id($this->childID):$this->childID;
111
-
112
- global $product;
113
- if(!is_object($product)|| !$product->is_visible()){
114
- continue;
115
- }
116
-
117
- $type1 = "";
118
- if (is_object($product) && $product->is_type('simple')) {
119
- # No variations to product
120
- $type1 = "simple";
121
- } elseif (is_object($product) && $product->is_type('variable')) {
122
- # Product has variations
123
- $type1 = "variable";
124
- } elseif (is_object($product) && $product->is_type('grouped')) {
125
- $type1 = "grouped";
126
- } elseif (is_object($product) && $product->is_type('external')) {
127
- $type1 = "external";
128
- } elseif (is_object($product) && $product->is_downloadable()) {
129
- $type1 = "downloadable";
130
- } elseif (is_object($product) && $product->is_virtual()) {
131
- $type1 = "virtual";
132
- }
133
-
134
-
135
- $post = get_post($this->parentID);
136
-
137
- if(!is_object($post)){
138
- continue;
139
- }
140
-
141
- if($post->post_status=='trash'){
142
- continue;
143
- }
144
-
145
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- if (get_post_type() == 'product_variation' && $this->feedRule['provider']!='facebook') {
148
- if ($this->parentID != 0) {
149
-
150
- $status=get_post($this->childID);
151
- if(!$status || !is_object($status) ){
152
- continue;
153
- }
154
-
155
- if($status->post_status=="trash"){
156
- continue;
157
- }
158
-
159
- $parentStatus=get_post($this->parentID);
160
- if($parentStatus && is_object($parentStatus) && $parentStatus->post_status!='publish'){
161
- continue;
162
- }
163
-
164
- # Check Valid URL
165
- $mainImage = wp_get_attachment_url($product->get_image_id());
166
- $link = $product->get_permalink($this->childID);
167
-
168
- if($this->feedRule['provider']!='custom'){
169
- if (substr(trim($link), 0, 4) !== "http" && substr(trim($mainImage), 0, 4) !== "http") {
170
- continue;
171
- }
172
- }
173
-
174
- if($getIDs){
175
- if(in_array($this->childID,$getIDs)){
176
- continue;
177
- }else{
178
- array_push($this->idExist,$this->childID);
179
- }
180
- }else{
181
- array_push($this->idExist,$this->childID);
182
- }
183
-
184
-
185
- $this->productsList[$i]['id'] = $this->childID;
186
- $this->productsList[$i]['variation_type'] = "child";
187
- $this->productsList[$i]['item_group_id'] = $this->parentID;
188
- $this->productsList[$i]['sku'] = $this->getAttributeValue($this->childID, "_sku");
189
- $this->productsList[$i]['parent_sku'] = $this->getAttributeValue($this->parentID, "_sku");
190
- $this->productsList[$i]['title'] = $post->post_title;
191
- $this->productsList[$i]['description'] = $post->post_content;
192
-
193
- # Short Description to variable description
194
- $vDesc = $this->getAttributeValue($this->childID, "_variation_description");
195
- if (!empty($vDesc)) {
196
- $this->productsList[$i]['short_description'] = $vDesc;
197
- } else {
198
- $this->productsList[$i]['short_description'] = $post->post_excerpt;
199
- }
200
-
201
- $this->productsList[$i]['product_type'] = $this->get_product_term_list($post->ID, 'product_cat', "", ">");// $this->categories($this->parentID);//TODO
202
- $this->productsList[$i]['link'] = $link;
203
- $this->productsList[$i]['ex_link'] = "";
204
- $this->productsList[$i]['image'] = $this->get_formatted_url($mainImage);
205
-
206
- # Featured Image
207
- if (has_post_thumbnail($post->ID)):
208
- $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
209
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($image[0]);
210
- else:
211
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($mainImage);
212
- endif;
213
-
214
- # Additional Images
215
- $imageLinks=array();
216
- $images = $this->additionalImages($this->childID);
217
- if ($images && is_array($images)) {
218
- $mKey=1;
219
- foreach ($images as $key => $value) {
220
- if ($value != $this->productsList[$i]['image']) {
221
- $imgLink=$this->get_formatted_url($value);
222
- $this->productsList[$i]["image_$mKey"] = $imgLink;
223
- if(!empty($imgLink)){
224
- array_push($imageLinks,$imgLink);
225
- }
226
- }
227
- $mKey++;
228
- }
229
- }
230
- $this->productsList[$i]['images'] = implode(",",$imageLinks);
231
- $this->productsList[$i]['condition'] = "New";
232
- $this->productsList[$i]['type'] = $product->get_type();
233
- $this->productsList[$i]['visibility'] = $this->getAttributeValue($this->childID,"_visibility");
234
- $this->productsList[$i]['rating_total'] = $product->get_rating_count();
235
- $this->productsList[$i]['rating_average'] = $product->get_average_rating();
236
- $this->productsList[$i]['tags'] = $this->get_product_term_list($post->ID, 'product_tag');
237
- $this->productsList[$i]['shipping'] = $product->get_shipping_class();
238
-
239
- $this->productsList[$i]['availability'] = $this->availability($this->childID);
240
- $this->productsList[$i]['quantity'] = $this->get_quantity($this->childID, "_stock");
241
- $this->productsList[$i]['sale_price_sdate'] = $this->get_date($this->childID, "_sale_price_dates_from");
242
- $this->productsList[$i]['sale_price_edate'] = $this->get_date($this->childID, "_sale_price_dates_to");
243
- $this->productsList[$i]['price'] = ($product->get_regular_price()) ? $product->get_regular_price() : $product->get_price();
244
- $this->productsList[$i]['sale_price'] = ($product->get_sale_price()) ? $product->get_sale_price() : "";
245
- $this->productsList[$i]['weight'] = ($product->get_weight()) ? $product->get_weight() : "";
246
- $this->productsList[$i]['width'] = ($product->get_width()) ? $product->get_width() : "";
247
- $this->productsList[$i]['height'] = ($product->get_height()) ? $product->get_height() : "";
248
- $this->productsList[$i]['length'] = ($product->get_length()) ? $product->get_length() : "";
249
-
250
- # Sale price effective date
251
- $from = $this->sale_price_effective_date($this->childID, '_sale_price_dates_from');
252
- $to = $this->sale_price_effective_date($this->childID, '_sale_price_dates_to');
253
- if (!empty($from) && !empty($to)) {
254
- $from = date("c", strtotime($from));
255
- $to = date("c", strtotime($to));
256
- $this->productsList[$i]['sale_price_effective_date'] = "$from" . "/" . "$to";
257
- } else {
258
- $this->productsList[$i]['sale_price_effective_date'] = "";
259
- }
260
 
261
- }
262
- } elseif (get_post_type() == 'product') {
263
- if ($type1 == 'simple') {
264
-
265
- $mainImage = wp_get_attachment_url($product->get_image_id());
266
- $link = get_permalink($post->ID);
267
-
268
- if($this->feedRule['provider']!='custom'){
269
- if (substr(trim($link), 0, 4) !== "http" && substr(trim($mainImage), 0, 4) !== "http") {
270
- continue;
271
- }
272
- }
273
-
274
- if($getIDs){
275
- if(in_array($post->ID,$getIDs)){
276
- continue;
277
- }else{
278
- array_push($this->idExist,$post->ID);
279
- }
280
- }else{
281
- array_push($this->idExist,$post->ID);
282
- }
283
-
284
- $this->productsList[$i]['id'] = $post->ID;
285
- $this->productsList[$i]['variation_type'] = "simple";
286
- $this->productsList[$i]['title'] = $product->get_title();
287
- $this->productsList[$i]['description'] =$post->post_content;
288
-
289
- $this->productsList[$i]['short_description'] = $post->post_excerpt;
290
- $this->productsList[$i]['product_type'] = $this->get_product_term_list($post->ID, 'product_cat', "", ">");// $this->categories($this->parentID);//TODO
291
- $this->productsList[$i]['link'] = $link;
292
- $this->productsList[$i]['ex_link'] = "";
293
- $this->productsList[$i]['image'] = $this->get_formatted_url($mainImage);
294
-
295
- # Featured Image
296
- if (has_post_thumbnail($post->ID)):
297
- $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
298
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($image[0]);
299
- else:
300
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($mainImage);
301
- endif;
302
-
303
- # Additional Images
304
- $imageLinks=array();
305
- $images = $this->additionalImages($post->ID);
306
- if ($images && is_array($images)) {
307
- $mKey=1;
308
- foreach ($images as $key => $value) {
309
- if ($value != $this->productsList[$i]['image']) {
310
- $imgLink=$this->get_formatted_url($value);
311
- $this->productsList[$i]["image_$mKey"] = $imgLink;
312
- if(!empty($imgLink)){
313
- array_push($imageLinks,$imgLink);
314
- }
315
- }
316
- $mKey++;
317
- }
318
- }
319
- $this->productsList[$i]['images'] = implode(",",$imageLinks);
320
-
321
- $this->productsList[$i]['condition'] = "New";
322
- $this->productsList[$i]['type'] = $product->get_type();
323
- $this->productsList[$i]['visibility'] =$this->getAttributeValue($post->ID,"_visibility");
324
- $this->productsList[$i]['rating_total'] = $product->get_rating_count();
325
- $this->productsList[$i]['rating_average'] = $product->get_average_rating();
326
- $this->productsList[$i]['tags'] = $this->get_product_term_list($post->ID, 'product_tag');
327
-
328
- $this->productsList[$i]['item_group_id'] = $post->ID;
329
- $this->productsList[$i]['sku'] = $this->getAttributeValue($post->ID,"_sku");
330
-
331
- $this->productsList[$i]['availability'] = $this->availability($post->ID);
332
- $this->productsList[$i]['quantity'] = $this->get_quantity($post->ID, "_stock");
333
- $this->productsList[$i]['sale_price_sdate'] = $this->get_date($post->ID, "_sale_price_dates_from");
334
- $this->productsList[$i]['sale_price_edate'] = $this->get_date($post->ID, "_sale_price_dates_to");
335
- $this->productsList[$i]['price'] = ($product->get_regular_price()) ? $product->get_regular_price() : $product->get_price();
336
- $this->productsList[$i]['sale_price'] = ($product->get_sale_price()) ? $product->get_sale_price() : "";
337
- $this->productsList[$i]['weight'] = ($product->get_weight()) ? $product->get_weight() : "";
338
- $this->productsList[$i]['width'] = ($product->get_width()) ? $product->get_width() : "";
339
- $this->productsList[$i]['height'] = ($product->get_height()) ? $product->get_height() : "";
340
- $this->productsList[$i]['length'] = ($product->get_length()) ? $product->get_length() : "";
341
-
342
- # Sale price effective date
343
- $from = $this->sale_price_effective_date($post->ID, '_sale_price_dates_from');
344
- $to = $this->sale_price_effective_date($post->ID, '_sale_price_dates_to');
345
- if (!empty($from) && !empty($to)) {
346
- $from = date("c", strtotime($from));
347
- $to = date("c", strtotime($to));
348
- $this->productsList[$i]['sale_price_effective_date'] = "$from" . "/" . "$to";
349
- } else {
350
- $this->productsList[$i]['sale_price_effective_date'] = "";
351
- }
352
 
353
- }
354
- else if($type1 == 'external'){
355
-
356
- $mainImage = wp_get_attachment_url($product->get_image_id());
357
-
358
- $getLink=new WC_Product_External($post->ID);
359
- $EX_link = $getLink->get_product_url();
360
- $link=get_permalink($post->ID);
361
- if($this->feedRule['provider']!='custom'){
362
- if (substr(trim($link), 0, 4) !== "http" && substr(trim($mainImage), 0, 4) !== "http") {
363
- continue;
364
- }
365
- }
366
-
367
- $this->productsList[$i]['id'] = $post->ID;
368
- $this->productsList[$i]['variation_type'] = "external";
369
- $this->productsList[$i]['title'] = $product->get_title();
370
- $this->productsList[$i]['description'] = do_shortcode($post->post_content);
371
-
372
- $this->productsList[$i]['short_description'] = $post->post_excerpt;
373
- $this->productsList[$i]['product_type'] = $this->get_product_term_list($post->ID, 'product_cat', "", ">");// $this->categories($this->parentID);//TODO
374
- $this->productsList[$i]['link'] = $link;
375
- $this->productsList[$i]['ex_link'] = $EX_link;
376
- $this->productsList[$i]['image'] = $this->get_formatted_url($mainImage);
377
-
378
- # Featured Image
379
- if (has_post_thumbnail($post->ID)):
380
- $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
381
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($image[0]);
382
- else:
383
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($mainImage);
384
- endif;
385
-
386
- # Additional Images
387
- $imageLinks=array();
388
- $images = $this->additionalImages($post->ID);
389
- if ($images && is_array($images)) {
390
- $mKey=1;
391
- foreach ($images as $key => $value) {
392
- if ($value != $this->productsList[$i]['image']) {
393
- $imgLink=$this->get_formatted_url($value);
394
- $this->productsList[$i]["image_$mKey"] = $imgLink;
395
- if(!empty($imgLink)){
396
- array_push($imageLinks,$imgLink);
397
- }
398
- }
399
- $mKey++;
400
- }
401
- }
402
- $this->productsList[$i]['images'] = implode(",",$imageLinks);
403
-
404
- $this->productsList[$i]['condition'] = "New";
405
- $this->productsList[$i]['type'] = $product->get_type();
406
- $this->productsList[$i]['visibility'] = $this->getAttributeValue($post->ID,"_visibility");
407
- $this->productsList[$i]['rating_total'] = $product->get_rating_count();
408
- $this->productsList[$i]['rating_average'] = $product->get_average_rating();
409
- $this->productsList[$i]['tags'] = $this->get_product_term_list($post->ID, 'product_tag');
410
-
411
- $this->productsList[$i]['item_group_id'] = $post->ID;
412
- $this->productsList[$i]['sku'] = $this->getAttributeValue($post->ID,"_sku");
413
-
414
- $this->productsList[$i]['availability'] = $this->availability($post->ID);
415
-
416
- $this->productsList[$i]['quantity'] = $this->get_quantity($post->ID, "_stock");
417
- $this->productsList[$i]['sale_price_sdate'] = $this->get_date($post->ID, "_sale_price_dates_from");
418
- $this->productsList[$i]['sale_price_edate'] = $this->get_date($post->ID, "_sale_price_dates_to");
419
- $this->productsList[$i]['price'] = ($product->get_regular_price()) ? $product->get_regular_price() : $product->get_price();
420
- $this->productsList[$i]['sale_price'] = ($product->get_sale_price()) ? $product->get_sale_price() : "";
421
- $this->productsList[$i]['weight'] = ($product->get_weight()) ? $product->get_weight() : "";
422
- $this->productsList[$i]['width'] = ($product->get_width()) ? $product->get_width() : "";
423
- $this->productsList[$i]['height'] = ($product->get_height()) ? $product->get_height() : "";
424
- $this->productsList[$i]['length'] = ($product->get_length()) ? $product->get_length() : "";
425
-
426
- # Sale price effective date
427
- $from = $this->sale_price_effective_date($post->ID, '_sale_price_dates_from');
428
- $to = $this->sale_price_effective_date($post->ID, '_sale_price_dates_to');
429
- if (!empty($from) && !empty($to)) {
430
- $from = date("c", strtotime($from));
431
- $to = date("c", strtotime($to));
432
- $this->productsList[$i]['sale_price_effective_date'] = "$from" . "/" . "$to";
433
- } else {
434
- $this->productsList[$i]['sale_price_effective_date'] = "";
435
- }
436
-
437
- }elseif($type1 == 'grouped'){
438
-
439
- $grouped=new WC_Product_Grouped($post->ID);
440
- $children=$grouped->get_children();
441
- $this->parentID=$post->ID;
442
- if($children){
443
- foreach ($children as $cKey=>$child){
444
-
445
- $product=new WC_Product($child);
446
- $this->childID=$child;
447
- $post=get_post($this->childID);
448
-
449
- if($post->post_status=='trash'){
450
- continue;
451
- }
452
-
453
- if (!empty($this->ids_in) && !in_array($post->ID, $this->ids_in)) {
454
- continue;
455
- }
456
-
457
- if (!empty($this->ids_not_in) && in_array($post->ID, $this->ids_in)) {
458
- continue;
459
- }
460
-
461
- if (!$product->is_visible()) {
462
- continue;
463
- }
464
-
465
- $i++;
466
-
467
- $mainImage = wp_get_attachment_url($product->get_image_id());
468
- $link = get_permalink($post->ID);
469
- if($this->feedRule['provider']!='custom'){
470
- if (substr(trim($link), 0, 4) !== "http" && substr(trim($mainImage), 0, 4) !== "http") {
471
- continue;
472
- }
473
- }
474
-
475
- $this->productsList[$i]['id'] = $post->ID;
476
- $this->productsList[$i]['variation_type'] = "grouped";
477
- $this->productsList[$i]['title'] = $product->get_title();
478
- $this->productsList[$i]['description'] = do_shortcode($post->post_content);
479
-
480
- $this->productsList[$i]['short_description'] = $post->post_excerpt;
481
- $this->productsList[$i]['product_type'] = $this->get_product_term_list($post->ID, 'product_cat', "", ">");// $this->categories($this->parentID);//TODO
482
- $this->productsList[$i]['link'] = $link;
483
- $this->productsList[$i]['ex_link'] = "";
484
- $this->productsList[$i]['image'] = $this->get_formatted_url($mainImage);
485
-
486
- # Featured Image
487
- if (has_post_thumbnail($post->ID)):
488
- $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
489
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($image[0]);
490
- else:
491
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($mainImage);
492
- endif;
493
-
494
- # Additional Images
495
- $imageLinks=array();
496
- $images = $this->additionalImages($this->childID);
497
- if ($images and is_array($images)) {
498
- $mKey=1;
499
- foreach ($images as $key => $value) {
500
- if ($value != $this->productsList[$i]['image']) {
501
- $imgLink=$this->get_formatted_url($value);
502
- $this->productsList[$i]["image_$mKey"] = $imgLink;
503
- if(!empty($imgLink)){
504
- array_push($imageLinks,$imgLink);
505
- }
506
- }
507
- $mKey++;
508
- }
509
- }
510
- $this->productsList[$i]['images'] = implode(",",$imageLinks);
511
- $this->productsList[$i]['condition'] = "New";
512
- $this->productsList[$i]['type'] = $product->get_type();
513
- $this->productsList[$i]['visibility'] = $this->getAttributeValue($post->ID,"_visibility");
514
- $this->productsList[$i]['rating_total'] = $product->get_rating_count();
515
- $this->productsList[$i]['rating_average'] = $product->get_average_rating();
516
- $this->productsList[$i]['tags'] = $this->get_product_term_list($post->ID, 'product_tag');
517
-
518
- $this->productsList[$i]['item_group_id'] = $this->parentID;
519
- $this->productsList[$i]['sku'] = $this->getAttributeValue($post->ID,"_sku");
520
-
521
- $this->productsList[$i]['availability'] = $this->availability($post->ID);
522
-
523
- $this->productsList[$i]['quantity'] = $this->get_quantity($post->ID, "_stock");
524
- $this->productsList[$i]['sale_price_sdate'] = $this->get_date($post->ID, "_sale_price_dates_from");
525
- $this->productsList[$i]['sale_price_edate'] = $this->get_date($post->ID, "_sale_price_dates_to");
526
- $this->productsList[$i]['price'] =($product->get_regular_price()) ? $product->get_regular_price() : $product->get_price();
527
- $this->productsList[$i]['sale_price'] =($product->get_sale_price()) ? $product->get_sale_price() : "";
528
- $this->productsList[$i]['weight'] = ($product->get_weight()) ? $product->get_weight() : "";
529
- $this->productsList[$i]['width'] = ($product->get_width()) ? $product->get_width() : "";
530
- $this->productsList[$i]['height'] = ($product->get_height()) ? $product->get_height() : "";
531
- $this->productsList[$i]['length'] = ($product->get_length()) ? $product->get_length() : "";
532
-
533
- # Sale price effective date
534
- $from = $this->sale_price_effective_date($post->ID, '_sale_price_dates_from');
535
- $to = $this->sale_price_effective_date($post->ID, '_sale_price_dates_to');
536
- if (!empty($from) && !empty($to)) {
537
- $from = date("c", strtotime($from));
538
- $to = date("c", strtotime($to));
539
- $this->productsList[$i]['sale_price_effective_date'] = "$from" . "/" . "$to";
540
- } else {
541
- $this->productsList[$i]['sale_price_effective_date'] = "";
542
- }
543
- }
544
- }
545
- }
546
 
547
- else if ($type1 == 'variable' && $product->has_child()) {
548
-
549
- # Check Valid URL
550
- $mainImage = wp_get_attachment_url($product->get_image_id());
551
- $link = get_permalink($post->ID);
552
-
553
- if($this->feedRule['provider']!='custom'){
554
- if (substr(trim($link), 0, 4) !== "http" && substr(trim($mainImage), 0, 4) !== "http") {
555
- continue;
556
- }
557
- }
558
-
559
-
560
- $this->productsList[$i]['id'] = $post->ID;
561
- $this->productsList[$i]['variation_type'] = "parent";
562
- $this->productsList[$i]['title'] = $post->post_title;
563
- $this->productsList[$i]['description'] =$post->post_content;
564
-
565
- $this->productsList[$i]['short_description'] = $post->post_excerpt;
566
- $this->productsList[$i]['product_type'] = $this->get_product_term_list($post->ID, 'product_cat', "", ">");// $this->categories($this->parentID);//TODO
567
- $this->productsList[$i]['link'] = $link;
568
- $this->productsList[$i]['ex_link'] = "";
569
- $this->productsList[$i]['image'] = $this->get_formatted_url($mainImage);
570
-
571
- # Featured Image
572
- if (has_post_thumbnail($post->ID)):
573
- $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
574
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($image[0]);
575
- else:
576
- $this->productsList[$i]['feature_image'] = $this->get_formatted_url($mainImage);
577
- endif;
578
-
579
- # Additional Images
580
- $imageLinks=array();
581
- $images = $this->additionalImages($post->ID);
582
- if ($images and is_array($images)) {
583
- $mKey=1;
584
- foreach ($images as $key => $value) {
585
- if ($value != $this->productsList[$i]['image']) {
586
- $imgLink=$this->get_formatted_url($value);
587
- $this->productsList[$i]["image_$mKey"] = $imgLink;
588
- if(!empty($imgLink)){
589
- array_push($imageLinks,$imgLink);
590
- }
591
- }
592
- $mKey++;
593
- }
594
- }
595
- $this->productsList[$i]['images'] = implode(",",$imageLinks);
596
-
597
- $this->productsList[$i]['condition'] = "New";
598
- $this->productsList[$i]['type'] = $product->get_type();
599
- $this->productsList[$i]['visibility'] = $this->getAttributeValue($post->ID,"_visibility");
600
- $this->productsList[$i]['rating_total'] = $product->get_rating_count();
601
- $this->productsList[$i]['rating_average'] = $product->get_average_rating();
602
- $this->productsList[$i]['tags'] = $this->get_product_term_list($post->ID, 'product_tag');
603
-
604
- $this->productsList[$i]['item_group_id'] = $post->ID;
605
- $this->productsList[$i]['sku'] =$this->getAttributeValue($post->ID,"_sku");
606
-
607
- $this->productsList[$i]['availability'] = $this->availability($post->ID);
608
- $this->productsList[$i]['quantity'] = $this->get_quantity($post->ID, "_stock");
609
- $this->productsList[$i]['sale_price_sdate'] = $this->get_date($post->ID, "_sale_price_dates_from");
610
- $this->productsList[$i]['sale_price_edate'] = $this->get_date($post->ID, "_sale_price_dates_to");
611
-
612
- $price=($product->get_price()) ? $product->get_price() : false;
613
-
614
- $this->productsList[$i]['price'] = ($product->get_regular_price()) ? $product->get_regular_price() : $price;
615
- $this->productsList[$i]['sale_price'] =($product->get_sale_price()) ? $product->get_sale_price() : "";
616
- $this->productsList[$i]['weight'] = ($product->get_weight()) ? $product->get_weight() : "";
617
- $this->productsList[$i]['width'] = ($product->get_width()) ? $product->get_width() : "";
618
- $this->productsList[$i]['height'] = ($product->get_height()) ? $product->get_height() : "";
619
- $this->productsList[$i]['length'] = ($product->get_length()) ? $product->get_length() : "";
620
-
621
- # Sale price effective date
622
- $from = $this->sale_price_effective_date($post->ID, '_sale_price_dates_from');
623
- $to = $this->sale_price_effective_date($post->ID, '_sale_price_dates_to');
624
- if (!empty($from) && !empty($to)) {
625
- $from = date("c", strtotime($from));
626
- $to = date("c", strtotime($to));
627
- $this->productsList[$i]['sale_price_effective_date'] = "$from" . "/" . "$to";
628
- } else {
629
- $this->productsList[$i]['sale_price_effective_date'] = "";
630
- }
631
- }
632
- }
633
- $i++;
634
- endwhile;
635
- wp_reset_query();
636
-
637
- if($getIDs){
638
- $mergedIds=array_merge($getIDs,$this->idExist);
639
- update_option("wf_check_duplicate",$mergedIds);
640
- }else{
641
- update_option("wf_check_duplicate",$this->idExist);
642
- }
643
-
644
- return $this->productsList;
645
- }catch (Exception $e){
646
- return $this->productsList;
647
- }
648
- }
649
 
650
  /**
651
  * Get formatted image url
@@ -778,6 +1463,59 @@ class Woo_Feed_Products
778
  return "out of stock";
779
  }
780
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
781
 
782
  /**
783
  * Get Product Attribute Value
@@ -787,18 +1525,20 @@ class Woo_Feed_Products
787
  *
788
  * @return mixed
789
  */
790
- public function getAttributeValue($id, $name)
791
- {
792
- if (strpos($name, 'attribute_pa') !== false) {
793
- $taxonomy = str_replace("attribute_","",$name);
794
- $meta = get_post_meta($id,$name, true);
795
- $term = get_term_by('slug', $meta, $taxonomy);
796
- return $term->name;
797
- }else{
798
- return get_post_meta($id, $name, true);
799
- }
800
 
801
- }
 
 
 
 
 
 
 
 
 
 
802
 
803
  /**
804
  * Get Sale price effective date for google
@@ -958,6 +1698,7 @@ class Woo_Feed_Products
958
  "width" => "Width",
959
  "height" => "Height",
960
  "length" => "Length",
 
961
  "type" => "Product Type",
962
  "variation_type" => "Variation Type",
963
  "visibility" => "Visibility",
@@ -965,6 +1706,7 @@ class Woo_Feed_Products
965
  "rating_average" => "Average Rating",
966
  "tags" => "Tags",
967
  "sale_price_effective_date" => "Sale Price Effective Date",
 
968
  );
969
 
970
  $images = array(
@@ -1086,6 +1828,7 @@ class Woo_Feed_Products
1086
  "width" => "Width",
1087
  "height" => "Height",
1088
  "length" => "Length",
 
1089
  "type" => "Product Type",
1090
  "variation_type" => "Variation Type",
1091
  "visibility" => "Visibility",
@@ -1093,6 +1836,7 @@ class Woo_Feed_Products
1093
  "rating_average" => "Average Rating",
1094
  "tags" => "Tags",
1095
  "sale_price_effective_date" => "Sale Price Effective Date",
 
1096
  );
1097
 
1098
  $images = array(
66
 
67
  public $feedRule;
68
  public $idExist=array();
69
+ public $pi;
70
+
71
+
72
+ /**
73
+ * Get All Products
74
+ * @since 2.2.0
75
+ * @for WC 3.1+
76
+ * @param $limit
77
+ * @param $offset
78
+ *
79
+ * @return array
80
+ */
81
+
82
+ public function getWC3Products($limit, $offset) {
83
+
84
+ $limit = ! empty( $limit ) && is_numeric( $limit ) ? absint( $limit ) : '2000';
85
+ $offset = ! empty( $offset ) && is_numeric( $offset ) ? absint( $offset ) : '0';
86
+
87
+
88
+ try {
89
+
90
+
91
+ # Query Arguments
92
+ $arg = array(
93
+ 'limit' => $limit,
94
+ 'offset' => $offset,
95
+ 'status' => 'publish',
96
+ 'orderby' => 'date',
97
+ 'order' => 'DESC',
98
+ );
99
+
100
+
101
+
102
+ # Don't Include Variations for Facebook
103
+ if ( $this->feedRule['provider'] == 'facebook' ) {
104
+ $this->feedRule['is_variations'] = 'n';
105
+ }
106
+
107
+ $query = new WC_Product_Query( $arg );
108
+ $products = $query->get_products();
109
+
110
+ # Test
111
+ //return $products;
112
+
113
+ $this->pi = 1; # Product Index
114
+ foreach ( $products as $key => $prod ) {
115
+ if ( $prod->is_type( 'simple' ) )
116
+ {
117
+
118
+ $id = $prod->get_id();
119
+ $simple = new WC_Product_Simple( $id );
120
+
121
+ if(!is_object($simple)){
122
+ continue;
123
+ }
124
+
125
+ $this->productsList[ $this->pi ]["id"] = $simple->get_id();
126
+ $this->productsList[ $this->pi ]["title"] = $simple->get_name();
127
+ $this->productsList[ $this->pi ]["description"] = $this->remove_short_codes($simple->get_description());
128
+ $this->productsList[ $this->pi ]['variation_type'] = $simple->get_type();
129
+
130
+ $this->productsList[ $this->pi ]['short_description'] = $this->remove_short_codes($simple->get_short_description());
131
+ $this->productsList[ $this->pi ]['product_type'] = strip_tags( wc_get_product_category_list( $id, ">", "" ) );
132
+ $this->productsList[ $this->pi ]['link'] = $simple->get_permalink();
133
+ $this->productsList[ $this->pi ]['ex_link'] = $simple->get_permalink();
134
+
135
+
136
+ # Featured Image
137
+ if ( has_post_thumbnail( $id ) ):
138
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
139
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
140
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
141
+ else:
142
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
143
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
144
+ endif;
145
+
146
+ # Additional Images
147
+ $attachmentIds = $simple->get_gallery_image_ids();
148
+ $imgUrls = array();
149
+ if ( $attachmentIds && is_array( $attachmentIds ) ) {
150
+ $mKey = 1;
151
+ foreach ( $attachmentIds as $attachmentId ) {
152
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
153
+ $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
154
+ $mKey ++;
155
+ }
156
+
157
+ }
158
+
159
+ $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
160
+ $this->productsList[ $this->pi ]['condition'] = "New";
161
+ $this->productsList[ $this->pi ]['type'] = $simple->get_type();
162
+ $this->productsList[ $this->pi ]['is_bundle'] = "no";
163
+ $this->productsList[ $this->pi ]['multipack'] = "";
164
+ $this->productsList[ $this->pi ]['visibility'] = $simple->get_catalog_visibility();
165
+ $this->productsList[ $this->pi ]['rating_total'] = $simple->get_rating_count();
166
+ $this->productsList[ $this->pi ]['rating_average'] = $simple->get_average_rating();
167
+ $this->productsList[ $this->pi ]['tags'] = strip_tags( wc_get_product_tag_list( $id, "," ) );
168
+ $this->productsList[ $this->pi ]['item_group_id'] = $simple->get_id();
169
+ $this->productsList[ $this->pi ]['sku'] = $simple->get_sku();
170
+ $this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
171
+ $this->productsList[ $this->pi ]['quantity'] = $simple->get_stock_quantity();
172
+ $this->productsList[ $this->pi ]['sale_price_sdate'] = $simple->get_date_on_sale_from();
173
+ $this->productsList[ $this->pi ]['sale_price_edate'] = $simple->get_date_on_sale_to();
174
+ $this->productsList[ $this->pi ]['price'] = $simple->get_regular_price();
175
+ $this->productsList[ $this->pi ]['sale_price'] = $simple->get_sale_price();
176
+ $this->productsList[ $this->pi ]['weight'] = $simple->get_weight();
177
+ $this->productsList[ $this->pi ]['width'] = $simple->get_width();
178
+ $this->productsList[ $this->pi ]['height'] = $simple->get_height();
179
+ $this->productsList[ $this->pi ]['length'] = $simple->get_length();
180
+ $this->productsList[ $this->pi ]['shipping_class'] = $simple->get_shipping_class();
181
+
182
+
183
+ # Sale price effective date
184
+ $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
185
+ $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
186
+ if ( ! empty( $from ) && ! empty( $to ) ) {
187
+ $from = date( "c", strtotime( $from ) );
188
+ $to = date( "c", strtotime( $to ) );
189
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
190
+ } else {
191
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
192
+ }
193
+
194
+ # Get all Attributes and their values
195
+ $data=$simple->get_data();
196
+ $attributes=$data['attributes'];
197
+ if(!empty($attributes)){
198
+ foreach ($attributes as $aKey=>$attr){
199
+ $this->productsList[ $this->pi ][$aKey] = $simple->get_attribute($aKey);
200
+ }
201
+ }
202
+
203
+
204
+ // # Get all Product Post Meta and Their Values
205
+ // $metas=get_post_meta($simple->get_id());
206
+ // if(!empty($metas)){
207
+ // foreach ($metas as $mKey=>$meta){
208
+ // if($mKey!="_product_attributes"){
209
+ // $metaValue=get_post_meta($id,$mKey,true);
210
+ // $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
211
+ // }
212
+ // }
213
+ // }
214
+ //
215
+ // # Get all Product Taxonomies and Their values
216
+ // $taxonomies=get_post_taxonomies($id);
217
+ // if(!empty($taxonomies)){
218
+ // foreach ($taxonomies as $tKey=>$taxonomy){
219
+ // $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
220
+ // }
221
+ // }
222
+
223
+ }
224
+ else if ( $prod->is_type( 'external' ) ) {
225
+ $id = $prod->get_id();
226
+ $external = new WC_Product_External( $id );
227
+
228
+ if(!is_object($external)){
229
+ continue;
230
+ }
231
+
232
+ $this->productsList[ $this->pi ]["id"] = $external->get_id();
233
+ $this->productsList[ $this->pi ]["title"] = $external->get_name();
234
+ $this->productsList[ $this->pi ]["description"] = $this->remove_short_codes($external->get_description());
235
+ $this->productsList[ $this->pi ]['variation_type'] = $external->get_type();
236
+
237
+ $this->productsList[ $this->pi ]['short_description'] = $this->remove_short_codes($external->get_short_description());
238
+ $this->productsList[ $this->pi ]['product_type'] = strip_tags( wc_get_product_category_list( $id, ">", "" ) );
239
+ $this->productsList[ $this->pi ]['link'] = $external->get_permalink();
240
+ $this->productsList[ $this->pi ]['ex_link'] = $external->get_product_url();
241
+
242
+
243
+ # Featured Image
244
+ if ( has_post_thumbnail( $id ) ):
245
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
246
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
247
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
248
+ else:
249
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
250
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
251
+ endif;
252
+
253
+ # Additional Images
254
+ $attachmentIds = $external->get_gallery_image_ids();
255
+ $imgUrls = array();
256
+ if ( $attachmentIds && is_array( $attachmentIds ) ) {
257
+ $mKey = 1;
258
+ foreach ( $attachmentIds as $attachmentId ) {
259
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
260
+ $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
261
+ $mKey ++;
262
+ }
263
+
264
+ }
265
+
266
+ $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
267
+ $this->productsList[ $this->pi ]['condition'] = "New";
268
+ $this->productsList[ $this->pi ]['type'] = $external->get_type();
269
+ $this->productsList[ $this->pi ]['is_bundle'] = "no";
270
+ $this->productsList[ $this->pi ]['multipack'] = "";
271
+ $this->productsList[ $this->pi ]['visibility'] = $external->get_catalog_visibility();
272
+ $this->productsList[ $this->pi ]['rating_total'] = $external->get_rating_count();
273
+ $this->productsList[ $this->pi ]['rating_average'] = $external->get_average_rating();
274
+ $this->productsList[ $this->pi ]['tags'] = strip_tags( wc_get_product_tag_list( $id, "," ) );
275
+ $this->productsList[ $this->pi ]['item_group_id'] = $external->get_id();
276
+ $this->productsList[ $this->pi ]['sku'] = $external->get_sku();
277
+ $this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
278
+ $this->productsList[ $this->pi ]['quantity'] = $external->get_stock_quantity();
279
+ $this->productsList[ $this->pi ]['sale_price_sdate'] = $external->get_date_on_sale_from();
280
+ $this->productsList[ $this->pi ]['sale_price_edate'] = $external->get_date_on_sale_to();
281
+ $this->productsList[ $this->pi ]['price'] = $external->get_regular_price();
282
+
283
+ $this->productsList[ $this->pi ]['sale_price'] = $external->get_sale_price();
284
+ $this->productsList[ $this->pi ]['weight'] = $external->get_weight();
285
+ $this->productsList[ $this->pi ]['width'] = $external->get_width();
286
+ $this->productsList[ $this->pi ]['height'] = $external->get_height();
287
+ $this->productsList[ $this->pi ]['length'] = $external->get_length();
288
+ $this->productsList[ $this->pi ]['shipping_class'] = $external->get_shipping_class();
289
+
290
+
291
+ # Sale price effective date
292
+ $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
293
+ $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
294
+ if ( ! empty( $from ) && ! empty( $to ) ) {
295
+ $from = date( "c", strtotime( $from ) );
296
+ $to = date( "c", strtotime( $to ) );
297
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
298
+ } else {
299
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
300
+ }
301
+
302
+ # Get all Attributes and their values
303
+ $data=$external->get_data();
304
+ $attributes=$data['attributes'];
305
+ if(!empty($attributes)){
306
+ foreach ($attributes as $aKey=>$attr){
307
+ $this->productsList[ $this->pi ][$aKey] = $external->get_attribute($aKey);
308
+ }
309
+ }
310
+
311
+
312
+ // # Get all Product Post Meta and Their Values
313
+ // $metas=get_post_meta($id);
314
+ // if(!empty($metas)){
315
+ // foreach ($metas as $mKey=>$meta){
316
+ // if($mKey!="_product_attributes"){
317
+ // $metaValue=get_post_meta($id,$mKey,true);
318
+ // $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
319
+ // }
320
+ // }
321
+ // }
322
+ //
323
+ // # Get all Product Taxonomies and Their values
324
+ // $taxonomies=get_post_taxonomies($id);
325
+ // if(!empty($taxonomies)){
326
+ // foreach ($taxonomies as $tKey=>$taxonomy){
327
+ // $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
328
+ // }
329
+ // }
330
+ }
331
+ else if ( $prod->is_type( 'grouped' ) ) {
332
+ $id = $prod->get_id();
333
+ $grouped = new WC_Product_Grouped( $id );
334
+
335
+ if(!is_object($grouped)){
336
+ continue;
337
+ }
338
+
339
+ $this->productsList[ $this->pi ]["id"] = $grouped->get_id();
340
+ $this->productsList[ $this->pi ]["title"] = $grouped->get_name();
341
+ $this->productsList[ $this->pi ]["description"] = $this->remove_short_codes($grouped->get_description());
342
+ $this->productsList[ $this->pi ]['variation_type'] = $grouped->get_type();
343
+
344
+ $this->productsList[ $this->pi ]['short_description'] = $this->remove_short_codes($grouped->get_short_description());
345
+ $this->productsList[ $this->pi ]['product_type'] = strip_tags( wc_get_product_category_list( $id, ">", "" ) );//$this->get_product_term_list( $post->ID, 'product_cat', "", ">" );// $this->categories($this->parentID);//TODO
346
+ $this->productsList[ $this->pi ]['link'] = $grouped->get_permalink();
347
+ $this->productsList[ $this->pi ]['ex_link'] = $grouped->get_permalink();
348
+
349
+
350
+ # Featured Image
351
+ if ( has_post_thumbnail( $id ) ):
352
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
353
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
354
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
355
+ else:
356
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
357
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
358
+ endif;
359
+
360
+ # Additional Images
361
+ $attachmentIds = $grouped->get_gallery_image_ids();
362
+ $imgUrls = array();
363
+ if ( $attachmentIds && is_array( $attachmentIds ) ) {
364
+ $mKey = 1;
365
+ foreach ( $attachmentIds as $attachmentId ) {
366
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
367
+ $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
368
+ $mKey ++;
369
+ }
370
+
371
+ }
372
+
373
+ $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
374
+ $this->productsList[ $this->pi ]['condition'] = "New";
375
+ $this->productsList[ $this->pi ]['type'] = $grouped->get_type();
376
+ $this->productsList[ $this->pi ]['is_bundle'] = "no";
377
+ $this->productsList[ $this->pi ]['multipack'] = ( count( $grouped->get_children() ) > 0 ) ? count( $grouped->get_children() ) : "";
378
+ $this->productsList[ $this->pi ]['visibility'] = $grouped->get_catalog_visibility();
379
+ $this->productsList[ $this->pi ]['rating_total'] = $grouped->get_rating_count();
380
+ $this->productsList[ $this->pi ]['rating_average'] = $grouped->get_average_rating();
381
+ $this->productsList[ $this->pi ]['tags'] = strip_tags( wc_get_product_tag_list( $id, "," ) );
382
+ $this->productsList[ $this->pi ]['item_group_id'] = $grouped->get_id();
383
+ $this->productsList[ $this->pi ]['sku'] = $grouped->get_sku();
384
+ $this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
385
+ $this->productsList[ $this->pi ]['quantity'] = $grouped->get_stock_quantity();
386
+ $this->productsList[ $this->pi ]['sale_price_sdate'] = $grouped->get_date_on_sale_from();
387
+ $this->productsList[ $this->pi ]['sale_price_edate'] = $grouped->get_date_on_sale_to();
388
+ $this->productsList[ $this->pi ]['price'] = $grouped->get_regular_price();
389
+ $this->productsList[ $this->pi ]['sale_price'] = $grouped->get_sale_price();
390
+ $this->productsList[ $this->pi ]['weight'] = $grouped->get_weight();
391
+ $this->productsList[ $this->pi ]['width'] = $grouped->get_width();
392
+ $this->productsList[ $this->pi ]['height'] = $grouped->get_height();
393
+ $this->productsList[ $this->pi ]['length'] = $grouped->get_length();
394
+ $this->productsList[ $this->pi ]['shipping_class'] = $grouped->get_shipping_class();
395
+
396
+
397
+ # Sale price effective date
398
+ $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
399
+ $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
400
+ if ( ! empty( $from ) && ! empty( $to ) ) {
401
+ $from = date( "c", strtotime( $from ) );
402
+ $to = date( "c", strtotime( $to ) );
403
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
404
+ } else {
405
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
406
+ }
407
+
408
+ # Get all Attributes and their values
409
+ $data=$grouped->get_data();
410
+ $attributes=$data['attributes'];
411
+ if(!empty($attributes)){
412
+ foreach ($attributes as $aKey=>$attr){
413
+ $this->productsList[ $this->pi ][$aKey] = $grouped->get_attribute($aKey);
414
+ }
415
+ }
416
+
417
+
418
+ // # Get all Product Post Meta and Their Values
419
+ // $metas=get_post_meta($id);
420
+ // if(!empty($metas)){
421
+ // foreach ($metas as $mKey=>$meta){
422
+ // if($mKey!="_product_attributes"){
423
+ // $metaValue=get_post_meta($id,$mKey,true);
424
+ // $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
425
+ // }
426
+ // }
427
+ // }
428
+ //
429
+ // # Get all Product Taxonomies and Their values
430
+ // $taxonomies=get_post_taxonomies($id);
431
+ // if(!empty($taxonomies)){
432
+ // foreach ($taxonomies as $tKey=>$taxonomy){
433
+ // $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
434
+ // }
435
+ // }
436
+ }
437
+ else if ( $prod->is_type( 'variable' ) ) {
438
+
439
+ $id = $prod->get_id();
440
+ $variable = new WC_Product_Variable( $id );
441
+
442
+ if(!is_object($variable)){
443
+ continue;
444
+ }
445
+
446
+
447
+
448
+ $this->productsList[ $this->pi ]["attrs"] = wc_get_attribute_taxonomy_names();
449
+ $this->productsList[ $this->pi ]["attrs_text"] = wc_get_attribute_taxonomies();
450
+
451
+ $this->productsList[ $this->pi ]["id"] = $variable->get_id();
452
+ $this->productsList[ $this->pi ]["title"] = $variable->get_name();
453
+ $this->productsList[ $this->pi ]["description"] = $this->remove_short_codes($variable->get_description());
454
+ $this->productsList[ $this->pi ]['variation_type'] = $variable->get_type();
455
+
456
+ $this->productsList[ $this->pi ]['short_description'] = $this->remove_short_codes($variable->get_short_description());
457
+ $this->productsList[ $this->pi ]['product_type'] = strip_tags( wc_get_product_category_list( $id, ">", "" ) );
458
+ $this->productsList[ $this->pi ]['link'] = $variable->get_permalink();
459
+ $this->productsList[ $this->pi ]['ex_link'] = $variable->get_permalink();
460
+
461
+
462
+ # Featured Image
463
+ if ( has_post_thumbnail( $id ) ):
464
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
465
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
466
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
467
+ else:
468
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
469
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( wp_get_attachment_url( $id ) );
470
+ endif;
471
+
472
+ # Additional Images
473
+ $attachmentIds = $variable->get_gallery_image_ids();
474
+ $imgUrls = array();
475
+ if ( $attachmentIds && is_array( $attachmentIds ) ) {
476
+ $mKey = 1;
477
+ foreach ( $attachmentIds as $attachmentId ) {
478
+ $imgUrls[ $mKey ] = $this->get_formatted_url( wp_get_attachment_url( $attachmentId ) );
479
+ $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[ $mKey ];
480
+ $mKey ++;
481
+ }
482
+
483
+ }
484
+
485
+ $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
486
+ $this->productsList[ $this->pi ]['condition'] = "New";
487
+ $this->productsList[ $this->pi ]['type'] = $variable->get_type();
488
+ $this->productsList[ $this->pi ]['is_bundle'] = "no";
489
+ $this->productsList[ $this->pi ]['multipack'] = "";
490
+ $this->productsList[ $this->pi ]['visibility'] = $variable->get_catalog_visibility();
491
+ $this->productsList[ $this->pi ]['rating_total'] = $variable->get_rating_count();
492
+ $this->productsList[ $this->pi ]['rating_average'] = $variable->get_average_rating();
493
+ $this->productsList[ $this->pi ]['tags'] = strip_tags( wc_get_product_tag_list( $id, "," ) );
494
+ $this->productsList[ $this->pi ]['item_group_id'] = $variable->get_id();
495
+ $this->productsList[ $this->pi ]['sku'] = $variable->get_sku();
496
+ $this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
497
+
498
+ if ( $this->feedRule['variable_price'] == 'first' ) {
499
+ $price = $variable->get_regular_price();
500
+ $sPrice = $variable->get_sale_price();
501
+ } else {
502
+ $price = $variable->get_variation_regular_price( $this->feedRule['variable_price'], $variable->is_taxable() );
503
+ $sPrice = $variable->get_variation_sale_price( $this->feedRule['variable_price'], $variable->is_taxable() );
504
+ }
505
+
506
+ $this->productsList[ $this->pi ]['quantity'] = $variable->get_stock_quantity();
507
+ $this->productsList[ $this->pi ]['sale_price_sdate'] = $variable->get_date_on_sale_from();
508
+ $this->productsList[ $this->pi ]['sale_price_edate'] = $variable->get_date_on_sale_to();
509
+ $this->productsList[ $this->pi ]['price'] = $price;
510
+ $this->productsList[ $this->pi ]['sale_price'] = $sPrice;
511
+ $this->productsList[ $this->pi ]['weight'] = $variable->get_weight();
512
+ $this->productsList[ $this->pi ]['width'] = $variable->get_width();
513
+ $this->productsList[ $this->pi ]['height'] = $variable->get_height();
514
+ $this->productsList[ $this->pi ]['length'] = $variable->get_length();
515
+ $this->productsList[ $this->pi ]['shipping_class'] = $variable->get_shipping_class();
516
+
517
+
518
+ # Sale price effective date
519
+ $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
520
+ $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
521
+ if ( ! empty( $from ) && ! empty( $to ) ) {
522
+ $from = date( "c", strtotime( $from ) );
523
+ $to = date( "c", strtotime( $to ) );
524
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
525
+ } else {
526
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
527
+ }
528
+
529
+ # Get all Attributes and their values
530
+ $data=$variable->get_data();
531
+ $attributes=$data['attributes'];
532
+ if(!empty($attributes)){
533
+ foreach ($attributes as $aKey=>$attr){
534
+ $this->productsList[ $this->pi ][$aKey] = $variable->get_attribute($aKey);
535
+ }
536
+ }
537
+
538
+
539
+ // # Get all Product Post Meta and Their Values
540
+ // $metas=get_post_meta($id);
541
+ // if(!empty($metas)){
542
+ // foreach ($metas as $mKey=>$meta){
543
+ // if($mKey!="_product_attributes"){
544
+ // $metaValue=get_post_meta($id,$mKey,true);
545
+ // $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
546
+ // }
547
+ // }
548
+ // }
549
+ //
550
+ // # Get all Product Taxonomies and Their values
551
+ // $taxonomies=get_post_taxonomies($id);
552
+ // if(!empty($taxonomies)){
553
+ // foreach ($taxonomies as $tKey=>$taxonomy){
554
+ // $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
555
+ // }
556
+ // }
557
+
558
+ # Don't Include Variations for Facebook
559
+ if ( $this->feedRule['provider'] != 'facebook' ) {
560
+ $this->getWC3Variations( $variable->get_available_variations(),$variable);
561
+ }
562
+
563
+ }
564
+
565
+ $this->pi ++;
566
+ }
567
+
568
+
569
+ return $this->productsList;
570
+ }catch (Exception $e){
571
+
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Get Product Variations of a variable product
577
+ * @since 2.2.0
578
+ * @for WC 3.1+
579
+ * @param $variations
580
+ * @param $parent
581
+ */
582
+ public function getWC3Variations($variations,$parent) {
583
+ try{
584
+ if(is_array($variations) && (sizeof($variations) > 0 )){
585
+ foreach ($variations as $vKey=>$variationProd){
586
+
587
+ $this->pi++;
588
+ $id=$variationProd['variation_id'];
589
+
590
+ $variation=new WC_Product_Variation($id);
591
+
592
+ if(!is_object($variation)){
593
+ continue;
594
+ }
595
+
596
+ # Parent Info
597
+ $parentInfo=$variation->get_parent_data();
598
+ $variationTitle= $parentInfo['title'];
599
+
600
+ # Set Variation Description
601
+ $description=$variation->get_description();
602
+ if(empty($description)){
603
+ $description=$parent->get_description();
604
+ }
605
+ $description=$this->remove_short_codes($description);
606
+
607
+ # Set Variation Short Description
608
+ $short_description=$variation->get_short_description();
609
+ if(empty($short_description)){
610
+ $short_description=$parent->get_short_description();
611
+ }
612
+ $short_description=$this->remove_short_codes($short_description);
613
+
614
+ $this->productsList[ $this->pi ]["id"] = $variation->get_id();
615
+ $this->productsList[ $this->pi ]["title"] = $variationTitle;
616
+ $this->productsList[ $this->pi ]["description"] = $description;
617
+ $this->productsList[ $this->pi ]['variation_type'] = $variation->get_type();
618
+
619
+ $this->productsList[ $this->pi ]['short_description'] = $short_description;
620
+ $this->productsList[ $this->pi ]['product_type'] = strip_tags(wc_get_product_category_list($variation->get_parent_id(),">",""));
621
+ $this->productsList[ $this->pi ]['link'] = $variation->get_permalink();
622
+ $this->productsList[ $this->pi ]['ex_link'] = $variation->get_permalink();
623
+
624
+
625
+ # Featured Image
626
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
627
+ if ( has_post_thumbnail( $id ) && !empty($image[0])):
628
+
629
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
630
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
631
+ else:
632
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $variation->get_parent_id() ), 'single-post-thumbnail' );
633
+ $this->productsList[ $this->pi ]['image'] = $this->get_formatted_url( $image[0] );
634
+ $this->productsList[ $this->pi ]['feature_image'] = $this->get_formatted_url( $image[0] );
635
+ endif;
636
+
637
+ # Additional Images
638
+ $attachmentIds = $variation->get_gallery_image_ids();
639
+ $imgUrls = array();
640
+ if ( $attachmentIds && is_array( $attachmentIds ) ) {
641
+ $mKey = 1;
642
+ foreach ( $attachmentIds as $attachmentId ) {
643
+ $imgUrls[$mKey] =$this->get_formatted_url( wp_get_attachment_url( $attachmentId ));
644
+ $this->productsList[ $this->pi ]["image_$mKey"] = $imgUrls[$mKey];
645
+ $mKey ++;
646
+ }
647
+
648
+ }
649
+
650
+ $this->productsList[ $this->pi ]['images'] = implode( ",", $imgUrls );
651
+ $this->productsList[ $this->pi ]['condition'] = "New";
652
+ $this->productsList[ $this->pi ]['type'] = $variation->get_type();
653
+ $this->productsList[ $this->pi ]['is_bundle'] = "no";
654
+ $this->productsList[ $this->pi ]['multipack'] = "";
655
+ $this->productsList[ $this->pi ]['visibility'] = $variation->get_catalog_visibility();
656
+ $this->productsList[ $this->pi ]['rating_total'] = $variation->get_rating_count();
657
+ $this->productsList[ $this->pi ]['rating_average'] = $variation->get_average_rating();
658
+ $this->productsList[ $this->pi ]['tags'] = strip_tags(wc_get_product_tag_list($id,","));
659
+ $this->productsList[ $this->pi ]['item_group_id'] = $variation->get_parent_id();
660
+ $this->productsList[ $this->pi ]['sku'] = $variation->get_sku();
661
+ $this->productsList[ $this->pi ]['availability'] = $this->availability( $id );
662
+ $this->productsList[ $this->pi ]['quantity'] = $variation->get_stock_quantity();
663
+ $this->productsList[ $this->pi ]['sale_price_sdate'] = $variation->get_date_on_sale_from();
664
+ $this->productsList[ $this->pi ]['sale_price_edate'] = $variation->get_date_on_sale_to();
665
+ $this->productsList[ $this->pi ]['price'] = $variation->get_regular_price();
666
+ $this->productsList[ $this->pi ]['sale_price'] = $variation->get_sale_price();
667
+ $this->productsList[ $this->pi ]['weight'] = $variation->get_weight();
668
+ $this->productsList[ $this->pi ]['width'] = $variation->get_width();
669
+ $this->productsList[ $this->pi ]['height'] = $variation->get_height();
670
+ $this->productsList[ $this->pi ]['length'] = $variation->get_length();
671
+ $this->productsList[ $this->pi ]['shipping_class'] = $variation->get_shipping_class();
672
+
673
+
674
+ # Sale price effective date
675
+ $from = $this->sale_price_effective_date( $id, '_sale_price_dates_from' );
676
+ $to = $this->sale_price_effective_date( $id, '_sale_price_dates_to' );
677
+ if ( ! empty( $from ) && ! empty( $to ) ) {
678
+ $from = date( "c", strtotime( $from ) );
679
+ $to = date( "c", strtotime( $to ) );
680
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "$from" . "/" . "$to";
681
+ } else {
682
+ $this->productsList[ $this->pi ]['sale_price_effective_date'] = "";
683
+ }
684
+
685
+ # Get all Attributes and their values
686
+ $data=$variation->get_data();
687
+ $attributes=$data['attributes'];
688
+ if(!empty($attributes)){
689
+ foreach ($attributes as $aKey=>$attr){
690
+ $this->productsList[ $this->pi ][$aKey] = $variation->get_attribute($aKey);
691
+ }
692
+ }
693
+
694
+
695
+ // # Get all Product Post Meta and Their Values
696
+ // $metas=get_post_meta($id);
697
+ // if(!empty($metas)){
698
+ // foreach ($metas as $mKey=>$meta){
699
+ // if($mKey!="_product_attributes"){
700
+ // $metaValue=get_post_meta($id,$mKey,true);
701
+ // $this->productsList[ $this->pi ]["wf_cattr_".$mKey]=(!empty($metaValue))?$metaValue:"";
702
+ // }
703
+ // }
704
+ // }
705
+ //
706
+ // # Get all Product Taxonomies and Their values
707
+ // $taxonomies=get_post_taxonomies($id);
708
+ // if(!empty($taxonomies)){
709
+ // foreach ($taxonomies as $tKey=>$taxonomy){
710
+ // $this->productsList[ $this->pi ]["wf_taxo_".$taxonomy]=strip_tags(get_the_term_list($id,$taxonomy,"",",",""));
711
+ // }
712
+ // }
713
+
714
+ }
715
+ }
716
+ }catch (Exception $e){
717
+
718
+ }
719
+
720
+
721
+ }
722
+
723
+
724
  /**
725
  * Get WooCommerce Product
726
  * @param string $feedRule
728
  */
729
  public function woo_feed_get_visible_product($feedRule="")
730
  {
731
+ $this->feedRule = $feedRule;
732
+ $limit = ! empty( $feedRule['Limit'] ) && is_numeric( $feedRule['Limit'] ) ? absint( $feedRule['Limit'] ) : '2000';
733
+ $offset = ! empty( $feedRule['Offset'] ) && is_numeric( $feedRule['Offset'] ) ? absint( $feedRule['Offset'] ) : '0';
734
+ # WC 3.1+ Compatibility
735
+
736
+ if ( woo_feed_wc_version_check(3.1) ) {
737
+
738
+ return $this->getWC3Products( $limit, $offset);
739
+
740
+ } else {
741
+ try {
742
+
743
+ if ( ! empty( $feedRule ) ) {
744
+ $this->feedRule = $feedRule;
745
+ }
746
+
747
+
748
+ if ( $offset == '0' ) {
749
+ delete_option( "wf_check_duplicate" );
750
+ }
751
+ $getIDs = get_option( "wf_check_duplicate" );
752
+ $arg = array(
753
+ 'post_type' => array( 'product', 'product_variation' ),
754
+ 'post_status' => 'publish',
755
+ 'posts_per_page' => $limit,
756
+ 'orderby' => 'date',
757
+ 'order' => 'desc',
758
+ 'fields' => 'ids',
759
+ 'offset' => $offset,
760
+ 'cache_results' => false,
761
+ 'update_post_term_cache' => false,
762
+ 'update_post_meta_cache' => false,
763
+ );
764
+
765
+
766
+ # Query Database for products
767
+ $loop = new WP_Query( $arg );
768
+
769
+ $i = 0;
770
+
771
+ while ( $loop->have_posts() ) : $loop->the_post();
772
+
773
+ $this->childID = get_the_ID();
774
+ $this->parentID = ( wp_get_post_parent_id( $this->childID ) ) ? wp_get_post_parent_id( $this->childID ) : $this->childID;
775
+
776
+ global $product;
777
+ if ( ! is_object( $product ) || ! $product->is_visible() ) {
778
+ continue;
779
+ }
780
+
781
+ $type1 = "";
782
+ if ( is_object( $product ) && $product->is_type( 'simple' ) ) {
783
+ # No variations to product
784
+ $type1 = "simple";
785
+ } elseif ( is_object( $product ) && $product->is_type( 'variable' ) ) {
786
+ # Product has variations
787
+ $type1 = "variable";
788
+ } elseif ( is_object( $product ) && $product->is_type( 'grouped' ) ) {
789
+ $type1 = "grouped";
790
+ } elseif ( is_object( $product ) && $product->is_type( 'external' ) ) {
791
+ $type1 = "external";
792
+ } elseif ( is_object( $product ) && $product->is_downloadable() ) {
793
+ $type1 = "downloadable";
794
+ } elseif ( is_object( $product ) && $product->is_virtual() ) {
795
+ $type1 = "virtual";
796
+ }
797
+
798
+
799
+ $post = get_post( $this->parentID );
800
+
801
+ if ( ! is_object( $post ) ) {
802
+ continue;
803
+ }
804
+
805
+ if ( $post->post_status == 'trash' ) {
806
+ continue;
807
+ }
808
+
809
+
810
+ if ( get_post_type() == 'product_variation' && $this->feedRule['provider'] != 'facebook' ) {
811
+ if ( $this->parentID != 0 ) {
812
+
813
+ $status = get_post( $this->childID );
814
+ if ( ! $status || ! is_object( $status ) ) {
815
+ continue;
816
+ }
817
+
818
+ if ( $status->post_status == "trash" ) {
819
+ continue;
820
+ }
821
+
822
+ $parentStatus = get_post( $this->parentID );
823
+ if ( $parentStatus && is_object( $parentStatus ) && $parentStatus->post_status != 'publish' ) {
824
+ continue;
825
+ }
826
+
827
+ # Check Valid URL
828
+ $mainImage = wp_get_attachment_url( $product->get_image_id() );
829
+ $link = $product->get_permalink( $this->childID );
830
+
831
+ if ( $this->feedRule['provider'] != 'custom' ) {
832
+ if ( substr( trim( $link ), 0, 4 ) !== "http" && substr( trim( $mainImage ), 0, 4 ) !== "http" ) {
833
+ continue;
834
+ }
835
+ }
836
+
837
+ if ( $getIDs ) {
838
+ if ( in_array( $this->childID, $getIDs ) ) {
839
+ continue;
840
+ } else {
841
+ array_push( $this->idExist, $this->childID );
842
+ }
843
+ } else {
844
+ array_push( $this->idExist, $this->childID );
845
+ }
846
+
847
+
848
+ $this->productsList[ $i ]['id'] = $this->childID;
849
+ $this->productsList[ $i ]['variation_type'] = "child";
850
+ $this->productsList[ $i ]['item_group_id'] = $this->parentID;
851
+ $this->productsList[ $i ]['sku'] = $this->getAttributeValue( $this->childID, "_sku" );
852
+ $this->productsList[ $i ]['parent_sku'] = $this->getAttributeValue( $this->parentID, "_sku" );
853
+ $this->productsList[ $i ]['title'] = $post->post_title;
854
+ $this->productsList[ $i ]['description'] = $post->post_content;
855
+
856
+ # Short Description to variable description
857
+ $vDesc = $this->getAttributeValue( $this->childID, "_variation_description" );
858
+ if ( ! empty( $vDesc ) ) {
859
+ $this->productsList[ $i ]['short_description'] = $vDesc;
860
+ } else {
861
+ $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
862
+ }
863
+
864
+ $this->productsList[ $i ]['product_type'] = $this->get_product_term_list( $post->ID, 'product_cat', "", ">" );
865
+ $this->productsList[ $i ]['link'] = $link;
866
+ $this->productsList[ $i ]['ex_link'] = "";
867
+ $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
868
+
869
+ # Featured Image
870
+ if ( has_post_thumbnail( $post->ID ) ):
871
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
872
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
873
+ else:
874
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
875
+ endif;
876
+
877
+ # Additional Images
878
+ $imageLinks = array();
879
+ $images = $this->additionalImages( $this->childID );
880
+ if ( $images && is_array( $images ) ) {
881
+ $mKey = 1;
882
+ foreach ( $images as $key => $value ) {
883
+ if ( $value != $this->productsList[ $i ]['image'] ) {
884
+ $imgLink = $this->get_formatted_url( $value );
885
+ $this->productsList[ $i ]["image_$mKey"] = $imgLink;
886
+ if ( ! empty( $imgLink ) ) {
887
+ array_push( $imageLinks, $imgLink );
888
+ }
889
+ }
890
+ $mKey ++;
891
+ }
892
+ }
893
+ $this->productsList[ $i ]['images'] = implode( ",", $imageLinks );
894
+ $this->productsList[ $i ]['condition'] = "New";
895
+ $this->productsList[ $i ]['type'] = $product->get_type();
896
+ $this->productsList[ $i ]['visibility'] = $this->getAttributeValue( $this->childID, "_visibility" );
897
+ $this->productsList[ $i ]['rating_total'] = $product->get_rating_count();
898
+ $this->productsList[ $i ]['rating_average'] = $product->get_average_rating();
899
+ $this->productsList[ $i ]['tags'] = $this->get_product_term_list( $post->ID, 'product_tag' );
900
+ $this->productsList[ $i ]['shipping'] = $product->get_shipping_class();
901
+
902
+ $this->productsList[ $i ]['availability'] = $this->availability( $this->childID );
903
+ $this->productsList[ $i ]['quantity'] = $this->get_quantity( $this->childID, "_stock" );
904
+ $this->productsList[ $i ]['sale_price_sdate'] = $this->get_date( $this->childID, "_sale_price_dates_from" );
905
+ $this->productsList[ $i ]['sale_price_edate'] = $this->get_date( $this->childID, "_sale_price_dates_to" );
906
+ $this->productsList[ $i ]['price'] = ( $product->get_regular_price() ) ? $product->get_regular_price() : $product->get_price();
907
+ $this->productsList[ $i ]['sale_price'] = ( $product->get_sale_price() ) ? $product->get_sale_price() : "";
908
+ $this->productsList[ $i ]['weight'] = ( $product->get_weight() ) ? $product->get_weight() : "";
909
+ $this->productsList[ $i ]['width'] = ( $product->get_width() ) ? $product->get_width() : "";
910
+ $this->productsList[ $i ]['height'] = ( $product->get_height() ) ? $product->get_height() : "";
911
+ $this->productsList[ $i ]['length'] = ( $product->get_length() ) ? $product->get_length() : "";
912
+
913
+ # Sale price effective date
914
+ $from = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_from' );
915
+ $to = $this->sale_price_effective_date( $this->childID, '_sale_price_dates_to' );
916
+ if ( ! empty( $from ) && ! empty( $to ) ) {
917
+ $from = date( "c", strtotime( $from ) );
918
+ $to = date( "c", strtotime( $to ) );
919
+ $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
920
+ } else {
921
+ $this->productsList[ $i ]['sale_price_effective_date'] = "";
922
+ }
923
+
924
+ }
925
+ } elseif ( get_post_type() == 'product' ) {
926
+ if ( $type1 == 'simple' ) {
927
+
928
+ $mainImage = wp_get_attachment_url( $product->get_image_id() );
929
+ $link = get_permalink( $post->ID );
930
+
931
+ if ( $this->feedRule['provider'] != 'custom' ) {
932
+ if ( substr( trim( $link ), 0, 4 ) !== "http" && substr( trim( $mainImage ), 0, 4 ) !== "http" ) {
933
+ continue;
934
+ }
935
+ }
936
+
937
+ if ( $getIDs ) {
938
+ if ( in_array( $post->ID, $getIDs ) ) {
939
+ continue;
940
+ } else {
941
+ array_push( $this->idExist, $post->ID );
942
+ }
943
+ } else {
944
+ array_push( $this->idExist, $post->ID );
945
+ }
946
+
947
+ $this->productsList[ $i ]['id'] = $post->ID;
948
+ $this->productsList[ $i ]['variation_type'] = "simple";
949
+ $this->productsList[ $i ]['title'] = $product->get_title();
950
+ $this->productsList[ $i ]['description'] = $post->post_content;
951
+
952
+ $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
953
+ $this->productsList[ $i ]['product_type'] = $this->get_product_term_list( $post->ID, 'product_cat', "", ">" );
954
+ $this->productsList[ $i ]['link'] = $link;
955
+ $this->productsList[ $i ]['ex_link'] = "";
956
+ $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
957
+
958
+ # Featured Image
959
+ if ( has_post_thumbnail( $post->ID ) ):
960
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
961
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
962
+ else:
963
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
964
+ endif;
965
+
966
+ # Additional Images
967
+ $imageLinks = array();
968
+ $images = $this->additionalImages( $post->ID );
969
+ if ( $images && is_array( $images ) ) {
970
+ $mKey = 1;
971
+ foreach ( $images as $key => $value ) {
972
+ if ( $value != $this->productsList[ $i ]['image'] ) {
973
+ $imgLink = $this->get_formatted_url( $value );
974
+ $this->productsList[ $i ]["image_$mKey"] = $imgLink;
975
+ if ( ! empty( $imgLink ) ) {
976
+ array_push( $imageLinks, $imgLink );
977
+ }
978
+ }
979
+ $mKey ++;
980
+ }
981
+ }
982
+ $this->productsList[ $i ]['images'] = implode( ",", $imageLinks );
983
+
984
+ $this->productsList[ $i ]['condition'] = "New";
985
+ $this->productsList[ $i ]['type'] = $product->get_type();
986
+ $this->productsList[ $i ]['visibility'] = $this->getAttributeValue( $post->ID, "_visibility" );
987
+ $this->productsList[ $i ]['rating_total'] = $product->get_rating_count();
988
+ $this->productsList[ $i ]['rating_average'] = $product->get_average_rating();
989
+ $this->productsList[ $i ]['tags'] = $this->get_product_term_list( $post->ID, 'product_tag' );
990
+
991
+ $this->productsList[ $i ]['item_group_id'] = $post->ID;
992
+ $this->productsList[ $i ]['sku'] = $this->getAttributeValue( $post->ID, "_sku" );
993
+
994
+ $this->productsList[ $i ]['availability'] = $this->availability( $post->ID );
995
+ $this->productsList[ $i ]['quantity'] = $this->get_quantity( $post->ID, "_stock" );
996
+ $this->productsList[ $i ]['sale_price_sdate'] = $this->get_date( $post->ID, "_sale_price_dates_from" );
997
+ $this->productsList[ $i ]['sale_price_edate'] = $this->get_date( $post->ID, "_sale_price_dates_to" );
998
+ $this->productsList[ $i ]['price'] = ( $product->get_regular_price() ) ? $product->get_regular_price() : $product->get_price();
999
+ $this->productsList[ $i ]['sale_price'] = ( $product->get_sale_price() ) ? $product->get_sale_price() : "";
1000
+ $this->productsList[ $i ]['weight'] = ( $product->get_weight() ) ? $product->get_weight() : "";
1001
+ $this->productsList[ $i ]['width'] = ( $product->get_width() ) ? $product->get_width() : "";
1002
+ $this->productsList[ $i ]['height'] = ( $product->get_height() ) ? $product->get_height() : "";
1003
+ $this->productsList[ $i ]['length'] = ( $product->get_length() ) ? $product->get_length() : "";
1004
+
1005
+ # Sale price effective date
1006
+ $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1007
+ $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1008
+ if ( ! empty( $from ) && ! empty( $to ) ) {
1009
+ $from = date( "c", strtotime( $from ) );
1010
+ $to = date( "c", strtotime( $to ) );
1011
+ $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1012
+ } else {
1013
+ $this->productsList[ $i ]['sale_price_effective_date'] = "";
1014
+ }
1015
+
1016
+ }
1017
+ else if ( $type1 == 'external' ) {
1018
+
1019
+ $mainImage = wp_get_attachment_url( $product->get_image_id() );
1020
+
1021
+ $getLink = new WC_Product_External( $post->ID );
1022
+ $EX_link = $getLink->get_product_url();
1023
+ $link = get_permalink( $post->ID );
1024
+ if ( $this->feedRule['provider'] != 'custom' ) {
1025
+ if ( substr( trim( $link ), 0, 4 ) !== "http" && substr( trim( $mainImage ), 0, 4 ) !== "http" ) {
1026
+ continue;
1027
+ }
1028
+ }
1029
+
1030
+ $this->productsList[ $i ]['id'] = $post->ID;
1031
+ $this->productsList[ $i ]['variation_type'] = "external";
1032
+ $this->productsList[ $i ]['title'] = $product->get_title();
1033
+ $this->productsList[ $i ]['description'] = do_shortcode( $post->post_content );
1034
+
1035
+ $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
1036
+ $this->productsList[ $i ]['product_type'] = $this->get_product_term_list( $post->ID, 'product_cat', "", ">" );
1037
+ $this->productsList[ $i ]['link'] = $link;
1038
+ $this->productsList[ $i ]['ex_link'] = $EX_link;
1039
+ $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1040
+
1041
+ # Featured Image
1042
+ if ( has_post_thumbnail( $post->ID ) ):
1043
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1044
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1045
+ else:
1046
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1047
+ endif;
1048
+
1049
+ # Additional Images
1050
+ $imageLinks = array();
1051
+ $images = $this->additionalImages( $post->ID );
1052
+ if ( $images && is_array( $images ) ) {
1053
+ $mKey = 1;
1054
+ foreach ( $images as $key => $value ) {
1055
+ if ( $value != $this->productsList[ $i ]['image'] ) {
1056
+ $imgLink = $this->get_formatted_url( $value );
1057
+ $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1058
+ if ( ! empty( $imgLink ) ) {
1059
+ array_push( $imageLinks, $imgLink );
1060
+ }
1061
+ }
1062
+ $mKey ++;
1063
+ }
1064
+ }
1065
+ $this->productsList[ $i ]['images'] = implode( ",", $imageLinks );
1066
+
1067
+ $this->productsList[ $i ]['condition'] = "New";
1068
+ $this->productsList[ $i ]['type'] = $product->get_type();
1069
+ $this->productsList[ $i ]['visibility'] = $this->getAttributeValue( $post->ID, "_visibility" );
1070
+ $this->productsList[ $i ]['rating_total'] = $product->get_rating_count();
1071
+ $this->productsList[ $i ]['rating_average'] = $product->get_average_rating();
1072
+ $this->productsList[ $i ]['tags'] = $this->get_product_term_list( $post->ID, 'product_tag' );
1073
+
1074
+ $this->productsList[ $i ]['item_group_id'] = $post->ID;
1075
+ $this->productsList[ $i ]['sku'] = $this->getAttributeValue( $post->ID, "_sku" );
1076
+
1077
+ $this->productsList[ $i ]['availability'] = $this->availability( $post->ID );
1078
+
1079
+ $this->productsList[ $i ]['quantity'] = $this->get_quantity( $post->ID, "_stock" );
1080
+ $this->productsList[ $i ]['sale_price_sdate'] = $this->get_date( $post->ID, "_sale_price_dates_from" );
1081
+ $this->productsList[ $i ]['sale_price_edate'] = $this->get_date( $post->ID, "_sale_price_dates_to" );
1082
+ $this->productsList[ $i ]['price'] = ( $product->get_regular_price() ) ? $product->get_regular_price() : $product->get_price();
1083
+ $this->productsList[ $i ]['sale_price'] = ( $product->get_sale_price() ) ? $product->get_sale_price() : "";
1084
+ $this->productsList[ $i ]['weight'] = ( $product->get_weight() ) ? $product->get_weight() : "";
1085
+ $this->productsList[ $i ]['width'] = ( $product->get_width() ) ? $product->get_width() : "";
1086
+ $this->productsList[ $i ]['height'] = ( $product->get_height() ) ? $product->get_height() : "";
1087
+ $this->productsList[ $i ]['length'] = ( $product->get_length() ) ? $product->get_length() : "";
1088
+
1089
+ # Sale price effective date
1090
+ $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1091
+ $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1092
+ if ( ! empty( $from ) && ! empty( $to ) ) {
1093
+ $from = date( "c", strtotime( $from ) );
1094
+ $to = date( "c", strtotime( $to ) );
1095
+ $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1096
+ } else {
1097
+ $this->productsList[ $i ]['sale_price_effective_date'] = "";
1098
+ }
1099
+
1100
+ }
1101
+ elseif ( $type1 == 'grouped' ) {
1102
+
1103
+ $grouped = new WC_Product_Grouped( $post->ID );
1104
+ $children = $grouped->get_children();
1105
+ $this->parentID = $post->ID;
1106
+ if ( $children ) {
1107
+ foreach ( $children as $cKey => $child ) {
1108
+
1109
+ $product = new WC_Product( $child );
1110
+ $this->childID = $child;
1111
+ $post = get_post( $this->childID );
1112
+
1113
+ if ( $post->post_status == 'trash' ) {
1114
+ continue;
1115
+ }
1116
+
1117
+ if ( ! empty( $this->ids_in ) && ! in_array( $post->ID, $this->ids_in ) ) {
1118
+ continue;
1119
+ }
1120
+
1121
+ if ( ! empty( $this->ids_not_in ) && in_array( $post->ID, $this->ids_in ) ) {
1122
+ continue;
1123
+ }
1124
+
1125
+ if ( ! $product->is_visible() ) {
1126
+ continue;
1127
+ }
1128
+
1129
+ $i ++;
1130
+
1131
+ $mainImage = wp_get_attachment_url( $product->get_image_id() );
1132
+ $link = get_permalink( $post->ID );
1133
+ if ( $this->feedRule['provider'] != 'custom' ) {
1134
+ if ( substr( trim( $link ), 0, 4 ) !== "http" && substr( trim( $mainImage ), 0, 4 ) !== "http" ) {
1135
+ continue;
1136
+ }
1137
+ }
1138
+
1139
+ $this->productsList[ $i ]['id'] = $post->ID;
1140
+ $this->productsList[ $i ]['variation_type'] = "grouped";
1141
+ $this->productsList[ $i ]['title'] = $product->get_title();
1142
+ $this->productsList[ $i ]['description'] = do_shortcode( $post->post_content );
1143
+
1144
+ $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
1145
+ $this->productsList[ $i ]['product_type'] = $this->get_product_term_list( $post->ID, 'product_cat', "", ">" );
1146
+ $this->productsList[ $i ]['link'] = $link;
1147
+ $this->productsList[ $i ]['ex_link'] = "";
1148
+ $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1149
+
1150
+ # Featured Image
1151
+ if ( has_post_thumbnail( $post->ID ) ):
1152
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1153
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1154
+ else:
1155
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1156
+ endif;
1157
+
1158
+ # Additional Images
1159
+ $imageLinks = array();
1160
+ $images = $this->additionalImages( $this->childID );
1161
+ if ( $images and is_array( $images ) ) {
1162
+ $mKey = 1;
1163
+ foreach ( $images as $key => $value ) {
1164
+ if ( $value != $this->productsList[ $i ]['image'] ) {
1165
+ $imgLink = $this->get_formatted_url( $value );
1166
+ $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1167
+ if ( ! empty( $imgLink ) ) {
1168
+ array_push( $imageLinks, $imgLink );
1169
+ }
1170
+ }
1171
+ $mKey ++;
1172
+ }
1173
+ }
1174
+ $this->productsList[ $i ]['images'] = implode( ",", $imageLinks );
1175
+ $this->productsList[ $i ]['condition'] = "New";
1176
+ $this->productsList[ $i ]['type'] = $product->get_type();
1177
+ $this->productsList[ $i ]['visibility'] = $this->getAttributeValue( $post->ID, "_visibility" );
1178
+ $this->productsList[ $i ]['rating_total'] = $product->get_rating_count();
1179
+ $this->productsList[ $i ]['rating_average'] = $product->get_average_rating();
1180
+ $this->productsList[ $i ]['tags'] = $this->get_product_term_list( $post->ID, 'product_tag' );
1181
+
1182
+ $this->productsList[ $i ]['item_group_id'] = $this->parentID;
1183
+ $this->productsList[ $i ]['sku'] = $this->getAttributeValue( $post->ID, "_sku" );
1184
+
1185
+ $this->productsList[ $i ]['availability'] = $this->availability( $post->ID );
1186
+
1187
+ $this->productsList[ $i ]['quantity'] = $this->get_quantity( $post->ID, "_stock" );
1188
+ $this->productsList[ $i ]['sale_price_sdate'] = $this->get_date( $post->ID, "_sale_price_dates_from" );
1189
+ $this->productsList[ $i ]['sale_price_edate'] = $this->get_date( $post->ID, "_sale_price_dates_to" );
1190
+ $this->productsList[ $i ]['price'] = ( $product->get_regular_price() ) ? $product->get_regular_price() : $product->get_price();
1191
+ $this->productsList[ $i ]['sale_price'] = ( $product->get_sale_price() ) ? $product->get_sale_price() : "";
1192
+ $this->productsList[ $i ]['weight'] = ( $product->get_weight() ) ? $product->get_weight() : "";
1193
+ $this->productsList[ $i ]['width'] = ( $product->get_width() ) ? $product->get_width() : "";
1194
+ $this->productsList[ $i ]['height'] = ( $product->get_height() ) ? $product->get_height() : "";
1195
+ $this->productsList[ $i ]['length'] = ( $product->get_length() ) ? $product->get_length() : "";
1196
+
1197
+ # Sale price effective date
1198
+ $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1199
+ $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1200
+ if ( ! empty( $from ) && ! empty( $to ) ) {
1201
+ $from = date( "c", strtotime( $from ) );
1202
+ $to = date( "c", strtotime( $to ) );
1203
+ $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1204
+ } else {
1205
+ $this->productsList[ $i ]['sale_price_effective_date'] = "";
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+ else if ( $type1 == 'variable' && $product->has_child() ) {
1211
+
1212
+ # Check Valid URL
1213
+ $mainImage = wp_get_attachment_url( $product->get_image_id() );
1214
+ $link = get_permalink( $post->ID );
1215
+
1216
+ if ( $this->feedRule['provider'] != 'custom' ) {
1217
+ if ( substr( trim( $link ), 0, 4 ) !== "http" && substr( trim( $mainImage ), 0, 4 ) !== "http" ) {
1218
+ continue;
1219
+ }
1220
+ }
1221
+
1222
+
1223
+ $this->productsList[ $i ]['id'] = $post->ID;
1224
+ $this->productsList[ $i ]['variation_type'] = "parent";
1225
+ $this->productsList[ $i ]['title'] = $post->post_title;
1226
+ $this->productsList[ $i ]['description'] = $post->post_content;
1227
+
1228
+ $this->productsList[ $i ]['short_description'] = $post->post_excerpt;
1229
+ $this->productsList[ $i ]['product_type'] = $this->get_product_term_list( $post->ID, 'product_cat', "", ">" );
1230
+ $this->productsList[ $i ]['link'] = $link;
1231
+ $this->productsList[ $i ]['ex_link'] = "";
1232
+ $this->productsList[ $i ]['image'] = $this->get_formatted_url( $mainImage );
1233
+
1234
+ # Featured Image
1235
+ if ( has_post_thumbnail( $post->ID ) ):
1236
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
1237
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $image[0] );
1238
+ else:
1239
+ $this->productsList[ $i ]['feature_image'] = $this->get_formatted_url( $mainImage );
1240
+ endif;
1241
+
1242
+ # Additional Images
1243
+ $imageLinks = array();
1244
+ $images = $this->additionalImages( $post->ID );
1245
+ if ( $images and is_array( $images ) ) {
1246
+ $mKey = 1;
1247
+ foreach ( $images as $key => $value ) {
1248
+ if ( $value != $this->productsList[ $i ]['image'] ) {
1249
+ $imgLink = $this->get_formatted_url( $value );
1250
+ $this->productsList[ $i ]["image_$mKey"] = $imgLink;
1251
+ if ( ! empty( $imgLink ) ) {
1252
+ array_push( $imageLinks, $imgLink );
1253
+ }
1254
+ }
1255
+ $mKey ++;
1256
+ }
1257
+ }
1258
+ $this->productsList[ $i ]['images'] = implode( ",", $imageLinks );
1259
+
1260
+ $this->productsList[ $i ]['condition'] = "New";
1261
+ $this->productsList[ $i ]['type'] = $product->get_type();
1262
+ $this->productsList[ $i ]['visibility'] = $this->getAttributeValue( $post->ID, "_visibility" );
1263
+ $this->productsList[ $i ]['rating_total'] = $product->get_rating_count();
1264
+ $this->productsList[ $i ]['rating_average'] = $product->get_average_rating();
1265
+ $this->productsList[ $i ]['tags'] = $this->get_product_term_list( $post->ID, 'product_tag' );
1266
+
1267
+ $this->productsList[ $i ]['item_group_id'] = $post->ID;
1268
+ $this->productsList[ $i ]['sku'] = $this->getAttributeValue( $post->ID, "_sku" );
1269
+
1270
+ $this->productsList[ $i ]['availability'] = $this->availability( $post->ID );
1271
+ $this->productsList[ $i ]['quantity'] = $this->get_quantity( $post->ID, "_stock" );
1272
+ $this->productsList[ $i ]['sale_price_sdate'] = $this->get_date( $post->ID, "_sale_price_dates_from" );
1273
+ $this->productsList[ $i ]['sale_price_edate'] = $this->get_date( $post->ID, "_sale_price_dates_to" );
1274
+
1275
+ $price = ( $product->get_price() ) ? $product->get_price() : false;
1276
+
1277
+ $this->productsList[ $i ]['price'] = ( $product->get_regular_price() ) ? $product->get_regular_price() : $price;
1278
+ $this->productsList[ $i ]['sale_price'] = ( $product->get_sale_price() ) ? $product->get_sale_price() : "";
1279
+ $this->productsList[ $i ]['weight'] = ( $product->get_weight() ) ? $product->get_weight() : "";
1280
+ $this->productsList[ $i ]['width'] = ( $product->get_width() ) ? $product->get_width() : "";
1281
+ $this->productsList[ $i ]['height'] = ( $product->get_height() ) ? $product->get_height() : "";
1282
+ $this->productsList[ $i ]['length'] = ( $product->get_length() ) ? $product->get_length() : "";
1283
+
1284
+ # Sale price effective date
1285
+ $from = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_from' );
1286
+ $to = $this->sale_price_effective_date( $post->ID, '_sale_price_dates_to' );
1287
+ if ( ! empty( $from ) && ! empty( $to ) ) {
1288
+ $from = date( "c", strtotime( $from ) );
1289
+ $to = date( "c", strtotime( $to ) );
1290
+ $this->productsList[ $i ]['sale_price_effective_date'] = "$from" . "/" . "$to";
1291
+ } else {
1292
+ $this->productsList[ $i ]['sale_price_effective_date'] = "";
1293
+ }
1294
+ }
1295
+ }
1296
+ $i ++;
1297
+ endwhile;
1298
+ wp_reset_query();
1299
+
1300
+ if ( $getIDs ) {
1301
+ $mergedIds = array_merge( $getIDs, $this->idExist );
1302
+ update_option( "wf_check_duplicate", $mergedIds );
1303
+ } else {
1304
+ update_option( "wf_check_duplicate", $this->idExist );
1305
+ }
1306
+
1307
+ return $this->productsList;
1308
+ } catch ( Exception $e ) {
1309
+ return $this->productsList;
1310
+ }
1311
+ }
1312
+ }
1313
 
1314
+ /**
1315
+ * Remove ShortCodes from contents
1316
+ * @param $content
1317
+ *
1318
+ * @return mixed|string
1319
+ */
1320
+ public function remove_short_codes($content)
1321
+ {
1322
+ if(empty($content)){
1323
+ return "";
1324
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1325
 
1326
+ if(class_exists("WPBMap")){
1327
+ WPBMap::addAllMappedShortcodes(); // This does all the work
1328
+ $content = apply_filters( 'the_content',$content);
1329
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1330
 
1331
+ return do_shortcode($content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1332
 
1333
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1334
 
1335
  /**
1336
  * Get formatted image url
1463
  return "out of stock";
1464
  }
1465
 
1466
+ /**
1467
+ * Ger Product Attribute
1468
+ *
1469
+ * @since 2.2.3
1470
+ * @param $id
1471
+ * @param $attr
1472
+ *
1473
+ * @return string
1474
+ */
1475
+ public function getProductAttribute($id,$attr) {
1476
+
1477
+ $attr=str_replace("wf_attr_", "",$attr);
1478
+
1479
+ if(woo_feed_wc_version_check(3.1)){
1480
+ # Get Product
1481
+ $product=wc_get_product($id);
1482
+
1483
+ if(!is_object($product)){
1484
+ return "";
1485
+ }
1486
+ $value=$product->get_attribute($attr);
1487
+
1488
+ if(!empty($value)){
1489
+ $value = str_replace(' ','',$value);
1490
+ }
1491
+
1492
+ return $value;
1493
+ }else{
1494
+ return implode(',', wc_get_product_terms($id,$attr, array('fields' => 'names')));
1495
+ }
1496
+ }
1497
+
1498
+
1499
+ /**
1500
+ * Get Meta
1501
+ *
1502
+ * @since 2.2.3
1503
+ * @param $id
1504
+ * @param $meta
1505
+ *
1506
+ * @return mixed|string
1507
+ */
1508
+
1509
+ public function getProductMeta($id,$meta) {
1510
+
1511
+ $meta=str_replace("wf_cattr_", "",$meta);
1512
+
1513
+ if (strpos($meta, 'attribute_pa') !== false) {
1514
+ return $this->getProductAttribute($id,str_replace("attribute_","",$meta));
1515
+ }else{
1516
+ return get_post_meta($id, $meta, true);
1517
+ }
1518
+ }
1519
 
1520
  /**
1521
  * Get Product Attribute Value
1525
  *
1526
  * @return mixed
1527
  */
1528
+ public function getAttributeValue($id, $name)
1529
+ {
 
 
 
 
 
 
 
 
1530
 
1531
+ return $this->getProductMeta($id,$name);
1532
+ // if (strpos($name, 'attribute_pa') !== false) {
1533
+ // $taxonomy = str_replace("attribute_","",$name);
1534
+ // $meta = get_post_meta($id,$name, true);
1535
+ // $term = get_term_by('slug', $meta, $taxonomy);
1536
+ // return $term->name;
1537
+ // }else{
1538
+ // return get_post_meta($id, $name, true);
1539
+ // }
1540
+
1541
+ }
1542
 
1543
  /**
1544
  * Get Sale price effective date for google
1698
  "width" => "Width",
1699
  "height" => "Height",
1700
  "length" => "Length",
1701
+ "shipping_class" => "Shipping Class",
1702
  "type" => "Product Type",
1703
  "variation_type" => "Variation Type",
1704
  "visibility" => "Visibility",
1706
  "rating_average" => "Average Rating",
1707
  "tags" => "Tags",
1708
  "sale_price_effective_date" => "Sale Price Effective Date",
1709
+ "is_bundle" => "Is Bundle",
1710
  );
1711
 
1712
  $images = array(
1828
  "width" => "Width",
1829
  "height" => "Height",
1830
  "length" => "Length",
1831
+ "shipping_class" => "Shipping Class",
1832
  "type" => "Product Type",
1833
  "variation_type" => "Variation Type",
1834
  "visibility" => "Visibility",
1836
  "rating_average" => "Average Rating",
1837
  "tags" => "Tags",
1838
  "sale_price_effective_date" => "Sale Price Effective Date",
1839
+ "is_bundle" => "Is Bundle",
1840
  );
1841
 
1842
  $images = array(
woo-feed.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: WooCommerce Product Feed
17
  * Plugin URI: https://webappick.com/
18
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
19
- * Version: 2.1.29
20
  * Author: WebAppick
21
  * Author URI: https://webappick.com/
22
  * License: GPL v2
@@ -267,25 +267,52 @@ function woo_feed_array_sanitize($array)
267
  */
268
 
269
  add_action('wp_ajax_get_product_information', 'woo_feed_get_product_information');
270
- add_action('wp_ajax_nopriv_get_product_information', 'woo_feed_get_product_information');
271
  function woo_feed_get_product_information(){
272
- check_ajax_referer('wpf_feed_nonce');
273
-
274
- $products=wp_count_posts('product');
275
- $variations=wp_count_posts('product_variation');
276
- $totalProducts=$products->publish + $variations->publish;
277
-
278
- $data=array('product'=>$totalProducts);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
- if($totalProducts>0){
281
- $data['success']=true;
282
- wp_send_json_success($data);
283
- }else{
284
- $data['success']=false;
285
- wp_send_json_error($data);
286
- }
287
 
288
- wp_die();
 
 
 
 
 
 
 
 
 
 
 
 
289
  }
290
 
291
  function woo_feed_generate_feed_data($info){
16
  * Plugin Name: WooCommerce Product Feed
17
  * Plugin URI: https://webappick.com/
18
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
19
+ * Version: 2.2.5
20
  * Author: WebAppick
21
  * Author URI: https://webappick.com/
22
  * License: GPL v2
267
  */
268
 
269
  add_action('wp_ajax_get_product_information', 'woo_feed_get_product_information');
 
270
  function woo_feed_get_product_information(){
271
+ check_ajax_referer('wpf_feed_nonce');
272
+
273
+ if(woo_feed_wc_version_check(3.1)){
274
+ $query=new WC_Product_Query(array(
275
+ 'limit' => -1,
276
+ 'status' => 'publish',
277
+ 'orderby' => 'date',
278
+ 'order' => 'DESC',
279
+ 'return' => 'ids',
280
+ ));
281
+ $products=$query->get_products();
282
+ $totalProducts=count($products);
283
+ }else{
284
+ $products=wp_count_posts('product');
285
+ $variations=wp_count_posts('product_variation');
286
+ $totalProducts=$products->publish + $variations->publish;
287
+ }
288
+
289
+ $data=array('product'=>$totalProducts);
290
+
291
+ if($totalProducts>0){
292
+ $data['success']=true;
293
+ wp_send_json_success($data);
294
+ }else{
295
+ $data['success']=false;
296
+ wp_send_json_error($data);
297
+ }
298
+
299
+ wp_die();
300
+ }
301
 
 
 
 
 
 
 
 
302
 
303
+ /**
304
+ * Check WooCommerce Version
305
+ * @param string $version
306
+ * @return bool
307
+ */
308
+ function woo_feed_wc_version_check( $version = '3.0' ) {
309
+ if ( class_exists( 'WooCommerce' ) ) {
310
+ global $woocommerce;
311
+ if ( version_compare( $woocommerce->version, $version, ">=" ) ) {
312
+ return true;
313
+ }
314
+ }
315
+ return false;
316
  }
317
 
318
  function woo_feed_generate_feed_data($info){