Here’s a script for ‘Google Product Feed‘ by Ademti Software which allows you to subdivide a large feed (for later use in Google Ads) by the ‘featured’ option in Woocommerce. If the product is ‘featured’ then ‘custom_label_0’ will be populated with: ‘featured’. I thought it was worth sharing.
function lw_woocommerce_gpf_edit_custom_label_featured( $elements, $product_id, $variation_id = null ) {
if ( ! is_null( $variation_id ) ) {
$id = $variation_id;
} else {
$id = $product_id;
}
$featured_product_ids = wc_get_featured_product_ids();
if ( in_array( $id, $featured_product_ids ) ) {
$elements['custom_label_0'] = array( 'featured' );
} else {
$elements['custom_label_0'] = array( 'not_featured' );
}
return $elements;
}
add_filter( 'woocommerce_gpf_elements', 'lw_woocommerce_gpf_edit_custom_label_featured', 11, 3 );
Leave a Reply