Add Message In Empty Category

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 10 months ago #82130

Is it possible to add a message when there are no products in a category? I know I can hide the category if there are no products but the client does not want to hide it instead would prefer a message something like "Sorry no products at this time".

Thanks!!

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

  • Posts: 13201
  • Thank you received: 2322
11 years 10 months ago #82315

Yes it's possible, you have to edit the view "category / listing" in HikaShop > Display > views and if there is no elements in the var "$this->fields" then display the message.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 9 months ago #86823

Sorry but I'm looking at the code but not sure what to do :huh:

I see the below what should I do here?

if(!empty($this->fields)){ ?>


Thanks!!

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #86879

Try to use this code:

if(empty($this->fields)) echo JText::_('NO_PRODUCTS_AT_THIS_TIME');

And add the translation: NO_PRODUCTS_AT_THIS_TIME="Sorry no products at this time"
in the translation override file:
www.hikashop.com/fr/support/documentation/faq.html#translation

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 8 months ago #92712

Hi Xavier,

I add the code you provided as per below and it works but it's also add the line "Additional Information" not sure why that is?

<?php
  }
  if(empty($this->fields)) echo JText::_('NO_PRODUCTS_AT_THIS_TIME');{ ?>

Sorry no products at this time
Additional information

Thanks!!

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

  • Posts: 13201
  • Thank you received: 2322
11 years 7 months ago #92826

First of all, you have to remove the "{" at the end of your code, it will return an error.
Or use:

if(empty($this->fields)){ echo JText::_('NO_PRODUCTS_AT_THIS_TIME'); }

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

  • Posts: 41
  • Thank you received: 0
9 years 7 months ago #196744

Hello,

I changed line 70 or something
if(empty($this->fields)) echo JText::_('NO_PRODUCTS_AT_THIS_TIME');

and added translation but now it shows on every page, not only on category page without products. Where's my error?

I edited category > listing.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 7 months ago #196748

Hi,

The error is that this modification allow to display a message if there is no subcategories, not if there is no products in the category.

So in your case the edition of the view "product / listing" seems to be more appropriate.
You should find existing topics about that in the forum :)

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

  • Posts: 41
  • Thank you received: 0
9 years 7 months ago #196835

Couldn't find any. Too many with vague topics.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 7 months ago #196896

Hi,

Please add the following code at the end of the view:

if(($this->module || (!$this->module && empty($this->modules))) && empty($this->rows))
	echo 'here';

The following user(s) said Thank You: MiloW

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

  • Posts: 41
  • Thank you received: 0
9 years 7 months ago #196918

Great, thank you!

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

Time to create page: 0.092 seconds
Powered by Kunena Forum