CATALOGUE MODE ONLY FOR SPECIFIC CATEGORIES

  • Posts: 19
  • Thank you received: 1
3 years 4 months ago #334446

-- HikaShop version -- : HikaShop Starter 4.4.2
-- Joomla version -- : 3.9.28
-- PHP version -- : 7.4.3
-- Browser(s) name and version -- : Chrome Versión 90.0.4430.212 (Build oficial) (64 bits)

Hi:
I am developing an online shop for a wine cellar, website has 2 lenguages: spanish and english, but we only want to sell products in Spain, so as there are few products (aprox 30 units) I have created two different product root categories, one for spanish and other for english.

I want to show price in both categories but disable "add to cart" button only in english root category. Is there a way to set "Catalogue mode" only for english category ?

Thanks in advance,

Ricardo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 4 months ago #334451

Hi,

There is no such option.
The display of the product is similar regardless of the current language or which category the customer came from to reach the product page.
You would have to create different products per language so that you could set the "quantity" to 0, or the product sale start date in the future or sale end date in the past in the products you don't want customers to buy. Then, you can use translation overrides to change the text displayed in place of the add to cart button to what you want.

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

  • Posts: 19
  • Thank you received: 1
3 years 4 months ago #334475

Hi Nicolas:

Ok, for english I wilI duplicate products and on the menu item for Hikashop product list I wll point them to correct english new categories. I will also set "available date to" a past date in order to be not available and I will make an english override for "Items sold not anymore". Catch it !!!

I have done that for one product, it works, but now I have the problem that if I am watching a product in spanish and I clic on the language switch flag icon to change tproduct in spanio english, the menu changes without problem , but the product doesn´t change, it continues the same in spanish.

I have the same product:
- in spanish: bodegasanmiguel.es/index.php/es/tienda-d...mpolosa-blanco-joven
- in english: bodegasanmiguel.es/index.php/en/tienda-d...ampolosa-young-white

You can test this: if you go to spanish lenguage product ( bodegasanmiguel.es/index.php/es/tienda-d...mpolosa-blanco-joven ) and then change to english (language flag icon top rigth), menu will change but product continues being the spanish one. Viceversa also fails.

How can I solve this?

Thanks in advance,

Ricardo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 4 months ago #334477

Hi,

I don't see a solution for that with the options available. However, I think it might be possible with a small modification.

First, what you can do is activate the "Force canonical URLs on listings" setting of the Hikashop configuration.
Then, in the "canonical URL" field of both products enter a new translation key. For example CAMPOLOSA_URL
And then go in the HikaShop configuration, under the languages tab, and edit each language. In each languages' override area (on the right side), you can enter a new line like so:
CAMPOLOSA_URL="XXX"
where XXX corresponds to the URL of the product in the corresponding language on the frontend.
Finally, in the file components/com_hikashop/helpers/association.php, after the line:

$class->addAlias($product);
add the code:
$config = hikashop_config();
$canonical = $config->get('force_canonical_urls');
if($canonical && !empty($product->product_canonical))
$result[$language->lang_code] = hikashop_cleanURL(hikashop_translate($product->product_canonical), false, true);
Please let us know how it goes as that's something we could add in HikaShop so that others with the same issue could do that, and so that you don't have to do that modification each time you update your HikaShop.

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

  • Posts: 19
  • Thank you received: 1
3 years 4 months ago #334525

Hi Nicolas:
I made all changes you suggested (see pdf attached with screenshots) but it doesn´t work, Could it be an error in association.php code?
regards
Ricardo

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 4 months ago #334527

Hi,

Your screenshots are fine.

However, looking at it again, I think I've forgotten something in the code I gave you.
Instead of :

if($canonical && !empty($product->product_canonical))
$result[$language->lang_code] = hikashop_cleanURL(hikashop_translate($product->product_canonical), false, true);
to code should actually be:
if($canonical && !empty($product->product_canonical)) {
$result[$language->lang_code] = hikashop_cleanURL(hikashop_translate($product->product_canonical, $language->lang_code), false, true);
continue;
}
so that the translation key is translated for the destination language and not for the current language and that the retrieved URL is not overwritten by the line
$result[$language->lang_code] = $lang_url . (!empty($item_id) ? '&Itemid='.$item_id : ''). '&lang='.substr($language->lang_code, 0,2);
at the end of the loop.

Please do that change and it should help.

The following user(s) said Thank You: kaito

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

  • Posts: 19
  • Thank you received: 1
3 years 4 months ago #334534

Hi Nicolas:
Now it works !!
Just to have it in mind for future updates, should I revise association.php code for future updates or will be this change implemented in next Hikashop version?
Thanks,
Ricardo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 4 months ago #334535

Hi,

Thank you for your feedback.
We'll, add that on our end too as it is normal that canonical URLs are taken into account for the language switching, similarily to how they are taken into account for products listings, search results, etc.

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

Time to create page: 0.067 seconds
Powered by Kunena Forum