News:

Looking for documentation? Take a look on our wiki

Main Menu

Special Price with line through

Started by wildb, December 27, 2012, 02:17:42 AM

Previous topic - Next topic

wildb


I have looked extensively for the answer for this on the forums (virtuemart 2).
How do I.................

1. Have the normal price
2. Have the sales price blank if its not on sale

3. Have the normal price turn red with a line through
4. Have the sales price underneath

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

wildb

One of the sites is 2.0.14

another is 2.0.15b

Please help!!!!

wildb

Actually what I managed to do was get the linethrough on the normal price and the special price

however, if the product is not on sale there is still a line through.


wildb

this was so easy in the old virtuemart!!!... I assumed its a fundamental part of virtuemart

jenkinhill

It is - I am using 2.0.16 and this is how I did it for a client.

First I set a price override for the product in the product editor, entering the selling price. The only price fields I publish are
Baseprice with Tax, but without discounts    and      Final salesprice    (but I change the text strings used for those items so they make sense)

The baseprice has a strikethrough automatically applied. You can add a colour to that price field by adding a suitable style to the end of your Joomla template css.
eg.    .price-crossed div.PricebasePriceWithTax .PricebasePriceWithTax { color:#E2020D; }
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

wildb

Thanks for the reply.

It doesnt  work for me.
I only see the final sales price. I do not see the original price.

wildb

I am using 2.0.18a

I have ticked
Baseprice with Tax, but without discounts    &      
Final salesprice    

I have selected a price override and made the product cheaper.

The published site shows the new price but doesnt present the old price at all.

wildb

this is abit of code from the default_showprices.php

<div class="product-price" id="productPrice<?php echo $this->product->virtuemart_product_id ?>">
   <?php
   if (!empty($this->product->prices)) {
      ////echo "<strong>" . JText::_ ('COM_VIRTUEMART_CART_PRICE') . "</strong>";
   }
   //vmdebug('view productdetails layout default show prices, prices',$this->product);
   if (empty($this->product->prices['salesPrice']) and VmConfig::get ('askprice', 1) and isset($this->product->images[0]) and !$this->product->images[0]->file_is_downloadable) {
      ?>
      <a class="ask-a-question bold" href="<?php echo $this->askquestion_url ?>"><?php echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE') ?></a>
      <?php
   } else {
   if ($this->showBasePrice) {
      echo $this->currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $this->product->prices);
      echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $this->product->prices);
   }
   echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $this->product->prices);
   if (round($this->product->prices['basePriceWithTax'],VmConfig::get('salesPriceRounding')) != $this->product->prices['salesPrice']) {
      echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";
   }
   if (round($this->product->prices['salesPriceWithDiscount'],VmConfig::get('salesPriceRounding')) != $this->product->prices['salesPrice']) {
      echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices);
   }
   echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
   echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices);
   echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);
   echo $this->currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $this->product->prices);
   $unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', JText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.$this->product->product_unit));
   echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $this->product->prices);
   }
   ?>
</div>

wildb

I spent ages figuring this out... theres a forum post with the answer... i have NO IDEA why this is the answer

Hi Coppo82.

I know its been a while, but I was looking do so the same thing.

I solved it by doing this:
Add a vat tax rule that adds 0 (just a dummy rule). Apply that rule to the vendor.

Then in your product pricing overwrite the base price with the discounted price. The system will automatically add a slash through the baseprice.

I'm new at this, so not sure if this it right or not, but seemed to work.

Any thoughts?

MMM

Dreeg

Hi all,

I have same problem.
On Joomla 2.5.9 and Virtuemart 2.0.20, I set the Price parameters in Administrator Panel of Joomla.


The strike price (crossed out with a red line) does not appear anywhere. On the homepage, of the categories it in the product details.

How can I fix? Is rather urgent :(


Dreeg

Thank you so much for your many answers.

I solved it by myself.

In root/modules/mod_virtuemart_product/tmpl/default.php:
1) Copy line 75 -> echo $currency->createPriceDiv ('salesPrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE);
2) Paste on line 82 with a small change. 'salesPrice' -> 'basePriceWithTax'

If you want the line-trough use this on point 2 -> echo '<span style="text-decoration:line-through; color:#ff0000;">'.$currency->createPriceDiv ('basePriceWithTax', '', $product->prices, FALSE, FALSE, 1.0, TRUE) .'</span>';


Joomla 2.5.9
Virtuemart 2.0.20b

lostmail

How to show the old price in mod_virtuemart_product ?
VirtueMart VirtueMart 4.2.16 11030 | Joomla 4.x | PHP 8.3 | Vp_neoteric 1.6

TrigWebDesignUSA

I don't know if anyone else is looking to do this in the new Virtuemart 3.0.12, but I was able to use the code in this thread as a base and setup both mod_Virtuemart_product and Virtuemart Product Details. My thanks to the entire community for always helping me out, hopefully someone can use this the way I did.

Open modules>>mod_virtuemart_product>>tmpl>>default.php
around line 42 you'll find:
if (!empty($product->prices['salesPrice'])) {
                  echo $currency->createPriceDiv ('basePrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE);
replace with:
if (!empty($product->prices['salesPrice'])) {
                  //   echo $currency->createPriceDiv ('basePrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE);
                  
                  // Added to insert red strikethrough BasePrice ONLY if Discount amount is greater than zero
                  if (!empty($product->prices['discountAmount'])) {
                     echo '<span class="price-crossed">', $currency->createPriceDiv ('basePrice', '', $product->prices), '</span>';
                  }
                  // End Add red strikethrough
Then, around line 50:
echo $currency->createPriceDiv ('salesPrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE);
insert after:
echo $currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);

This will add Discount: -$xx under the Sales Price.

For the same effect on the Product Details page, open Components>>com_virtuemart>>sublayouts>>prices.php
Find around line 50:
//if ($showBasePrice) {
      echo $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
Replace with:
//if ($showBasePrice) {
   //      echo $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
      // Added to insert red strikethrough BasePrice ONLY if Discount amount is greater than zero
         if (!empty($product->prices['discountAmount'])) {
            echo '<span class="price-crossed">', $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices), '</span>';
         }
      // End Add red strikethrough

Add to your custom.css file:

.price-crossed {
   color:red;
   text-decoration:line-through;
}

In your VM config Pricing Tab, set


This is how my VM Product Module displays a product:


My product Details:


Now if anyone can give me a code that gets the red line out of the label 'Regular Price', that would be cool.