VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: wildb on December 27, 2012, 02:17:42 AM

Title: Special Price with line through
Post by: wildb on December 27, 2012, 02:17:42 AM

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
Title: Re: Special Price with line through
Post by: jenkinhill on December 27, 2012, 10:50:30 AM
http://forum.virtuemart.net/index.php?topic=79799.0
Title: Re: Special Price with line through
Post by: wildb on December 29, 2012, 03:36:49 AM
One of the sites is 2.0.14

another is 2.0.15b

Please help!!!!
Title: Re: Special Price with line through
Post by: wildb on December 29, 2012, 03:39:15 AM
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.

Title: Re: Special Price with line through
Post by: wildb on December 29, 2012, 11:51:59 AM
this was so easy in the old virtuemart!!!... I assumed its a fundamental part of virtuemart
Title: Re: Special Price with line through
Post by: jenkinhill on December 29, 2012, 12:26:00 PM
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; }
Title: Re: Special Price with line through
Post by: wildb on January 03, 2013, 02:10:14 AM
Thanks for the reply.

It doesnt  work for me.
I only see the final sales price. I do not see the original price.
Title: Re: Special Price with line through
Post by: wildb on January 16, 2013, 01:39:38 AM
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.
Title: Re: Special Price with line through
Post by: wildb on January 16, 2013, 01:42:56 AM
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>
Title: Re: Special Price with line through
Post by: wildb on January 16, 2013, 03:14:15 AM
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
Title: Re: Special Price with line through
Post by: Dreeg on April 08, 2013, 05:17:34 AM
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.
(http://i48.tinypic.com/727h9w.jpg)

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 :(
Title: Re: Special Price with line through
Post by: Dreeg on April 12, 2013, 09:16:04 AM
Up?  :-\
Title: Re: Special Price with line through
Post by: Dreeg on April 21, 2013, 04:44:16 AM
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
Title: Re: Special Price with line through
Post by: lostmail on May 13, 2013, 16:44:20 PM
How to show the old price in mod_virtuemart_product ?
Title: Re: Special Price with line through
Post by: TrigWebDesignUSA on December 30, 2015, 04:58:57 AM
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
(http://www.vbandp.com/images/show-prices.jpg)

This is how my VM Product Module displays a product:
(http://www.vbandp.com/images/mod-price.jpg)

My product Details:
(http://www.vbandp.com/images/product-price.jpg)

Now if anyone can give me a code that gets the red line out of the label 'Regular Price', that would be cool.
Title: Re: Special Price with line through
Post by: Spiros Petrakis on December 30, 2015, 19:14:46 PM
Hi,

based on your code example replace


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


with


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


Title: Re: Special Price with line through
Post by: Mart DOP on March 17, 2016, 19:03:58 PM
Tried to modify the file modules/mod_virtuemart_product/tmpl/default.php to get the discounted price with line-through within my modules displaying virtuemart products. It seems like i don't get the good file. No matter what i change or line i comment, i don't see any changes happening inside the module.

Anyone know which files it could be using?

J! 3.4
VM 3

Thanks.