Last active
June 7, 2023 06:20
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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