Add brand type to WooCommerce - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, September 2, 2022

Add brand type to WooCommerce

I am trying to add the Brand Name to rich data in Woocommerce. Before i used the code below, but Google has updated their guidance on how to do this. It used to be "Brand":"Brandname"; but they changed it to: “brand”: {“@type”: “Brand”, “name”: “Brandname”}.

Could somebody help me adjust the code below to include the new markup structure?

function custom_woocommerce_structured_data_product ($data) {
    global $product;
    
    $data['Brand'] = $product->get_attribute('Fabrikant') ?? null;
    $data['mpn'] = $product->get_sku() ?? null;
    
    return $data;
}
add_filter( 'woocommerce_structured_data_product', 'custom_woocommerce_structured_data_product' );


source https://stackoverflow.com/questions/73574550/add-brand-type-to-woocommerce

No comments:

Post a Comment