WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Show the price only once in variable products? (5 posts)

  1. hgieg
    Member
    Posted 1 year ago #

    Hello,

    When using variable products, prices are shown twice.

    Right below the product title appears the base price, within this DIV:
    <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">

    Below appears the price with selected variations, in this DIV:
    <div class="single_variation_wrap" style="">

    I would like to hide the base price, which is the first DIV, when the product is variable.

    Is it possible?

    http://wordpress.org/extend/plugins/woocommerce/

  2. hgieg
    Member
    Posted 1 year ago #

    An image to make it clearer:

    http://i.imgur.com/Lgt0M.jpg

  3. samueljeden
    Member
    Posted 1 year ago #

    Hey

    Replace your price.php file with the following, i gather that if your wanting this on variable products you'll also want this doing on grouped too..

    <?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;
    ?>
    
    <?php if ( !$product->is_type( array( 'variable', 'grouped' ) ) ) : ?>
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    
    	<p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>
    
    	<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>
    <?php endif; ?>

    The above code on shows the price under the title when the product is not variable or grouped. you do lose your SEO this way though.

  4. hgieg
    Member
    Posted 1 year ago #

    Dear samueljeden,

    Your solution worked perfectly!

    I am deeply grateful.

    A tip for anyone reading this thread in the future:

    When upgrading Woocommerce, the file will be replaced by the original prices.php, undoing the changes.

    To ensure that does not happen, instead of directly changing the "prices.php", create a folder in your theme called "woocommerce", and inside another folder called "single-product", in this folder create a file "prices.php" with content provided by samueljeden.

    Hugs.

  5. DRabbit
    Member
    Posted 1 year ago #

    I'm going to ask this here since Samueljeden was so helpful and knowledgeable :) -- I'm beating my head against a wall here...

    I'm using the variations as images/swatches plugin.
    I've got multiple choices for a product. Color and then packaging have to be selected.

    When the user selects their color and then their packaging option, I'd like those selections to be echoed above the price, in text and/or image form.

    Example, I click "cashmere" (color) and then "black designer jar" (packaging) by clicking on the swatches.

    The dynamic price apperas and above it, I'd like it to show thumbnails of my selections and/or the text/title of my selection (as confirmation of what the customer picks before they hit "add to cart").

    Cashmere
    Black Designer Jar
    $3.95

    Anyone know how to make this work? I'm desperate...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.