Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created December 12, 2024 09:21
Show Gist options
  • Select an option

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

Select an option

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)
<?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