Skip Navigation

[Resolved] Implementing multiple relationships and CPTs

This support ticket is created 2 years, 2 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.

Our next available supporter will start replying to tickets in about 3.67 hours from now. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by mayurJ 2 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2451761

Tell us what you are trying to do? I have a challenging setup with potentially multiple CPTs, Relationships, and Views and need someone with deep Toolset expertise to help solve an issue.

Website: hidden link

Background info:
The website features online educators and multiple classes being taught by multiple providers. Education pages on the site are just pages built in Elementor right now with some Elementor sections. Educators on the page appear through a view and are a CPT. Schedule data is static content. Online purchase for classes is handled via Woocommerce product + variations - so no connection or relationship with educators.

Summary of what the issue is:
Schedules change often. Currently, schedule data is static content on the education pages, but I want to create a CPT for them and relate them to educators (a custom CPT) as well as classes and schedules (not a CPT right now). Some classes are held over a multi-day schedule (probably need nested groups).

TLDR: I want to create at least two new CPTs, and create a many-to-many relationship with them and optionally add online purchase as well. I think Toolset can support most of this, but I suspect I'm going to run into some issues with nested groups (for the schedule). I also haven't done payments coming out of Toolset before. Also, I suspect that I will need to create a CPT called "class" to make this all work.

What is the link to your site?
https//sunnsideupyouth.org

If someone on the team can provide guidance so that I can successfully implement this improvement. Is what I'm doing even possible? Thanks

#2452415

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mayur,

What you're trying to achieve is certainly possible. The hardest part is getting the relationships setup correctly.

Also what will the students be paying for, will they be paying for the classes? or will they be paying for the course. Or is it that they will be paying for their application to the course.

I'm thinking the courses and classes as well as educators would've already been setup.

The Classes can have schedules as you say implemented as repeatable field groups which can be displayed on the classes page.

Essentially a class will belong to a Course, will that class be attached to more than one courses or is it unique to the class.

I'm thinking teachers would be many to many with Classes since they can teach multiple classes and have multiple classes assigned to them.

Thanks,
Shane

#2452435
Also what will the students be paying for, will they be paying for the classes? or will they be paying for the course. Or is it that they will be paying for their application to the course.

Good question. Students purchase a class (CPT) which may or may not be held over multiple days (schedule CPT)

I'm thinking the courses and classes as well as educators would've already been setup.

Just educators are setup right now. Everything else is static or a product in Woocommerce

The Classes can have schedules as you say implemented as repeatable field groups which can be displayed on the classes page.

Agreed

Essentially a class will belong to a Course, will that class be attached to more than one course or is it unique to the class?

Each class created would be unique to only that course. So for example, a course called "Baby Nutrition" would have multiple classes of which the student would purchase one. So for example, student A might purchase the September class which is held over two days, while student B might purchase the January class which is held on just one day.

I'm thinking teachers would be many to many with Classes since they can teach multiple classes and have multiple classes assigned to them.

Exactly.

So in summary this?

Setup 3 CPTs:

1. Teacher/Educator
2. Class - simple CPT with just a name
3. Schedule - have a repeating field group with start date/time and end date/time

Create these Relationships:

Teacher <> Class = many/many
Class <> Schedule = one/many

Questions I still have:

1. Is it possible to force a rule that for the Schedule CPT, that the end date must match the start date?
2. Is it possible to require the user to input an end date/time?
3. How would I add an e-commerce layer with inventory control? I assume I would create a field called "stock" for the Class CPT but how would I implement payment and stock reduction?
4. If the e-comm part is difficult, could I still use Woocommerce products instead and have a variable product be modified when a class or schedule changes?

Classes and Schedules are likely to change often by the client. This is the core issue I'm trying to solve. At the moment, I adjust the static page, and then adjust the Woocommerce product attributes and variations. Its functional, but not great for content management.

#2452437

Is it possible that I could get help from Toolset to create this implementation, and have it turned into a blog post and educational training on the Toolset website?

#2453161

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mayur,

1. Is it possible to force a rule that for the Schedule CPT, that the end date must match the start date?
It is possible, however you will need to write some custom code in order to do the validation checks for the date fields.

2. Is it possible to require the user to input an end date/time?

With the date custom date field you can set it to be a datetime so the user can set a date and end time.

3. How would I add an e-commerce layer with inventory control? I assume I would create a field called "stock" for the Class CPT but how would I implement payment and stock reduction?

The inventory control would need to be done by Woocommerce and the product. So in order for the user to purchase a course there must be a corresponding product. From there you can manage the inventory of that specific product using Woocommerce.

I would recommend taking a look here.
https://toolset.com/course-lesson/charge-users-for-submitting-content/

4. If the e-comm part is difficult, could I still use Woocommerce products instead and have a variable product be modified when a class or schedule changes?

I wouldn't recommend this unless you have some way of gathering data from the user through the product.

Thanks,
Shane

#2455677

My issue is resolved now. Thank you!