Empty categories message

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 1 week ago #330362

-- HikaShop version -- : 4.4.1
-- Joomla version -- : 3.9.25
-- PHP version -- : 7.4.14

Hello

Some of our product categories have not any products for sale yet.

Is there a way to show a message to visitors of these categories to inform them that there are no products in the parent category for the moment?

Something like.. "Currently there are no products in this category..."

Thank you

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

  • Posts: 72790
  • Thank you received: 11101
  • MODERATOR
2 months 1 week ago #330369

Hi,

Could you provide more information on the situation ?
I checked on your link and tried to select about 15 different categories and they all had products in them.
So I also used the text search to reduce the results to 0 and I did get a "no products found" message:
i.imgur.com/BGiGqlJ.png
So if you just want to change that text, you could use a translation override, but I suspect that you're talking about something else...

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 1 week ago #330374

The screenshot that you send me shows the filter results page. This shows the message fine but we are talking about something else.

Please foollow the bellow link:
OUR_SITE.com/hikashop-menu-for-categories-listing

Now select category Deck / Ropes (third from the bottom to the top)

When you open this category to view the products in it, it shows absolutely nothing. We want to show the message when someone goes there through the categories list.

Thank you.

Last edit: 2 months 1 week ago by liaskas. Reason: Edited the link so that the domain will not be visible.

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

  • Posts: 3177
  • Thank you received: 418
  • MODERATOR
2 months 1 week ago #330390

Hello,

First you have to understand how to customize your view file, via the HikaShop Override system, and so have a look on this documentation .

Then, we will guide you to perform this override, first you have to create an override view from the view Category/listing.
Around line 100, you will see this :

...
$html = $this->loadTemplate($layout_type);
if(!empty($html)) echo '<div class="hikashop_subcategories_listing">'.$html.'</div>';

if(!$this->module)
...
Add this kind of element for display your required message, only if there are nothing to display, and you will have this :
...
$html = $this->loadTemplate($layout_type);
if(!empty($html)) echo '<div class="hikashop_subcategories_listing">'.$html.'</div>';
else echo '<div class="hikashop_no_subcategories_listing">NO PRODUCT AVAILABLE</div>';

if(!$this->module)
...

Hope this will help you to achieve what your requested.
Regards

Last edit: 2 months 1 week ago by Philip.
The following user(s) said Thank You: liaskas

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 1 week ago #330409

The message works Philip but...

Can we make it not show in the Brands categories?

Example...
When user is in a product details page, he sees the Manufacturer link. When clicking the manufacturer link he is transfered to a page that shows all the products from this manufacturer correctly, but right above the products it shows this message that is created by the modification you previously gave me.

Thank you

Last edit: 2 months 1 week ago by liaskas. Reason: Just discovered a small problem with the solution provided

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

  • Posts: 3177
  • Thank you received: 418
  • MODERATOR
2 months 5 days ago #330451

Hello,

In order to refine our advice can you provide us with the following elements :
- An url to the context where the message is displayed when this isn't desired.
=> No need to have the current custom message display.
- A screenshot of this same context but with the Display view files option activate on Front-end
=> You will find this option from Main HikaShop Configuration => Advanced tab, first displayed option.

Awaiting your element to better answer you.
Regards

Last edit: 2 months 5 days ago by Philip.

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 4 days ago #330462

(Removed from post owner) (here we do not want the "NO PRODUCTS AVAILABLE" message to how because as you can see there are products in this category.)

We need to show this message to all lowest level categories that do not have any products, no matter if you visit these categories by menu item or any other way.

Attachments:
Last edit: 2 months 23 hours ago by liaskas.

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

  • Posts: 3177
  • Thank you received: 418
  • MODERATOR
2 months 4 days ago #330468

Hello,

Thanks for your elements, these allow us to progress on your subject, and so can you try this code :
Previously, I suggest you this :

...
$html = $this->loadTemplate($layout_type);
if(!empty($html)) echo '<div class="hikashop_subcategories_listing">'.$html.'</div>';
else echo '<div class="hikashop_no_subcategories_listing">NO PRODUCT AVAILABLE</div>';

if(!$this->module)
...

Try this to see if that works better :
...
$html = $this->loadTemplate($layout_type);
if(!empty($html)) echo '<div class="hikashop_subcategories_listing">'.$html.'</div>';

if ((empty($html)) && (empty(!$this->module))) {
	echo '<div class="hikashop_no_subcategories_listing">NO PRODUCT AVAILABLE</div>';
}
if(!$this->module)
...

Hope this meet your expectations.
Regards

Last edit: 2 months 4 days ago by Philip.

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 4 days ago #330500

Thank you for your reply Philip, but i could not test your patch.
When i apply it in the script, the category listing page gives a page with the message... "0 syntax error, unexpected '}', expecting end of file".
I am not a coder, so is it possible to check?

Thank you

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

  • Posts: 3177
  • Thank you received: 418
  • MODERATOR
2 months 3 days ago #330518

Hello,

We check the code that we provide but it seems that our code didn't have any mistake or typo, from this and your reported error message it seems that you have forget an ";".

To be sure, go back to the default file, without modifications and just pasted this code (in the same line):

if ((empty($html)) && (empty(!$this->module))) {
	echo '<div class="hikashop_no_subcategories_listing">NO PRODUCT AVAILABLE</div>';
}

To have this, the addition of code is here in red :
...
if(!empty($html)) echo '<div class="hikashop_subcategories_listing">'.$html.'</div>';

if ((empty($html)) && (empty(!$this->module))) {
echo '<div class="hikashop_no_subcategories_listing">NO PRODUCT AVAILABLE</div>';
}


if(!$this->module){
...


We can highly recommend you to use a code editor, because this tool will spot this kind of little error.
Hope this will help you to progress.
Regards

Last edit: 2 months 4 days ago by Philip.

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 2 days ago #330643

Thank you Philip for taking the time to help me. I appreciate it. You are right it was my mistake that was giving the error.

Unfortunately with the new code the message does not show at all...

Here is the code as it has been entered to listing.php



Let me try to explain better what we need.

We have a multi level category tree and only the bottom level categories contain products.
Example:
Category1
- Subcategory1
- Sub-Subcategory1
- Sub-Subcategory2
- Sub-Subcategory3
- ...
Only Sub-Subcategories contain products

Visitors can access these Sub-Subcategories 2 ways.
  1. By clicking on a menu item that links directly to the Sub-Subcategory
  2. By following the categories list menu item, and reach the Sub-Subcategory step by step

Example:
Menu item link to Sub-Subcategory: There is no message at all. The page shows nothing!


Step by step following the categories till we reach the bottom level category: There is no message at all. The page shows nothing!


Thank you

Attachments:
Last edit: 2 months 23 hours ago by liaskas.

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

  • Posts: 3177
  • Thank you received: 418
  • MODERATOR
2 months 1 day ago #330663

Hello,

Sorry for this but I have made a mistake, really sorry for this, I analyze deeper the solution let's restart from scratch, follow me step by step :
- First don't use category/Listing view but rather the product/Listing
- Go around line 270, find this code :

} elseif(( !$this->module || hikaInput::get()->getVar('hikashop_front_end_main',0) ) && ($ctrl == 'product'  || $ctrl == 'category') && $task == 'listing' && !empty($this->filters) && is_array($this->filters) && count($this->filters) && !empty($this->filter_set)) {

Code view :

The part underlined in red is the one that must be deleted.

- Remove the part after the "...|| $ctrl == 'category') && $task == 'listing' ", to have this :
} elseif(( !$this->module || hikaInput::get()->getVar('hikashop_front_end_main',0) ) && ($ctrl == 'product'  || $ctrl == 'category') && $task == 'listing') {

This solution is a little tricky but must better fit your needs, and will display automatically a message thanks to this code :
echo '<div class="hk-well hika_no_products"><i class="fa fa-search"></i> ' . JText::_('HIKASHOP_NO_RESULT') . '</div>';
Hope this will fit your needs.
Regards

Last edit: 2 months 1 day ago by Philip.
The following user(s) said Thank You: liaskas

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

  • Posts: 196
  • Thank you received: 12
  • Hikamarket Multivendor Hikashop Business
2 months 1 day ago #330694

PERFECT....
Thank you! Everything is Ok now and no worries. What matters is that you have the will to help.
Thank you again.

The following user(s) said Thank You: Philip

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

Time to create page: 0.097 seconds
Powered by Kunena Forum