Display warehouse on product page possible?

  • Posts: 27
  • Thank you received: 0
  • Hikaserial Standard Hikashop Business
8 years 2 months ago #251551

-- HikaShop version -- : 2.6.4

Hi

Is it possible to display the selected warehouse (title) for the user on the product page?

Thanks

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
8 years 2 months ago #251558

Hi,

Sure. Edit the show_default view file and add such code:

<?php 
$class = hikashop_get('class.warehouse');
$warehouse = $class->get($this->element->product_warehouse_id);
echo $warehouse->warehouse_name;
?>

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

  • Posts: 88
  • Thank you received: 3
  • Hikashop Business Hikashop Essential
2 months 2 weeks ago #363547

I would also like to show the warehouse on the product - but only if stock is below threshold - how to do that ?

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
2 months 2 weeks ago #363558

Hi,

You can use the same code and add a condition around it, like that:

<?php 
if($this->element->product_quantity > 0 && $this->element->product_quantity < 10) {
$class = hikashop_get('class.warehouse');
$warehouse = $class->get($this->element->product_warehouse_id);
echo $warehouse->warehouse_name;
}
?>
where 10 can be replaced by your threshold.

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

  • Posts: 88
  • Thank you received: 3
  • Hikashop Business Hikashop Essential
2 months 2 weeks ago #363559

Hmmm seems that this condition also takes the pre-order stock in account - that does not work. I need to show the warehouse text if the stock is zero, but the pre-order stock can still be more than zero - howto do that ?

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
2 months 2 weeks ago #363560

Hi,

You didn't mention you were using the pre order plugin so I didn't take this possibility into account.
If you want to take into account the pre order stock, then you'll want to use something like this instead:

<?php 
if($this->element->product_quantity >= 0) {
$stock = $this->element->product_quantity - $this->element->product_preorder;
if($stock < 10) {
$class = hikashop_get('class.warehouse');
$warehouse = $class->get($this->element->product_warehouse_id);
echo $warehouse->warehouse_name;
}
}
?>

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

Time to create page: 0.083 seconds
Powered by Kunena Forum