TOPIC:

Check for coupon codes in form and update payment & display 1 year 8 months ago #239480

  • Topic Author
  • sdcoil
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 1
  • Thanks: 0
I need help. Mostly I need to know if I'm thinking along the right lines and help with some of the code.

On our registration form I want the ability for a client to enter a coupon code and a click verify button. The form will then validate the code from a db table of codes, apply the discount, adjust the value sent to PayPal, and display the result.

I've looked at several posts and have gained some insight from the following:

https://crosstec.org/en/support/online-documentation/breezingforms/12-examples-scripts/215-paypal-donation-form.html

h https://crosstec.org/de/forums/38-foren/113466-coupon-code-with-paypalselect-list.html?start=0

https://crosstec.org/en/support/online-documentation/breezingforms/12-examples-scripts/135-auto-populate-select-list-from-db.html

What I want to do is have an SQL table of coupon codes with varying discounts as well as be valid for only a certain amount of time. I'm thinking I need to write some PHP to be executed before the form that will pull the coupon codes from the table and create a Javascript array. Then have a custom validation code for the verify button.

Something like this:

Pre-form code
// php?
var Results
// Open db and return all current coupon codes
var CurrentTime = get the current date & time
Open DB
Results = dbQuery(Select * on Table CouponCodes where CurrentTime >= StartTime and CurrentTime <= EndTime;)
// Build Table and pass to JS???

Coupon Validation
// Javascript?
Function ff_couponVerify_action(element, action)
{
If (action==’click’)
{
var code=ff_getElementByName(‘couponCode’).value.toLowerCase();
If (code !== ‘’)
{
var found = coupons; If (typeof found !== “undefined”) { \\ print coupon accepted below couponCode field ff_getElementByName(‘bfPaymentSelect’).value = 'Donation|0|’ + price - coupons[code] + '|0'; } Else { \\ print coupon expired or invalid } } Else { \\ print please enter coupon code } } } Am I close? Thanks, --Stacy[code];
If (typeof found !== “undefined”)
{
\\ print coupon accepted below couponCode field
ff_getElementByName(‘bfPaymentSelect’).value = 'Donation|0|’ + price - coupons + '|0'; } Else { \\ print coupon expired or invalid } } Else { \\ print please enter coupon code } } } Am I close? Thanks, --Stacy[code] + '|0';
}
Else
{
\\ print coupon expired or invalid
}
}
Else
{
\\ print please enter coupon code

}
}
}

Am I close?

Thanks,

--Stacy

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.041 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!