How To Create Coupon From Username At Registration

  • Posts: 17
  • Thank you received: 0
4 months 3 weeks ago #306058

Is it possible for somehow when a user signs up on my site, when their account is created a promo code/discount/coupon is automatically created from their username?

So basically, when John signs up with the username; john37 , when he presses register on the default Joomla registration form it creates a coupon with the code; john37


Is there any way to do this?

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

  • Posts: 66841
  • Thank you received: 9875
  • MODERATOR
4 months 2 weeks ago #306079

Hi,

Yes. You can do that with AcyMailing and the tag integration we have with it.
With AcyMailing, you can configure it to send an email automatically after the user registration. And in that email, you can use the HikaShop coupon tag to generate a HikaShop coupon and replace the tag in the email by the code of the coupon:
www.acyba.com/acymailing/161-acymailing-...hikashop.html#coupon

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

  • Posts: 17
  • Thank you received: 0
4 months 2 weeks ago #306081

Would this require the registration to be done via AcyMailing?

And would the coupon be able to be their username? I can't seem to see username in the code variables?

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

  • Posts: 66841
  • Thank you received: 9875
  • MODERATOR
4 months 2 weeks ago #306085

Hi,

No, it will work with the registration done through Joomla or HikaShop's registration forms (AcyMailing doesn't have a registration form).

Regarding the username, I checked in the code of the plugin and it doesn't support it.
It would require some code modification to the acymailing-hikashop integration to support it.
In the file plugins/acymailing/hikashop/hikashop.php you can find this line which replaces the tags:

$code = str_replace(array('[name]', '[clean_name]', '[subid]', '[email]', '[key]', '[flat]', '[percent]', '[value]', '[prodid]'), array($user->name, $clean_name, $user->subid, $user->email, $key, $flat_amount, $percent_amount, $value, $product_id), $code);
Unfortunately, $user doesn't contain the information of the username and so to handle it would require loading the user with a MySQL query and then do the replacement. It's possible but it will require some development.

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

  • Posts: 17
  • Thank you received: 0
4 months 2 weeks ago #306111

What about instead of creating a plugin to do all this, couldn't there just be a line of code added to the registration that inserts the username entered into the MySQL table for the discounts?

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

  • Posts: 66841
  • Thank you received: 9875
  • MODERATOR
4 months 2 weeks ago #306124

Hi,

That could be a solution yes.
Here is some documentation on how to create a Joomla plugin for the registration:
www.informit.com/articles/article.aspx?p=1858258&seqNum=5
This is compatible with HikaShop's registration too.
Then, in the plugin, you can do that MySQL query to insert the coupon in the hikashop_coupon table.

The following user(s) said Thank You: workspace

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

  • Posts: 17
  • Thank you received: 0
4 months 2 weeks ago #306128

Thank you, I have succeeded with this by adding some PHP to the registration.php file that when the user registers it adds the username as a coupon. However I will definitely look into your link and learn to make a plugin as that is a more preferred method than having to put code in the core files. Thank you for that.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum