Sell products even if they are out of stock

  • Posts: 29
  • Thank you received: 0
9 years 4 months ago #181710

Hello

Is there any way to keep sell products even if they are out of stock.

For exampel: if we have a product in stock, but a customer wants to order 2, then hikashop should not refuse the customer's order. But we still wants to show the customer just how many products we have in stock so they know.

Is this possible?

Thanks in advance...

Best regards,
Henrik

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
9 years 4 months ago #181748

Hi,

In that case, the best is to artificially increase the stock of the products (so for example, when you have 5 products in stock, you enter 1005 in the quantity field of the product) and then you edit the file "quantity" of the view "product" via the menu Display>Views and change the line:
$text = JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity);
to:
$text = JText::sprintf('X_ITEMS_IN_STOCK',max($this->row->product_quantity-1000,0));

That way customers can still purchase out of stock goods and they still see the correct stock.

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

  • Posts: 29
  • Thank you received: 0
9 years 4 months ago #181757

Hi Nicolas,

Thanks for your answer.

That code dont seem to change anything on the site. If i set the quantity to 1014 on a product the site shows available products 1014.

<div class="hikashop_product_stock">
	<?php
		if($this->row->product_quantity==1){
			if(JText::_('X_ITEM_IN_STOCK')=='X_ITEM_IN_STOCK'){
				$text = JText::sprintf('X_ITEMS_IN_STOCK',max($this->row->product_quantity-1000,0));
			}else{
				$text = JText::sprintf('X_ITEM_IN_STOCK',$this->row->product_quantity);
			}
		}else{
			$text = JText::sprintf('X_ITEM_IN_STOCK',$this->row->product_quantity);
		}

But if i instead changes this line
$text = JText::sprintf('X_ITEM_IN_STOCK',$this->row->product_quantity);
to
$text = JText::sprintf('X_ITEM_IN_STOCK',max($this->row->product_quantity-1000,0));
the page displays the correct quantity of some of the products, but not all.

Any ideas?

Regards,
Henrik

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
9 years 4 months ago #181766

Hi,

Well, you need to change the three lines with JText::sprintf( on that code in order to do it for all the cases.
I just gave you a simplified instruction thinking it would be enough.

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

Time to create page: 0.053 seconds
Powered by Kunena Forum