Skip to content

Instantly share code, notes, and snippets.

@leewillis77
Created December 3, 2018 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leewillis77/19179188828d04624ce5d3fbdbae6c23 to your computer and use it in GitHub Desktop.
Save leewillis77/19179188828d04624ce5d3fbdbae6c23 to your computer and use it in GitHub Desktop.
Populate the feed with custom values
<?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