WooCommerce Structured Data Product

WooCommerce provides structured data for products out-of-the-box, which can help search engines like Google better understand and display information about your products in search results. Here’s how to access and customize the structured data for products in WooCommerce:

  1. Check that structured data is enabled in WooCommerce. Go to WooCommerce > Settings > Products > General and make sure that “Enable structured data” is checked.
  2. Check that the correct product data is included. Go to WooCommerce > Settings > Products > General and review the “Include variations” and “Variation data” settings to make sure that the correct product data is included in the structured data.
  3. Customize the structured data using filters. WooCommerce provides several filters that can be used to customize the structured data output. Here are a examples:
  • woocommerce_structured_data_product: Used to modify the product data that is included in the structured data output. This filter passes an array of data for the product, which can be modified before it is output as JSON-LD.

To use these filters, you can add your own functions to your theme’s functions.php file or a custom plugin.

function custom_woocommerce_structured_data_product ($data) {
  global $product;
  
  $data['brand'] = 'Optimise Wellbeing Ltd';
  $data['mpn'] = 'test';
  $data['aggregateRating'] = array(
    'ratingValue' => '4.5',
    'reviewCount' => '84'
  );
  $data['review'] = array(
      '@type' => 'Review',
      'author' => 'Optimise Wellbeing Ltd',
      'datePublished' => '2020-10-04',
      'name' => 'Admin',
      'description' => 'Best company Optimise Wellbeing Ltd',
      'reviewRating' => array(
        '@type' => 'Rating',
        'bestRating' => 5,
        'worstRating' => 1,
        'ratingValue' => 5
      ),
    );
  return $data;
}
add_filter( 'woocommerce_structured_data_product', 'custom_woocommerce_structured_data_product', 10  );

Leave a Reply

Your email address will not be published. Required fields are marked *