Skip to content

Instantly share code, notes, and snippets.

@zsy715
Last active November 11, 2020 03:09
Show Gist options
  • Save zsy715/509f4d45c992032b86327f827e986715 to your computer and use it in GitHub Desktop.
Save zsy715/509f4d45c992032b86327f827e986715 to your computer and use it in GitHub Desktop.

RAF codes have been already created in referral_code table(I guess it's created along with new account)

Both referral and nudge email are sent by magento via cron job:

  • Refering a Friend
  • code:
  • cron: REFERRAL_EMAIL_TEMPLATE_ID
    ADVENT_EMAIL_TEMPLATE_ID we have referral invitation without email template id since 2017/12/13 last time we sent raf_code='__advent' is 2017/12/13

That being said, recent email template should be refer_a_friend which can be fetched by querying select * from core_email_templatewheretemplate_code like '%ref%' in magento db.
Then, magento sent out emails here
Finally, update sent_at field for referral_invation and save it

  • send nudge fetch email template based on CONFIG_NUDGE_TEMPLATE here. It checks store config enterprise_reward/notification/nudge_template in core_config_data table and retrieve template id 76. Then fetch template in table core_email_template according to template_id
  • Friend has subscribed - send reward notification after referral order a subscription which is triggered by sales_order_place_after eventconfig here. Then onOrderSuccess->linkReferrerToOrder(try to find and attach rafcode to existing ref conversion)->awardPointsForRaf->sendRewardNotificationEmail in referral helper->then query enterprise_reward/notification/points_awarded_template in core_config_data which return 54 as template_id.
## US
SERVER_NAME=www.birchbox.com
0,10,20,30,40,50 * * * * cd $BASEDIR/_birchboxadmin/raf && php -f send_raf_emails.php 2>&1 | $LOG_WRAPPER >> $LOGDIR/send_raf_emails.log

## ES
SERVER_NAME=www.birchbox.es
4,14,24,34,44,54 * * * * cd $BASEDIR_ES/_birchboxadmin/raf && php -f send_raf_emails.php 2>&1 | $LOG_WRAPPER >> $LOGDIR_ES/send_raf_emails.log 

## UK
SERVER_NAME=www.birchbox.co.uk
6,16,26,36,46,56 * * * * cd $BASEDIR_UK/_birchboxadmin/raf && php -f send_raf_emails.php 2>&1 | $LOG_WRAPPER >> $LOGDIR_UK/send_raf_emails.log 

referral helper template code
Refering a Friend(33) . Reminder(76)
Friend Has Reserved(57) also has 55 which is the same as 57 Friend has subscribed(54) Friend Feedback Survey(56)

curl -X POST -H "x-session-id:xxxxx" -d "email=xxx@xxx" 'https://api.b.c/user/referrals'
curl -X POST -H "x-session-id:xxxxx" -d "email=xxx@xxx" 'https://api.b.c/user/referrals/:id/nudge'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment