Skip Navigation

[Resolved] Many to Many relationship with fields attached question

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by XavierB6433 3 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1930463

Hi there,

I have a Many to Many relationship between Businesses and Services and have the following attached fields: Price and Duration

Services are for instance: Massage / Manicure...

I want to be able to create a Massage for 60 minutes for $120 and a Massage for 90 minutes for $200

I'm able to create a first association (60mn / $120) but after it's created and I want to create the second one for 90 minutes, it's not in the list of services anymore.

I looked at the settings of the relationship: hidden link but can't see where it decides that it has to be a unique selection.

Thanks for letting me know what I'm missing here.

#1930671

Hello,

I assume you are going to multiple relationships between the same "Businesses" post and "Services" post on the same many-to-many relation ship "Businesses and Services".

If it is, it is not possible, one post can connect other post once on the same relationship.
You will consider other workaround, for example:
1) Create another new post type: "child-cpts", setup those custom fields "Price", "Duration" ...
2) Setup two one-to-many relationships between below post types:
- "Businesses" and "child-cpts"
- "Services" and "child-cpts"

Then you will be able to connect the same "Businesses" post and "Services" post by different "child-cpts" posts

#1932465

Ok, that's really too bad it isn't possible. Your solution works technically speaking but it looks like it wouldn't really work as a convenient way to enter lots of services and to offer that possibility in the front end for businesses to easily add new services. I want the user to be able to easily add new services.

So does it mean that I would be stuck with using a repeatable group in Businesses instead of a many to many relationship with three fields: a dropdown list for the services + duration + price?

I'll have thousands of services to add so I wanted to stay away from that solution for performances. Also I want services to be a filter on the main search page, do you think that would work and wouldn't get too slow?

#1932623

Unfortunately, it is a limitation of Many-to-many relationship.
In your case, it needs to setup the post type relationship as I mentioned above:
https://toolset.com/forums/topic/many-to-many-relationship-with-fields-attached-question/#post-1930671

Anyway, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it

#1933909

I did what you suggested but when I'm on the business and click to add a new "biz-service" (the equivalent of your child-cpts), it doesn't give me the option to choose a service, only the fields from the biz-service table: hidden link
Even though it's selected hidden link

So I don't really understand how I can make it work...

Thanks,

#1934425

You just need to edit the single "biz-service" post, there you can select it's parent "Businesses" post and "Services" post

#1934489

Ok so you're right, that's a workaround but absolutely impossible to do in real life with hundreds of business to choose from and more services to enter...

#1934545

That is how Toolset Many-to-many relationship works, I don't think there is other better workaround for now.

Anyway, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

#1935881

My issue is resolved now. Thank you!