Hi,
I want to hide the price in the category view and featured products as I have a few items that have a price of 0.00 (due to product variants) so I want the price to be hidden on the category view and featured products; I've searched the forum and done a lot of googling and not found an answer.
I have tried un-checking the "Include the Product Price into the description?" box under configuration > template tab for both category feed and featured products feed but it doesn't hide the price.
What's the best way to hide the prices in these views?
Thanks,
Jamie
Do you want to show price in other then category/featured places?
Yes.
What im looking to do is just hide the price so you can't see the price until you click on the product and then there the price will be. Is there a way to do this?
Customizing of such things is the method of using template overrides (read about them in a sticked threads in Template forum section).
I've tried to do an over ride, but what I'm looking to do is hide the price only when it is 0.00 in these views so you have to click the product to see the price (which is generated using child products and custom fields)
How would I hide the price when browsing products only when it = 0.00? So you can see the price for other products when it is above 0.00, but hide it for products with a price = 0.00?
I don't think an override would do it? Perhaps I need an IF statement?
Any help would be greatly appreciated.
Override could eat your IF, no problem. Try it.
Ok I'll give it a whirl and report back, where can I find the sticky to the over rides? I checked the templates templates section and couldn't find it?
I take it this would be an over ride for categories or would it be product view or both?
Thanks!
I think you need both views.
http://forum.virtuemart.net/index.php?topic=90935.0
http://forum.virtuemart.net/index.php?topic=97744.0
http://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_template_system
http://docs.virtuemart.net/tutorials/33-templating-layouts/78-introduction-template-system.html
Well I've been trying this for a few days now and cannot get it to work.
What I'm trying to do is make the price on this page not appear if sales price <= 0:
(http://aswholesale.co.uk/images/As-category.png)
I've created a copy of webroot / components / com_virtuemart / views / category / tmpl / default.php
The code that writes the price in is here:
<div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
<?php
if ($this->show_prices == '1') {
if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and !$product->images[0]->file_is_downloadable) {
echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE');
}
//todo add config settings
if ($this->showBasePrice) {
echo $this->currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $product->prices);
}
echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
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>";
}
if (round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
}
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
echo $this->currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
$unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', $product->product_unit);
echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
} ?>
</div>
I tried adding to it:
if ($product->prices['basePriceWithTax'] =<1 {
echo "Click for Price";
}
I then placed the amended default.php into mytemplate/html/com_virtuemart folder and selected it as the category view over ride in the virtuemart back end.
However that did not work, and the prices still displayed on the category view.
I think I have some issues with the php. I am really really new to php so I think that's probably where I'm going wrong. Can anyone give me any pointers on what code I should be writing here to make the price only show if it is bigger than 0.00?
I'll keep playing around with it, its difficult when your knowledge of php is really limited! :-\
Quote from: beardedhobo on August 21, 2013, 21:05:46 PM
I've created a copy of webroot / components / com_virtuemart / views / category / tmpl / default.php
...
I then placed the amended default.php into mytemplate/html/com_virtuemart folder and selected it as the category view over ride in the virtuemart back end.
place it into mytemplate/html/com_virtuemart/
category folder
Jamie and Maxim - just a hint. If you want to customize the category browse pages, place a copy of
...\components\com_virtuemart\views\category\tmpl\default.php
with a different name, i.e. noprice.php in the same folder.
Then comment out the price (which one(s), depends on your selections in the pricing configuration) in your noprice.php
Thereafter you can select your customized 'noprice.php' from the 'Category Browse Page' dropdown selection in the 'Category Edit view'.
Thank you for pointing this, JJK.
Thanks for the info guys. I've been trying for months to get this sorted now with no luck. In the default category view I've narrowed it down to this section of code:
<div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
<?php
if ($this->show_prices == '1') {
if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and !$product->images[0]->file_is_downloadable) {
echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE');
}
//todo add config settings
if ($this->showBasePrice) {
echo $this->currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $product->prices);
}
echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
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>";
}
if (round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
}
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
echo $this->currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
$unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', $product->product_unit);
echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
} ?>
</div>
Can anybody tell me what if statement I should add so if sales price = 0 then it will hide the price and echo "click for price"
I've nearly gone bald pulling my hair out for 4 months over this!
Any help would be massively appreciated!
Thanks,
Jamie