VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: OriyanJ on February 07, 2016, 09:11:14 AM

Title: Modified price disappears on quantity change
Post by: OriyanJ on February 07, 2016, 09:11:14 AM
I've modified currencydisplay.php in order to add a crossed price by using the following code -

// Checks if there is a discount.
if ($name == "discountAmount" && $vis == "none") {
// If discount is empty (discountAmount) (display: none) it gives you an empty string instead of <div>
return "";
}

// If you have an discount and want to show the Price with Tax
if ($name == "basePriceWithTax") {
// Checks if there is a discount.
if(!empty($product_price['discountAmount'])) {
// Discount exist: Show Price with Tax and with an extended CSS class
      $css = "crossed";
      return '<div class="Price'.$name.'" style="display : '.$vis.';" ><span class="vm-price-desc">'.$descr.'</span><span class="Price'.$name.' '.$css.'" >'.$this->getFormattedCurrency($product_price['basePrice'],$nb).'</span></div>';
   }
}


When I change product's quantity that price disappears, I guess the solution is simple and I'm missing it.

VirtueMart 3.0.12
Title: Re: Modified price disappears on quantity change
Post by: GJC Web Design on February 07, 2016, 11:35:10 AM
the code is incomplete.. where r u getting $name and $vis from?

Check what they are after a q change
Title: Re: Modified price disappears on quantity change
Post by: OriyanJ on February 08, 2016, 09:38:32 AM
They are all declared at the same PHP file (currencydisplay.php) -

$vis = " vm-display vm-price-value";

if($sprgrp){
    if($sprgrp->custom_price_display){
        if($sprgrp->show_prices){
            foreach($priceFieldsRoots as $name){ ...


Title: Re: Modified price disappears on quantity change
Post by: Milbo on February 10, 2016, 01:02:27 AM
You should not hack the code for that, do it by CSS itself.
Title: Re: Modified price disappears on quantity change
Post by: OriyanJ on February 14, 2016, 08:20:42 AM
Like how, Milbo? I've took this solution from numerous threads here who addressed the same hack.
Title: Re: Modified price disappears on quantity change
Post by: GJC Web Design on February 14, 2016, 10:35:38 AM
there are many ways to this

obviously the simpler the better and in the template over rides

e.g.  something like below in the prices.php sublayout


echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
   
if ($product->prices['discountAmount'] != -0) {
    echo $currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
}
echo $currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);


with css


.PricebasePrice.vm-display.vm-price-value .PricebasePrice {
  color: #bf112b;
  text-decoration: line-through;
}


gives http://www.baby-natur.ch/bekleidung/basics/bodys/be-lake-bodensee-body-bodenseeraeuber-tuerkis-detail