Schema.org on Woocommerce
-
I am inserting microdata on the free products of my website.
The problem is about price. When I test microdata on this link https://developers.google.com/structured-data, Google show me this error:
<p itemprop=”price” class=”price”><span class=”amount”>Gratis!</span></p>
I have got italian version of WordPress and “Gratis!” means “For free!”.
The system accepts only “0” value, but not “For free!”.
How can I change this value without show on my website “0” ?
I am a PHP beginner. If you got a good walk-through or a good tutorial about this, I would be thankful.
-
Hi @mago7891
You can change the price HTML by updating the WooCommerce price.php template file(s). There’s one for “loop” (or archive pages) and “single-product”). Are you familiar with how to add WooCommerce template files to your theme, so you can modify them?
There are also a number of filters for adjusting the HTML that comes our for the price, but they are different for different types of products (grouped, variable, etc).
Hello @ancawonka
Unfortunately, I don’t know how add Woocommerce template files to my theme.
I know only how to create a child theme.This is archive-product.php
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/if ( ! defined( ‘ABSPATH’ ) ) {
exit;
} // Exit if accessed directlyglobal $sf_options;
$sidebar_config = $sf_options[‘woo_sidebar_config’];
$left_sidebar = strtolower($sf_options[‘woo_left_sidebar’]);
$right_sidebar = strtolower($sf_options[‘woo_right_sidebar’]);
$product_display_fullwidth = $sf_options[‘product_display_fullwidth’];
$product_display_columns = $sf_options[‘product_display_columns’];
$product_display_type = $sf_options[‘product_display_type’];
$product_fw_mode = false;if (isset($_GET[‘sidebar’])) {
$sidebar_config = $_GET[‘sidebar’];
}if ( $product_display_fullwidth ) {
$product_fw_mode = true;
}$width = “”;
if ( $product_display_columns == “4” ) {
$width = ‘col-sm-3’;
} else if ( $product_display_columns == “5” ) {
$width = ‘col-sm-sf-5’;
} else if ( $product_display_columns == “3” ) {
$width = ‘col-sm-4’;
} else if ( $product_display_columns == “2” ) {
$width = ‘col-sm-6’;
} else if ( $product_display_columns == “6” ) {
$width = ‘col-sm-2’;
}if ( $sidebar_config == “” ) {
$sidebar_config = ‘right-sidebar’;
}
if ( $left_sidebar == “” ) {
$left_sidebar = ‘woocommerce-sidebar’;
}
if ( $right_sidebar == “” ) {
$right_sidebar = ‘woocommerce-sidebar’;
}$page_class = $content_class = $orig_sidebar_config = $cont_width = $sidebar_width = $cont_push = $sidebar_pull = ”;
$page_wrap_class = “woocommerce-shop-page “;if ( $product_fw_mode ) {
$page_wrap_class .= ‘full-width-shop ‘;
$orig_sidebar_config = $sidebar_config;
$sidebar_config = “no-sidebars”;
}if ( $sf_options[‘sidebar_width’] == “reduced” ) {
$cont_width = “col-sm-9”;
$cont_push = “col-sm-push-3”;
$sidebar_width = “col-sm-3”;
$sidebar_pull = “col-sm-pull-9”;
} else {
$cont_width = “col-sm-8”;
$cont_push = “col-sm-push-4”;
$sidebar_width = “col-sm-4”;
$sidebar_pull = “col-sm-pull-8”;
}if ( $orig_sidebar_config != “” ) {
if ( $orig_sidebar_config == “left-sidebar” ) {
$page_wrap_class .= ‘has-left-sidebar has-one-sidebar’;
} else if ( $orig_sidebar_config == “right-sidebar” ) {
$page_wrap_class .= ‘has-right-sidebar has-one-sidebar’;
} else if ( $orig_sidebar_config == “both-sidebars” ) {
$page_wrap_class .= ‘has-both-sidebars’;
} else {
$page_wrap_class .= ‘has-no-sidebar’;
}
$page_class = “row clearfix”;
$content_class = “col-sm-12 clearfix”;
} else {
if ( $sidebar_config == “left-sidebar” ) {
$page_wrap_class .= ‘has-left-sidebar has-one-sidebar row’;
$page_class = $cont_width . ” ” . $cont_push . ” clearfix”;
$content_class = “clearfix”;
} else if ( $sidebar_config == “right-sidebar” ) {
$page_wrap_class .= ‘has-right-sidebar has-one-sidebar row’;
$page_class = $cont_width . ” clearfix”;
$content_class = “clearfix”;
} else if ( $sidebar_config == “both-sidebars” ) {
$page_wrap_class .= ‘has-both-sidebars row’;
$page_class = $cont_width . ” clearfix”;
$content_class = $cont_width . ” clearfix”;
} else {
$page_wrap_class .= ‘has-no-sidebar’;
$page_class = “row clearfix”;
$content_class = “col-sm-12 clearfix”;
}
}$content_class .= ‘ product-type-‘ . $product_display_type;
global $sf_include_isotope, $sf_has_products;
$sf_include_isotope = true;
$sf_has_products = true;get_header( ‘shop’ ); ?>
<?php if ( ! $product_fw_mode ) { ?>
<div class=”container”>
<?php } ?><?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper – 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb – 20
*/
do_action( ‘woocommerce_before_main_content’ );
?><div class=”inner-page-wrap <?php echo $page_wrap_class; ?> clearfix”
data-shopcolumns=”<?php echo $product_display_columns; ?>”><!– OPEN section –>
<section class=”<?php echo $page_class; ?>”><!– OPEN .page-content –>
<div class=”page-content <?php echo $content_class; ?>”><?php do_action( ‘woocommerce_archive_description’ ); ?>
<?php if ( have_posts() ) : ?>
<!– LOOP START –>
<?php woocommerce_product_loop_start(); ?><?php woocommerce_product_subcategories(); ?>
<?php if ( $product_fw_mode && ( $orig_sidebar_config == “left-sidebar” || $orig_sidebar_config == “both-sidebars” ) ) { ?>
<div class=”sidebar left-sidebar <?php echo $width; ?>”>
<?php dynamic_sidebar( $left_sidebar ); ?>
</div><?php } ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( ‘content’, ‘product’ ); ?>
<?php endwhile; // end of the loop. ?>
<?php if ( $product_fw_mode && ( $orig_sidebar_config == “right-sidebar” || $orig_sidebar_config == “both-sidebars” ) ) { ?>
<div class=”sidebar right-sidebar <?php echo $width; ?>”>
<?php dynamic_sidebar( $right_sidebar ); ?>
</div><?php } ?>
<!– LOOP END –>
<?php woocommerce_product_loop_end(); ?><?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination – 10
*/
do_action( ‘woocommerce_after_shop_loop’ );
?><?php elseif ( ! woocommerce_product_subcategories( array(
‘before’ => woocommerce_product_loop_start( false ),
‘after’ => woocommerce_product_loop_end( false )
) )
) : ?><div class=”no-products-wrap container”>
<?php woocommerce_get_template( ‘loop/no-products-found.php’ ); ?>
</div><?php endif; ?>
<!– CLOSE .page-content –>
</div><?php if ( $sidebar_config == “both-sidebars” ) { ?>
<aside class=”sidebar left-sidebar col-sm-3″><?php do_action( ‘sf_after_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $left_sidebar ); ?>
</div><?php do_action( ‘sf_before_sidebar’ ); ?>
</aside>
<?php } ?><!– CLOSE section –>
</section><?php if ( $sidebar_config == “left-sidebar” ) { ?>
<aside class=”sidebar left-sidebar <?php echo $sidebar_width; ?> <?php echo $sidebar_pull; ?>”>
<?php do_action( ‘sf_after_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $left_sidebar ); ?>
</div><?php do_action( ‘sf_before_sidebar’ ); ?>
</aside>
<?php } else if ( $sidebar_config == “right-sidebar” ) { ?>
<aside class=”sidebar right-sidebar <?php echo $sidebar_width; ?>”>
<?php do_action( ‘sf_after_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $right_sidebar ); ?>
</div><?php do_action( ‘sf_before_sidebar’ ); ?>
</aside>
<?php } else if ( $sidebar_config == “both-sidebars” ) { ?>
<aside class=”sidebar right-sidebar col-sm-3″>
<?php do_action( ‘sf_after_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $right_sidebar ); ?>
</div><?php do_action( ‘sf_before_sidebar’ ); ?>
</aside>
<?php } ?>
</div>
<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end – 10 (outputs closing divs for the content)
*/
do_action( ‘woocommerce_after_main_content’ );
?><?php if ( ! $product_fw_mode ) { ?>
</div>
<?php } ?><?php get_footer( ‘shop’ ); ?>
And this is single-product.php
<?php
/**
* The Template for displaying all single products.
* Override this template by copying it to yourtheme/woocommerce/single-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/global $sf_options;
$default_sidebar_config = $sf_options[‘default_product_sidebar_config’];
$default_left_sidebar = strtolower($sf_options[‘default_product_left_sidebar’]);
$default_right_sidebar = strtolower($sf_options[‘default_product_right_sidebar’]);$pb_active = sf_get_post_meta( $post->ID, ‘_spb_js_status’, true );
$sidebar_config = sf_get_post_meta( $post->ID, ‘sf_sidebar_config’, true );
$left_sidebar = strtolower(sf_get_post_meta( $post->ID, ‘sf_left_sidebar’, true ));
$right_sidebar = strtolower(sf_get_post_meta( $post->ID, ‘sf_right_sidebar’, true ));if ( $sidebar_config == “” ) {
$sidebar_config = $default_sidebar_config;
}
if ( $left_sidebar == “” ) {
$left_sidebar = $default_left_sidebar;
}
if ( $right_sidebar == “” ) {
$right_sidebar = $default_right_sidebar;
}sf_set_sidebar_global( $sidebar_config );
$page_wrap_class = $cont_width = $sidebar_width = ”;
if ( $sidebar_config == “left-sidebar” ) {
$page_wrap_class = ‘has-left-sidebar has-one-sidebar row’;
} else if ( $sidebar_config == “right-sidebar” ) {
$page_wrap_class = ‘has-right-sidebar has-one-sidebar row’;
} else if ( $sidebar_config == “both-sidebars” ) {
$page_wrap_class = ‘has-both-sidebars’;
} else {
$page_wrap_class = ‘has-no-sidebar’;
}if ( $sf_options[‘sidebar_width’] == “reduced” ) {
$cont_width = “col-sm-9”;
$sidebar_width = “col-sm-3”;
} else {
$cont_width = “col-sm-8”;
$sidebar_width = “col-sm-4”;
}global $sf_has_products, $sf_include_isotope;
$sf_has_products = true;
$sf_include_isotope = true;
?><?php get_header( ‘shop’ ); ?>
<?php if ( have_posts() ) : the_post(); ?>
<?php if ( $sidebar_config != “no-sidebars” ) { ?>
<div class=”container”>
<?php } ?><div class=”inner-page-wrap <?php echo $page_wrap_class; ?> clearfix”>
<!– OPEN article –>
<?php if ($sidebar_config == “left-sidebar”) { ?>
<article class=”clearfix <?php echo $cont_width; ?>”>
<?php } else if ($sidebar_config == “right-sidebar”) { ?>
<article class=”clearfix <?php echo $cont_width; ?>”>
<?php } else if ($sidebar_config == “no-sidebars”) { ?>
<article>
<?php } else { ?>
<article class=”clearfix row”>
<?php } ?><?php if ($sidebar_config == “both-sidebars”) { ?>
<div class=”page-content col-sm-6 clearfix”>
<?php } else if ($sidebar_config == “no-sidebars”) { ?>
<div class=”page-content col-sm-12 clearfix”>
<?php } else { ?>
<div class=”page-content clearfix”>
<?php } ?><section class=”article-body-wrap”>
<?php woocommerce_get_template_part( ‘content’, ‘single-product’ ); ?>
</section>
</div>
<?php if ( $sidebar_config == “both-sidebars” ) { ?>
<aside class=”sidebar left-sidebar col-sm-3″><?php do_action( ‘sf_before_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $left_sidebar ); ?>
</div><?php do_action( ‘sf_after_sidebar’ ); ?>
</aside>
<?php } ?><!– CLOSE article –>
</article><?php if ( $sidebar_config == “left-sidebar” ) { ?>
<aside class=”sidebar left-sidebar <?php echo $sidebar_width; ?>”>
<?php do_action( ‘sf_before_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $left_sidebar ); ?>
</div><?php do_action( ‘sf_after_sidebar’ ); ?>
</aside>
<?php } else if ( $sidebar_config == “right-sidebar” ) { ?>
<aside class=”sidebar right-sidebar <?php echo $sidebar_width; ?>”>
<?php do_action( ‘sf_before_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $right_sidebar ); ?>
</div><?php do_action( ‘sf_after_sidebar’ ); ?>
</aside>
<?php } else if ( $sidebar_config == “both-sidebars” ) { ?>
<aside class=”sidebar right-sidebar col-sm-3″>
<?php do_action( ‘sf_before_sidebar’ ); ?>
<div class=”sidebar-widget-wrap”>
<?php dynamic_sidebar( $right_sidebar ); ?>
</div><?php do_action( ‘sf_after_sidebar’ ); ?>
</aside>
<?php } ?>
</div>
<?php if ( $sidebar_config != “no-sidebars” ) { ?>
</div>
<?php } ?><?php endif; ?>
<?php get_footer( ‘shop’ ); ?>
- The topic ‘Schema.org on Woocommerce’ is closed to new replies.