Displaying Coupon Code amount

  • Darrenr
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 11 months ago #15622 by Darrenr
Displaying Coupon Code amount was created by Darrenr
Hello,
I have been searching the forums for the last couple of days and didn't find the answer I was looking for, so please be gentle if this has already been answered. When using a coupon in Event Booking, is there a way to display the amount of price reduction that the user will get before before they submit their payment? So, for example, I have a coupon code that is valid for 30% off an event when the user enters save30 as their coupon code, I would like them to see that the coupon is valid and what percentage or price differential they are receiving.

Thank you,
Darren R

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

  • Darrenr
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 11 months ago #15794 by Darrenr
Replied by Darrenr on topic Re: Displaying Coupon Code amount
so far I have made some progress. I can get it to now tell me when I enter 6! I added this little function to the public_html/components/com_eventbooking/views/register/tmpl/default.php file
Code:
function checkCode(couponCode) { var code = couponCode.value if(code == '6'){ alert("you have entered 6"); return; } }

and modified this near the top of the page when it creates the textbox for the coupon code
Code:
<input type="text" class="inputbox" name="coupon_code" onkeyup="checkCode(this)" value="<?php echo $this->couponCode; ?>" size="18" />

now, if anyone can help with checking the current coupon codes in the database and returning the discount percentage, that would be awesome!

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

More
11 years 11 months ago #15805 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Displaying Coupon Code amount
Hi Darren

Showing the amount of coupon code .... right now Registration Form is difficult (you will need to know PHP / Joomla / AJAX programming to do that) . So I believe the simplest way is that you leave the extension works as how it is (the discount amount will be showed on Registration Confirmation page before they confirmed their registration) .

Tuan

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

  • Darrenr
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 11 months ago #15839 by Darrenr
Replied by Darrenr on topic Re: Displaying Coupon Code amount
OK, I made a couple of changes. First, I changed the form where it is setting up the field to this, because I wanted it to check the coupon code when it loses focus:
Code:
<input type="text" class="inputbox" name="coupon_code" onblur="checkCode(this)" value="<?php echo $this->couponCode; ?>" size="18" />


then I changed the function that I created to:
Code:
function checkCode(couponCode, coupon) { var code = couponCode.value var $coupon = "" if(code == '6') { $coupon = "you have entered 6"; return $coupon; } else if(code == "BrewClub") { alert("30% off will be applied at checkout if valid"); } else if(code == "WineClub") { alert("40% off will be applied at checkout if valid"); } else if(code == "YP Brew Club") { alert("30% off will be applied at checkout if valid"); } else if(code == "GF YP Brew Tour") { alert("52% off will be applied at checkout if valid"); } else if(code == "GF YP Wine Tour") { alert("48% off will be applied at checkout if valid"); } else { } }

What I would like it to do at this point, and I would appreciate any help, is to pull in the coupon codes in the database into an array, along with the discount percentage, then check the coupon code against that array and return the discount percentage to be displayed in an alert box (as is accomplished above). Otherwise, everytime I enter an new code, I would have to come back and edit the form and function.

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

Moderators: Tuan Pham Ngoc