Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active June 7, 2023 06:20
Show Gist options
  • Select an option

  • Save webtoffee-git/e81feac2b907220a341064b6a61c7102 to your computer and use it in GitHub Desktop.

Select an option

Save webtoffee-git/e81feac2b907220a341064b6a61c7102 to your computer and use it in GitHub Desktop.
Code snippet for adding parent description to child variation description - WebToffee Product Feed and Catalog Sync free version by Webtoffee
<?php //do not copy this line
add_filter('wt_feed_filter_product_description', 'wt_feed_product_description', 10, 2);
function wt_feed_product_description($description, $product) {
$description = $product->get_description();
// Get Variation Description
if ('' === $description && $product->is_type('variation')) {
$description = '';
$parent_product = wc_get_product($product->get_parent_id());
if (is_object($parent_product)) {
$description = $parent_product->get_description();
}
}
if ('' === $description) {
$description = $product->get_short_description();
}
//strip tags and special characters
$description = strip_tags($description);
return $description;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment