limit product category selection when mutually exclusive

  • Posts: 105
  • Thank you received: 2
8 years 4 weeks ago #253409

-- HikaShop version -- : 2.6.0
-- HikaMarket version -- : 1.6.7

Hello,
in the different categories a vendor can select for a product, there are some that are mutually exclusive.
For example category "personal performance" and "organisation performance" are mutually exclusive on my site.
So I would like that one of them is selected, the user can't select the other one.
I had a look at the product creation page and initially thought I could develop some javascript in the "form.php" file when the vendor clicks on the product category area and get the ids of the categories and perform some checks.
but first it seems complec and second, I can't figure out how to get the category ids, since it seems that the "node.id" (used to differentiate the different categories in the tree category, if I understood well) are not using the real category id, but a made up category.

Could you help on this matter (either on suggesting a recommended approach) or by telling me how I can get the real category ids when a user clicks on one of the category node.

regards.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 4 weeks ago #253414

Hi,

My approach would be using a custom plugin and the HikaShop product triggers.
www.hikashop.com/support/documentation/6...nBeforeProductUpdate

Interacting using javascript to block the user to select the content will not really stop the user to do it if he wants to.
Like I said recently "security in the view is a security issue".

Thanks to "onBeforeProductUpdate" (and onBeforeProductCreate) you can check the product content before it is being saved.
Because you just want to filter the data for your vendors, you have to check the Joomla context (admin or not) and also check that the vendor is updating the product categories (if the categories are not set or empty, no need to check).

Afterwards, you will be able to put your own algorithm and change the dynamically the content.
So if the vendor selected "personal performance" and "organisation performance", you remove the last one from the list just before the product is being saved.

It requires some PHP/development skills but it will not be a big plugin.
And thanks to that check directly in the server, you are sure that your vendors cannot pick up mutually exclusive categories for theirs products.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: rfonta

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

Moderators: Obsidev
Time to create page: 0.055 seconds
Powered by Kunena Forum