Can the 'Sale Price' Post If It's On Sale? If Not On Sale, Not Post 'Sale' Price

Started by toad78, November 13, 2012, 00:30:13 AM

Previous topic - Next topic

toad78

Let's say that I have a product that has a 'Retail Price' of $6.00, but it's on sale for $4.00. Currently, I have VM showing both a Retail and a Sale price, but this isn't the way it should display. I only want 'Sale' to display if the product's price is different than the 'Retail' price. If there is no difference in price, then just leave 'Retail' posted and do not display 'Sale'.

Can someone give me a hand with this one?

There should be a tax applied after the total in the cart, so I'm not sure I've set that up correctly.

J2.5, V.2.0.12f

Attachments are available.

[attachment cleanup by admin]

bytelord

Hello,

I think this was happen automated in vm2.0.12f. In any case you should edit your template files:
1. joomla_folder/templates/your_joomla_template/html/com_virtuemart/category/default.php
2. joomla_folder/templates/your_joomla_template/html/com_virtuemart/productdetails/default_showprices.php
3. joomla_folder/templates/your_joomla_template/html/com_virtuemart/virtuemart/default_products.php

for category view, around line 285 fine the print out of base price with tax and replace with:

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
}


for product details view (file default_showprices) around line 41 find the print out of base price and replace with:

if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {
echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";
}


for the front page view (default_products.php) around line 76 find the print out of base price and replace with:

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
}


This will show a stripe out previous price if the base price is different with the sales price.

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

toad78

I did your recommendations, but I'm still not getting the results I need.

These items are not taxed (there's not tax on food here), so I need to make this work to where it will display the Retail Price on all of the products.

If the item is on Sale, then the Retail Price will be crossed out and the Sale Price will display.

If the item is NOT on Sale, do not display 'Sale' but display the Retail price NOT crossed out.

So, in this case, would your code work better for 'priceWithoutTax' for being crossed-out if a 'salesPrice' is being used?

toad78

Just in case, with your current code being used, this is what it looks like. I've also attached what the front end looks like.

What I need:
Retail to be crossed out when Sale price is defined and display Sale price.
If no Sale price, then just display the Retail price.

As for Pricing Rules:
both Tax and Discount are set to 'No Rule'.


[attachment cleanup by admin]

toad78

Quote from: bytelord on November 13, 2012, 06:22:09 AM
Hello,

I think this was happen automated in vm2.0.12f. In any case you should edit your template files:
1. joomla_folder/templates/your_joomla_template/html/com_virtuemart/category/default.php
2. joomla_folder/templates/your_joomla_template/html/com_virtuemart/productdetails/default_showprices.php
3. joomla_folder/templates/your_joomla_template/html/com_virtuemart/virtuemart/default_products.php

for category view, around line 285 fine the print out of base price with tax and replace with:

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
}


Okay, bytelord, I think I'm getting closer:

if (round($product->prices['priceWithoutTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
   echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices) . "</span>";   }

I've done this, which does accomplish what I need halfway. The problem now is that for items that are not on Sale, the Retail price still needs to show across the board for all products, but no 'Sale' price.

bytelord

Hello,
Use the same if statement ... show only discount price when is different from baseprice.

if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);
}


Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

toad78

Thank you, bytelord!

YAY! I've managed to get want I want!


if ($this->product->prices['priceWithoutTax'] !== $this->product->prices['salesPrice']) {

echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices) . "</span>";

echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);

} else { echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices); }


Unfortunately, this code does not work in the 'Related Products' template. When I use this code, it echos the same price from the 'Product Details' page on each item in the 'Related Products' display.

Any way to adapt this within the 'default_relatedproducts.php' template?

bytelord

Hello,

Not sure for that... i have to check .... may be anyone else in the forum have some ideas?

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

kyaj

Hello,
its my first time posting.

I have a similar problem...
I would like to show the price of the product with out tax. And if the item is on sale..show original, sale price then discount price
i do not really understand coding...just very basic knowledge...if posting solution please baby steps(exact locations and line numbers and exact code to change.)
example
Sale item

t-shirt
Price $1.99
Sale price $1.49
discount $.50

normal priced item
t-shirt
price $1.99


Thank You all in advanced ;D
Enjoy your new years eve!!!

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

kyaj


rzrz