-
-
Save leewillis77/19179188828d04624ce5d3fbdbae6c23 to your computer and use it in GitHub Desktop.
Populate the feed with custom values
This file contains 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 | |
function lw_woocommerce_gpf_add_brand( $elements, $product_id, $variation_id = null ) { | |
if ( ! is_null( $variation_id ) ) { | |
$id = $variation_id; | |
} else { | |
$id = $product_id; | |
} | |
$product = wc_get_product( $id ); | |
$brand = $product->get_meta( 'supplier_brand_name' ); | |
if ( ! empty( $brand ) ) { | |
$elements['brand'] = array( $brand ); | |
} | |
return $elements; | |
} | |
add_filter( 'woocommerce_gpf_elements', 'lw_woocommerce_gpf_add_brand', 11, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment