hide price if out of stock

  • Posts: 31
  • Thank you received: 1
4 days 20 hours ago #372503

-- HikaShop version -- : 6.5.0
-- Joomla version -- : 6.1.1

Hello
I would like to request that you add the option to "hide price if out of stock" in the product settings.

Please Log in or Create an account to join the conversation.

  • Posts: 85860
  • Thank you received: 14101
  • MODERATOR
4 days 9 hours ago #372510

Hi,

There is no built-in setting for that yet, but you can do it with a small view override, without touching HikaShop's own files, so it survives updates.

Go to Display>Views in the HikaShop backend and edit the product / listing_price.php file and add this right after the opening <?php line at the very top of the file:

$in_stock = (((int)$this->row->product_quantity == -1 && (empty($this->element->main) || $this->element->main->product_quantity == -1 || $this->element->main->product_quantity > 0)) || (int)$this->row->product_quantity > 0);
if(!$in_stock) {
	return;
}

This reuses HikaShop's own in-stock test, so it behaves correctly with variants and with products that don't manage stock: the price is hidden only when the product is really out of stock, and products with unlimited stock still show their price. It applies both to the product listings and to the product page, since they share the same price layout.

If you prefer to show a short text in place of the price rather than hide it entirely, replace the return line with:
	echo '<span class="hikashop_product_price_full">'.JText::_('OUT_OF_STOCK').'</span>';
	return;

I've noted the request for a real option in the product/display settings for a future version.

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum