I have this code:
I tried to upload an image attachment but was presented with an error, but you can see what the above code looks like by seeing 'Featured Products' towards the bottom of the page.Code:if ($show_price) { $db->setQuery("SELECT REPLACE(REPLACE(C.currency_positive_style,'{symbol}',C.currency_symbol ),'{number}',cast(P.product_price as decimal(19,2))) As pricetext FROM #__virtuemart_product_prices as P LEFT JOIN #__virtuemart_currencies as C on C.virtuemart_currency_id = P.product_currency WHERE P.virtuemart_product_id = '" . $product_id . "' LIMIT 1 "); $price_object = $db->loadObject(); //var_dump($pr->prices); $price = $pr->prices['salesPrice']; //$price = '<div class="PricepriceWithoutTax">Retail: '.$price_object->pricetext.round($pr->prices,2).'</div>'.'<div class="PricesalesPrice">Sale: '.round($pr->prices['salesPrice'],2).'</div>'; $price = '<span class="price-crossed"><div class="PricepriceWithoutTax PricebasePriceWithTax">Retail: '.'<span class="PricebasePriceWithTax">'.$price_object->pricetext.round($pr->prices,2).'</span>'.'</div></span>'.'<div class="PricesalesPrice">Sale: $'.sprintf("%1.2f",$pr->prices['salesPrice']).'</div>'; // $price = '<div class="productPrice">'.$price_object->pricetext.', '.round($pr->prices,2).'</div>'; //$price = '<div class="productPrice">'.$price_object->pricetext.'</div>'; } else $price=''; if ($show_detail) { $html .= '<span class="VMDetail" style="color: '.$this->detailcolor.'; text-align: '.$this->detailalign.'">'.$pr->product_s_desc.'</span>'; }
What I want is to adapt this code:
to display the 'Sale' price only if the product is actually on sale. If not, then only display the 'Retail' price, much like how it displays here.Code: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>"; } else { echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices) . "<br />"; } if (round($product->prices['salesPrice'],$this->currency->_priceConfig['priceWithoutTax'][1]) != $product->prices['priceWithoutTax']) { echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices); }
When I attempt to modify the code, my page winds up blank; obviously there's an error somewhere in my code.
Does someone have a suggestion?



Reply With Quote
Bookmarks