curve

How to Remove Structured Data from WooCommerce

Structured data is a vital to have on your website, especially if you’re running an online store. Your products contain a range of structured data which can assist in providing search engines with valuable data.

While this benefits majority of websites, there are cases where you might need to remove things like stock levels or price (both examples of structured data) from your website.

What is Structured Data?

Structured data enables search engines to display additional data in their results page, such as the product price, stock and product review information.

Having this additional data available in your SERP listing can boost your Click Through Rate (CTR) and conversions. Structured data can also do wonders for your business if you’re offering competitive pricing and/or have a great positive review backing.

Compare the following structured listing with the same listing without any structured data.

structured-data

With structured data

without-structured-data

Without structured data

 

Structured Data in WooCommerce

WooCommerce offers a range of structured data including:

  1. Product (includes pricing, stock and aggregated ratings)
  2. Review (individual review markup)
  3. Breadcrumbs
  4. Website
  5. Order

To remove structured data you can use and implement some code snippets listed below.

Removing Review Structured Data

If your website doesn’t require reviews; you can turn this feature off in your WooCommerce settings. Structured data for reviews is only added when a product has at least 1 review. While you can remove structured data for reviews by disabling reviews in the settings (what we recommend) you can still add this code below!

<?php 

/**
 * Remove Product Structured Data - Reviews
 */
function ace_remove_partial_product_structured_data( $markup, $product ) {
	unset( $markup['aggregateRating'] );

	return $markup;
}
add_filter( 'woocommerce_structured_data_product', 'ace_remove_partial_product_structured_data', 10, 2 );</pre>

 

 

Removing Product Price Structured Data

<?php /** * Remove Product's Structured Data - Price */ function ace_remove_partial_product_structured_data( $markup_offer, $product ) { $markup_offer = array( 'availability' => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ),
		'url'           => get_permalink( $product->get_id() ),
		'seller'        => array(
			'@type' => 'Organization',
			'name'  => get_bloginfo( 'name' ),
			'url'   => home_url(),
		),
	);

	return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'ace_remove_partial_product_structured_data', 10, 2 );

 

Removing Product Stock Structured Data

<?php 

/**
 * Remove Product Structured Data - Stock
 */
function ace_remove_partial_product_structured_data( $markup_offer, $product ) {
	unset( $markup_offer['availability'] );

	return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'ace_remove_partial_product_structured_data', 10, 2 );

Need assistance removing structured data from your WooCommerce website? Speak to our website developers today, contact us online and we’ll be in touch.

  •  
  •  
  •  
  •  
  •  
  •  
  •  

Tags: