Support » Plugin: WooCommerce Product Feed for Marketing Channels » Use customs fields instead of attributes

  • Hi, As I have most of my brand and mpn data in custom fields rather than attributes I am looking for some help to convert the below code to pull the data from a custom field rather than an attribute, I’ve been advised it’s straight forward but it’s not something I can do, any help is appreciated.

    function wpec_gpf_add_brand( $elements, $product_id ) {
    $product = get_product( $product_id );
    $attribute_string = $product->get_attribute( ‘pa_brand’ );
    if ( ! empty( $attribute_string ) ) {
    $attrs = explode( ‘,’, $attribute_string );
    $elements[‘brand’] = $attrs;
    }
    return $elements;
    }
    add_filter( ‘woocommerce_gpf_elements’, ‘wpec_gpf_add_brand’, 11, 2 );

  • The topic ‘Use customs fields instead of attributes’ is closed to new replies.