How To Display A Message When Category Is Empty

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #183677

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6

Is it possible to automatically show a message when there aren't any products in a category? Something like "We're sorry, there aren't any products here at the moment, please check back later".

I've tried a few solutions from other (older) posts but none of them worked with this version of HikaShop.

Any help would be greatly appreciated,
Thanks.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #183686

Hi,

You can potentially edit the view "product / listing_div" and at the end add:

<?php else{echo "We're sorry, there aren't any products here at the moment, please check back later";} ?>

Last edit: 10 years 6 months ago by Mohamed Thelji.
The following user(s) said Thank You: dancingkazzaf

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

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #183927

Hi Xavier,

Thanks for your reply. I've just tried this but when I add the code at the bottom of the file it make the pages lose all formatting and they seem to lose all CSS styling too (see attached screenshots of before and after).

Do you have any other ideas?

Thank you.

Attachments:

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

  • Posts: 84079
  • Thank you received: 13635
  • MODERATOR
10 years 6 months ago #183939

Hi,

This indicates an error in the code.
Please do a screenshot of the modification you made in the listing_div view file so that we can see what you did.

The following user(s) said Thank You: dancingkazzaf

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

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #184098

Here is the screenshot of how I implemented the code. I put the code at the end of the file as suggested earlier.

Attachments:

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

  • Posts: 12953
  • Thank you received: 1778
10 years 6 months ago #184113

Can you replace that line :

<?php else{echo "We're sorry, there aren't any products here at the moment, please check back later"} ?>
By :
<?php else{echo "We're sorry, there aren't any products here at the moment, please check back later";} ?>

The following user(s) said Thank You: dancingkazzaf

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

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #184220

Hi, thanks for your reply.

Unfortunately this code brings the same error as before. Is it possible i've put the code in the wrong place? It is right at the end of the listing_div file as seen in my earlier post.

Thanks.

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

  • Posts: 84079
  • Thank you received: 13635
  • MODERATOR
10 years 6 months ago #184228

Try to remove the code:
?>

<?php

before the echo after doing your modification.
Maybe PHP doesn't like having the else statement cut from the if statement like that

The following user(s) said Thank You: dancingkazzaf

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

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #185543

Thank you for your reply, I have the message appearing now, although it is also appearing on the 'categories listing' pages too (see link: www.treasurefindersuk.com/our-products/jewellery-and-gold ) where as we only need it to show on 'product listing' pages.

Is there anything I can do to stop it showing on the 'categories listing' pages?

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

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #185579

Hi,

You can potentially use that code instead:

elseif(!in_array(hikashop_getCID('category'),array('2'))){
    echo "We're sorry, there aren't any products here at the moment, please check back later";
}

And in the array, you can add more values for the parent categories, for example add the id of the parent categories of the categories "Gold Jewellery, Silver Jewellery, Gold Collectables", etc.

The following user(s) said Thank You: dancingkazzaf

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

  • Posts: 256
  • Thank you received: 2
10 years 6 months ago #186308

Thank you very much, this is working perfectly!

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

Time to create page: 0.095 seconds
Powered by Kunena Forum