Skip to content

Instantly share code, notes, and snippets.

@agusmu
Created July 17, 2013 12:52
Show Gist options
  • Save agusmu/6020315 to your computer and use it in GitHub Desktop.
Save agusmu/6020315 to your computer and use it in GitHub Desktop.
WooCommerce - Fix Google Rich Snippets For On Sale Product
<?php
/**
* Single Product Price, including microdata for SEO
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $post, $product;
?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<p class="price"><?php echo $product->get_price_html(); ?></p>
<meta itemprop="price" content="<?php echo $product->get_price(); ?>" />
<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />
</div>
@agusmu
Copy link
Author

agusmu commented Sep 28, 2013

@Nigeltjuh
Copy link

Still doesnt work for me... @ sale products still no prices and stock shown at snippets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment