Menu Close

Get Support From ShopWired Close

All Systems Are Operational

Subscribe To Updates
Prefer To Live Chat? Chat directly with ShopWired support Available 9.00am to 7.00pm Monday to Friday
11.00am to 5.00pm Saturday
Quickest response time

Send A Message
Response within 24 hours

Menu Close

Menu

Send to a friend

Word of mouth is a great marketing method and adding a 'send to a friend' feature to your website can be a powerful way to increase sales on your store through viral marketing.

When combined with a referral programme, such as in the example above, you can provide a great incentive for your customers to refer their friends and for those they're referring to make the purchase.


How the feature works
GDPR compliance
Installation instructions (for all theme versions)
Implementing a referral link (to use as part of a referral system)
Customising the referral email


How does the feature work

The extension works to place a 'send to a friend' form on your website.

This form can either be directly on the product page or you can display a small information section and then the user clicks a button to bring up the form (as shown in the example below).

The email that's sent to the referred friend can be customised in your account in the same way as other emails. See below.

Many ShopWired users combine the send to a friend email system with the reward points app's referral features to offer their website visitors an incentive to recommend products to their friends.

To do so, a referring customer will need to be logged into a customer account in order for their unique referral link to be generated. If you're installing the extension code yourself this is described in more detail below.


GDPR compliance

The new GDPR (data protection) regulations came into effect on 25th May 2018. You can read more about them here. The 'send to a friend' feature described above is GDPR Compliant because your website is merely acting as the email sender (the recipient email address of the 'send to a friend' is not stored or captured through your website). You can read more here.


Installation instructions (all theme versions)

Once the extension is activated you'll need to add the relevant code to your website's files (described below). Select 'apps and extensions' from the left menu and then 'available extensions'. Find the 'send to a friend' extension and click to activate it on your account.

Adding the code will display the form for your visitors to complete. On submission of the form an email will then be generated to the referred friend.

The code provided below does not include CSS styling, so you'll need to use CSS in order to make the form appear nicely.

Instructions on how to make the email form appear in a pop-up (like our example below) are not included. To do so you'll need to use some HTML/JS to create a popup. If you're not familiar with this process, W3schools has a tutorial which you can follow (you will need HTML/CSS/JS experience).


Where to place the code

If you are using a theme of version 2 or earlier, your code will need to be placed within the product.twig file.

If you are using a theme of version 3 or later, your code will need to be placed within either the product.twig file or product_form.twig file.


Code example

<form action="{{ global.current_url }}" method="post">
    <input type="text" name="email_address">
    <textarea cols="30" rows="5" name="message"></textarea>
    <input type="text" name="{{ global.honeypot_field_name }}" autocomplete="off" class="hidden">
    {% if recommendation_recaptcha %}
        <div class="g-recaptcha"></div>
    {% endif %}
    <input type="hidden" name="redirect_path" value="/thanks">
    <input type="hidden" name="redirect_message" value="The email has been sent">
    <button name="send_recommendation_email" value="1">
        Send
    </button>
</form>

The code displayed above is the code required that generates the form to send the referral email.

Displaying Google's reCAPTCHA is a requirement for the form. The user will need to pass the reCAPTCHA test in order for the form to submit (this is to prevent abuse of the system by bots). You can read more about reCAPTCHA here.

Once the form has been submitted, you have two options for showing the customer a success message (to confirm the message has been sent). You should only implement one of these methods.


Redirecting to a different page

<input type="hidden" name="redirect_path" value="/thanks">

The code above will redirect the customer to another page. In this example, a page located at /thanks.


Keeping the user on the same page

<input type="hidden" name="redirect_message" value="The email has been sent">

The code above will keep the user on the current page (and refresh it) and show a success message from the bottom of the screen.


The message field

The message field, as shown below

<textarea cols="30" rows="5" name="message"></textarea>

Allows the user to enter the message that's sent with the email. You can predefine the message if you want to.


Additional information about the product

If you'd like to include details about the product automatically (prefilled in the message content) then you can include details using the product object, e.g. {{ product.url }} will output the URL of the product that's being referred.


Implementing a referral link

The example at the top of this page shows how the feature can be combined to give the referred customer a discount off their order. The referring customer will also receive a bonus too.

To implement this, you'll need to have the reward points app installed in your account and have it setup.

You can then write details about what each customer will get in reward for their friend making a purchase.

When using the referral scheme, each registered customer has a unique referral link which they give to their friends. This needs to be included in the email that's sent to the customer (in the message field).

The referring friend will need to be logged into a customer account in order for the referral URL to be generated, you can detect this using {% if global.customer.id %} (which will return TRUE if they are logged in).

<textarea cols="30" rows="5" name="message">Please check this out {{ product.url }}?{{ global.customer.referral_scheme_url|replace({'http://www.domain.com/?': '' }) }} and get £5 off your first order.</textarea>

In the example above, the referred customer is getting £5 off their first order.

The {{ product.url }} variable will create the link of the product, but without the referring customer's unique referral URL. In order to add this, we're using some additional code (and removing the domain name from the variable with the |replace filter (because the product.url variable already contains this). You'll need to substitute domain.com for your own domain.


Customising the referral email

The email that's sent to the friend can be customised like any other email that's sent out from your website. Follow the instructions here.

The email name is referral email.

The email has full access to the product object so other details about the product (like the image or price) can be included in the email.

The {{ message }} variable is used in the email to output the contents of the message entered by the referring friend.