VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: meysam66 on January 20, 2021, 13:20:40 PM

Title: hide price in case of out of stock
Post by: meysam66 on January 20, 2021, 13:20:40 PM
hello can anyone suggest me a solution or a hack code to make virtuemart not showing the price when a product stock number become zero,

i just can make add to card button disappear or the whole product page unpublish, with the options that virtumart offers me for situations that stock become zero.

but it is not what i want, i want to people see the product details without the price and add to card button.

believe me with being of a price on product-details page it is still confusing for customers. i have got several messages talking about they can see the price but can't add them to card.

Title: Re: hide price in case of out of stock
Post by: sirius on January 20, 2021, 14:24:36 PM
Hi
this could help
This is just an example, you must adapt this to suit your template and do this on an override of the original file for sure: /your_template_name/html/com_virtuemart/sublayouts/prices.php

Code (php) Select

$stockhandle    = VmConfig::get('stockhandle', 'none');
if ($stockhandle != 'none' && ($product->product_in_stock - $product->product_ordered) < 1) :

/* the prices you want to hide here */

endif;
Title: Re: hide price in case of out of stock
Post by: axelf on October 04, 2023, 01:04:20 AM
Hi,
can you please add more info on how to hide price if the product is out of stock?

This part I don't understand:
/* the prices you want to hide here */

Or is there any other solution? I couldn't find any.

Thank you.
Title: Re: hide price in case of out of stock
Post by: sirius on October 04, 2023, 17:25:37 PM
ok so let's show the price when we have some stock
$stockhandle    = VmConfig::get('stockhandle', 'none');
if ($stockhandle != 'none' && ($product->product_in_stock - $product->product_ordered) > 1) :

/* the prices you want to show here */
echo $currency->createPriceDiv('basePrice', '', $product->prices);

endif;


And here you are all the prices that you can call, (those present in the VM configuration.
$product->prices['basePriceWithTax']
$product->prices['discountAmount']
$product->prices['discountAmountTt']
$product->prices['basePrice']
$product->prices['discountedPriceWithoutTax']
$product->prices['discountedPriceWithoutTaxTt']
$product->prices['priceWithoutTax']
$product->prices['priceWithoutTaxTt']
$product->prices['taxAmount']
$product->prices['taxAmountTt']
$product->prices['salesPrice']
$product->prices['salesPriceTt']
$product->prices['salesPriceWithDiscount']
$product->prices['PricebasePrice']