Magento Discount Coupon Code for Facebook Likes

created June 22, 2012, last updated May 15, 2013.

.
closeThis post was last updated 11 years 8 months 29 days ago, some of the information contained here may no longer be actual and any referenced software versions may have been updated!

The Facebook “Like” is an important Social Media Marketing tool. It instills customer confidence and enables new marketing opportunities. Increasing the number of likes your e-Commerce site has can sometimes be difficult but one way to really boost those likes is to offer a reward in the form of a discount code if customers like your Facebook page.

I wanted to accomplish this with a standalone PHP application embedded into a Facebook page tab. The goals were to step the customer through connecting with the Facebook application, liking the page and generating / managing the discount codes and Magento coupons.

We want to take full advantage of the marketing information we can glean from Facebook so another requirement was so store the customers Facebook profile information in a database along with the generated discount code.

We can also generate a wall post on the customers Facebook wall to ensure our offer is shared with their Facebook friends.

The application uses the Facebook API to communicate with Facebook and loads Magento externally to generate the Magento coupon sales rules dynamically.

Here are the main features of the application:

1. Connect the customer to the Facebook application and save the customers Facebook profile information  to a MySQL database.

2. Get the customer to click the Like button for this Facebook page

Customer has connected with the application in Facebook and must click the Like button to continue.

 

 

3. Generate discount code and Magento coupon.

Customer has liked the page , the discount code and Magento coupon are dynamically generated and displayed to the customer.

 

and post to the customers Facebook wall (optional).

Share the love, an automatic wall post is created when a discount code is issued.

 

4. Manage subsequent attempts to generate codes by the same Facebook user. Of course customers can create multiple Facebook accounts to obtain codes so your discount amount has to be thought out properly and relevant terms and conditions applied to try and prevent abuse. How much are Facebook likes worth to you?  A good idea would be to make the discounts valid for a certain spend amount, $15 discount when you spend over $100 for example. Remember if you already have 1,000 likes on your Facebook page, you are potentially giving away 1,000 discount codes to existing customers as this application does not distinguish between new and old likes!

A discount code has already been generated for this Facebook account.

 

The customer can now copy and paste the code directly into the Magento frontend store coupon box.

Generated discount code is entered at checkout and discount is shown in cart.

 

Test the application here.

Download the application source code here check out the readme file for installation instructions. The main installation requirements are

PHP5.x/MYSQL
Public webspace on the same server as your Magento installation
A valid configured Facebook Tab application.
Magento 1.3+

Edit the config.php file with your configuration settings and create the database and database table using the SQL in the readme file.

This could be developed as a Magento module too, the advantages I can see for a module would be to allow the whole process to run within your Magento shop instead of a Facebook page tab.

 

 

 

 

Comments

  1. Pat says:

    Hey! Any success stories? The test link does not seem to work…will try the code anyways… hoping for the best. thx!

    • PAJ says:

      It’s not a module, its a standalone php app that integrates with your magento intall. The download link is in the blog post above.

  2. seema says:

    Hi, I integrate as per mention in readme file and also create apps and page after we click on site.com/TEST its redirect to my page.But after when I click on like page its nothing redirect. can you please help me to short out this issue.

  3. jonn says:

    I have the same problem as seema, and can some one please explain what to do with these secure url, i dont want to buy ssl, exist some other solutions?!

    • PAJ says:

      There is not much you can do about the SSL requirement, Facebook must provide its customers with an HTTPS secure connection which means if your tab does not support SSL then it will not work for Facebook users who only view facebook over an SSL connection. I would say that SSL for a Magento site is a requirement. You want to instill trust in your customers when they register, checkout and provide payment info. I haven’t looked at this code for a while but if you provide me with the access details to your site I will have a look.

  4. seema says:

    Hello,
    I am still facing the same problem i have done my config file like this

    const appURL = ‘http://apps.facebook.com/435766836501898/’;
    // The URL to the facebook page or tab
    const fbURL = ‘http://www.facebook.com/pages/eshishdirectcom/455022474569787?sk=app_435766836501898&app_data’;
    // image file to use as an icon for facebook wallposts etc.
    and configured database details as well in config.php file
    now when i run site.com/coupon/index.php it goes to facebook page nothing is happening .can you please help me with this issue

    seema

  5. James Ludlow says:

    Had a problem with the FB App page constantly reloading (which I believe is the same problem some of the commentators above me have had).

    Traced it down to a line of JavaScript right at the bottom of /php/class.PageMainHTML.php – line 105:
    return document.referrer.indexOf(“apps.facebook.com”) != -1;

    I believe this should be:
    return document.referrer.indexOf(“apps.facebook.com”) === -1;

    • PAJ says:

      The app will include this javascript in the html if you set the allowstandalone variable in the config to false. It checks if the app is running within a facebook frame or not and redirects. Set allowstandalone to true if you are debugging the app.

      • James Ludlow says:

        But if “apps.facebook.com” is NOT in the document.referrer string, then it will return -1, therefore returning false.

        Surely it should be === -1, so that it returns true?

        Also, the SQL code to create the database misses the ’email’ field.

        And lastly, I’ve got it all working within a tab on my Facebook Page – it displays the page when I haven’t Liked the page, but once I press the Like button, the page refreshes but shows a blank page. If I refresh I’m then presented with the page saying that I’ve already been issued with a discount code. If I look at the database, the discount code has been generated, so something seems to be stopping the display of the page in between the code being created and the page being rendered?

      • PAJ says:

        Hmmm, you could be right about that. I have actually revamped the whole thing in the last couple of weeks for another project and used another method of detecting if the app is running in Facebook. The new version also runs as a normal facebook canvas app as mobile devices do not see facebook tab apps. I improved the like logic and changed the way the code is displayed to the customer, it also has the ability to validate the code within Magento, and to restrict the code to the users email address, this means users must have an account in the shop registered with the same email address they obtain the facebook code with. This stops people from getting multiple codes from friends, family, new accounts etc. You can see it under the tabs on my facebook page as DEV Discount. If you are interested in the code I can send it to you, its not on my git hub yet. Thanks for the note about the DB file missing a column, I have fixed that, but will probably replace this version of the app with the newer version soon.

  6. Sagar says:

    I have set up the app as per instruction but not able to generate coupon and nor share any thing on our wall

  7. Manh Tu says:

    Hello PAJ,

    I install your app, i’am facing same problem with James Ludlow: the discount code has been generated in database but no code has been displayed for customer.
    Could you please send the new code to me ?

    Thank you in advance.
    Tu

  8. Lou says:

    Your extensions looks really good but after setting up Fb App , the sql
    With standalone true and debug on , I have the following php error with different php version 5.3 to 5.5 , do you have any update of your extension
    changing the php error level doesnt change , still have this issue 🙁 and even i like the page the coupon discountvoucher1.png come back

    Thanks if you could provide some help
    (
    [type] => 2048
    [message] => Non-static method applicationCredentials::load() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/config/applicationConfig.php
    [line] => 139
    )
    (
    [type] => 2048
    [message] => Non-static method applicationCredentials::load() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/config/applicationConfig.php
    [line] => 139
    )
    (
    [type] => 8
    [message] => Undefined index: signed_request
    [file] => /var/www/html/test/php/class.DecodeSignedLikeRequest.php
    [line] => 43
    )
    (
    [type] => 8
    [message] => Undefined offset: 1
    [file] => /var/www/html/test/php/class.DecodeSignedLikeRequest.php
    [line] => 60
    )
    (
    [type] => 8
    [message] => Undefined index: discountCodeMessage
    [file] => /var/www/html/test/php/class.Application.php
    [line] => 214
    )
    (
    [type] => 2048
    [message] => Non-static method applicationCredentials::load() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/config/applicationConfig.php
    [line] => 139
    )
    (
    [type] => 2048
    [message] => Non-static method PageMainData::loadConfig() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/php/class.PageMain.php
    [line] => 41
    )
    (
    [type] => 2048
    [message] => Non-static method PageMainData::menuHTML() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/php/class.PageMain.php
    [line] => 43
    )
    (
    [type] => 2048
    [message] => Non-static method PageMainHTML::html() should not be called statically, assuming $this from incompatible context
    [file] => /var/www/html/test/php/class.PageMain.php
    [line] => 46
    )
    (
    [type] => 8
    [message] => Undefined variable: _pageHtml
    [file] => /var/www/html/test/php/class.PageMain.php
    [line] => 146
    )

    • PAJ says:

      I dont plan to update this module any time soon, sorry. Also Facebook will ban applications that require a like as an incentive for something, so it is likely that this app would not pass facebooks standards anymore. Eventually I will get around to rewriting all my apps to support the new facebook SDK and PHP 5.5+ but at the moment I do not have the time to look at it.

      • Bob says:

        That’s a shame. I was looking for an App that worked exactly as you had it originally. No change in hell that this will ever get updated?

This site uses Akismet to reduce spam. Learn how your comment data is processed.