Limit Amount of Tickets Sold - Using PayPal Add-on

By: Jason Ryan | Asked: 11/29/2022
ForumsCategory: General questionsLimit Amount of Tickets Sold - Using PayPal Add-on
Jason Ryan asked 2 years ago
Hello - Have a form set up for a client that is selling raffle tickets. There is a limit on how many tickets can be sold (100), the caveat is that there is no limit each person can buy (e.g. One person can buy all 100 tickets if they wanted) This means that limiting "Entries" will not work in this scenario. That said, is the a where to check against the "quantity" of tickets in "completed" entries and then disable the form once that "quantity" is reached? Entries are only created once there is a Successful Payment. Thanks in advance.
1 Answers
Bobby Clapp answered 2 years ago

Can you use this: https://formidableforms.com/knowledgebase/general-form-settings/#kb-submit-button-logic

You'll have a hidden field with a default value that counts the total of the quantity field like this: [frm-stats id=x type=total 25="completed"]

Maybe you have "hide" if quantity total (hidden field) is greater than 99

Jason Ryan replied 2 years ago

Thanks @Bobby Clapp but not sure I follow. How would that check say 4 previous entries for how many tickets were purchased? Can you increment and store a value as entries come in and then check against that stored value for each form submission?

Bobby Clapp replied 2 years ago

The frm-stats shortcode is going to total the values entered for the field across the board.

Jason Ryan replied 2 years ago

Sorry, I am still a little lost here, let me see if I can talk this out here to make sense of what you are saying...

1. Create a hidden field: total_tickets_sold
2. Add the frm_stats shortcode to the form itself(?)
3. Add conditional logic to the submit button: "Disable when > 99"

Btw, this would've been the more helpful link to see all of the parameters of the frm_stats shortcode

https://formidableforms.com/knowledgebase/add-field-totals-and-statistics/

Thanks

Bobby Clapp replied 2 years ago

Plug that shortcode into the hidden field. It will carry a running total. Then it's always checked against on every new entry based on the new condition. The link would have been helpful, yes.

Jason Ryan replied 2 years ago

I think I am still confused about this part of the shortcode: 25="completed"

Bobby Clapp replied 2 years ago

25 is the field that holds the status value. 25 is the field ID of that field. In this way you are totaling the value of one field where another field, 25 here, has a particular value.

Jason Ryan replied 2 years ago

Again, still confused as to what you mean. Here is my shortcode:

[frm-stats id=ticket_qty type=total total_tickets_purchased="completed"]

ticket_qty = The ID of the field where people select how many tickets they want to purchase

total_tickets_purchased = The ID of the hidden field this shortcode is placed

What am I missing here?

Bobby Clapp replied 2 years ago

Seems right. Not sure if it takes field keys if that is what you are using, but it probably does.

Test run it. Sometimes seeing is believing. 🙂

Jason Ryan replied 2 years ago

I have and it is not storing any type of value.

Jason Ryan replied 2 years ago

Shouldn't I use the following maybe?

total_tickets_purchased_less_than_or_equal_to="100"

Jason Ryan replied 2 years ago

That didn't work either, I tried shortening it to just:

[frm-stats id=ticket_qty type=total]

No value is being saved here.

Bobby Clapp replied 2 years ago

There might be something with the paypal addon. Can you create a test form without a paypal action?

Jason Ryan replied 2 years ago

Nevermind, shortening it to just the above-mentioned shortcode is saving the values now. However, it doesn't display that in the Entry Viewer until a new entry is created, so it looks confusing:

https://i.imgur.com/7MdmTzR.png

Checked the hidden field on the front end and the total is showing for total_tickets_purchased = 40

Bobby Clapp replied 2 years ago

That is correct process. Now we just need to ensure that once 100 is reached, the submit goes away as desired. You may need to bring back in the status into the shortcode, otherwise everything will be totaled. That may be okay as you have some on reserve but awaiting payment approval. That's all in your court though.

Jason Ryan replied 2 years ago

I do have a conditional on the Submit button that if total_tickets_purchased is Greater or Equal To 100 - disable the button

However, I had 4 entries already with a total of 40 tickets purchased, I submitted the form one more time buying 65 tickets - it allowed me to do so, thus putting the total at 105 tickets sold - which cannot go beyond that 100 ticket limit.

It is disabling the button when I go back to the form though. Almost there.

Bobby Clapp replied 2 years ago

Yep. So we now need to calculate the remaining amount of tickets available. Add a new field (read-only) that subtracts the previous total from 100 via field calculation. This will be visible to the user to show how many tickets remain. Now only show the submit if the tickets that remain is less than or equal to the [frm-stats id=ticket_remain type=total]

I think it will work like that. Hard with me not seeing it.

Jason Ryan replied 2 years ago

I will give this a go and report back. I appreciate the help!

Jason Ryan replied 2 years ago

@Bobby Clapp -

I am still having issue with this form. Here is the link to the form:

https://theikefoundation.org/2022-hobie-kayak-raffle/

I disabled the PayPal action on the form and all submissions come to me.

Its properly showing the "Remaining Tickets" and I have the submit button enabled like so:

Remaining Tickets - Greater than or equal to - 0
Remaining Tickets - Less than or equal to - 100

The issue is that it doesn't prevent someone from buying more than the total allowed tickets - which is 100. If I submit the form and buy 50, then refresh the form and buy 55, it allows it to go through, and then it says -5. I need to prevent someone from buying more than the Remaining Tickets.

Bobby Clapp replied 2 years ago

Let's try some jquery to help here. In the customize HTML, add the linked code into the "after fields" box.

https://paste2.org/1LI4ApwO

Jason Ryan replied 2 years ago

For some reason, the "Default Value" for #field_tickets_remaining is not being passed initially, the value is showing as empty - even though there is a calculation there for that field: 100 - [fieldID] which should pass 100 since the fieldID's value at first is zero.

Bobby Clapp replied 2 years ago

Send me an email with the appropriate info to get in and poke around if you're willing to do that. [email protected].

Jason Ryan replied 2 years ago

I just sent you an email with login info for the site. Thank you for looking into this, it is greatly appreciated!

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right