Plugin Documentation by “MB Création” v2.0


“WooCommerce Sponsor a Friend Plugin”

Created: 30/01/2013
By: Benoit Mercusot
Email: benoit@mbcreation.net

Thank you for purchasing WooCommerce Sponsor a Friend Plugin. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much! Online documentation and demo : http://wsafp.mbcreation.net/


Table of Contents

  1. Introduction
  2. Translation
  3. Installation
  4. Quick Start
  5. Sponsor a Friend Scenario
  6. Available aliases in plugin settings
  7. Default email text (in case you messed up :) )
  8. Actions & Filters

A) Introduction - top

WooCommerce Sponsor a Friend is a great marketing plugin that allow your customers to become your ambassadors.

Once the plugin is set up it gives the opportunity to your customers to sponsor (or refer) friends by filling a simple form with their friends data (First Name, Last Name, Email address) and an optionnal message. If the form is okay (email must not already be in your active customers database), it will send an email containing a unique Coupon for that person. You decide the coupon type, the amount and the duration of that coupon.

Then, if the person uses the coupon to buy stuff on your website, the process goes on and the sponsor will receive a “Reward Coupon”by email. The Reward Coupon is automatically created at “the order completed” event. Since 2.0 the reward coupon settings are independant and can be different. You can also choose to allow sponsors to keep their coupon and accumulate reward on it everytime they refer a friend.

Both email uses native woocommerce email header and footer and you can off course customize the inner content. See “aliases” section bellow.


B) Translation - top

WooCommerce Sponsor a Friend is translation ready with .po and .mo files.
Including french (fr_FR) and almost english (en_US) translations (the one used on that demo site)


C) Installation - top

If you are upgrading from a previous installation. Replace your folder with the files. Deactivate then reactivate the plugin to populate the new available options in the database. Previous settings won't be deleted.

  1. Just like any WordPress plugin, unzip the plugin folder an copy paste it in your wp-content/plugins folder.
  2. As an administrator, activate the plugin in the plugin management of your WordPress
  3. You now have a new entry in the WooCommerce menu “Sponsor a friend” where you can edit settings.

D) Quick Start - top

  1. Create and publish a page to host the plugin shortcode : [wsafp-form-shortcode]. You are encouraged to add a graphic or text explanation about the process of sponsoring since the shortcode will only echo the form.
  2. Set the created page as the plugin page in WooCommerce Sponsor a Friend plugin page settings. Under the main WooCommerce menu.
  3. Modify as needed the coupon type, coupon amount, duration and minimum amount for both sponsors and refered friend coupons. And adapt html email content to reflect this changes and don't forget to mention the type of reduction you are offering. (% or € for exemple, just beside the {{amount}} placeholder)
  4. Save and promote your page !

F) Sponsor a Friend Scenario - top

At start there's a form in a page.

Then a request. (that can contain errors)

Or not

At this stage of the process, an email has been sent and a coupon created

Everything in the email can be modified.

So now the coupon can be used in checkout

To perform an order

The coupon has been used. Great news !

If everything is okay with the order. You complete it so a new coupon is created.

A special "Reward Coupon" to the sponsor that helped you gaining a new customer !

And here is the final step


G) Available placeholder in plugin settings - top

{{placeholder}} will be replaced with actual data when sending emails.

The invitation email :

Available aliases for email subjects & for email headings :

{{sponsor}} => name and first name of the sponsor
{{sitename}} => your sitename

Available aliases for email content :

{{sponsor}} => “User Billing Firstname User Billing LastName” (ie John Doe).
{{coupon}} => The coupon code (ie 15221313fdf).
{{amount}} => The amount of the coupon parsed by woocommerce_price() function.
{{sitename}} => bloginfo() (ie My Great Site).
{{message}} => The message left by the sponsor for his/her friend.
{{homeurl}} => Hyperlink to your home page with sitename as anchor (aka home_url())
{{email}} => The email used in form and used as the recipient. Match the coupon code (customer email)
{{validity}} => A well formated expiry date for coupon

The reward email :

Available aliases for email subjects :

{{friend}} => name and first name of the friend
{{sitename}} => your sitename

Available aliases for email headings :

{{friend}} => name and first name of the friend
{{sitename}} => your sitename

Available aliases for email content :

{{sponsor}} => Name and First name of the sponsor
{{friend}} => Name and first name of the friend
{{coupon}} => Coupon code
{{amount}} => Amount of the coupon code parsed by woocommerce_price()
{{sitename}} => Name of your site
{{homeurl}} => Hyperlink to your home page with sitename as anchor (aka home_url())
{{email}} => The email of the sponsor. Match the coupon code (customer email)
{{validity}} => A well formated expiry date for coupon


H) Default email text (in case you messed up :) ) - top

Default email text (in case you messed up)

The invitation email

{{sponsor}} thinks you should be shopping with {{sitename}} !
Message from {{sponsor}} :

{{message}}

As welcome gift, here’s a {{amount}} voucher you can use to discover our great products.

Personnel gift code : {{coupon}}
Email address associated with it *: {{email}}

See you soon on {{homeurl}} !

* You will need to use this email as the billing email address on checkout.

The reward email

Hi {{sponsor}},

{{friend}} just ordered on our site thanks to you !

As reward gift, here’s a {{amount}} voucher you can use to order great new products.

Personnel gift code : {{coupon}}
Email address associated with it *: {{email}}

See you soon on {{homeurl}} !

* You will need to use this email as the billing email address on checkout.


I) Actions & filters - top

We spent a lot of time adding a lot of extra filters and action in the latest release of the plugin.
You should be able with them to change almost every message or variable used by the plugin to make the tool fits your exact needs. Just look in code and find the perfect spot the hook correcty.

Here are some filters you might certainly use :

  1. wsafp_coupon_coupon_code_filter : to change the coupon name. By default it is a php uniqid().
  2. wsafp_form_shorcode_buttonlabel_filter : to modify the text of the button in the form.
  3. wsafp_form_shorcode_html_filter : for the entire html form markup

Here are some actions you might certainly use :

  1. wsafp_coupon_generate_code_promo($coupon_id) : to do stuff with the newly created coupon for the refered friend.
  2. wsafp_coupon_generate_code_promo_sponsor($coupon_id) : to do stuff with the newly created coupon for the sponsor

Benoit Mercusot

Go To Table of Contents