Update Custom Fee Fields dynamically by javascript

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
10 years 2 months ago #61616 by James Riley
Hi Tuan,
What I am trying to accomplish for one of my events is to have a custom, active "secret discount code" field that shows up only when a particular checkbox is set. I've figured out that I can run custom html & javascript in the Description field of some of the Custom Field types and I've got everything working on the front-end form (I'm running a test against the value of a Text Field via js), except I am unable to figure out an easy way to get the new discount to apply.
With the ability to run js / jQuery code, I was wondering if there is any way that I can modify the Fee Values of other checkbox/radio Fee Field and trigger the calculate[Individual/Group]RegistrationFee() function to update the current price. I don't see the Fee Values written in my site's live code, so I'm assuming that they are held in a variable some where, or read live from the database. What is the variable / array / object / etc name that I would need to access in order to update the fee, and can a call to the update...RegistrationFee function do what I need it to for all this to work?

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

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

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
10 years 2 months ago #61619 by James Riley
Replied by James Riley on topic Update Custom Fee Fields dynamically by javascript
This is what I have (all working!!) so far:


Just need to modify the Fee (and Value) affiliated with RegistrationType -> Standard .

Or should I go about this some other way completely? I just want my Code to apply to 1 single Registration Type.

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

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

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
10 years 2 months ago #61620 by James Riley
Replied by James Riley on topic Update Custom Fee Fields dynamically by javascript
Would I be better off trying to add my discount somehow to $('#discount_amount') or val(msg.discount_amount)?

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

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

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
10 years 2 months ago #61624 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Update Custom Fee Fields dynamically by javascript
Hi James

Unfortunately, wrong way :D. If you process it using javascript code, it is still not being saved to database and not being passed to payment gateway.

Further more, it is not safe as well. An experienced user can easily view source code of the page and then see that secret code, enter it to the field to get discount....

So that's a wrong approach.

Why don't you try to use coupon code feature in Events Booking for that purpose ?

Tuan

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

  • James Riley
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
10 years 2 months ago #61629 by James Riley
Replied by James Riley on topic Update Custom Fee Fields dynamically by javascript
Thanks for your response, Tuan.

I chose to ignore the fact that someone could hack their way through the javascript and discover the code (I don't think it'll be an issue with my clients). However, I didn't think about the database angle. As I said long ago: I'm more a code tweaker than an actual programmer, so I appreciate the insight on the "errors of my ways"!

My problem with using the standard coupon code is that I'm only able to offer this discount to full price registration. The discount registrations offered (eg. for students / commuters) via the RegistrationType fee field, are already reduced too far for me to offer an additional discount. As an aside, I also have the same problem with EarlyBird discounts (needing them to apply to Standard rates only, and not discounted rates; I've worked around this by simply making manually changes my Fee Values to compensate for earlybird vs non-earlybird pricing).

Perhaps I will look for a way to disable the coupon code based on the value of RegistrationType instead. Or I simply tell my customers that the code is ONLY to be used for full price, Standard registrations.

James Riley .: EventBooking user since 2014 ::: JoomDonation user since 2016 :.
.: grfx & web design / IT / AV @ St. Therese Institute of Faith and Mission, Bruno, SK, Canada :.

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

Moderators: Tuan Pham Ngoc