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

hide price in case of out of stock

Started by meysam66, January 20, 2021, 13:20:40 PM

Previous topic - Next topic

meysam66

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.


sirius

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;
J3.10.12 | PHP 7.4.33 + APC + Opcode
VM Prod : 3.8.6 | VM Test : 4.4.0.11095

axelf

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.

sirius

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']
J3.10.12 | PHP 7.4.33 + APC + Opcode
VM Prod : 3.8.6 | VM Test : 4.4.0.11095