kmaroff
7/23/2019 - 7:28 AM

Микроразметка schema.org для карточки товаров

<?php
$meta = get_post_meta(get_the_ID());
$_product = new WC_Product(get_the_ID());
if ($_product->regular_price!=NULL){
	$price = $_product->regular_price;
}elseif ($_product->price!=NULL){
	$price = $_product->price;
}
if ( ($_product->price > $_product->sale_price) && ($_product->sale_price!=NULL) ){
	$price = $_product->sale_price;
}
if (isset($product)){ ?>
<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="<?php echo get_the_title(get_the_ID()); ?>">
	<meta itemprop="productID" content="<?php echo get_the_ID(); ?>">
	<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
		<meta itemprop="price" content="<?php echo $price; ?>" />
		<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" />
		<link itemprop="availability" href="http://schema.org/<?php echo $meta['_stock_status'][0] ? 'InStock' : 'OutOfStock'; ?>" />
		<meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />
  </div>
</div>
<?php } ?>