Auto-generated coupons

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 3 months ago #108094 by sebba
Auto-generated coupons was created by sebba
Hello there,

I'm a "brand new" user of this component.
I manage a sailing school and I have to manage courses which consist in 2 parts.
A part for theory course and a part for practical course. Each part have different location and date.
So, when I have to provide a complete sailing course, I have to manage two different events

The problem is I cannot "sell" only the theory course, I have to sell a bundle (theory + practice, with different dates and locations).
But I am allowed to sell the practical course as a stand-alone course, for people which need additional practice.

I tried to use BUNDLE but is not an easy way because for each BUNDLE I have to specify the DATE for events, not only the type of them (or category)

My idea is to have an option in the event's setup for auto-generating customized coupon(s) for each paid registration.
When somebody book this event will receive also this auto-generated coupon.

If the coupon will provide a 100% discount, the participant will use it for booking the second event for free. (depending on auto-generated coupon's details)

To simplify the code for generating the coupon I think will be OK to use the payment transaction ID as the coupon code.
This ID will be available after a payment and will be unique for each payment/customer

Or, if this could be done easier... please let me know

Kind regards,
Seb

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109003 by sebba
Replied by sebba on topic Auto-generated coupons
After a lot of wasted nights I managed to make a plugin which will auto-generate coupon codes for any successful payment of the selected events.
I also want to send many thanks for Tuan which help me a lot.

It is not 100% ready (which is? :D ) but I think I can name it as a Beta Release version! :)

How is working?
Let's say you have two events: A and B, each event with it's own price.
But you want to let the registered members of A to book for free the B
This plugin will allow you to set event A (when a payment occur) to generate a coupon which will be valid for event B and only for the registered member which made the payment.
Applying the auto-generated coupon, that member will book the B event for free.

After installing and activating the plugin a new tab will be available in the event's editing area named Auto-Generated Coupons
Here you'll find an unfinished but technically functional page. I have to reorder some input fields and to create some drop-down menus instead of simple input text forms.
But I think you can use it after a short explanation.

In the first row of the table you'll find the following input forms:

"Coupon valid for Event ID" - in this column you have to enter the ID of the event for AG coupons will be available. It have to be a PARENT event. If this event is a recurrent event, the generated coupon will be available for all it's children. Here I have to replace the input text form with a drop-down menu.

"Coupon Value" - here you'll have to enter the coupon's value.

"Discount type" - input 0 for "Percent" or 1 for fixed amount. Here, too, I have to replace this form with a radio-type selector.

"Times" - for how many times the coupon could be applied. Usually 1

"Validity days" - number of day - starting with the payment's date - the coupon will be valid. Enter 0 for unlimited

ATTENTION: even you can add more rows in that form, only values from first row will be processed, EXCEPT first column, for Event ID. This will allow you to have the generated coupon valid for many events.
Add only one event ID per row.
Add any rows you want

The plugin work only for "parent events", even these events are single events or recurring events.
For recurring events, all these settings will be automatically valid for any children of the parent event, so the entire series of this event will auto-generate if some payment occur.
For now is not possible to select single child event. Maybe in the future I'll implement this feature, if required.

Saving the event will save this settings, too
Editing values from first row or events from first column is ok, make all modifications you want and "save event"

The generated coupons are applying "for each registration", not for "each member"
If a group registration will occur, the coupon's value will be multiplied by the number of members of the group.

The generated coupons could be visible in "Coupons" administration page of EB component.
After someone (member) will make a registration and after the payment is done, the coupon will be automatically created.
For now, the coupon code, value and validity date is visible in a notice which appear for any event where the coupon can be applied.
Maybe I'll can handle a way for automatically applying the coupon when booking "paired" events.

If the coupon was used, it will be un-publish but will remain in the "Coupons" list (in the administration of EB)
Also, all initially available events of this coupon are deleted, except the event which used the coupon"

This is a work in progress and I almost forgot a lot of php/mysql stuff... And Joomla... it was totally unknown until now. :)
So please don't laugh if something is not made in the proper way! :D :) :)

All comments are welcome!

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109004 by sebba
Replied by sebba on topic Auto-generated coupons
I forgot to write about sql tables
You have to add a new table in your database
#__eb_autocoupons

I don't know to make an autoinstall for adding this table so I'll pun an export from my table.
Maybe somebody will help me to put it into the plugin's zip file

thanks

Attachment not found

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109008 by sebba
Replied by sebba on topic Auto-generated coupons

sebba wrote: ATTENTION: even you can add more rows in that form, only values from first row will be processed, EXCEPT first column, for Event ID.


I made a mistake in my previous post, sorry
Instead the quoted text, please read bellow:

all values for value, discount type, times and validity, except first cell (event_id), should have the same value
I'll try to fix this page ASAP

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109057 by sebba
Replied by sebba on topic Auto-generated coupons
Last update
I managed to fix some issues
Also, the database table will be automated created when install
Just install the plugin and enable it then go into any event and look for "Auto-Generated Coupons" tab
Attachments:

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109232 by sebba
Replied by sebba on topic Auto-generated coupons
v1.0 available

--- changelog ---
+ sending email with the autogenerated coupons to the user which made the reservation;
+ adding editor for email's body with [TAGS] available (available in plugin's setup)
+ adding recalculation function for coupons which have a value bigger than the registration value where coupon code applied

File Attachment:

File Name: plg_eb_aut...v1.0.zip
File Size:9 KB



The recalculation function of the coupon's value will be used when the initial registration (which will generate auto-coupons) is made for a group of participants but the coupon will be applied for the "paired" event in a registration with a lower number of participants.
Let's say a member will made a registration for a group of 4 participants, for the initial event. After the payment is made he will receive a coupon code which will have a value of "coupon_value" x "goup's_members_number" and will use this coupon to register for free at the second event (the paired event)
But not all the group's members will be able to go in the same time at the second event.
Having this recalculation function, the coupon's value is recalculated if it's value is bigger than the registration for the second event's value, until will be totally used.

In my config I used to generate coupons with fixed amount value (not percent), value which is equal with the individual price of the second event. I intend to sell packages of events, where the price of the second event is included in the price of first event. Or, for anybody who made a reservation of the first event will get for free access to the second (paired) event.

---

a list of available tags available in the email's body editor:
[AGC_CODE] - coupon code
[AGC_VAL] - individual value of the coupon
[AGC_REGISTRANTS] - nr. of the registrants (for calculating the total value of the coupon)
[AGC_TOTAL_VAL] - total value of the coupon
[AGC_VALID_UNTIL] - validity of the coupon (0 for unlimited, +xx for xx days after the payment date)
[AGC_ACTIVE_EVENT] - ID if the event which generated the coupon
[NAME] - name of the member which made the registration
[AGC_EVENT_TITLE] - title of the event which generated the coupon
[AGC_EVENT_DATE] - date of the event which generated the coupon
[AGC_EVENT_END_DATE] - end date
[AGC_VALID_FOR] - list of events where the generated coupon could be applied

---

still working
...
Attachments:

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #109325 by sebba
Replied by sebba on topic Auto-generated coupons
v1.1

+ adding fields for editing the message body of the email which is sent when a coupon's value is updated
+ available [TAGS] are displayed in the form and now there are available for email's subject, too
+ added toggle button for the type of discount (percent or fixed amount)

File Attachment:

File Name: plg_eb_aut...v1.1.zip
File Size:9 KB
Attachments:

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

More
7 years 1 month ago #110537 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Auto-generated coupons
Thanks for sharing the code. Just want to update that in latest version, we have now have similar plugin. The coupon code will be sent in the confirmation email to registrant (It is sent in [REGISTRATION_DETAIL] tag or you can use the tag [AUTO_COUPON_CODE])

Regards,

Tuan

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

  • sebba
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 1 month ago #110538 by sebba
Replied by sebba on topic Auto-generated coupons
wow, nice!
I hope my work was useful for you

Regards,
Seb

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

More
7 years 1 month ago #110539 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Auto-generated coupons
To be honest, I didn't look at your code. But the idea is nice and could be useful in some case

Tuan

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

Moderators: Tuan Pham Ngoc