[Skip to main content](#vessel-content)

#   limit product category selection when mutually exclusive

##

- **[rfonta](/forum/user/30933-rfonta "View rfonta's Profile")**
- [![rfonta's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30933-rfonta "View rfonta's Profile") Topic Author
- [ Offline](/forum/user/30933-rfonta)

Less More

- Posts: 105
- Thank you received: 2
-
-

10 years 1 month ago [\#253409](#253409) by [rfonta](/forum/user/30933-rfonta "View rfonta's Profile")  *[limit product category selection when mutually exclusive](/forum/23-market-how-to/887118-limit-product-category-selection-when-mutually-exclusive#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 &quot;personal performance&quot; and &quot;organisation performance&quot; 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 &quot;form.php&quot; 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 &quot;node.id&quot; (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.")* was created by *[rfonta](/forum/user/30933-rfonta "View rfonta's Profile")*

-- 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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzIzLW1hcmtldC1ob3ctdG8vODg3MTE4LWxpbWl0LXByb2R1Y3QtY2F0ZWdvcnktc2VsZWN0aW9uLXdoZW4tbXV0dWFsbHktZXhjbHVzaXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

10 years 1 month ago [\#253414](#253414) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[limit product category selection when mutually exclusive](/forum/23-market-how-to/887118-limit-product-category-selection-when-mutually-exclusive#253414 "-- 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 &quot;personal performance&quot; and &quot;organisation performance&quot; 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 &quot;form.php&quot; 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 &quot;node.id&quot; (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.")*

Hi,

My approach would be using a custom plugin and the HikaShop product triggers.
[ www.hikashop.com/support/documentation/6...nBeforeProductUpdate](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onBeforeProductUpdate)

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 &amp; HikaSerial developer / HikaShop core dev team.

The following user(s) said Thank You: [rfonta](/forum/user/30933-rfonta "View rfonta's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzIzLW1hcmtldC1ob3ctdG8vODg3MTE4LWxpbWl0LXByb2R1Y3QtY2F0ZWdvcnktc2VsZWN0aW9uLXdoZW4tbXV0dWFsbHktZXhjbHVzaXZlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

Moderators: [Obsidev](/forum/user/7040-obsidev "View Obsidev's Profile")

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.047 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
