Created
December 12, 2024 09:21
-
-
Save webtoffee-git/196b8cb45c9672c03f76e48a58654fc3 to your computer and use it in GitHub Desktop.
Alter the product brand in the feed file with respective to the category that the product belongs to - By WebToffee (WooCommerce Product Feed and Sync Manager)
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 of code | |
| add_filter('wt_feed_filter_product_brand', 'wt_feed_filter_product_brand', 10, 2); | |
| function wt_feed_filter_product_brand($brand, $product) { | |
| $category_id = 38; // Replace with your category ID | |
| $pid = $product->get_id(); | |
| if ($product->is_type('variation')) { | |
| $pid = $product->get_parent_id(); | |
| } | |
| if (has_term($category_id, 'product_cat', $pid)) { | |
| $brand = 'Karini Jwelry'; | |
| } | |
| return $brand; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment