Skip Navigation

[Resolved] Creating Functions for Inventory Management

This support ticket is created 7 years, 1 month 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 48 replies, has 2 voices.

Last updated by Christian Cox 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#582152

Great, that looks like it's done the trick.

Now I've just been through the thread to see if I've missed anything and spotted the following...

Another thing to consider is that you'll have to add some additional validation to ensure that you don't oversell. It's unlikely but it could happen, for instance if an Owner and a Reseller are both logged on and see that 1 ticket is remaining, they might both start the process to mark that ticket sold. If one of them finishes while the other is still working, then they both might actually be able to sell a ticket. So you'll need to have some additional validation code that determines if there truly is a ticket available to sell at the point of form submission. We offer the cred_form_validate API that can help with this.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

So we implemented the validation to make sure the number of Variations that can be booked is no more than the number of Tickets available, but if I'm right you're suggesting it may still be possible to overbook if both users are logged in and booking the same remaining place at the same time?

#582410

That sounds correct, you should perform validation when that form is submitted to verify there are still available tickets. If no tickets are available, it means that someone took the last ticket while the current user was in the process of booking. In that case you should show an error. The code should be similar to the solution in this ticket, but you'll need to do a bit more to figure out the ancestor ticket ID since it's not a direct parent of the booking post:
https://toolset.com/forums/topic/limit-numerical-field-value-in-child-to-the-value-of-numerical-field-in-parent/

#584965

Here's a quick message to keep the thread from closing - I'll test the above as soon as possible and get back to you.

#585343

Sounds good, we'll stand by for now.