Version Description
(2022-10-28) = * Added: Featured Status attribute added. * Tweak: WordPress 6.1 compatibility checked.
Download this release
Release Info
Developer | wahid0003 |
Plugin | CTX Feed – WooCommerce Product Feed Manager Plugin |
Version | 4.5.7 |
Comparing to | |
See all releases |
Code changes from version 4.5.6 to 4.5.7
README.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: wahid0003, webappick, shuvo586, nayanchamp7, mrinal013
|
|
3 |
Donate link: https://webappick.com
|
4 |
Tags: WooCommerce Product Feed, WooCommerce, Google Shopping, Google Merchant, Facebook Catalog, Bing Shopping, Instagram Shop, Skroutz Data Feed, XML Feed, CSV Feed, TXT Feed, Product Feed
|
5 |
Requires at least: 4.4
|
6 |
-
Tested Up To: 6.
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 4.5.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -590,6 +590,10 @@ Using pro version:
|
|
590 |
|
591 |
== Changelog ==
|
592 |
|
|
|
|
|
|
|
|
|
593 |
= 4.5.6 (2022-10-26) =
|
594 |
* Fixed: Snapchat image attribute changes from image to image_link.
|
595 |
* Fixed: Halloween discount banner only shows into plugin pages.
|
3 |
Donate link: https://webappick.com
|
4 |
Tags: WooCommerce Product Feed, WooCommerce, Google Shopping, Google Merchant, Facebook Catalog, Bing Shopping, Instagram Shop, Skroutz Data Feed, XML Feed, CSV Feed, TXT Feed, Product Feed
|
5 |
Requires at least: 4.4
|
6 |
+
Tested Up To: 6.1
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 4.5.7
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
590 |
|
591 |
== Changelog ==
|
592 |
|
593 |
+
= 4.5.7 (2022-10-28) =
|
594 |
+
* Added: Featured Status attribute added.
|
595 |
+
* Tweak: WordPress 6.1 compatibility checked.
|
596 |
+
|
597 |
= 4.5.6 (2022-10-26) =
|
598 |
* Fixed: Snapchat image attribute changes from image to image_link.
|
599 |
* Fixed: Halloween discount banner only shows into plugin pages.
|
V5/Product/ProductAttributeFactory.php
CHANGED
@@ -82,6 +82,7 @@ class ProductAttributeFactory {
|
|
82 |
'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
|
83 |
'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
|
84 |
'product_status' => esc_html__( 'Product Status', 'woo-feed' ),
|
|
|
85 |
]
|
86 |
];
|
87 |
|
82 |
'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
|
83 |
'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
|
84 |
'product_status' => esc_html__( 'Product Status', 'woo-feed' ),
|
85 |
+
'featured_status' => esc_html__( 'Featured Status', 'woo-feed' ),
|
86 |
]
|
87 |
];
|
88 |
|
V5/Product/ProductInfo.php
CHANGED
@@ -28,7 +28,7 @@ class ProductInfo {
|
|
28 |
* @var Config
|
29 |
*/
|
30 |
private $config;
|
31 |
-
|
32 |
/**
|
33 |
*
|
34 |
* @param WC_Product $product
|
@@ -39,7 +39,7 @@ class ProductInfo {
|
|
39 |
$this->parent_product = $product;//->is_type('variable') ? wc_get_product( $product->get_parent_id() ) : wc_get_product( $product->get_id() );
|
40 |
$this->config = $config;
|
41 |
}
|
42 |
-
|
43 |
/**
|
44 |
* Get product id.
|
45 |
*
|
@@ -48,16 +48,16 @@ class ProductInfo {
|
|
48 |
public function id() {
|
49 |
return apply_filters( 'woo_feed_filter_product_id', $this->product->get_id(), $this->product, $this->config );
|
50 |
}
|
51 |
-
|
52 |
/**
|
53 |
* Get product name.
|
54 |
*
|
55 |
* @return mixed|void
|
56 |
*/
|
57 |
public function title() {
|
58 |
-
|
59 |
$title = woo_feed_strip_all_tags( CommonHelper::remove_shortcodes( $this->product->get_name() ) );
|
60 |
-
|
61 |
// Add all available variation attributes to variation title.
|
62 |
if ( $this->product->is_type( 'variation' ) && ! empty( $this->product->get_attributes() ) ) {
|
63 |
$title = $this->parent_product->get_name();
|
@@ -68,25 +68,25 @@ class ProductInfo {
|
|
68 |
$attributes[ $slug ] = $attribute;
|
69 |
}
|
70 |
}
|
71 |
-
|
72 |
// set variation attributes with separator
|
73 |
$separator = ',';
|
74 |
if ( 'google' === $this->config->get_feed_template() ) {
|
75 |
$separator = '-';
|
76 |
}
|
77 |
$variation_attributes = implode( $separator, $attributes );
|
78 |
-
|
79 |
//get product title with variation attribute
|
80 |
$get_with_var_attributes = apply_filters( "woo_feed_get_product_title_with_variation_attribute", true, $this->product, $this->config );
|
81 |
-
|
82 |
if ( $get_with_var_attributes ) {
|
83 |
$title .= " - " . $variation_attributes;
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
return apply_filters( 'woo_feed_filter_product_title', $title, $this->product, $this->config );
|
88 |
}
|
89 |
-
|
90 |
/**
|
91 |
* Get parent product title for variation.
|
92 |
*
|
@@ -98,10 +98,10 @@ class ProductInfo {
|
|
98 |
} else {
|
99 |
$title = $this->title();
|
100 |
}
|
101 |
-
|
102 |
return apply_filters( 'woo_feed_filter_product_parent_title', $title, $this->product, $this->config );
|
103 |
}
|
104 |
-
|
105 |
/**
|
106 |
* Get product description.
|
107 |
*
|
@@ -109,7 +109,7 @@ class ProductInfo {
|
|
109 |
*/
|
110 |
public function description() {
|
111 |
$description = $this->product->get_description();
|
112 |
-
|
113 |
// Get Variation Description
|
114 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
115 |
$description = '';
|
@@ -117,13 +117,13 @@ class ProductInfo {
|
|
117 |
$description = $this->parent_product->get_description();
|
118 |
}
|
119 |
}
|
120 |
-
|
121 |
if ( empty( $description ) ) {
|
122 |
$description = $this->product->get_short_description();
|
123 |
}
|
124 |
-
|
125 |
$description = CommonHelper::remove_shortcodes( $description );
|
126 |
-
|
127 |
// Add variations attributes after description to prevent Facebook error
|
128 |
if ( 'facebook' === $this->config->get_feed_template() && $this->product->is_type( 'variation' ) ) {
|
129 |
$variationInfo = explode( '-', $this->product->get_name() );
|
@@ -134,15 +134,15 @@ class ProductInfo {
|
|
134 |
}
|
135 |
$description .= ' ' . $extension;
|
136 |
}
|
137 |
-
|
138 |
//strip tags and spacial characters
|
139 |
$strip_description = woo_feed_strip_all_tags( wp_specialchars_decode( $description ) );
|
140 |
-
|
141 |
$description = ! empty( strlen( $strip_description ) ) && 0 < strlen( $strip_description ) ? $strip_description : $description;
|
142 |
-
|
143 |
return apply_filters( 'woo_feed_filter_product_description', $description, $this->product, $this->config );
|
144 |
}
|
145 |
-
|
146 |
/**
|
147 |
* Get product description with HTML tags.
|
148 |
*
|
@@ -150,7 +150,7 @@ class ProductInfo {
|
|
150 |
*/
|
151 |
public function description_with_html() {
|
152 |
$description = $this->product->get_description();
|
153 |
-
|
154 |
// Get Variation Description
|
155 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
156 |
$description = '';
|
@@ -158,13 +158,13 @@ class ProductInfo {
|
|
158 |
$description = $this->parent_product->get_description();
|
159 |
}
|
160 |
}
|
161 |
-
|
162 |
if ( empty( $description ) ) {
|
163 |
$description = $this->product->get_short_description();
|
164 |
}
|
165 |
-
|
166 |
$description = CommonHelper::remove_shortcodes( $description );
|
167 |
-
|
168 |
// Add variations attributes after description to prevent Facebook error
|
169 |
if ( 'facebook' === $this->config->get_feed_template() && $this->product->is_type( 'variation' ) ) {
|
170 |
$variationInfo = explode( '-', $this->product->get_name() );
|
@@ -175,13 +175,13 @@ class ProductInfo {
|
|
175 |
}
|
176 |
$description .= ' ' . $extension;
|
177 |
}
|
178 |
-
|
179 |
//remove spacial characters
|
180 |
$description = wp_check_invalid_utf8( wp_specialchars_decode( $description ), true );
|
181 |
-
|
182 |
return apply_filters( 'woo_feed_filter_product_description_with_html', $description, $this->product, $this->config );
|
183 |
}
|
184 |
-
|
185 |
/**
|
186 |
* Get product short description.
|
187 |
*
|
@@ -189,20 +189,20 @@ class ProductInfo {
|
|
189 |
*/
|
190 |
public function short_description() {
|
191 |
$short_description = $this->product->get_short_description();
|
192 |
-
|
193 |
// Get Variation Short Description
|
194 |
if ( empty( $short_description ) && $this->product->is_type( 'variation' ) ) {
|
195 |
$short_description = $this->parent_product->get_short_description();
|
196 |
}
|
197 |
-
|
198 |
$short_description = CommonHelper::remove_shortcodes( $short_description );
|
199 |
-
|
200 |
// Strip tags and spacial characters
|
201 |
$short_description = woo_feed_strip_all_tags( wp_specialchars_decode( $short_description ) );
|
202 |
-
|
203 |
return apply_filters( 'woo_feed_filter_product_short_description', $short_description, $this->product, $this->config );
|
204 |
}
|
205 |
-
|
206 |
/**
|
207 |
* Get product primary category.
|
208 |
*
|
@@ -211,16 +211,16 @@ class ProductInfo {
|
|
211 |
public function primary_category() {
|
212 |
$parent_category = "";
|
213 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config );
|
214 |
-
|
215 |
$full_category = $this->product_type();
|
216 |
if ( ! empty( $full_category ) ) {
|
217 |
$full_category_array = explode( $separator, $full_category );
|
218 |
$parent_category = $full_category_array[0];
|
219 |
}
|
220 |
-
|
221 |
return apply_filters( 'woo_feed_filter_product_primary_category', $parent_category, $this->product, $this->config );
|
222 |
}
|
223 |
-
|
224 |
/**
|
225 |
* Get product primary category id.
|
226 |
*
|
@@ -235,10 +235,10 @@ class ProductInfo {
|
|
235 |
$parent_category_obj = get_term_by( 'name', $full_category_array[0], 'product_cat' );
|
236 |
$parent_category_id = isset( $parent_category_obj->term_id ) ? $parent_category_obj->term_id : "";
|
237 |
}
|
238 |
-
|
239 |
return apply_filters( 'woo_feed_filter_product_primary_category_id', $parent_category_id, $this->product, $this->config );
|
240 |
}
|
241 |
-
|
242 |
/**
|
243 |
* Get product child category.
|
244 |
*
|
@@ -252,10 +252,10 @@ class ProductInfo {
|
|
252 |
$full_category_array = explode( $separator, $full_category );
|
253 |
$child_category = end( $full_category_array );
|
254 |
}
|
255 |
-
|
256 |
return apply_filters( 'woo_feed_filter_product_child_category', $child_category, $this->product, $this->config );
|
257 |
}
|
258 |
-
|
259 |
/**
|
260 |
* Get product child category id.
|
261 |
*
|
@@ -270,10 +270,10 @@ class ProductInfo {
|
|
270 |
$child_category_obj = get_term_by( 'name', end( $full_category_array ), 'product_cat' );
|
271 |
$child_category_id = isset( $child_category_obj->term_id ) ? $child_category_obj->term_id : "";
|
272 |
}
|
273 |
-
|
274 |
return apply_filters( 'woo_feed_filter_product_child_category_id', $child_category_id, $this->product, $this->config );
|
275 |
}
|
276 |
-
|
277 |
/**
|
278 |
* Get product type.
|
279 |
*
|
@@ -284,11 +284,11 @@ class ProductInfo {
|
|
284 |
if ( $this->product->is_type( 'variation' ) ) {
|
285 |
$id = $this->product->get_parent_id();
|
286 |
}
|
287 |
-
|
288 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config );
|
289 |
$product_categories = '';
|
290 |
$term_list = get_the_terms( $id, 'product_cat' );
|
291 |
-
|
292 |
if ( is_array( $term_list ) ) {
|
293 |
$col = array_column( $term_list, "term_id" );
|
294 |
array_multisort( $col, SORT_ASC, $term_list );
|
@@ -296,31 +296,52 @@ class ProductInfo {
|
|
296 |
//TODO: Remove Manual Separator and add Dynamically with hook. Hook function also need to modified from array to object.
|
297 |
$product_categories = implode( ' > ', $term_list );
|
298 |
}
|
299 |
-
|
300 |
-
|
301 |
return apply_filters( 'woo_feed_filter_product_local_category', $product_categories, $this->product, $this->config );
|
302 |
}
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
/**
|
305 |
* Get product full category.
|
306 |
*
|
307 |
* @return mixed|void
|
308 |
*/
|
309 |
public function product_full_cat() {
|
310 |
-
|
311 |
$id = $this->product->get_id();
|
312 |
if ( $this->product->is_type( 'variation' ) ) {
|
313 |
$id = $this->product->get_parent_id();
|
314 |
}
|
315 |
-
|
316 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config, $this->product );
|
317 |
-
|
318 |
$product_type = wp_strip_all_tags( wc_get_product_category_list( $id, $separator ) );
|
319 |
-
|
320 |
-
|
321 |
return apply_filters( 'woo_feed_filter_product_local_category', $product_type, $this->product, $this->config );
|
322 |
}
|
323 |
-
|
324 |
/**
|
325 |
* Get product URL.
|
326 |
*
|
@@ -328,14 +349,14 @@ class ProductInfo {
|
|
328 |
*/
|
329 |
public function link() {
|
330 |
$link = $this->product->get_permalink();
|
331 |
-
|
332 |
if ( $this->config->get_campaign_parameters() ) {
|
333 |
$link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $link );
|
334 |
}
|
335 |
-
|
336 |
return apply_filters( 'woo_feed_filter_product_link', $link, $this->product, $this->config );
|
337 |
}
|
338 |
-
|
339 |
/**
|
340 |
* Get product parent URL.
|
341 |
*
|
@@ -346,14 +367,14 @@ class ProductInfo {
|
|
346 |
if ( $this->product->is_type( 'variation' ) ) {
|
347 |
$link = $this->parent_product->get_permalink();
|
348 |
}
|
349 |
-
|
350 |
if ( $this->config->get_campaign_parameters() ) {
|
351 |
$link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $link );
|
352 |
}
|
353 |
-
|
354 |
return apply_filters( 'woo_feed_filter_product_parent_link', $link, $this->product, $this->config );
|
355 |
}
|
356 |
-
|
357 |
/**
|
358 |
* Get product Canonical URL.
|
359 |
*
|
@@ -362,10 +383,10 @@ class ProductInfo {
|
|
362 |
public function canonical_link() {
|
363 |
//TODO: check if SEO plugin installed then return SEO canonical URL
|
364 |
$canonical_link = $this->parent_link();
|
365 |
-
|
366 |
return apply_filters( 'woo_feed_filter_product_canonical_link', $canonical_link, $this->product, $this->config );
|
367 |
}
|
368 |
-
|
369 |
/**
|
370 |
* Get external product URL.
|
371 |
*
|
@@ -379,10 +400,10 @@ class ProductInfo {
|
|
379 |
$ex_link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $ex_link );
|
380 |
}
|
381 |
}
|
382 |
-
|
383 |
return apply_filters( 'woo_feed_filter_product_ex_link', $ex_link, $this->product, $this->config );
|
384 |
}
|
385 |
-
|
386 |
/**
|
387 |
* Get product image URL.
|
388 |
*
|
@@ -403,10 +424,10 @@ class ProductInfo {
|
|
403 |
$getImage = wp_get_attachment_image_src( get_post_thumbnail_id( $this->product->get_id() ), 'single-post-thumbnail' );
|
404 |
$image = isset( $getImage[0] ) ? woo_feed_get_formatted_url( $getImage[0] ) : '';
|
405 |
}
|
406 |
-
|
407 |
return apply_filters( 'woo_feed_filter_product_image', $image, $this->product, $this->config );
|
408 |
}
|
409 |
-
|
410 |
/**
|
411 |
* Get product featured image URL.
|
412 |
*
|
@@ -417,13 +438,13 @@ class ProductInfo {
|
|
417 |
if ( $this->product->is_type( 'variation' ) ) {
|
418 |
$id = $this->product->get_parent_id();
|
419 |
}
|
420 |
-
|
421 |
$getImage = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
|
422 |
$image = isset( $getImage[0] ) ? woo_feed_get_formatted_url( $getImage[0] ) : '';
|
423 |
-
|
424 |
return apply_filters( 'woo_feed_filter_product_feature_image', $image, $this->product, $this->config );
|
425 |
}
|
426 |
-
|
427 |
/**
|
428 |
* Get product images (comma separated URLs).
|
429 |
*
|
@@ -432,7 +453,7 @@ class ProductInfo {
|
|
432 |
public function images( $additionalImg = '' ) {
|
433 |
$imgUrls = ProductHelper::get_product_gallery( $this->product );
|
434 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
435 |
-
|
436 |
// Return Specific Additional Image URL
|
437 |
if ( '' !== $additionalImg ) {
|
438 |
if ( array_key_exists( $additionalImg, $imgUrls ) ) {
|
@@ -444,60 +465,60 @@ class ProductInfo {
|
|
444 |
if ( "idealo" === $this->config->get_feed_template() ) {
|
445 |
$separator = ';';
|
446 |
}
|
447 |
-
|
448 |
$images = implode( $separator, array_filter( $imgUrls ) );
|
449 |
}
|
450 |
-
|
451 |
return apply_filters( 'woo_feed_filter_product_images', $images, $this->product, $this->config );
|
452 |
}
|
453 |
-
|
454 |
public function condition() {
|
455 |
return apply_filters( 'woo_feed_product_condition', 'new', $this->product, $this->config );
|
456 |
}
|
457 |
-
|
458 |
public function type() {
|
459 |
return apply_filters( 'woo_feed_filter_product_type', $this->product->get_type(), $this->product, $this->config );
|
460 |
}
|
461 |
-
|
462 |
public function is_bundle() {
|
463 |
$is_bundle = 'no';
|
464 |
if ( $this->product->is_type( 'bundle' ) || $this->product->is_type( 'yith_bundle' ) ) {
|
465 |
$is_bundle = 'yes';
|
466 |
}
|
467 |
-
|
468 |
return apply_filters( 'woo_feed_filter_product_is_bundle', $is_bundle, $this->product, $this->config );
|
469 |
}
|
470 |
-
|
471 |
public function multipack() {
|
472 |
$multi_pack = '';
|
473 |
if ( $this->product->is_type( 'grouped' ) ) {
|
474 |
$multi_pack = ( ! empty( $this->product->get_children() ) ) ? count( $this->product->get_children() ) : '';
|
475 |
}
|
476 |
-
|
477 |
return apply_filters( 'woo_feed_filter_product_is_multipack', $multi_pack, $this->product, $this->config );
|
478 |
}
|
479 |
-
|
480 |
public function visibility() {
|
481 |
return apply_filters( 'woo_feed_filter_product_visibility', $this->product->get_catalog_visibility(), $this->product, $this->config );
|
482 |
}
|
483 |
-
|
484 |
public function rating_total() {
|
485 |
return apply_filters( 'woo_feed_filter_product_rating_total', $this->product->get_rating_count(), $this->product, $this->config );
|
486 |
}
|
487 |
-
|
488 |
public function rating_average() {
|
489 |
return apply_filters( 'woo_feed_filter_product_rating_average', $this->product->get_average_rating(), $this->product, $this->config );
|
490 |
}
|
491 |
-
|
492 |
public function total_sold() {
|
493 |
} //TODO: Implement this
|
494 |
-
|
495 |
public function tags() {
|
496 |
$id = $this->product->get_id();
|
497 |
if ( $this->product->is_type( 'variation' ) ) {
|
498 |
$id = $this->product->get_parent_id();
|
499 |
}
|
500 |
-
|
501 |
/**
|
502 |
* Separator for multiple tags
|
503 |
*
|
@@ -508,41 +529,41 @@ class ProductInfo {
|
|
508 |
* @since 3.4.3
|
509 |
*/
|
510 |
$separator = apply_filters( 'woo_feed_tags_separator', ',', $this->product, $this->config );
|
511 |
-
|
512 |
$tags = woo_feed_strip_all_tags( get_the_term_list( $id, 'product_tag', '', $separator, '' ) );
|
513 |
-
|
514 |
return apply_filters( 'woo_feed_filter_product_tags', $tags, $this->product, $this->config );
|
515 |
}
|
516 |
-
|
517 |
public function item_group_id() {
|
518 |
$id = $this->product->get_id();
|
519 |
if ( $this->product->is_type( 'variation' ) ) {
|
520 |
$id = $this->product->get_parent_id();
|
521 |
}
|
522 |
-
|
523 |
return apply_filters( 'woo_feed_filter_product_item_group_id', $id, $this->product, $this->config );
|
524 |
}
|
525 |
-
|
526 |
public function sku() {
|
527 |
return apply_filters( 'woo_feed_filter_product_sku', $this->product->get_sku(), $this->product, $this->config );
|
528 |
}
|
529 |
-
|
530 |
public function sku_id() {
|
531 |
$sku = ! empty( $this->product->get_sku() ) ? $this->product->get_sku() . '_' : '';
|
532 |
$sku_id = $sku . $this->product->get_id();
|
533 |
-
|
534 |
return apply_filters( 'woo_feed_filter_product_sku_id', $sku_id, $this->product, $this->config );
|
535 |
}
|
536 |
-
|
537 |
public function parent_sku() {
|
538 |
$parent_sku = $this->product->get_sku();
|
539 |
if ( $this->product->is_type( 'variation' ) ) {
|
540 |
$parent_sku = $this->parent_product->get_sku();
|
541 |
}
|
542 |
-
|
543 |
return apply_filters( 'woo_feed_filter_product_parent_sku', $parent_sku, $this->product, $this->config );
|
544 |
}
|
545 |
-
|
546 |
public function availability() {
|
547 |
$status = $this->product->get_stock_status();
|
548 |
if ( 'instock' === $status ) {
|
@@ -552,36 +573,36 @@ class ProductInfo {
|
|
552 |
} elseif ( 'onbackorder' === $status ) {
|
553 |
$status = 'on backorder';
|
554 |
}
|
555 |
-
|
556 |
// set (_) as separator for google merchant
|
557 |
if ( 'google' === $this->config->get_feed_template() ) {
|
558 |
$status = explode( ' ', $status );
|
559 |
$status = implode( '_', $status );
|
560 |
}
|
561 |
-
|
562 |
return apply_filters( 'woo_feed_filter_product_availability', $status, $this->product, $this->config );
|
563 |
}
|
564 |
-
|
565 |
public function availability_date() {
|
566 |
-
|
567 |
$feed_settings = get_option( 'woo_feed_settings' );
|
568 |
-
|
569 |
$availability_date_settings = isset( $feed_settings['woo_feed_identifier']['availability_date'] )
|
570 |
? $feed_settings['woo_feed_identifier']['availability_date']
|
571 |
: 'enable';
|
572 |
-
|
573 |
if ( $this->product->get_stock_status() !== 'onbackorder' || $availability_date_settings === 'disable' ) {
|
574 |
return '';
|
575 |
}
|
576 |
-
|
577 |
$meta_field_name = 'woo_feed_availability_date';
|
578 |
-
|
579 |
if ( $this->product->is_type( 'variation' ) ) {
|
580 |
$meta_field_name .= '_var';
|
581 |
}
|
582 |
-
|
583 |
$availability_date = get_post_meta( $this->product->get_id(), $meta_field_name, true );
|
584 |
-
|
585 |
if ( '' !== $availability_date && in_array( $this->config->get_feed_template(), [
|
586 |
'google',
|
587 |
'facebook',
|
@@ -591,28 +612,28 @@ class ProductInfo {
|
|
591 |
], true ) ) {
|
592 |
$availability_date = gmdate( 'c', strtotime( $availability_date ) );
|
593 |
}
|
594 |
-
|
595 |
return apply_filters( 'woo_feed_filter_product_availability_date', $availability_date, $this->product, $this->config );
|
596 |
}
|
597 |
-
|
598 |
public function add_to_cart_link() {
|
599 |
$url = $this->link();
|
600 |
$suffix = 'add-to-cart=' . $this->product->get_id();
|
601 |
-
|
602 |
$add_to_cart_link = woo_feed_make_url_with_parameter( $url, $suffix );
|
603 |
-
|
604 |
return apply_filters( 'woo_feed_filter_product_add_to_cart_link', $add_to_cart_link, $this->product, $this->config );
|
605 |
}
|
606 |
-
|
607 |
public function quantity() {
|
608 |
$quantity = $this->product->get_stock_quantity();
|
609 |
$status = $this->product->get_stock_status();
|
610 |
-
|
611 |
//when product is outofstock , and it's quantity is empty, set quantity to 0
|
612 |
if ( 'outofstock' === $status && $quantity === null ) {
|
613 |
$quantity = 0;
|
614 |
}
|
615 |
-
|
616 |
if ( $this->product->is_type( 'variable' ) && $this->product->has_child() ) {
|
617 |
$visible_children = $this->product->get_visible_children();
|
618 |
$qty = array();
|
@@ -620,7 +641,7 @@ class ProductInfo {
|
|
620 |
$childQty = get_post_meta( $child, '_stock', true );
|
621 |
$qty[] = (int) $childQty + 0;
|
622 |
}
|
623 |
-
|
624 |
if ( isset( $this->config['variable_quantity'] ) ) {
|
625 |
$vaQty = $this->config['variable_quantity'];
|
626 |
if ( 'max' === $vaQty ) {
|
@@ -636,10 +657,10 @@ class ProductInfo {
|
|
636 |
}
|
637 |
}
|
638 |
}
|
639 |
-
|
640 |
return apply_filters( 'woo_feed_filter_product_quantity', $quantity, $this->product, $this->config );
|
641 |
}
|
642 |
-
|
643 |
/**
|
644 |
* Get Store Currency.
|
645 |
*
|
@@ -647,10 +668,10 @@ class ProductInfo {
|
|
647 |
*/
|
648 |
public function currency() {
|
649 |
$quantity = get_option( 'woocommerce_currency' );
|
650 |
-
|
651 |
return apply_filters( 'woo_feed_filter_product_currency', $quantity, $this->product, $this->config );
|
652 |
}
|
653 |
-
|
654 |
/**
|
655 |
* Get Product Sale Price start date.
|
656 |
*
|
@@ -663,10 +684,10 @@ class ProductInfo {
|
|
663 |
} else {
|
664 |
$sale_price_sdate = '';
|
665 |
}
|
666 |
-
|
667 |
return apply_filters( 'woo_feed_filter_product_sale_price_sdate', $sale_price_sdate, $this->product, $this->config );
|
668 |
}
|
669 |
-
|
670 |
/**
|
671 |
* Get Product Sale Price End Date.
|
672 |
*
|
@@ -679,34 +700,34 @@ class ProductInfo {
|
|
679 |
} else {
|
680 |
$sale_price_edate = "";
|
681 |
}
|
682 |
-
|
683 |
return apply_filters( 'woo_feed_filter_product_sale_price_edate', $sale_price_edate, $this->product, $this->config );
|
684 |
}
|
685 |
-
|
686 |
public function price() {
|
687 |
return PriceFactory::get( $this->product, $this->config )->regular_price();
|
688 |
}
|
689 |
-
|
690 |
public function current_price() {
|
691 |
return PriceFactory::get( $this->product, $this->config )->price();
|
692 |
}
|
693 |
-
|
694 |
public function sale_price() {
|
695 |
return PriceFactory::get( $this->product, $this->config )->sale_price();
|
696 |
}
|
697 |
-
|
698 |
public function price_with_tax() {
|
699 |
return PriceFactory::get( $this->product, $this->config )->regular_price( true );
|
700 |
}
|
701 |
-
|
702 |
public function current_price_with_tax() {
|
703 |
return PriceFactory::get( $this->product, $this->config )->price( true );
|
704 |
}
|
705 |
-
|
706 |
public function sale_price_with_tax() {
|
707 |
return PriceFactory::get( $this->product, $this->config )->sale_price( true );
|
708 |
}
|
709 |
-
|
710 |
/**
|
711 |
* Get Product Weight.
|
712 |
*
|
@@ -715,7 +736,7 @@ class ProductInfo {
|
|
715 |
public function weight() {
|
716 |
return apply_filters( 'woo_feed_filter_product_weight', $this->product->get_weight(), $this->product, $this->config );
|
717 |
}
|
718 |
-
|
719 |
/**
|
720 |
* Get Weight Unit.
|
721 |
*
|
@@ -724,7 +745,7 @@ class ProductInfo {
|
|
724 |
public function weight_unit() {
|
725 |
return apply_filters( 'woo_feed_filter_product_weight_unit', get_option( 'woocommerce_weight_unit' ), $this->product, $this->config );
|
726 |
}
|
727 |
-
|
728 |
/**
|
729 |
* Get Product Width.
|
730 |
*
|
@@ -733,7 +754,7 @@ class ProductInfo {
|
|
733 |
public function width() {
|
734 |
return apply_filters( 'woo_feed_filter_product_width', $this->product->get_width(), $this->product, $this->config );
|
735 |
}
|
736 |
-
|
737 |
/**
|
738 |
* Get Product Height.
|
739 |
*
|
@@ -742,7 +763,7 @@ class ProductInfo {
|
|
742 |
public function height() {
|
743 |
return apply_filters( 'woo_feed_filter_product_height', $this->product->get_height(), $this->product, $this->config );
|
744 |
}
|
745 |
-
|
746 |
/**
|
747 |
* Get Product Length.
|
748 |
*
|
@@ -751,7 +772,7 @@ class ProductInfo {
|
|
751 |
public function length() {
|
752 |
return apply_filters( 'woo_feed_filter_product_length', $this->product->get_length(), $this->product, $this->config );
|
753 |
}
|
754 |
-
|
755 |
/** Google Formatted Shipping info
|
756 |
*
|
757 |
* @return string
|
@@ -762,11 +783,11 @@ class ProductInfo {
|
|
762 |
return ( ShippingFactory::get( $this->product, $this->config ) )->get_shipping($key);
|
763 |
// return apply_filters( 'woo_feed_filter_product_shipping', $shipping, $this->product, $this->config );
|
764 |
} catch ( Exception $e ) {
|
765 |
-
|
766 |
}
|
767 |
}
|
768 |
-
|
769 |
-
|
770 |
/**
|
771 |
* Get Shipping Cost.
|
772 |
*
|
@@ -775,7 +796,7 @@ class ProductInfo {
|
|
775 |
public function shipping_cost() {
|
776 |
// Get config to which shipping price to return (first, highest or lowest)
|
777 |
$shipping = ( ShippingFactory::get( $this->product, $this->config ) )->get_shipping_info();
|
778 |
-
|
779 |
$price = "0";
|
780 |
if ( ! empty( $shipping ) ) {
|
781 |
if ( isset( $this->config->shipping_price ) ) {
|
@@ -792,11 +813,11 @@ class ProductInfo {
|
|
792 |
$price = reset( $shipping_prices );
|
793 |
}
|
794 |
}
|
795 |
-
|
796 |
return apply_filters( 'woo_feed_filter_product_shipping_cost', $price, $this->product, $this->config );
|
797 |
}
|
798 |
-
|
799 |
-
|
800 |
/**
|
801 |
* Get Product Shipping Class
|
802 |
*
|
@@ -807,7 +828,7 @@ class ProductInfo {
|
|
807 |
public function shipping_class() {
|
808 |
return apply_filters( 'woo_feed_filter_product_shipping_class', $this->product->get_shipping_class(), $this->product, $this->config );
|
809 |
}
|
810 |
-
|
811 |
/**
|
812 |
* Get author name.
|
813 |
*
|
@@ -815,10 +836,10 @@ class ProductInfo {
|
|
815 |
*/
|
816 |
public function author_name() {
|
817 |
$post = get_post( $this->product->get_id() );
|
818 |
-
|
819 |
return get_the_author_meta( 'user_login', $post->post_author );
|
820 |
}
|
821 |
-
|
822 |
/**
|
823 |
* Get Author Email.
|
824 |
*
|
@@ -826,10 +847,10 @@ class ProductInfo {
|
|
826 |
*/
|
827 |
public function author_email() {
|
828 |
$post = get_post( $this->product->get_id() );
|
829 |
-
|
830 |
return get_the_author_meta( 'user_email', $post->post_author );
|
831 |
}
|
832 |
-
|
833 |
/**
|
834 |
* Get Date Created.
|
835 |
*
|
@@ -837,10 +858,10 @@ class ProductInfo {
|
|
837 |
*/
|
838 |
public function date_created() {
|
839 |
$date_created = gmdate( 'Y-m-d', strtotime( $this->product->get_date_created() ) );
|
840 |
-
|
841 |
return apply_filters( 'woo_feed_filter_product_date_created', $date_created, $this->product, $this->config );
|
842 |
}
|
843 |
-
|
844 |
/**
|
845 |
* Get Date updated.
|
846 |
*
|
@@ -848,10 +869,10 @@ class ProductInfo {
|
|
848 |
*/
|
849 |
public function date_updated() {
|
850 |
$date_updated = gmdate( 'Y-m-d', strtotime( $this->product->get_date_modified() ) );
|
851 |
-
|
852 |
return apply_filters( 'woo_feed_filter_product_date_updated', $date_updated, $this->product, $this->config );
|
853 |
}
|
854 |
-
|
855 |
/** Get Google Sale Price effective date.
|
856 |
*
|
857 |
* @return string
|
@@ -863,45 +884,45 @@ class ProductInfo {
|
|
863 |
if ( ! empty( $from ) && ! empty( $to ) ) {
|
864 |
$from = gmdate( 'c', strtotime( $from ) );
|
865 |
$to = gmdate( 'c', strtotime( $to ) );
|
866 |
-
|
867 |
$effective_date = $from . '/' . $to;
|
868 |
}
|
869 |
-
|
870 |
return $effective_date;
|
871 |
}
|
872 |
-
|
873 |
public function subscription_period() {
|
874 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
875 |
return ProductHelper::get_product_meta( '_subscription_period', $this->product, $this->config );
|
876 |
}
|
877 |
-
|
878 |
return '';
|
879 |
}
|
880 |
-
|
881 |
public function subscription_period_interval() {
|
882 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
883 |
return ProductHelper::get_product_meta( '_subscription_period_interval', $this->product, $this->config );
|
884 |
}
|
885 |
-
|
886 |
return '';
|
887 |
}
|
888 |
-
|
889 |
public function subscription_amount() {
|
890 |
// return $this->price($product);
|
891 |
}
|
892 |
-
|
893 |
public function installment_amount() {
|
894 |
// return $this->price($product);
|
895 |
}
|
896 |
-
|
897 |
public function installment_months() {
|
898 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
899 |
return ProductHelper::get_product_meta( '_subscription_length', $this->product, $this->config );
|
900 |
}
|
901 |
-
|
902 |
return '';
|
903 |
}
|
904 |
-
|
905 |
public function unit_price_measure() {
|
906 |
$unit_price_measure = '';
|
907 |
$identifiers = woo_feed_get_options( 'woo_feed_identifier' );
|
@@ -911,20 +932,20 @@ class ProductInfo {
|
|
911 |
) {
|
912 |
$unit = ProductHelper::get_custom_filed( 'woo_feed_unit', $this->product, $this->config );
|
913 |
$unit_price_measure = ProductHelper::get_custom_filed( 'woo_feed_unit_pricing_measure', $this->product, $this->config );
|
914 |
-
|
915 |
$unit_price_measure .= " " . $unit;
|
916 |
}
|
917 |
-
|
918 |
if ( empty( $unit_price_measure ) && class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
919 |
$unit = ProductHelper::get_product_meta( '_unit', $this->product, $this->config );
|
920 |
$unit_price_measure = ProductHelper::get_product_meta( '_unit_product', $this->product, $this->config );
|
921 |
-
|
922 |
$unit_price_measure .= " " . $unit;
|
923 |
}
|
924 |
-
|
925 |
return apply_filters( 'woo_feed_filter_unit_price_measure', $unit_price_measure, $this->product, $this->config );
|
926 |
}
|
927 |
-
|
928 |
public function unit_price_base_measure() {
|
929 |
$unit_price_base_measure = '';
|
930 |
$identifiers = woo_feed_get_options( 'woo_feed_identifier' );
|
@@ -936,36 +957,36 @@ class ProductInfo {
|
|
936 |
$unit_price_base_measure = ProductHelper::get_custom_filed( 'woo_feed_unit_pricing_base_measure', $this->product, $this->config );
|
937 |
$unit_price_base_measure .= " " . $unit;
|
938 |
}
|
939 |
-
|
940 |
if ( empty( $unit_price_base_measure ) && class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
941 |
$unit = ProductHelper::get_product_meta( '_unit', $this->product, $this->config );
|
942 |
$unit_price_base_measure = ProductHelper::get_product_meta( '_unit_base', $this->product, $this->config );
|
943 |
$unit_price_base_measure .= " " . $unit;
|
944 |
}
|
945 |
-
|
946 |
return apply_filters( 'woo_feed_filter_unit_price_base_measure', $unit_price_base_measure, $this->product, $this->config );
|
947 |
}
|
948 |
-
|
949 |
public function wc_germanized_gtin() {
|
950 |
$wc_germanized_gtin = '';
|
951 |
if ( class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
952 |
$wc_germanized_gtin = ProductHelper::get_product_meta( '_ts_gtin', $this->product, $this->config );
|
953 |
}
|
954 |
-
|
955 |
return apply_filters( 'woo_feed_filter_wc_germanized_gtin', $wc_germanized_gtin, $this->product, $this->config );
|
956 |
}
|
957 |
-
|
958 |
public function wc_germanized_mpn() {
|
959 |
$wc_germanized_mpn = '';
|
960 |
if ( class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
961 |
$wc_germanized_mpn = ProductHelper::get_product_meta( '_ts_mpn', $this->product, $this->config );
|
962 |
}
|
963 |
-
|
964 |
return apply_filters( 'woo_feed_filter_wc_germanized_mpn', $wc_germanized_mpn, $this->product, $this->config );
|
965 |
}
|
966 |
-
|
967 |
# SEO Plugins
|
968 |
-
|
969 |
public function yoast_wpseo_title() {
|
970 |
$product_id = woo_feed_parent_product_id( $this->product );
|
971 |
$yoast_title = get_post_meta( $product_id, '_yoast_wpseo_title', true );
|
@@ -975,18 +996,18 @@ class ProductInfo {
|
|
975 |
$title = get_the_title( $product_id );
|
976 |
}
|
977 |
$wpseo_titles = get_option( 'wpseo_titles' );
|
978 |
-
|
979 |
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
|
980 |
if ( isset( $wpseo_titles['separator'], $sep_options[ $wpseo_titles['separator'] ] ) ) {
|
981 |
$sep = $sep_options[ $wpseo_titles['separator'] ];
|
982 |
} else {
|
983 |
$sep = '-'; //setting default separator if Admin didn't set it from backed
|
984 |
}
|
985 |
-
|
986 |
$site_title = get_bloginfo( 'name' );
|
987 |
-
|
988 |
$meta_title = $title . ' ' . $sep . ' ' . $site_title;
|
989 |
-
|
990 |
if ( ! empty( $meta_title ) ) {
|
991 |
$title = $meta_title;
|
992 |
}
|
@@ -995,10 +1016,10 @@ class ProductInfo {
|
|
995 |
} else {
|
996 |
$title = $this->title();
|
997 |
}
|
998 |
-
|
999 |
return apply_filters( 'woo_feed_filter_product_yoast_wpseo_title', $title, $this->product, $this->config );
|
1000 |
}
|
1001 |
-
|
1002 |
public function yoast_wpseo_metadesc() {
|
1003 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1004 |
$description = '';
|
@@ -1008,57 +1029,57 @@ class ProductInfo {
|
|
1008 |
} else {
|
1009 |
$description = YoastSEO()->meta->for_post( $product_id )->description;
|
1010 |
}
|
1011 |
-
|
1012 |
if ( empty( $description ) ) {
|
1013 |
$description = $this->description();
|
1014 |
}
|
1015 |
-
|
1016 |
return apply_filters( 'woo_feed_filter_product_yoast_wpseo_metadesc', $description, $this->product, $this->config );
|
1017 |
}
|
1018 |
-
|
1019 |
public function yoast_canonical_url() {
|
1020 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1021 |
$yoast_canonical_url = get_post_meta( $product_id, '_yoast_wpseo_canonical', true );
|
1022 |
-
|
1023 |
return apply_filters( 'woo_feed_filter_product_yoast_canonical_url', $yoast_canonical_url, $this->product, $this->config );
|
1024 |
}
|
1025 |
-
|
1026 |
public function yoast_gtin8() {
|
1027 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin8', $this->product );
|
1028 |
-
|
1029 |
return apply_filters( 'yoast_gtin8_attribute_value', $yoast_gtin8_value, $this->product );
|
1030 |
}
|
1031 |
-
|
1032 |
public function yoast_gtin12() {
|
1033 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin12', $this->product );
|
1034 |
-
|
1035 |
return apply_filters( 'yoast_gtin12_attribute_value', $yoast_gtin8_value, $this->product );
|
1036 |
}
|
1037 |
-
|
1038 |
public function yoast_gtin13() {
|
1039 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin13', $this->product );
|
1040 |
-
|
1041 |
return apply_filters( 'yoast_gtin13_attribute_value', $yoast_gtin8_value, $this->product );
|
1042 |
}
|
1043 |
-
|
1044 |
public function yoast_gtin14() {
|
1045 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin14', $this->product );
|
1046 |
-
|
1047 |
return apply_filters( 'yoast_gtin14_attribute_value', $yoast_gtin8_value, $this->product );
|
1048 |
}
|
1049 |
-
|
1050 |
public function yoast_isbn() {
|
1051 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'isbn', $this->product );
|
1052 |
-
|
1053 |
return apply_filters( 'yoast_isbn_attribute_value', $yoast_gtin8_value, $this->product );
|
1054 |
}
|
1055 |
-
|
1056 |
public function yoast_mpn() {
|
1057 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'mpn', $this->product );
|
1058 |
-
|
1059 |
return apply_filters( 'yoast_mpn_attribute_value', $yoast_gtin8_value, $this->product );
|
1060 |
}
|
1061 |
-
|
1062 |
public function rank_math_title() {
|
1063 |
$rank_title = '';
|
1064 |
if ( class_exists( 'RankMath' ) ) {
|
@@ -1067,7 +1088,7 @@ class ProductInfo {
|
|
1067 |
$title_format = Helper::get_settings( "titles.pt_product_title" );
|
1068 |
$title_format = $title_format ? $title_format : '%title%';
|
1069 |
$sep = Helper::get_settings( 'titles.title_separator' );
|
1070 |
-
|
1071 |
$rank_title = str_replace( '%title%', $this->product->get_title(), $title_format );
|
1072 |
$rank_title = str_replace( '%sep%', $sep, $rank_title );
|
1073 |
$rank_title = str_replace( '%page%', '', $rank_title );
|
@@ -1076,128 +1097,128 @@ class ProductInfo {
|
|
1076 |
$rank_title = $title;
|
1077 |
}
|
1078 |
}
|
1079 |
-
|
1080 |
return apply_filters( 'woo_feed_filter_product_rank_math_title', $rank_title, $this->product, $this->config );
|
1081 |
}
|
1082 |
-
|
1083 |
public function rank_math_description() {
|
1084 |
$description = '';
|
1085 |
if ( class_exists( 'RankMath' ) ) {
|
1086 |
$description = get_post_meta( $this->product->get_id(), 'rank_math_description' );
|
1087 |
$desc_format = \RankMath\Helper::get_settings( "titles.pt_post_description" );
|
1088 |
-
|
1089 |
if ( empty( $description ) ) {
|
1090 |
if ( ! empty( $desc_format ) && strpos( (string) $desc_format, 'excerpt' ) !== false ) {
|
1091 |
$description = str_replace( '%excerpt%', get_the_excerpt( $this->product->get_id() ), $desc_format );
|
1092 |
}
|
1093 |
-
|
1094 |
// Get Variation Description
|
1095 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
1096 |
$description = $this->parent_product->get_description();
|
1097 |
}
|
1098 |
}
|
1099 |
-
|
1100 |
if ( is_array( $description ) ) {
|
1101 |
$description = reset( $description );
|
1102 |
}
|
1103 |
-
|
1104 |
$description = CommonHelper::remove_shortcodes( $description );
|
1105 |
-
|
1106 |
//strip tags and spacial characters
|
1107 |
$strip_description = woo_feed_strip_all_tags( wp_specialchars_decode( $description ) );
|
1108 |
-
|
1109 |
$description = ! empty( strlen( $strip_description ) ) && 0 < strlen( $strip_description ) ? $strip_description : $description;
|
1110 |
}
|
1111 |
-
|
1112 |
return apply_filters( 'woo_feed_filter_product_rank_math_description', $description, $this->product, $this->config );
|
1113 |
}
|
1114 |
-
|
1115 |
public function rank_math_canonical_url() {
|
1116 |
$canonical_url = '';
|
1117 |
-
|
1118 |
if ( class_exists( 'RankMath' ) ) {
|
1119 |
$post_canonical_url = get_post_meta( $this->product->get_id(), 'rank_math_canonical_url' );
|
1120 |
-
|
1121 |
if ( empty( $post_canonical_url ) ) {
|
1122 |
$canonical_url = get_the_permalink( $this->product->get_id() );
|
1123 |
} else {
|
1124 |
$canonical_url = $post_canonical_url;
|
1125 |
}
|
1126 |
-
|
1127 |
if ( is_array( $canonical_url ) ) {
|
1128 |
$canonical_url = reset( $canonical_url );
|
1129 |
}
|
1130 |
}
|
1131 |
-
|
1132 |
return apply_filters( 'woo_feed_filter_product_rank_math_canonical_url', $canonical_url, $this->product, $this->config );
|
1133 |
}
|
1134 |
-
|
1135 |
public function rank_math_gtin() {
|
1136 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1137 |
$rankmath_gtin_value = get_post_meta( $product_id, '_rank_math_gtin_code' );
|
1138 |
$rankmath_gtin_value = ! empty( $rankmath_gtin_value ) && is_array( $rankmath_gtin_value ) ? $rankmath_gtin_value[0] : '';
|
1139 |
-
|
1140 |
return apply_filters( 'rankmath_gtin_attribute_value', $rankmath_gtin_value, $this->product, $this->config );
|
1141 |
}
|
1142 |
-
|
1143 |
public function _aioseop_title() {
|
1144 |
$title = '';
|
1145 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1146 |
-
|
1147 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1148 |
$title = ! empty( $post->title ) ? $post->title : aioseo()->meta->title->getPostTypeTitle( 'product' );
|
1149 |
}
|
1150 |
-
|
1151 |
$title = ! empty( $title ) ? $title : $this->title();
|
1152 |
-
|
1153 |
return apply_filters( 'woo_feed_filter_product_aioseop_title', $title, $this->product, $this->config );
|
1154 |
}
|
1155 |
-
|
1156 |
public function _aioseop_description() {
|
1157 |
$description = '';
|
1158 |
-
|
1159 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1160 |
-
|
1161 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1162 |
$description = ! empty( $post->description ) ? $post->description : aioseo()->meta->description->getPostTypeDescription( 'product' );
|
1163 |
}
|
1164 |
-
|
1165 |
if ( empty( $description ) ) {
|
1166 |
$description = $this->description();
|
1167 |
}
|
1168 |
-
|
1169 |
return apply_filters( 'woo_feed_filter_product_aioseop_description', $description, $this->product, $this->config );
|
1170 |
}
|
1171 |
-
|
1172 |
public function _aioseop_canonical_url() {
|
1173 |
$aioseop_canonical_url = '';
|
1174 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1175 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1176 |
$aioseop_canonical_url = $post->canonical_url;
|
1177 |
}
|
1178 |
-
|
1179 |
return apply_filters( 'woo_feed_filter_product_aioseop_canonical_url', $aioseop_canonical_url, $this->product, $this->config );
|
1180 |
}
|
1181 |
-
|
1182 |
############# TAX #############
|
1183 |
-
|
1184 |
public function tax( $key = '' ) {
|
1185 |
$tax = TaxFactory::get( $this->product, $this->config )->merchant_formatted_tax( $key );
|
1186 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1187 |
-
|
1188 |
// GoogleTax and CustomTax class is available.
|
1189 |
// For others merchant use filter hook to modify value.
|
1190 |
return apply_filters( 'woo_feed_filter_product_tax', $tax, $this->product, $this->config, $taxes );
|
1191 |
}
|
1192 |
-
|
1193 |
public function tax_class() {
|
1194 |
return apply_filters( 'woo_feed_filter_product_tax_class', $this->product->get_tax_class(), $this->product, $this->config );
|
1195 |
}
|
1196 |
-
|
1197 |
public function tax_status() {
|
1198 |
return apply_filters( 'woo_feed_filter_product_tax_status', $this->product->get_tax_status(), $this->product, $this->config );
|
1199 |
}
|
1200 |
-
|
1201 |
public function tax_country() {
|
1202 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1203 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1206,10 +1227,10 @@ class ProductInfo {
|
|
1206 |
$rates = array_values( $taxes[ $taxClass ] );
|
1207 |
$country = $rates[0]['country'];
|
1208 |
}
|
1209 |
-
|
1210 |
return apply_filters( 'woo_feed_filter_product_tax_country', $country, $this->product, $this->config, $taxes );
|
1211 |
}
|
1212 |
-
|
1213 |
public function tax_state() {
|
1214 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1215 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1218,10 +1239,10 @@ class ProductInfo {
|
|
1218 |
$rates = array_values( $taxes[ $taxClass ] );
|
1219 |
$state = $rates[0]['state'];
|
1220 |
}
|
1221 |
-
|
1222 |
return apply_filters( 'woo_feed_filter_product_tax_state', $state, $this->product, $this->config, $taxes );
|
1223 |
}
|
1224 |
-
|
1225 |
public function tax_postcode() {
|
1226 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1227 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1230,10 +1251,10 @@ class ProductInfo {
|
|
1230 |
$rates = array_values( $taxes[ $taxClass ] );
|
1231 |
$postcode = $rates[0]['postcode'];
|
1232 |
}
|
1233 |
-
|
1234 |
return apply_filters( 'woo_feed_filter_product_tax_postcode', $postcode, $this->product, $this->config, $taxes );
|
1235 |
}
|
1236 |
-
|
1237 |
public function tax_city() {
|
1238 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1239 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1242,10 +1263,10 @@ class ProductInfo {
|
|
1242 |
$rates = array_values( $taxes[ $taxClass ] );
|
1243 |
$city = $rates[0]['city'];
|
1244 |
}
|
1245 |
-
|
1246 |
return apply_filters( 'woo_feed_filter_product_tax_city', $city, $this->product, $this->config, $taxes );
|
1247 |
}
|
1248 |
-
|
1249 |
public function tax_rate() {
|
1250 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1251 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1254,10 +1275,10 @@ class ProductInfo {
|
|
1254 |
$rates = array_values( $taxes[ $taxClass ] );
|
1255 |
$rate = $rates[0]['rate'];
|
1256 |
}
|
1257 |
-
|
1258 |
return apply_filters( 'woo_feed_filter_product_tax_rate', $rate, $this->product, $this->config, $taxes );
|
1259 |
}
|
1260 |
-
|
1261 |
public function tax_label() {
|
1262 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1263 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
@@ -1266,12 +1287,12 @@ class ProductInfo {
|
|
1266 |
$rates = array_values( $taxes[ $taxClass ] );
|
1267 |
$label = $rates[0]['label'];
|
1268 |
}
|
1269 |
-
|
1270 |
return apply_filters( 'woo_feed_filter_product_tax_label', $label, $this->product, $this->config, $taxes );
|
1271 |
}
|
1272 |
-
|
1273 |
# Custom XML Template
|
1274 |
-
|
1275 |
/**
|
1276 |
* Custom Template 2 images loop
|
1277 |
*
|
@@ -1280,10 +1301,10 @@ class ProductInfo {
|
|
1280 |
public function custom_xml_images() {
|
1281 |
$images = $this->images();
|
1282 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
1283 |
-
|
1284 |
return explode( $separator, $images );
|
1285 |
}
|
1286 |
-
|
1287 |
/**
|
1288 |
* Custom Template 2 attributes loop
|
1289 |
*
|
@@ -1298,27 +1319,27 @@ class ProductInfo {
|
|
1298 |
$attributes[ $key ]['value'] = $this->product->get_attribute( wc_attribute_label( $key ) );
|
1299 |
}
|
1300 |
}
|
1301 |
-
|
1302 |
return $attributes;
|
1303 |
}
|
1304 |
-
|
1305 |
public function custom_xml_shipping() {
|
1306 |
}
|
1307 |
-
|
1308 |
public function custom_xml_tax() {
|
1309 |
}
|
1310 |
-
|
1311 |
public function custom_xml_categories() {
|
1312 |
$output = []; // Initialising
|
1313 |
$taxonomy = 'product_cat'; // Taxonomy for product category
|
1314 |
-
|
1315 |
// Get the product categories terms ids in the product:
|
1316 |
$terms_ids = wp_get_post_terms( $this->product->get_id(), $taxonomy, array( 'fields' => 'ids' ) );
|
1317 |
-
|
1318 |
// Loop though terms ids (product categories)
|
1319 |
foreach ( $terms_ids as $term_id ) {
|
1320 |
$term_names = []; // Initialising category array
|
1321 |
-
|
1322 |
// Loop through product category ancestors
|
1323 |
foreach ( get_ancestors( $term_id, $taxonomy ) as $ancestor_id ) {
|
1324 |
// Add the ancestor's term names to the category array
|
@@ -1326,15 +1347,15 @@ class ProductInfo {
|
|
1326 |
}
|
1327 |
// Add the product category term name to the category array
|
1328 |
$term_names[] = get_term( $term_id, $taxonomy )->name;
|
1329 |
-
|
1330 |
// Get category separator
|
1331 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
1332 |
-
|
1333 |
// Add the formatted ancestors with the product category to main array
|
1334 |
$output[] = implode( $separator, $term_names );
|
1335 |
}
|
1336 |
-
|
1337 |
return $output;
|
1338 |
}
|
1339 |
-
|
1340 |
-
}
|
28 |
* @var Config
|
29 |
*/
|
30 |
private $config;
|
31 |
+
|
32 |
/**
|
33 |
*
|
34 |
* @param WC_Product $product
|
39 |
$this->parent_product = $product;//->is_type('variable') ? wc_get_product( $product->get_parent_id() ) : wc_get_product( $product->get_id() );
|
40 |
$this->config = $config;
|
41 |
}
|
42 |
+
|
43 |
/**
|
44 |
* Get product id.
|
45 |
*
|
48 |
public function id() {
|
49 |
return apply_filters( 'woo_feed_filter_product_id', $this->product->get_id(), $this->product, $this->config );
|
50 |
}
|
51 |
+
|
52 |
/**
|
53 |
* Get product name.
|
54 |
*
|
55 |
* @return mixed|void
|
56 |
*/
|
57 |
public function title() {
|
58 |
+
|
59 |
$title = woo_feed_strip_all_tags( CommonHelper::remove_shortcodes( $this->product->get_name() ) );
|
60 |
+
|
61 |
// Add all available variation attributes to variation title.
|
62 |
if ( $this->product->is_type( 'variation' ) && ! empty( $this->product->get_attributes() ) ) {
|
63 |
$title = $this->parent_product->get_name();
|
68 |
$attributes[ $slug ] = $attribute;
|
69 |
}
|
70 |
}
|
71 |
+
|
72 |
// set variation attributes with separator
|
73 |
$separator = ',';
|
74 |
if ( 'google' === $this->config->get_feed_template() ) {
|
75 |
$separator = '-';
|
76 |
}
|
77 |
$variation_attributes = implode( $separator, $attributes );
|
78 |
+
|
79 |
//get product title with variation attribute
|
80 |
$get_with_var_attributes = apply_filters( "woo_feed_get_product_title_with_variation_attribute", true, $this->product, $this->config );
|
81 |
+
|
82 |
if ( $get_with_var_attributes ) {
|
83 |
$title .= " - " . $variation_attributes;
|
84 |
}
|
85 |
}
|
86 |
+
|
87 |
return apply_filters( 'woo_feed_filter_product_title', $title, $this->product, $this->config );
|
88 |
}
|
89 |
+
|
90 |
/**
|
91 |
* Get parent product title for variation.
|
92 |
*
|
98 |
} else {
|
99 |
$title = $this->title();
|
100 |
}
|
101 |
+
|
102 |
return apply_filters( 'woo_feed_filter_product_parent_title', $title, $this->product, $this->config );
|
103 |
}
|
104 |
+
|
105 |
/**
|
106 |
* Get product description.
|
107 |
*
|
109 |
*/
|
110 |
public function description() {
|
111 |
$description = $this->product->get_description();
|
112 |
+
|
113 |
// Get Variation Description
|
114 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
115 |
$description = '';
|
117 |
$description = $this->parent_product->get_description();
|
118 |
}
|
119 |
}
|
120 |
+
|
121 |
if ( empty( $description ) ) {
|
122 |
$description = $this->product->get_short_description();
|
123 |
}
|
124 |
+
|
125 |
$description = CommonHelper::remove_shortcodes( $description );
|
126 |
+
|
127 |
// Add variations attributes after description to prevent Facebook error
|
128 |
if ( 'facebook' === $this->config->get_feed_template() && $this->product->is_type( 'variation' ) ) {
|
129 |
$variationInfo = explode( '-', $this->product->get_name() );
|
134 |
}
|
135 |
$description .= ' ' . $extension;
|
136 |
}
|
137 |
+
|
138 |
//strip tags and spacial characters
|
139 |
$strip_description = woo_feed_strip_all_tags( wp_specialchars_decode( $description ) );
|
140 |
+
|
141 |
$description = ! empty( strlen( $strip_description ) ) && 0 < strlen( $strip_description ) ? $strip_description : $description;
|
142 |
+
|
143 |
return apply_filters( 'woo_feed_filter_product_description', $description, $this->product, $this->config );
|
144 |
}
|
145 |
+
|
146 |
/**
|
147 |
* Get product description with HTML tags.
|
148 |
*
|
150 |
*/
|
151 |
public function description_with_html() {
|
152 |
$description = $this->product->get_description();
|
153 |
+
|
154 |
// Get Variation Description
|
155 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
156 |
$description = '';
|
158 |
$description = $this->parent_product->get_description();
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
if ( empty( $description ) ) {
|
163 |
$description = $this->product->get_short_description();
|
164 |
}
|
165 |
+
|
166 |
$description = CommonHelper::remove_shortcodes( $description );
|
167 |
+
|
168 |
// Add variations attributes after description to prevent Facebook error
|
169 |
if ( 'facebook' === $this->config->get_feed_template() && $this->product->is_type( 'variation' ) ) {
|
170 |
$variationInfo = explode( '-', $this->product->get_name() );
|
175 |
}
|
176 |
$description .= ' ' . $extension;
|
177 |
}
|
178 |
+
|
179 |
//remove spacial characters
|
180 |
$description = wp_check_invalid_utf8( wp_specialchars_decode( $description ), true );
|
181 |
+
|
182 |
return apply_filters( 'woo_feed_filter_product_description_with_html', $description, $this->product, $this->config );
|
183 |
}
|
184 |
+
|
185 |
/**
|
186 |
* Get product short description.
|
187 |
*
|
189 |
*/
|
190 |
public function short_description() {
|
191 |
$short_description = $this->product->get_short_description();
|
192 |
+
|
193 |
// Get Variation Short Description
|
194 |
if ( empty( $short_description ) && $this->product->is_type( 'variation' ) ) {
|
195 |
$short_description = $this->parent_product->get_short_description();
|
196 |
}
|
197 |
+
|
198 |
$short_description = CommonHelper::remove_shortcodes( $short_description );
|
199 |
+
|
200 |
// Strip tags and spacial characters
|
201 |
$short_description = woo_feed_strip_all_tags( wp_specialchars_decode( $short_description ) );
|
202 |
+
|
203 |
return apply_filters( 'woo_feed_filter_product_short_description', $short_description, $this->product, $this->config );
|
204 |
}
|
205 |
+
|
206 |
/**
|
207 |
* Get product primary category.
|
208 |
*
|
211 |
public function primary_category() {
|
212 |
$parent_category = "";
|
213 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config );
|
214 |
+
|
215 |
$full_category = $this->product_type();
|
216 |
if ( ! empty( $full_category ) ) {
|
217 |
$full_category_array = explode( $separator, $full_category );
|
218 |
$parent_category = $full_category_array[0];
|
219 |
}
|
220 |
+
|
221 |
return apply_filters( 'woo_feed_filter_product_primary_category', $parent_category, $this->product, $this->config );
|
222 |
}
|
223 |
+
|
224 |
/**
|
225 |
* Get product primary category id.
|
226 |
*
|
235 |
$parent_category_obj = get_term_by( 'name', $full_category_array[0], 'product_cat' );
|
236 |
$parent_category_id = isset( $parent_category_obj->term_id ) ? $parent_category_obj->term_id : "";
|
237 |
}
|
238 |
+
|
239 |
return apply_filters( 'woo_feed_filter_product_primary_category_id', $parent_category_id, $this->product, $this->config );
|
240 |
}
|
241 |
+
|
242 |
/**
|
243 |
* Get product child category.
|
244 |
*
|
252 |
$full_category_array = explode( $separator, $full_category );
|
253 |
$child_category = end( $full_category_array );
|
254 |
}
|
255 |
+
|
256 |
return apply_filters( 'woo_feed_filter_product_child_category', $child_category, $this->product, $this->config );
|
257 |
}
|
258 |
+
|
259 |
/**
|
260 |
* Get product child category id.
|
261 |
*
|
270 |
$child_category_obj = get_term_by( 'name', end( $full_category_array ), 'product_cat' );
|
271 |
$child_category_id = isset( $child_category_obj->term_id ) ? $child_category_obj->term_id : "";
|
272 |
}
|
273 |
+
|
274 |
return apply_filters( 'woo_feed_filter_product_child_category_id', $child_category_id, $this->product, $this->config );
|
275 |
}
|
276 |
+
|
277 |
/**
|
278 |
* Get product type.
|
279 |
*
|
284 |
if ( $this->product->is_type( 'variation' ) ) {
|
285 |
$id = $this->product->get_parent_id();
|
286 |
}
|
287 |
+
|
288 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config );
|
289 |
$product_categories = '';
|
290 |
$term_list = get_the_terms( $id, 'product_cat' );
|
291 |
+
|
292 |
if ( is_array( $term_list ) ) {
|
293 |
$col = array_column( $term_list, "term_id" );
|
294 |
array_multisort( $col, SORT_ASC, $term_list );
|
296 |
//TODO: Remove Manual Separator and add Dynamically with hook. Hook function also need to modified from array to object.
|
297 |
$product_categories = implode( ' > ', $term_list );
|
298 |
}
|
299 |
+
|
300 |
+
|
301 |
return apply_filters( 'woo_feed_filter_product_local_category', $product_categories, $this->product, $this->config );
|
302 |
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* @param \WC_Product $product
|
306 |
+
*
|
307 |
+
* @return void
|
308 |
+
*/
|
309 |
+
public function product_status( $product ) {
|
310 |
+
$status = $product->get_status();
|
311 |
+
return apply_filters( 'woo_feed_filter_product_status', $status, $product, $this->config );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* @param \WC_Product $product
|
316 |
+
*
|
317 |
+
* @return void
|
318 |
+
*/
|
319 |
+
public function featured_status( $product ) {
|
320 |
+
$status = $product->is_featured() ? 'yes' : 'no';
|
321 |
+
|
322 |
+
return apply_filters( 'woo_feed_filter_featured_status', $status, $product, $this->config );
|
323 |
+
}
|
324 |
+
|
325 |
/**
|
326 |
* Get product full category.
|
327 |
*
|
328 |
* @return mixed|void
|
329 |
*/
|
330 |
public function product_full_cat() {
|
331 |
+
|
332 |
$id = $this->product->get_id();
|
333 |
if ( $this->product->is_type( 'variation' ) ) {
|
334 |
$id = $this->product->get_parent_id();
|
335 |
}
|
336 |
+
|
337 |
$separator = apply_filters( 'woo_feed_product_type_separator', ' > ', $this->config, $this->product );
|
338 |
+
|
339 |
$product_type = wp_strip_all_tags( wc_get_product_category_list( $id, $separator ) );
|
340 |
+
|
341 |
+
|
342 |
return apply_filters( 'woo_feed_filter_product_local_category', $product_type, $this->product, $this->config );
|
343 |
}
|
344 |
+
|
345 |
/**
|
346 |
* Get product URL.
|
347 |
*
|
349 |
*/
|
350 |
public function link() {
|
351 |
$link = $this->product->get_permalink();
|
352 |
+
|
353 |
if ( $this->config->get_campaign_parameters() ) {
|
354 |
$link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $link );
|
355 |
}
|
356 |
+
|
357 |
return apply_filters( 'woo_feed_filter_product_link', $link, $this->product, $this->config );
|
358 |
}
|
359 |
+
|
360 |
/**
|
361 |
* Get product parent URL.
|
362 |
*
|
367 |
if ( $this->product->is_type( 'variation' ) ) {
|
368 |
$link = $this->parent_product->get_permalink();
|
369 |
}
|
370 |
+
|
371 |
if ( $this->config->get_campaign_parameters() ) {
|
372 |
$link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $link );
|
373 |
}
|
374 |
+
|
375 |
return apply_filters( 'woo_feed_filter_product_parent_link', $link, $this->product, $this->config );
|
376 |
}
|
377 |
+
|
378 |
/**
|
379 |
* Get product Canonical URL.
|
380 |
*
|
383 |
public function canonical_link() {
|
384 |
//TODO: check if SEO plugin installed then return SEO canonical URL
|
385 |
$canonical_link = $this->parent_link();
|
386 |
+
|
387 |
return apply_filters( 'woo_feed_filter_product_canonical_link', $canonical_link, $this->product, $this->config );
|
388 |
}
|
389 |
+
|
390 |
/**
|
391 |
* Get external product URL.
|
392 |
*
|
400 |
$ex_link = CommonHelper::add_utm_parameter( $this->config->get_campaign_parameters(), $ex_link );
|
401 |
}
|
402 |
}
|
403 |
+
|
404 |
return apply_filters( 'woo_feed_filter_product_ex_link', $ex_link, $this->product, $this->config );
|
405 |
}
|
406 |
+
|
407 |
/**
|
408 |
* Get product image URL.
|
409 |
*
|
424 |
$getImage = wp_get_attachment_image_src( get_post_thumbnail_id( $this->product->get_id() ), 'single-post-thumbnail' );
|
425 |
$image = isset( $getImage[0] ) ? woo_feed_get_formatted_url( $getImage[0] ) : '';
|
426 |
}
|
427 |
+
|
428 |
return apply_filters( 'woo_feed_filter_product_image', $image, $this->product, $this->config );
|
429 |
}
|
430 |
+
|
431 |
/**
|
432 |
* Get product featured image URL.
|
433 |
*
|
438 |
if ( $this->product->is_type( 'variation' ) ) {
|
439 |
$id = $this->product->get_parent_id();
|
440 |
}
|
441 |
+
|
442 |
$getImage = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
|
443 |
$image = isset( $getImage[0] ) ? woo_feed_get_formatted_url( $getImage[0] ) : '';
|
444 |
+
|
445 |
return apply_filters( 'woo_feed_filter_product_feature_image', $image, $this->product, $this->config );
|
446 |
}
|
447 |
+
|
448 |
/**
|
449 |
* Get product images (comma separated URLs).
|
450 |
*
|
453 |
public function images( $additionalImg = '' ) {
|
454 |
$imgUrls = ProductHelper::get_product_gallery( $this->product );
|
455 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
456 |
+
|
457 |
// Return Specific Additional Image URL
|
458 |
if ( '' !== $additionalImg ) {
|
459 |
if ( array_key_exists( $additionalImg, $imgUrls ) ) {
|
465 |
if ( "idealo" === $this->config->get_feed_template() ) {
|
466 |
$separator = ';';
|
467 |
}
|
468 |
+
|
469 |
$images = implode( $separator, array_filter( $imgUrls ) );
|
470 |
}
|
471 |
+
|
472 |
return apply_filters( 'woo_feed_filter_product_images', $images, $this->product, $this->config );
|
473 |
}
|
474 |
+
|
475 |
public function condition() {
|
476 |
return apply_filters( 'woo_feed_product_condition', 'new', $this->product, $this->config );
|
477 |
}
|
478 |
+
|
479 |
public function type() {
|
480 |
return apply_filters( 'woo_feed_filter_product_type', $this->product->get_type(), $this->product, $this->config );
|
481 |
}
|
482 |
+
|
483 |
public function is_bundle() {
|
484 |
$is_bundle = 'no';
|
485 |
if ( $this->product->is_type( 'bundle' ) || $this->product->is_type( 'yith_bundle' ) ) {
|
486 |
$is_bundle = 'yes';
|
487 |
}
|
488 |
+
|
489 |
return apply_filters( 'woo_feed_filter_product_is_bundle', $is_bundle, $this->product, $this->config );
|
490 |
}
|
491 |
+
|
492 |
public function multipack() {
|
493 |
$multi_pack = '';
|
494 |
if ( $this->product->is_type( 'grouped' ) ) {
|
495 |
$multi_pack = ( ! empty( $this->product->get_children() ) ) ? count( $this->product->get_children() ) : '';
|
496 |
}
|
497 |
+
|
498 |
return apply_filters( 'woo_feed_filter_product_is_multipack', $multi_pack, $this->product, $this->config );
|
499 |
}
|
500 |
+
|
501 |
public function visibility() {
|
502 |
return apply_filters( 'woo_feed_filter_product_visibility', $this->product->get_catalog_visibility(), $this->product, $this->config );
|
503 |
}
|
504 |
+
|
505 |
public function rating_total() {
|
506 |
return apply_filters( 'woo_feed_filter_product_rating_total', $this->product->get_rating_count(), $this->product, $this->config );
|
507 |
}
|
508 |
+
|
509 |
public function rating_average() {
|
510 |
return apply_filters( 'woo_feed_filter_product_rating_average', $this->product->get_average_rating(), $this->product, $this->config );
|
511 |
}
|
512 |
+
|
513 |
public function total_sold() {
|
514 |
} //TODO: Implement this
|
515 |
+
|
516 |
public function tags() {
|
517 |
$id = $this->product->get_id();
|
518 |
if ( $this->product->is_type( 'variation' ) ) {
|
519 |
$id = $this->product->get_parent_id();
|
520 |
}
|
521 |
+
|
522 |
/**
|
523 |
* Separator for multiple tags
|
524 |
*
|
529 |
* @since 3.4.3
|
530 |
*/
|
531 |
$separator = apply_filters( 'woo_feed_tags_separator', ',', $this->product, $this->config );
|
532 |
+
|
533 |
$tags = woo_feed_strip_all_tags( get_the_term_list( $id, 'product_tag', '', $separator, '' ) );
|
534 |
+
|
535 |
return apply_filters( 'woo_feed_filter_product_tags', $tags, $this->product, $this->config );
|
536 |
}
|
537 |
+
|
538 |
public function item_group_id() {
|
539 |
$id = $this->product->get_id();
|
540 |
if ( $this->product->is_type( 'variation' ) ) {
|
541 |
$id = $this->product->get_parent_id();
|
542 |
}
|
543 |
+
|
544 |
return apply_filters( 'woo_feed_filter_product_item_group_id', $id, $this->product, $this->config );
|
545 |
}
|
546 |
+
|
547 |
public function sku() {
|
548 |
return apply_filters( 'woo_feed_filter_product_sku', $this->product->get_sku(), $this->product, $this->config );
|
549 |
}
|
550 |
+
|
551 |
public function sku_id() {
|
552 |
$sku = ! empty( $this->product->get_sku() ) ? $this->product->get_sku() . '_' : '';
|
553 |
$sku_id = $sku . $this->product->get_id();
|
554 |
+
|
555 |
return apply_filters( 'woo_feed_filter_product_sku_id', $sku_id, $this->product, $this->config );
|
556 |
}
|
557 |
+
|
558 |
public function parent_sku() {
|
559 |
$parent_sku = $this->product->get_sku();
|
560 |
if ( $this->product->is_type( 'variation' ) ) {
|
561 |
$parent_sku = $this->parent_product->get_sku();
|
562 |
}
|
563 |
+
|
564 |
return apply_filters( 'woo_feed_filter_product_parent_sku', $parent_sku, $this->product, $this->config );
|
565 |
}
|
566 |
+
|
567 |
public function availability() {
|
568 |
$status = $this->product->get_stock_status();
|
569 |
if ( 'instock' === $status ) {
|
573 |
} elseif ( 'onbackorder' === $status ) {
|
574 |
$status = 'on backorder';
|
575 |
}
|
576 |
+
|
577 |
// set (_) as separator for google merchant
|
578 |
if ( 'google' === $this->config->get_feed_template() ) {
|
579 |
$status = explode( ' ', $status );
|
580 |
$status = implode( '_', $status );
|
581 |
}
|
582 |
+
|
583 |
return apply_filters( 'woo_feed_filter_product_availability', $status, $this->product, $this->config );
|
584 |
}
|
585 |
+
|
586 |
public function availability_date() {
|
587 |
+
|
588 |
$feed_settings = get_option( 'woo_feed_settings' );
|
589 |
+
|
590 |
$availability_date_settings = isset( $feed_settings['woo_feed_identifier']['availability_date'] )
|
591 |
? $feed_settings['woo_feed_identifier']['availability_date']
|
592 |
: 'enable';
|
593 |
+
|
594 |
if ( $this->product->get_stock_status() !== 'onbackorder' || $availability_date_settings === 'disable' ) {
|
595 |
return '';
|
596 |
}
|
597 |
+
|
598 |
$meta_field_name = 'woo_feed_availability_date';
|
599 |
+
|
600 |
if ( $this->product->is_type( 'variation' ) ) {
|
601 |
$meta_field_name .= '_var';
|
602 |
}
|
603 |
+
|
604 |
$availability_date = get_post_meta( $this->product->get_id(), $meta_field_name, true );
|
605 |
+
|
606 |
if ( '' !== $availability_date && in_array( $this->config->get_feed_template(), [
|
607 |
'google',
|
608 |
'facebook',
|
612 |
], true ) ) {
|
613 |
$availability_date = gmdate( 'c', strtotime( $availability_date ) );
|
614 |
}
|
615 |
+
|
616 |
return apply_filters( 'woo_feed_filter_product_availability_date', $availability_date, $this->product, $this->config );
|
617 |
}
|
618 |
+
|
619 |
public function add_to_cart_link() {
|
620 |
$url = $this->link();
|
621 |
$suffix = 'add-to-cart=' . $this->product->get_id();
|
622 |
+
|
623 |
$add_to_cart_link = woo_feed_make_url_with_parameter( $url, $suffix );
|
624 |
+
|
625 |
return apply_filters( 'woo_feed_filter_product_add_to_cart_link', $add_to_cart_link, $this->product, $this->config );
|
626 |
}
|
627 |
+
|
628 |
public function quantity() {
|
629 |
$quantity = $this->product->get_stock_quantity();
|
630 |
$status = $this->product->get_stock_status();
|
631 |
+
|
632 |
//when product is outofstock , and it's quantity is empty, set quantity to 0
|
633 |
if ( 'outofstock' === $status && $quantity === null ) {
|
634 |
$quantity = 0;
|
635 |
}
|
636 |
+
|
637 |
if ( $this->product->is_type( 'variable' ) && $this->product->has_child() ) {
|
638 |
$visible_children = $this->product->get_visible_children();
|
639 |
$qty = array();
|
641 |
$childQty = get_post_meta( $child, '_stock', true );
|
642 |
$qty[] = (int) $childQty + 0;
|
643 |
}
|
644 |
+
|
645 |
if ( isset( $this->config['variable_quantity'] ) ) {
|
646 |
$vaQty = $this->config['variable_quantity'];
|
647 |
if ( 'max' === $vaQty ) {
|
657 |
}
|
658 |
}
|
659 |
}
|
660 |
+
|
661 |
return apply_filters( 'woo_feed_filter_product_quantity', $quantity, $this->product, $this->config );
|
662 |
}
|
663 |
+
|
664 |
/**
|
665 |
* Get Store Currency.
|
666 |
*
|
668 |
*/
|
669 |
public function currency() {
|
670 |
$quantity = get_option( 'woocommerce_currency' );
|
671 |
+
|
672 |
return apply_filters( 'woo_feed_filter_product_currency', $quantity, $this->product, $this->config );
|
673 |
}
|
674 |
+
|
675 |
/**
|
676 |
* Get Product Sale Price start date.
|
677 |
*
|
684 |
} else {
|
685 |
$sale_price_sdate = '';
|
686 |
}
|
687 |
+
|
688 |
return apply_filters( 'woo_feed_filter_product_sale_price_sdate', $sale_price_sdate, $this->product, $this->config );
|
689 |
}
|
690 |
+
|
691 |
/**
|
692 |
* Get Product Sale Price End Date.
|
693 |
*
|
700 |
} else {
|
701 |
$sale_price_edate = "";
|
702 |
}
|
703 |
+
|
704 |
return apply_filters( 'woo_feed_filter_product_sale_price_edate', $sale_price_edate, $this->product, $this->config );
|
705 |
}
|
706 |
+
|
707 |
public function price() {
|
708 |
return PriceFactory::get( $this->product, $this->config )->regular_price();
|
709 |
}
|
710 |
+
|
711 |
public function current_price() {
|
712 |
return PriceFactory::get( $this->product, $this->config )->price();
|
713 |
}
|
714 |
+
|
715 |
public function sale_price() {
|
716 |
return PriceFactory::get( $this->product, $this->config )->sale_price();
|
717 |
}
|
718 |
+
|
719 |
public function price_with_tax() {
|
720 |
return PriceFactory::get( $this->product, $this->config )->regular_price( true );
|
721 |
}
|
722 |
+
|
723 |
public function current_price_with_tax() {
|
724 |
return PriceFactory::get( $this->product, $this->config )->price( true );
|
725 |
}
|
726 |
+
|
727 |
public function sale_price_with_tax() {
|
728 |
return PriceFactory::get( $this->product, $this->config )->sale_price( true );
|
729 |
}
|
730 |
+
|
731 |
/**
|
732 |
* Get Product Weight.
|
733 |
*
|
736 |
public function weight() {
|
737 |
return apply_filters( 'woo_feed_filter_product_weight', $this->product->get_weight(), $this->product, $this->config );
|
738 |
}
|
739 |
+
|
740 |
/**
|
741 |
* Get Weight Unit.
|
742 |
*
|
745 |
public function weight_unit() {
|
746 |
return apply_filters( 'woo_feed_filter_product_weight_unit', get_option( 'woocommerce_weight_unit' ), $this->product, $this->config );
|
747 |
}
|
748 |
+
|
749 |
/**
|
750 |
* Get Product Width.
|
751 |
*
|
754 |
public function width() {
|
755 |
return apply_filters( 'woo_feed_filter_product_width', $this->product->get_width(), $this->product, $this->config );
|
756 |
}
|
757 |
+
|
758 |
/**
|
759 |
* Get Product Height.
|
760 |
*
|
763 |
public function height() {
|
764 |
return apply_filters( 'woo_feed_filter_product_height', $this->product->get_height(), $this->product, $this->config );
|
765 |
}
|
766 |
+
|
767 |
/**
|
768 |
* Get Product Length.
|
769 |
*
|
772 |
public function length() {
|
773 |
return apply_filters( 'woo_feed_filter_product_length', $this->product->get_length(), $this->product, $this->config );
|
774 |
}
|
775 |
+
|
776 |
/** Google Formatted Shipping info
|
777 |
*
|
778 |
* @return string
|
783 |
return ( ShippingFactory::get( $this->product, $this->config ) )->get_shipping($key);
|
784 |
// return apply_filters( 'woo_feed_filter_product_shipping', $shipping, $this->product, $this->config );
|
785 |
} catch ( Exception $e ) {
|
786 |
+
|
787 |
}
|
788 |
}
|
789 |
+
|
790 |
+
|
791 |
/**
|
792 |
* Get Shipping Cost.
|
793 |
*
|
796 |
public function shipping_cost() {
|
797 |
// Get config to which shipping price to return (first, highest or lowest)
|
798 |
$shipping = ( ShippingFactory::get( $this->product, $this->config ) )->get_shipping_info();
|
799 |
+
|
800 |
$price = "0";
|
801 |
if ( ! empty( $shipping ) ) {
|
802 |
if ( isset( $this->config->shipping_price ) ) {
|
813 |
$price = reset( $shipping_prices );
|
814 |
}
|
815 |
}
|
816 |
+
|
817 |
return apply_filters( 'woo_feed_filter_product_shipping_cost', $price, $this->product, $this->config );
|
818 |
}
|
819 |
+
|
820 |
+
|
821 |
/**
|
822 |
* Get Product Shipping Class
|
823 |
*
|
828 |
public function shipping_class() {
|
829 |
return apply_filters( 'woo_feed_filter_product_shipping_class', $this->product->get_shipping_class(), $this->product, $this->config );
|
830 |
}
|
831 |
+
|
832 |
/**
|
833 |
* Get author name.
|
834 |
*
|
836 |
*/
|
837 |
public function author_name() {
|
838 |
$post = get_post( $this->product->get_id() );
|
839 |
+
|
840 |
return get_the_author_meta( 'user_login', $post->post_author );
|
841 |
}
|
842 |
+
|
843 |
/**
|
844 |
* Get Author Email.
|
845 |
*
|
847 |
*/
|
848 |
public function author_email() {
|
849 |
$post = get_post( $this->product->get_id() );
|
850 |
+
|
851 |
return get_the_author_meta( 'user_email', $post->post_author );
|
852 |
}
|
853 |
+
|
854 |
/**
|
855 |
* Get Date Created.
|
856 |
*
|
858 |
*/
|
859 |
public function date_created() {
|
860 |
$date_created = gmdate( 'Y-m-d', strtotime( $this->product->get_date_created() ) );
|
861 |
+
|
862 |
return apply_filters( 'woo_feed_filter_product_date_created', $date_created, $this->product, $this->config );
|
863 |
}
|
864 |
+
|
865 |
/**
|
866 |
* Get Date updated.
|
867 |
*
|
869 |
*/
|
870 |
public function date_updated() {
|
871 |
$date_updated = gmdate( 'Y-m-d', strtotime( $this->product->get_date_modified() ) );
|
872 |
+
|
873 |
return apply_filters( 'woo_feed_filter_product_date_updated', $date_updated, $this->product, $this->config );
|
874 |
}
|
875 |
+
|
876 |
/** Get Google Sale Price effective date.
|
877 |
*
|
878 |
* @return string
|
884 |
if ( ! empty( $from ) && ! empty( $to ) ) {
|
885 |
$from = gmdate( 'c', strtotime( $from ) );
|
886 |
$to = gmdate( 'c', strtotime( $to ) );
|
887 |
+
|
888 |
$effective_date = $from . '/' . $to;
|
889 |
}
|
890 |
+
|
891 |
return $effective_date;
|
892 |
}
|
893 |
+
|
894 |
public function subscription_period() {
|
895 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
896 |
return ProductHelper::get_product_meta( '_subscription_period', $this->product, $this->config );
|
897 |
}
|
898 |
+
|
899 |
return '';
|
900 |
}
|
901 |
+
|
902 |
public function subscription_period_interval() {
|
903 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
904 |
return ProductHelper::get_product_meta( '_subscription_period_interval', $this->product, $this->config );
|
905 |
}
|
906 |
+
|
907 |
return '';
|
908 |
}
|
909 |
+
|
910 |
public function subscription_amount() {
|
911 |
// return $this->price($product);
|
912 |
}
|
913 |
+
|
914 |
public function installment_amount() {
|
915 |
// return $this->price($product);
|
916 |
}
|
917 |
+
|
918 |
public function installment_months() {
|
919 |
if ( class_exists( 'WC_Subscriptions' ) ) {
|
920 |
return ProductHelper::get_product_meta( '_subscription_length', $this->product, $this->config );
|
921 |
}
|
922 |
+
|
923 |
return '';
|
924 |
}
|
925 |
+
|
926 |
public function unit_price_measure() {
|
927 |
$unit_price_measure = '';
|
928 |
$identifiers = woo_feed_get_options( 'woo_feed_identifier' );
|
932 |
) {
|
933 |
$unit = ProductHelper::get_custom_filed( 'woo_feed_unit', $this->product, $this->config );
|
934 |
$unit_price_measure = ProductHelper::get_custom_filed( 'woo_feed_unit_pricing_measure', $this->product, $this->config );
|
935 |
+
|
936 |
$unit_price_measure .= " " . $unit;
|
937 |
}
|
938 |
+
|
939 |
if ( empty( $unit_price_measure ) && class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
940 |
$unit = ProductHelper::get_product_meta( '_unit', $this->product, $this->config );
|
941 |
$unit_price_measure = ProductHelper::get_product_meta( '_unit_product', $this->product, $this->config );
|
942 |
+
|
943 |
$unit_price_measure .= " " . $unit;
|
944 |
}
|
945 |
+
|
946 |
return apply_filters( 'woo_feed_filter_unit_price_measure', $unit_price_measure, $this->product, $this->config );
|
947 |
}
|
948 |
+
|
949 |
public function unit_price_base_measure() {
|
950 |
$unit_price_base_measure = '';
|
951 |
$identifiers = woo_feed_get_options( 'woo_feed_identifier' );
|
957 |
$unit_price_base_measure = ProductHelper::get_custom_filed( 'woo_feed_unit_pricing_base_measure', $this->product, $this->config );
|
958 |
$unit_price_base_measure .= " " . $unit;
|
959 |
}
|
960 |
+
|
961 |
if ( empty( $unit_price_base_measure ) && class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
962 |
$unit = ProductHelper::get_product_meta( '_unit', $this->product, $this->config );
|
963 |
$unit_price_base_measure = ProductHelper::get_product_meta( '_unit_base', $this->product, $this->config );
|
964 |
$unit_price_base_measure .= " " . $unit;
|
965 |
}
|
966 |
+
|
967 |
return apply_filters( 'woo_feed_filter_unit_price_base_measure', $unit_price_base_measure, $this->product, $this->config );
|
968 |
}
|
969 |
+
|
970 |
public function wc_germanized_gtin() {
|
971 |
$wc_germanized_gtin = '';
|
972 |
if ( class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
973 |
$wc_germanized_gtin = ProductHelper::get_product_meta( '_ts_gtin', $this->product, $this->config );
|
974 |
}
|
975 |
+
|
976 |
return apply_filters( 'woo_feed_filter_wc_germanized_gtin', $wc_germanized_gtin, $this->product, $this->config );
|
977 |
}
|
978 |
+
|
979 |
public function wc_germanized_mpn() {
|
980 |
$wc_germanized_mpn = '';
|
981 |
if ( class_exists( 'WooCommerce_Germanized' ) ) { // For WooCommerce Germanized Plugin
|
982 |
$wc_germanized_mpn = ProductHelper::get_product_meta( '_ts_mpn', $this->product, $this->config );
|
983 |
}
|
984 |
+
|
985 |
return apply_filters( 'woo_feed_filter_wc_germanized_mpn', $wc_germanized_mpn, $this->product, $this->config );
|
986 |
}
|
987 |
+
|
988 |
# SEO Plugins
|
989 |
+
|
990 |
public function yoast_wpseo_title() {
|
991 |
$product_id = woo_feed_parent_product_id( $this->product );
|
992 |
$yoast_title = get_post_meta( $product_id, '_yoast_wpseo_title', true );
|
996 |
$title = get_the_title( $product_id );
|
997 |
}
|
998 |
$wpseo_titles = get_option( 'wpseo_titles' );
|
999 |
+
|
1000 |
$sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options();
|
1001 |
if ( isset( $wpseo_titles['separator'], $sep_options[ $wpseo_titles['separator'] ] ) ) {
|
1002 |
$sep = $sep_options[ $wpseo_titles['separator'] ];
|
1003 |
} else {
|
1004 |
$sep = '-'; //setting default separator if Admin didn't set it from backed
|
1005 |
}
|
1006 |
+
|
1007 |
$site_title = get_bloginfo( 'name' );
|
1008 |
+
|
1009 |
$meta_title = $title . ' ' . $sep . ' ' . $site_title;
|
1010 |
+
|
1011 |
if ( ! empty( $meta_title ) ) {
|
1012 |
$title = $meta_title;
|
1013 |
}
|
1016 |
} else {
|
1017 |
$title = $this->title();
|
1018 |
}
|
1019 |
+
|
1020 |
return apply_filters( 'woo_feed_filter_product_yoast_wpseo_title', $title, $this->product, $this->config );
|
1021 |
}
|
1022 |
+
|
1023 |
public function yoast_wpseo_metadesc() {
|
1024 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1025 |
$description = '';
|
1029 |
} else {
|
1030 |
$description = YoastSEO()->meta->for_post( $product_id )->description;
|
1031 |
}
|
1032 |
+
|
1033 |
if ( empty( $description ) ) {
|
1034 |
$description = $this->description();
|
1035 |
}
|
1036 |
+
|
1037 |
return apply_filters( 'woo_feed_filter_product_yoast_wpseo_metadesc', $description, $this->product, $this->config );
|
1038 |
}
|
1039 |
+
|
1040 |
public function yoast_canonical_url() {
|
1041 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1042 |
$yoast_canonical_url = get_post_meta( $product_id, '_yoast_wpseo_canonical', true );
|
1043 |
+
|
1044 |
return apply_filters( 'woo_feed_filter_product_yoast_canonical_url', $yoast_canonical_url, $this->product, $this->config );
|
1045 |
}
|
1046 |
+
|
1047 |
public function yoast_gtin8() {
|
1048 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin8', $this->product );
|
1049 |
+
|
1050 |
return apply_filters( 'yoast_gtin8_attribute_value', $yoast_gtin8_value, $this->product );
|
1051 |
}
|
1052 |
+
|
1053 |
public function yoast_gtin12() {
|
1054 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin12', $this->product );
|
1055 |
+
|
1056 |
return apply_filters( 'yoast_gtin12_attribute_value', $yoast_gtin8_value, $this->product );
|
1057 |
}
|
1058 |
+
|
1059 |
public function yoast_gtin13() {
|
1060 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin13', $this->product );
|
1061 |
+
|
1062 |
return apply_filters( 'yoast_gtin13_attribute_value', $yoast_gtin8_value, $this->product );
|
1063 |
}
|
1064 |
+
|
1065 |
public function yoast_gtin14() {
|
1066 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'gtin14', $this->product );
|
1067 |
+
|
1068 |
return apply_filters( 'yoast_gtin14_attribute_value', $yoast_gtin8_value, $this->product );
|
1069 |
}
|
1070 |
+
|
1071 |
public function yoast_isbn() {
|
1072 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'isbn', $this->product );
|
1073 |
+
|
1074 |
return apply_filters( 'yoast_isbn_attribute_value', $yoast_gtin8_value, $this->product );
|
1075 |
}
|
1076 |
+
|
1077 |
public function yoast_mpn() {
|
1078 |
$yoast_gtin8_value = woo_feed_get_yoast_identifiers_value( 'mpn', $this->product );
|
1079 |
+
|
1080 |
return apply_filters( 'yoast_mpn_attribute_value', $yoast_gtin8_value, $this->product );
|
1081 |
}
|
1082 |
+
|
1083 |
public function rank_math_title() {
|
1084 |
$rank_title = '';
|
1085 |
if ( class_exists( 'RankMath' ) ) {
|
1088 |
$title_format = Helper::get_settings( "titles.pt_product_title" );
|
1089 |
$title_format = $title_format ? $title_format : '%title%';
|
1090 |
$sep = Helper::get_settings( 'titles.title_separator' );
|
1091 |
+
|
1092 |
$rank_title = str_replace( '%title%', $this->product->get_title(), $title_format );
|
1093 |
$rank_title = str_replace( '%sep%', $sep, $rank_title );
|
1094 |
$rank_title = str_replace( '%page%', '', $rank_title );
|
1097 |
$rank_title = $title;
|
1098 |
}
|
1099 |
}
|
1100 |
+
|
1101 |
return apply_filters( 'woo_feed_filter_product_rank_math_title', $rank_title, $this->product, $this->config );
|
1102 |
}
|
1103 |
+
|
1104 |
public function rank_math_description() {
|
1105 |
$description = '';
|
1106 |
if ( class_exists( 'RankMath' ) ) {
|
1107 |
$description = get_post_meta( $this->product->get_id(), 'rank_math_description' );
|
1108 |
$desc_format = \RankMath\Helper::get_settings( "titles.pt_post_description" );
|
1109 |
+
|
1110 |
if ( empty( $description ) ) {
|
1111 |
if ( ! empty( $desc_format ) && strpos( (string) $desc_format, 'excerpt' ) !== false ) {
|
1112 |
$description = str_replace( '%excerpt%', get_the_excerpt( $this->product->get_id() ), $desc_format );
|
1113 |
}
|
1114 |
+
|
1115 |
// Get Variation Description
|
1116 |
if ( empty( $description ) && $this->product->is_type( 'variation' ) ) {
|
1117 |
$description = $this->parent_product->get_description();
|
1118 |
}
|
1119 |
}
|
1120 |
+
|
1121 |
if ( is_array( $description ) ) {
|
1122 |
$description = reset( $description );
|
1123 |
}
|
1124 |
+
|
1125 |
$description = CommonHelper::remove_shortcodes( $description );
|
1126 |
+
|
1127 |
//strip tags and spacial characters
|
1128 |
$strip_description = woo_feed_strip_all_tags( wp_specialchars_decode( $description ) );
|
1129 |
+
|
1130 |
$description = ! empty( strlen( $strip_description ) ) && 0 < strlen( $strip_description ) ? $strip_description : $description;
|
1131 |
}
|
1132 |
+
|
1133 |
return apply_filters( 'woo_feed_filter_product_rank_math_description', $description, $this->product, $this->config );
|
1134 |
}
|
1135 |
+
|
1136 |
public function rank_math_canonical_url() {
|
1137 |
$canonical_url = '';
|
1138 |
+
|
1139 |
if ( class_exists( 'RankMath' ) ) {
|
1140 |
$post_canonical_url = get_post_meta( $this->product->get_id(), 'rank_math_canonical_url' );
|
1141 |
+
|
1142 |
if ( empty( $post_canonical_url ) ) {
|
1143 |
$canonical_url = get_the_permalink( $this->product->get_id() );
|
1144 |
} else {
|
1145 |
$canonical_url = $post_canonical_url;
|
1146 |
}
|
1147 |
+
|
1148 |
if ( is_array( $canonical_url ) ) {
|
1149 |
$canonical_url = reset( $canonical_url );
|
1150 |
}
|
1151 |
}
|
1152 |
+
|
1153 |
return apply_filters( 'woo_feed_filter_product_rank_math_canonical_url', $canonical_url, $this->product, $this->config );
|
1154 |
}
|
1155 |
+
|
1156 |
public function rank_math_gtin() {
|
1157 |
$product_id = woo_feed_parent_product_id( $this->product );
|
1158 |
$rankmath_gtin_value = get_post_meta( $product_id, '_rank_math_gtin_code' );
|
1159 |
$rankmath_gtin_value = ! empty( $rankmath_gtin_value ) && is_array( $rankmath_gtin_value ) ? $rankmath_gtin_value[0] : '';
|
1160 |
+
|
1161 |
return apply_filters( 'rankmath_gtin_attribute_value', $rankmath_gtin_value, $this->product, $this->config );
|
1162 |
}
|
1163 |
+
|
1164 |
public function _aioseop_title() {
|
1165 |
$title = '';
|
1166 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1167 |
+
|
1168 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1169 |
$title = ! empty( $post->title ) ? $post->title : aioseo()->meta->title->getPostTypeTitle( 'product' );
|
1170 |
}
|
1171 |
+
|
1172 |
$title = ! empty( $title ) ? $title : $this->title();
|
1173 |
+
|
1174 |
return apply_filters( 'woo_feed_filter_product_aioseop_title', $title, $this->product, $this->config );
|
1175 |
}
|
1176 |
+
|
1177 |
public function _aioseop_description() {
|
1178 |
$description = '';
|
1179 |
+
|
1180 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1181 |
+
|
1182 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1183 |
$description = ! empty( $post->description ) ? $post->description : aioseo()->meta->description->getPostTypeDescription( 'product' );
|
1184 |
}
|
1185 |
+
|
1186 |
if ( empty( $description ) ) {
|
1187 |
$description = $this->description();
|
1188 |
}
|
1189 |
+
|
1190 |
return apply_filters( 'woo_feed_filter_product_aioseop_description', $description, $this->product, $this->config );
|
1191 |
}
|
1192 |
+
|
1193 |
public function _aioseop_canonical_url() {
|
1194 |
$aioseop_canonical_url = '';
|
1195 |
if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) && class_exists( 'AIOSEO\Plugin\Common\Models\Post' ) ) {
|
1196 |
$post = AIOSEO\Plugin\Common\Models\Post::getPost( $this->product->get_id() );
|
1197 |
$aioseop_canonical_url = $post->canonical_url;
|
1198 |
}
|
1199 |
+
|
1200 |
return apply_filters( 'woo_feed_filter_product_aioseop_canonical_url', $aioseop_canonical_url, $this->product, $this->config );
|
1201 |
}
|
1202 |
+
|
1203 |
############# TAX #############
|
1204 |
+
|
1205 |
public function tax( $key = '' ) {
|
1206 |
$tax = TaxFactory::get( $this->product, $this->config )->merchant_formatted_tax( $key );
|
1207 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1208 |
+
|
1209 |
// GoogleTax and CustomTax class is available.
|
1210 |
// For others merchant use filter hook to modify value.
|
1211 |
return apply_filters( 'woo_feed_filter_product_tax', $tax, $this->product, $this->config, $taxes );
|
1212 |
}
|
1213 |
+
|
1214 |
public function tax_class() {
|
1215 |
return apply_filters( 'woo_feed_filter_product_tax_class', $this->product->get_tax_class(), $this->product, $this->config );
|
1216 |
}
|
1217 |
+
|
1218 |
public function tax_status() {
|
1219 |
return apply_filters( 'woo_feed_filter_product_tax_status', $this->product->get_tax_status(), $this->product, $this->config );
|
1220 |
}
|
1221 |
+
|
1222 |
public function tax_country() {
|
1223 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1224 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1227 |
$rates = array_values( $taxes[ $taxClass ] );
|
1228 |
$country = $rates[0]['country'];
|
1229 |
}
|
1230 |
+
|
1231 |
return apply_filters( 'woo_feed_filter_product_tax_country', $country, $this->product, $this->config, $taxes );
|
1232 |
}
|
1233 |
+
|
1234 |
public function tax_state() {
|
1235 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1236 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1239 |
$rates = array_values( $taxes[ $taxClass ] );
|
1240 |
$state = $rates[0]['state'];
|
1241 |
}
|
1242 |
+
|
1243 |
return apply_filters( 'woo_feed_filter_product_tax_state', $state, $this->product, $this->config, $taxes );
|
1244 |
}
|
1245 |
+
|
1246 |
public function tax_postcode() {
|
1247 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1248 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1251 |
$rates = array_values( $taxes[ $taxClass ] );
|
1252 |
$postcode = $rates[0]['postcode'];
|
1253 |
}
|
1254 |
+
|
1255 |
return apply_filters( 'woo_feed_filter_product_tax_postcode', $postcode, $this->product, $this->config, $taxes );
|
1256 |
}
|
1257 |
+
|
1258 |
public function tax_city() {
|
1259 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1260 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1263 |
$rates = array_values( $taxes[ $taxClass ] );
|
1264 |
$city = $rates[0]['city'];
|
1265 |
}
|
1266 |
+
|
1267 |
return apply_filters( 'woo_feed_filter_product_tax_city', $city, $this->product, $this->config, $taxes );
|
1268 |
}
|
1269 |
+
|
1270 |
public function tax_rate() {
|
1271 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1272 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1275 |
$rates = array_values( $taxes[ $taxClass ] );
|
1276 |
$rate = $rates[0]['rate'];
|
1277 |
}
|
1278 |
+
|
1279 |
return apply_filters( 'woo_feed_filter_product_tax_rate', $rate, $this->product, $this->config, $taxes );
|
1280 |
}
|
1281 |
+
|
1282 |
public function tax_label() {
|
1283 |
$taxes = TaxFactory::get( $this->product, $this->config )->get_taxes();
|
1284 |
$taxClass = empty( $this->product->get_tax_class() ) ? 'standard-rate' : $this->product->get_tax_class();
|
1287 |
$rates = array_values( $taxes[ $taxClass ] );
|
1288 |
$label = $rates[0]['label'];
|
1289 |
}
|
1290 |
+
|
1291 |
return apply_filters( 'woo_feed_filter_product_tax_label', $label, $this->product, $this->config, $taxes );
|
1292 |
}
|
1293 |
+
|
1294 |
# Custom XML Template
|
1295 |
+
|
1296 |
/**
|
1297 |
* Custom Template 2 images loop
|
1298 |
*
|
1301 |
public function custom_xml_images() {
|
1302 |
$images = $this->images();
|
1303 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
1304 |
+
|
1305 |
return explode( $separator, $images );
|
1306 |
}
|
1307 |
+
|
1308 |
/**
|
1309 |
* Custom Template 2 attributes loop
|
1310 |
*
|
1319 |
$attributes[ $key ]['value'] = $this->product->get_attribute( wc_attribute_label( $key ) );
|
1320 |
}
|
1321 |
}
|
1322 |
+
|
1323 |
return $attributes;
|
1324 |
}
|
1325 |
+
|
1326 |
public function custom_xml_shipping() {
|
1327 |
}
|
1328 |
+
|
1329 |
public function custom_xml_tax() {
|
1330 |
}
|
1331 |
+
|
1332 |
public function custom_xml_categories() {
|
1333 |
$output = []; // Initialising
|
1334 |
$taxonomy = 'product_cat'; // Taxonomy for product category
|
1335 |
+
|
1336 |
// Get the product categories terms ids in the product:
|
1337 |
$terms_ids = wp_get_post_terms( $this->product->get_id(), $taxonomy, array( 'fields' => 'ids' ) );
|
1338 |
+
|
1339 |
// Loop though terms ids (product categories)
|
1340 |
foreach ( $terms_ids as $term_id ) {
|
1341 |
$term_names = []; // Initialising category array
|
1342 |
+
|
1343 |
// Loop through product category ancestors
|
1344 |
foreach ( get_ancestors( $term_id, $taxonomy ) as $ancestor_id ) {
|
1345 |
// Add the ancestor's term names to the category array
|
1347 |
}
|
1348 |
// Add the product category term name to the category array
|
1349 |
$term_names[] = get_term( $term_id, $taxonomy )->name;
|
1350 |
+
|
1351 |
// Get category separator
|
1352 |
$separator = apply_filters( 'woo_feed_filter_category_separator', ' > ', $this->product, $this->config );
|
1353 |
+
|
1354 |
// Add the formatted ancestors with the product category to main array
|
1355 |
$output[] = implode( $separator, $term_names );
|
1356 |
}
|
1357 |
+
|
1358 |
return $output;
|
1359 |
}
|
1360 |
+
|
1361 |
+
}
|
includes/classes/class-woo-feed-constants.php
CHANGED
@@ -23,7 +23,7 @@ if( ! class_exists("Woo_Feed_Constants") ) {
|
|
23 |
* @var string
|
24 |
* @since 3.1.6
|
25 |
*/
|
26 |
-
define( 'WOO_FEED_FREE_VERSION', '4.5.
|
27 |
}
|
28 |
|
29 |
if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
|
23 |
* @var string
|
24 |
* @since 3.1.6
|
25 |
*/
|
26 |
+
define( 'WOO_FEED_FREE_VERSION', '4.5.7' );
|
27 |
}
|
28 |
|
29 |
if ( ! defined( 'WOO_FEED_FREE_PATH' ) ) {
|
includes/classes/class-woo-feed-product-attributes.php
CHANGED
@@ -140,6 +140,7 @@ class Woo_Feed_Product_Attributes {
|
|
140 |
'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
|
141 |
'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
|
142 |
'product_status' => esc_html__( 'Product Status', 'woo-feed' ),
|
|
|
143 |
]
|
144 |
];
|
145 |
|
140 |
'date_created' => esc_html__( 'Date Created', 'woo-feed' ),
|
141 |
'date_updated' => esc_html__( 'Date Updated', 'woo-feed' ),
|
142 |
'product_status' => esc_html__( 'Product Status', 'woo-feed' ),
|
143 |
+
'featured_status' => esc_html__( 'Featured Status', 'woo-feed' ),
|
144 |
]
|
145 |
];
|
146 |
|
includes/classes/class-woo-feed-products-v3.php
CHANGED
@@ -2327,9 +2327,21 @@ class Woo_Feed_Products_v3 {
|
|
2327 |
*/
|
2328 |
public function product_status( $product ) {
|
2329 |
$status = $product->get_status();
|
|
|
2330 |
return apply_filters( 'woo_feed_filter_product_status', $status, $product, $this->config );
|
2331 |
}
|
2332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2333 |
/**
|
2334 |
* Get Product Full Categories with unselected category parent
|
2335 |
*
|
2327 |
*/
|
2328 |
public function product_status( $product ) {
|
2329 |
$status = $product->get_status();
|
2330 |
+
|
2331 |
return apply_filters( 'woo_feed_filter_product_status', $status, $product, $this->config );
|
2332 |
}
|
2333 |
|
2334 |
+
/**
|
2335 |
+
* @param \WC_Product $product
|
2336 |
+
*
|
2337 |
+
* @return void
|
2338 |
+
*/
|
2339 |
+
public function featured_status( $product ) {
|
2340 |
+
$status = $product->is_featured() ? 'yes' : 'no';
|
2341 |
+
|
2342 |
+
return apply_filters( 'woo_feed_filter_featured_status', $status, $product, $this->config );
|
2343 |
+
}
|
2344 |
+
|
2345 |
/**
|
2346 |
* Get Product Full Categories with unselected category parent
|
2347 |
*
|
woo-feed.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
* Plugin Name: CTX Feed
|
11 |
* Plugin URI: https://webappick.com/
|
12 |
* Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
|
13 |
-
* Version: 4.5.
|
14 |
* Author: WebAppick
|
15 |
* Author URI: https://webappick.com/
|
16 |
* License: GPL v2
|
@@ -32,6 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
32 |
die(); // If this file is called directly, abort.
|
33 |
}
|
34 |
|
|
|
35 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|
36 |
/**
|
37 |
* Plugin Base File
|
@@ -54,6 +55,7 @@ if ( ! defined( 'WOO_FEED_FREE_ADMIN_URL' ) ) {
|
|
54 |
|
55 |
require_once __DIR__ . '/includes/classes/class-woo-feed-constants.php';
|
56 |
Woo_Feed_Constants::defined_constants();
|
|
|
57 |
/*
|
58 |
* Autoloader
|
59 |
*
|
10 |
* Plugin Name: CTX Feed
|
11 |
* Plugin URI: https://webappick.com/
|
12 |
* Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
|
13 |
+
* Version: 4.5.7
|
14 |
* Author: WebAppick
|
15 |
* Author URI: https://webappick.com/
|
16 |
* License: GPL v2
|
32 |
die(); // If this file is called directly, abort.
|
33 |
}
|
34 |
|
35 |
+
|
36 |
if ( ! defined( 'WOO_FEED_FREE_FILE' ) ) {
|
37 |
/**
|
38 |
* Plugin Base File
|
55 |
|
56 |
require_once __DIR__ . '/includes/classes/class-woo-feed-constants.php';
|
57 |
Woo_Feed_Constants::defined_constants();
|
58 |
+
|
59 |
/*
|
60 |
* Autoloader
|
61 |
*
|