News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

VM3 - How to display final price only for discounted product?

Started by Roccofx1, March 04, 2016, 06:59:31 AM

Previous topic - Next topic

Roccofx1

Hi, I have Joomla 3.4.8 and VM 3.0.12

How can i show the finall price only for products with discount applied, main reason is right now we can select to show base price, final price, discount, but the problem with this is that products without any discunt will still show both prices, same price twice: base price and final price, so it looks strange, like this:

WITHOUT DISCOUNT:

Base Price $20
Final Price: $20

WITH DISCOUNT

Base price $20
Discount -$10
Final Price: $10

So i want to add a rule or something so this "final price" only appears if that product has discount, so product without discount will only show 1 price

Please help


Studio 42

Check if you have a discount price, and only display it in this case.
You need to do this in your price render here : YOURSITE\components\com_virtuemart\sublayouts\prices.php

Roccofx1


GJC Web Design

QuoteCheck if you have a discount price, and only display it in this case.
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Roccofx1

Not any clear answer to edit the file

I already got that file, and it shows codes... i cant check codes, i can only create a rule in virtuemart for that product but in order to display the "discount" tag i have to enable it for all products! but i only want to discount 1 not 20... so the other 19 will show an empty discount, for example Discount: nothing (it looks bad) so if i make a rule that only discounts the price of 1 product, it will change the actual price fo that 1 product but by not saying discount is 20% or -$10 then people wont now it has been discounted already. It must say "discunt is" -$10 only for that product, i want this tag only to appear for dicounted products.

This is what the file shows, how can i edit this to show the discount tag only for discounted products:

<div class="product-price" id="productPrice<?php echo $product->virtuemart_product_id ?>">
   <?php
   if (!empty($product->prices['salesPrice'])) {
      //echo '<div class="vm-cart-price">' . vmText::_ ('COM_VIRTUEMART_CART_PRICE') . '</div>';
   }

   if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and isset($product->images[0]) and !$product->images[0]->file_is_downloadable) {
      $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component', FALSE);
      ?>
      <a class="ask-a-question bold" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE') ?></a>
      <?php
   } else {
   //if ($showBasePrice) {
      echo $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
      //if (round($product->prices['basePrice'],$currency->_priceConfig['basePriceVariant'][1]) != $product->prices['basePriceVariant']) {
         echo $currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $product->prices);
      //}

   //}
   echo $currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
   if (round($product->prices['basePriceWithTax'],$currency->_priceConfig['salesPrice'][1]) != round($product->prices['salesPrice'],$currency->_priceConfig['salesPrice'][1])) {
      echo '<span class="price-crossed" >' . $currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
   }
   if (round($product->prices['salesPriceWithDiscount'],$currency->_priceConfig['salesPrice'][1]) != round($product->prices['salesPrice'],$currency->_priceConfig['salesPrice'][1])) {
      echo $currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
   }
   echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
   if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
      echo $currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
   } else {
      echo $currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
   }
   echo $currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
   echo $currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
   $unitPriceDescription = vmText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', vmText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.$product->product_unit));
   echo $currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
   }
   ?>
</div>

?

Studio 42

The base code to check is
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
// your price here
}

To check if you have a discount or
if ($product->prices['discountedPriceWithoutTax'] == $product->prices['priceWithoutTax']) {
// your price here
}

To check if you have no discount

You have to use one or other depending your need with the right price type (unitPrice,taxAmount, ...)
eg.
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
}


Mart DOP

i understand what you are trying to do as i am trying to achieve the same thing.

the prices.php file from Virtuemart only check which option is checked in the configuration file and display whatever.

So basically we only want one price to display, let's say the Final Sales Price. But we need a condition that check if the product is currently in discount and if yes you fetch the basePrice and display it above the Final Price and customize the Final price with some CSS.








julash

Hello Friends,

I am also looking this solution. I dont know php and so could not understand how "Studio 42" and "Mart DOP" doing it.

Its really confusing for product with no discount showing double price. So I think virtuemart should include a feature not to show base price when there is no discount in product.

Can anyone explain how to get this working? Will really appreciate any help.

Thanks
Julash

Studio 42