WooCommerce Missing microdata for condition solution

This snippet will add the itemCondition microdata to all of your WooCommerce products.

This is recommended by Google Merchant Center, which typically throws a warning if it's not present.
/* drop this in your themes functions.php file */


add_filter( 'woocommerce_structured_data_product_offer', 'my_woocommerce_structured_data_product_offer', 10, 2 );

function my_woocommerce_structured_data_product_offer( $markup, $product ) {
	
	/* new condition */
	if ( empty( $markup[ 'itemCondition' ] ) ) {
		$markup[ 'itemCondition' ] = 'http://schema.org/NewCondition';
	}
	
	return $markup;

}


/* other conditions available 
http://schema.org/DamagedCondition
http://schema.org/NewCondition
http://schema.org/RefurbishedCondition
http://schema.org/UsedCondition
*/
Posted by
Want to return the favor?

Share your WooCommerce code snippets:

  • Get some recognition & link back to your site.
Submit | Browse

Most Recent woocommerce snippets

Most Viewed

The FitDesk Under Desk Elliptical