Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variation Product Shows Price Twice | Wordpress WooCommerce

In wordpress WooCommerce, when i add a Variation Product, variation is set only by Two colors,

Starwhite = 9000 Ivory = 15000

On the Single Product page, I get to see price mentioned twice, as shown in screenshots.

I want to retain the price defined in variation. Remove the other one.

The price which is not required is showing up under the div below

<div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">

    <p class="price"><span class="amount">Rs.9,000.00</span>–<span class="amount">Rs.15,000.00</span></p>

    <meta itemprop="price" content="9000" style="
    /* display: none; */
">
    <meta itemprop="priceCurrency" content="INR">
    <link itemprop="availability" href="http://schema.org/InStock">

</div>

But when i mark it has display none or visibility hidden, the price from variation is also gone..

enter image description here

1st Color Variation settings: enter image description here

2nd Color Variation settings: enter image description here

Also, there are times when i use Simple Product on the website, so any changes suggested should not impact simple product settings.

If i have to make any changes in the code, what should be the code and under which php files should it be changes.

like image 593
John Franky Avatar asked Jul 07 '15 08:07

John Franky


People also ask

What is dynamic pricing in WooCommerce?

WooCommerce Dynamic pricing refers to “Price changes actively based on the rules we create.” A simple example of WooCommerce Dynamic Pricing is the tiered bulk discounts. Example: Buy 5 or more, get 10% off, Buy 10 or more and get 20% discount.


1 Answers

I believe the file you need to edit is "/single-product/price.php", you should have a copy of that file in your theme folder (/your-theme/woocommerce/single-product/price.php), if not you can copy it there from /wp-content/plugins/woocommerce/templates/

Change:

<p class="price"><?php echo $product->get_price_html(); ?></p>

To:

<?php if( $product->is_type( 'simple' ) ){ ?><p class="price"><?php echo $product->get_price_html(); ?></p><?php } ?>

That will make it only display the price for Simple Products. The other price display that changes when you select a different variation is set in /single-product/add-to-cart/variable.php so that will be unaffected.

like image 167
Tom Green Avatar answered Oct 21 '22 14:10

Tom Green