From 111f4add150657ca25724ac4910535e2cb40549d Mon Sep 17 00:00:00 2001
From: Bohdan Zhuravel <bohdan@zhuravel.bz>
Date: Fri, 15 Jan 2016 23:20:36 +0200
Subject: [PATCH] 1.0.0 Release

---
 .../SocialReferrals/Block/Affiliate.php       |  14 --
 .../Block/Customer/Dashboard.php              |  14 --
 .../Talkable/SocialReferrals/Helper/Data.php  | 189 +++++++++---------
 .../SocialReferrals/Model/Observer.php        |   2 +-
 .../Customer/DashboardController.php          |   2 +-
 .../controllers/IndexController.php           |   2 +-
 .../Talkable/SocialReferrals/etc/config.xml   |  32 +--
 .../Talkable/SocialReferrals/etc/system.xml   | 169 +++-------------
 .../layout/talkable/socialreferrals.xml       |  25 ++-
 .../socialreferrals/advocate_dashboard.phtml  |  31 +++
 .../floating_widget_popup.phtml               |  33 +++
 .../{dashboard.phtml => head.phtml}           |  11 +-
 .../talkable/socialreferrals/invite.phtml     |  16 +-
 .../socialreferrals/post_purchase.phtml       |  12 +-
 package.xml                                   |  17 +-
 15 files changed, 229 insertions(+), 340 deletions(-)
 delete mode 100644 app/code/community/Talkable/SocialReferrals/Block/Affiliate.php
 delete mode 100644 app/code/community/Talkable/SocialReferrals/Block/Customer/Dashboard.php
 create mode 100644 app/design/frontend/base/default/template/talkable/socialreferrals/advocate_dashboard.phtml
 create mode 100644 app/design/frontend/base/default/template/talkable/socialreferrals/floating_widget_popup.phtml
 rename app/design/frontend/base/default/template/talkable/socialreferrals/{dashboard.phtml => head.phtml} (62%)

diff --git a/app/code/community/Talkable/SocialReferrals/Block/Affiliate.php b/app/code/community/Talkable/SocialReferrals/Block/Affiliate.php
deleted file mode 100644
index f9560a2..0000000
--- a/app/code/community/Talkable/SocialReferrals/Block/Affiliate.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-/**
- * Talkable SocialReferrals for Magento
- *
- * @package     Talkable_SocialReferrals
- * @author      Talkable (http://www.talkable.com/)
- * @copyright   Copyright (c) 2015 Talkable (http://www.talkable.com/)
- * @license     MIT
- */
-
-class Talkable_SocialReferrals_Block_Affiliate extends Mage_Core_Block_Template
-{
-
-}
diff --git a/app/code/community/Talkable/SocialReferrals/Block/Customer/Dashboard.php b/app/code/community/Talkable/SocialReferrals/Block/Customer/Dashboard.php
deleted file mode 100644
index aa3410b..0000000
--- a/app/code/community/Talkable/SocialReferrals/Block/Customer/Dashboard.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-/**
- * Talkable SocialReferrals for Magento
- *
- * @package     Talkable_SocialReferrals
- * @author      Talkable (http://www.talkable.com/)
- * @copyright   Copyright (c) 2015 Talkable (http://www.talkable.com/)
- * @license     MIT
- */
-
-class Talkable_SocialReferrals_Block_Customer_Dashboard extends Mage_Core_Block_Template
-{
-
-}
diff --git a/app/code/community/Talkable/SocialReferrals/Helper/Data.php b/app/code/community/Talkable/SocialReferrals/Helper/Data.php
index 810b73b..63e3e58 100644
--- a/app/code/community/Talkable/SocialReferrals/Helper/Data.php
+++ b/app/code/community/Talkable/SocialReferrals/Helper/Data.php
@@ -11,9 +11,9 @@
 class Talkable_SocialReferrals_Helper_Data extends Mage_Core_Helper_Abstract
 {
 
-    //------------------+
-    // Default Settings |
-    //------------------+
+    //------------------------+
+    // Talkable Configuration |
+    //------------------------+
 
     public function getSiteId()
     {
@@ -22,120 +22,131 @@ public function getSiteId()
 
     public function getIntegrationJsUrl()
     {
-        $retval = $this->_getTextConfigValue("general/integration_js_url");
-
-        if ($retval == "") {
-            return "//d2jjzw81hqbuqv.cloudfront.net/integration/talkable-1.0.min.js";
-        } else {
+        if ($retval = $this->_getTextConfigValue("general/integration_js_url")) {
             return $retval;
+        } else {
+            return Mage::getConfig()
+                ->loadModulesConfiguration("config.xml")
+                ->getNode("default/socialreferrals/general")
+                ->integration_js_url;
         }
     }
 
-    //------------------------+
-    // Post-Checkout Campaign |
-    //------------------------+
+    //--------------------+
+    // Talkable Campaigns |
+    //--------------------+
 
     /**
-     * @return bool Whether or not Post-Checkout Integration is enabled
+     * @return bool Whether or not Talkable Integration is enabled
      */
-    public function isPurchaseEnabled()
+    public function isEnabled()
     {
-        return $this->_getBoolConfigValue("purchase/enabled");
+        return (
+            $this->isInviteEnabled() ||
+            $this->isPostPurchaseEnabled() ||
+            $this->isAdvocateDashboardEnabled() ||
+            $this->isFloatingWidgetPopupEnabled()
+        );
     }
 
-    public function getPurchaseCampaignTags()
+    /**
+     * @return bool Whether or not Post Purchase Integration is enabled
+     */
+    public function isPostPurchaseEnabled()
     {
-        return $this->_getListConfigValue("purchase/campaign_tags");
+        return $this->_getBoolConfigValue("campaigns/post_purchase");
     }
 
-    public function getPurchaseData($order)
+    /**
+     * @return bool Whether or not Invite Integration is enabled
+     */
+    public function isInviteEnabled()
     {
-        $retval = array(
-            "order_number" => $order->getIncrementId(),
-            "order_date"   => $order->getCreatedAt(),
-            "subtotal"     => $order->getSubtotal(),
-            "coupon_code"  => $order->getCouponCode(),
-            "customer_id"  => $order->getCustomerId(),
-            "email"        => $order->getCustomerEmail(),
-            "first_name"   => $order->getCustomerFirstname(),
-            "last_name"    => $order->getCustomerLastname(),
-            "items"        => array(),
-        );
-
-        foreach ($order->getAllVisibleItems() as $product) {
-            $retval["items"][] = array(
-                "product_id" => $product->getSku(),
-                "price"      => $product->getPrice(),
-                "quantity"   => $product->getQtyOrdered(),
-                "title"      => $product->getName(),
-            );
-        }
-
-        return $retval;
+        return $this->_getBoolConfigValue("campaigns/invite");
     }
 
-    //-----------------+
-    // Invite Campaign |
-    //-----------------+
-
     /**
-     * @return bool Whether or not Standalone Integration is enabled
+     * @return bool Whether or not Advocate Dashboard Integration is enabled
      */
-    public function isAffiliateEnabled()
+    public function isAdvocateDashboardEnabled()
     {
-        return $this->_getBoolConfigValue("affiliate/enabled");
+        return $this->_getBoolConfigValue("campaigns/advocate_dashboard");
     }
 
-    public function getAffiliateCampaignTags()
+    /**
+     * @return bool Whether or not Floating Widget Popup Integration is enabled
+     */
+    public function isFloatingWidgetPopupEnabled()
     {
-        return $this->_getListConfigValue("affiliate/campaign_tags");
+        return $this->_getBoolConfigValue("campaigns/floating_widget_popup");
     }
 
-    public function getAffiliateIframeOptions()
+    //-------------+
+    // Origin Data |
+    //-------------+
+
+    public function getPurchaseData($order)
     {
-        return $this->_getIntegrationIframeOptions("affiliate");
+        $shippingAddress = $order->getShippingAddress();
+        $countryName = Mage::getModel("directory/country")
+            ->loadByCode($shippingAddress->getCountryId())
+            ->getName();
+
+        $shippingFields = array_filter(array(
+            implode(", ", $shippingAddress->getStreet()),
+            $shippingAddress->getCity(),
+            $shippingAddress->getRegion(),
+            $shippingAddress->getPostcode(),
+            $countryName,
+        ));
+
+        $retval = array(
+            "customer" => array(
+                "email"        => $order->getCustomerEmail(),
+                "first_name"   => $order->getCustomerFirstname(),
+                "last_name"    => $order->getCustomerLastname(),
+                "customer_id"  => $order->getCustomerId(),
+            ),
+            "purchase" => array(
+                "order_number" => $order->getIncrementId(),
+                "order_date"   => $order->getCreatedAt(),
+                "subtotal"     => $this->_normalizeAmount($order->getSubtotal()),
+                "coupon_code"  => $order->getCouponCode(),
+                "items"        => array(),
+                "shipping_zip" => $shippingAddress->getPostcode(),
+                "shipping_address" => implode(", ", $shippingFields),
+            ),
+        );
+
+        foreach ($order->getAllVisibleItems() as $product) {
+            $retval["purchase"]["items"][] = array(
+                "product_id" => $product->getSku(),
+                "price"      => $this->_normalizeAmount($product->getPrice()),
+                "quantity"   => strval(round($product->getQtyOrdered())),
+                "title"      => $product->getName(),
+            );
+        }
+
+        return $retval;
     }
 
-    public function getAffiliateData()
+    public function getCustomerData()
     {
         $helper = Mage::helper("customer");
 
         if ($helper->isLoggedIn()) {
             $customer = $helper->getCustomer();
-            return array("affiliate_member" => array(
+            return array(
                 "email"       => $customer->getEmail(),
                 "first_name"  => $customer->getFirstname(),
                 "last_name"   => $customer->getLastname(),
                 "customer_id" => $customer->getId(),
-            ));
+            );
         } else {
-            $emptyObject = new stdClass();
-            return array("affiliate_member" => $emptyObject);
+            return new stdClass();
         }
     }
 
-    //--------------------+
-    // Dashboard Campaign |
-    //--------------------+
-
-    /**
-     * @return bool Whether or not Dashboard Integration is enabled
-     */
-    public function isDashboardEnabled()
-    {
-        return $this->_getBoolConfigValue("dashboard/enabled");
-    }
-
-    public function getDashboardCampaignTags()
-    {
-        return $this->_getListConfigValue("dashboard/campaign_tags");
-    }
-
-    public function getDashboardIframeOptions()
-    {
-        return $this->_getIntegrationIframeOptions("dashboard");
-    }
-
     //---------+
     // Private |
     //---------+
@@ -145,34 +156,14 @@ private function _getBoolConfigValue($path)
         return (bool) Mage::getStoreConfig("socialreferrals/" . $path);
     }
 
-    private function _getListConfigValue($path)
-    {
-        return array_filter(array_map("trim", explode(",", Mage::getStoreConfig("socialreferrals/" . $path))));
-    }
-
     private function _getTextConfigValue($path)
     {
         return trim(Mage::getStoreConfig("socialreferrals/" . $path));
     }
 
-    private function _getIntegrationIframeOptions($path)
+    private function _normalizeAmount($value)
     {
-        $width  = $this->_getTextConfigValue($path . "/iframe_width");
-        $width  = strpos($width, "%") !== false ? $width : (int) $width;
-
-        $height = $this->_getTextConfigValue($path . "/iframe_height");
-        $height = strpos($height, "%") !== false ? $height : (int) $height;
-
-        $container = $this->_getTextConfigValue($path . "/iframe_container");
-
-        return array(
-            "responsive" => $this->_getBoolConfigValue($path . "/iframe_responsive"),
-            "iframe"     => array(
-                "container" => $container ? $container : "talkable-container",
-                "width"     => $width     ? $width     : "100%",
-                "height"    => $height    ? $height    : 960,
-            ),
-        );
+        return number_format((float) $value, 2, ".", "");
     }
 
 }
diff --git a/app/code/community/Talkable/SocialReferrals/Model/Observer.php b/app/code/community/Talkable/SocialReferrals/Model/Observer.php
index fe853c1..96ac60a 100644
--- a/app/code/community/Talkable/SocialReferrals/Model/Observer.php
+++ b/app/code/community/Talkable/SocialReferrals/Model/Observer.php
@@ -13,7 +13,7 @@ class Talkable_SocialReferrals_Model_Observer extends Mage_Core_Model_Abstract
 
     public function customerDashboardLink(Varien_Event_Observer $observer)
     {
-        if (Mage::helper("socialreferrals")->isDashboardEnabled()) {
+        if (Mage::helper("socialreferrals")->isAdvocateDashboardEnabled()) {
             $observer->getEvent()->getLayout()->getUpdate()->addHandle("customer_dashboard_handle");
         }
     }
diff --git a/app/code/community/Talkable/SocialReferrals/controllers/Customer/DashboardController.php b/app/code/community/Talkable/SocialReferrals/controllers/Customer/DashboardController.php
index 8f80fc8..2bc9c9f 100644
--- a/app/code/community/Talkable/SocialReferrals/controllers/Customer/DashboardController.php
+++ b/app/code/community/Talkable/SocialReferrals/controllers/Customer/DashboardController.php
@@ -13,7 +13,7 @@ class Talkable_SocialReferrals_Customer_DashboardController extends Mage_Core_Co
 
     public function indexAction()
     {
-        if (Mage::helper("socialreferrals")->isDashboardEnabled()) {
+        if (Mage::helper("socialreferrals")->isAdvocateDashboardEnabled()) {
             $this->loadLayout();
             $this->renderLayout();
         } else {
diff --git a/app/code/community/Talkable/SocialReferrals/controllers/IndexController.php b/app/code/community/Talkable/SocialReferrals/controllers/IndexController.php
index e9784e7..ee22752 100644
--- a/app/code/community/Talkable/SocialReferrals/controllers/IndexController.php
+++ b/app/code/community/Talkable/SocialReferrals/controllers/IndexController.php
@@ -13,7 +13,7 @@ class Talkable_SocialReferrals_IndexController extends Mage_Core_Controller_Fron
 
     public function indexAction()
     {
-        if (Mage::helper("socialreferrals")->isAffiliateEnabled()) {
+        if (Mage::helper("socialreferrals")->isInviteEnabled()) {
             $this->loadLayout();
             $this->renderLayout();
         } else {
diff --git a/app/code/community/Talkable/SocialReferrals/etc/config.xml b/app/code/community/Talkable/SocialReferrals/etc/config.xml
index 8b6590e..98bedf1 100644
--- a/app/code/community/Talkable/SocialReferrals/etc/config.xml
+++ b/app/code/community/Talkable/SocialReferrals/etc/config.xml
@@ -12,7 +12,7 @@
 <config>
     <modules>
         <Talkable_SocialReferrals>
-            <version>0.1.8</version>
+            <version>1.0.0</version>
         </Talkable_SocialReferrals>
     </modules>
 
@@ -80,31 +80,15 @@
         <socialreferrals>
             <general>
                 <site_id></site_id>
-                <integration_js_url>//d2jjzw81hqbuqv.cloudfront.net/integration/talkable-1.0.min.js</integration_js_url>
+                <integration_js_url>//d2jjzw81hqbuqv.cloudfront.net/integration/talkable-2.1.min.js</integration_js_url>
             </general>
 
-            <purchase>
-                <enabled>0</enabled>
-                <campaign_tags>post-purchase</campaign_tags>
-            </purchase>
-
-            <affiliate>
-                <enabled>0</enabled>
-                <campaign_tags>invite</campaign_tags>
-                <iframe_responsive>1</iframe_responsive>
-                <iframe_container>talkable-container</iframe_container>
-                <iframe_width>100%</iframe_width>
-                <iframe_height>960</iframe_height>
-            </affiliate>
-
-            <dashboard>
-                <enabled>0</enabled>
-                <campaign_tags>dashboard</campaign_tags>
-                <iframe_responsive>1</iframe_responsive>
-                <iframe_container>talkable-container</iframe_container>
-                <iframe_width>100%</iframe_width>
-                <iframe_height>960</iframe_height>
-            </dashboard>
+            <campaigns>
+                <post_purchase>0</post_purchase>
+                <invite>0</invite>
+                <advocate_dashboard>0</advocate_dashboard>
+                <floating_widget_popup>0</floating_widget_popup>
+            </campaigns>
         </socialreferrals>
     </default>
 </config>
diff --git a/app/code/community/Talkable/SocialReferrals/etc/system.xml b/app/code/community/Talkable/SocialReferrals/etc/system.xml
index 22725a0..6f1bea7 100644
--- a/app/code/community/Talkable/SocialReferrals/etc/system.xml
+++ b/app/code/community/Talkable/SocialReferrals/etc/system.xml
@@ -28,7 +28,7 @@
 
             <groups>
                 <general translate="label">
-                    <label>Default Settings</label>
+                    <label>Talkable Integration</label>
                     <frontend_type>text</frontend_type>
                     <sort_order>1</sort_order>
                     <show_in_default>1</show_in_default>
@@ -58,8 +58,8 @@
                     </fields>
                 </general>
 
-                <purchase translate="label">
-                    <label>Post-Checkout Integration</label>
+                <campaigns translate="label">
+                    <label>Talkable Campaigns</label>
                     <frontend_type>text</frontend_type>
                     <sort_order>2</sort_order>
                     <show_in_default>1</show_in_default>
@@ -67,172 +67,51 @@
                     <show_in_store>1</show_in_store>
 
                     <fields>
-                        <enabled translate="label">
-                            <label>Enabled</label>
-                            <comment><![CDATA[(Offer will be shown on the Checkout Success page)]]></comment>
+                        <post_purchase translate="label">
+                            <label>Post Purchase</label>
+                            <comment><![CDATA[Shown on the Checkout Success page]]></comment>
                             <frontend_type>select</frontend_type>
-                            <source_model>adminhtml/system_config_source_yesno</source_model>
+                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                             <sort_order>1</sort_order>
                             <show_in_default>1</show_in_default>
                             <show_in_website>1</show_in_website>
                             <show_in_store>1</show_in_store>
-                        </enabled>
+                        </post_purchase>
 
-                        <campaign_tags translate="label">
-                            <label>Campaign Tags</label>
-                            <comment><![CDATA[CSV-list of campaign tags]]></comment>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>2</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </campaign_tags>
-                    </fields>
-                </purchase>
-
-                <affiliate translate="label">
-                    <label>Standalone Integration</label>
-                    <frontend_type>text</frontend_type>
-                    <sort_order>3</sort_order>
-                    <show_in_default>1</show_in_default>
-                    <show_in_website>1</show_in_website>
-                    <show_in_store>1</show_in_store>
-
-                    <fields>
-                        <enabled translate="label">
-                            <label>Enabled</label>
-                            <comment><![CDATA[(Standalone campaign will be mounted at /share)]]></comment>
+                        <invite translate="label">
+                            <label>Invite</label>
+                            <comment><![CDATA[Mounted at /share]]></comment>
                             <frontend_type>select</frontend_type>
-                            <source_model>adminhtml/system_config_source_yesno</source_model>
-                            <sort_order>1</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </enabled>
-
-                        <campaign_tags translate="label">
-                            <label>Campaign Tags</label>
-                            <comment><![CDATA[CSV-list of campaign tags]]></comment>
-                            <frontend_type>text</frontend_type>
+                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                             <sort_order>2</sort_order>
                             <show_in_default>1</show_in_default>
                             <show_in_website>1</show_in_website>
                             <show_in_store>1</show_in_store>
-                        </campaign_tags>
+                        </invite>
 
-                        <iframe_responsive translate="label">
-                            <label>IFrame responsive</label>
-                            <comment><![CDATA[Automatically adapt the IFrame to the viewport size]]></comment>
+                        <advocate_dashboard translate="label">
+                            <label>Advocate Dashboard</label>
+                            <comment><![CDATA[Added to the Customer Account section]]></comment>
                             <frontend_type>select</frontend_type>
-                            <source_model>adminhtml/system_config_source_yesno</source_model>
+                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                             <sort_order>3</sort_order>
                             <show_in_default>1</show_in_default>
                             <show_in_website>1</show_in_website>
                             <show_in_store>1</show_in_store>
-                        </iframe_responsive>
-
-                        <iframe_container translate="label">
-                            <label>IFrame container</label>
-                            <comment><![CDATA[ID of a DOM element to contain the IFrame]]></comment>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>4</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_container>
-
-                        <iframe_width translate="label">
-                            <label>IFrame width</label>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>5</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_width>
-
-                        <iframe_height translate="label">
-                            <label>IFrame height</label>
-                            <comment><![CDATA[Not applied if <em>responsive</em> is set to "No"]]></comment>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>6</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_height>
-                    </fields>
-                </affiliate>
+                        </advocate_dashboard>
 
-                <dashboard translate="label">
-                    <label>Dashboard Integration</label>
-                    <frontend_type>text</frontend_type>
-                    <sort_order>4</sort_order>
-                    <show_in_default>1</show_in_default>
-                    <show_in_website>1</show_in_website>
-                    <show_in_store>1</show_in_store>
-
-                    <fields>
-                        <enabled translate="label">
-                            <label>Enabled</label>
-                            <comment><![CDATA[(Will be added to the Customer Account section)]]></comment>
+                        <floating_widget_popup translate="label">
+                            <label>Floating Widget Popup</label>
+                            <comment><![CDATA[Shown on every page]]></comment>
                             <frontend_type>select</frontend_type>
-                            <source_model>adminhtml/system_config_source_yesno</source_model>
-                            <sort_order>1</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </enabled>
-
-                        <campaign_tags translate="label">
-                            <label>Campaign Tags</label>
-                            <comment><![CDATA[CSV-list of campaign tags]]></comment>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>2</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </campaign_tags>
-
-                        <iframe_responsive translate="label">
-                            <label>IFrame responsive</label>
-                            <comment><![CDATA[Automatically adapt the IFrame to the viewport size]]></comment>
-                            <frontend_type>select</frontend_type>
-                            <source_model>adminhtml/system_config_source_yesno</source_model>
-                            <sort_order>3</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_responsive>
-
-                        <iframe_container translate="label">
-                            <label>IFrame container</label>
-                            <comment><![CDATA[ID of a DOM element to contain the IFrame]]></comment>
-                            <frontend_type>text</frontend_type>
+                            <source_model>adminhtml/system_config_source_enabledisable</source_model>
                             <sort_order>4</sort_order>
                             <show_in_default>1</show_in_default>
                             <show_in_website>1</show_in_website>
                             <show_in_store>1</show_in_store>
-                        </iframe_container>
-
-                        <iframe_width translate="label">
-                            <label>IFrame width</label>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>5</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_width>
-
-                        <iframe_height translate="label">
-                            <label>IFrame height</label>
-                            <comment><![CDATA[Not applied if <em>responsive</em> is set to "No"]]></comment>
-                            <frontend_type>text</frontend_type>
-                            <sort_order>6</sort_order>
-                            <show_in_default>1</show_in_default>
-                            <show_in_website>1</show_in_website>
-                            <show_in_store>1</show_in_store>
-                        </iframe_height>
+                        </floating_widget_popup>
                     </fields>
-                </dashboard>
+                </campaigns>
             </groups>
         </socialreferrals>
     </sections>
diff --git a/app/design/frontend/base/default/layout/talkable/socialreferrals.xml b/app/design/frontend/base/default/layout/talkable/socialreferrals.xml
index 8941e05..107e6e7 100644
--- a/app/design/frontend/base/default/layout/talkable/socialreferrals.xml
+++ b/app/design/frontend/base/default/layout/talkable/socialreferrals.xml
@@ -10,33 +10,50 @@
  */
 -->
 <layout version="0.1.0">
+    <default>
+        <reference name="head">
+            <block type="core/template" name="talkable.socialreferrals.head" template="talkable/socialreferrals/head.phtml" />
+        </reference>
+
+        <reference name="before_body_end">
+            <block type="core/template" name="talkable.socialreferrals.floating_widget_popup" template="talkable/socialreferrals/floating_widget_popup.phtml" />
+        </reference>
+    </default>
+
     <checkout_onepage_success>
+        <remove name="talkable.socialreferrals.floating_widget_popup" />
+
         <reference name="before_body_end">
-            <block type="socialreferrals/purchase" name="talkable.socialreferrals.purchase" template="talkable/socialreferrals/post_purchase.phtml" />
+            <block type="socialreferrals/purchase" name="talkable.socialreferrals.post_purchase" template="talkable/socialreferrals/post_purchase.phtml" />
         </reference>
     </checkout_onepage_success>
 
     <checkout_multishipping_success>
+        <remove name="talkable.socialreferrals.floating_widget_popup" />
+
         <reference name="before_body_end">
-            <block type="socialreferrals/multishipping_purchase" name="talkable.socialreferrals.multishipping_purchase" template="talkable/socialreferrals/post_purchase.phtml" />
+            <block type="socialreferrals/multishipping_purchase" name="talkable.socialreferrals.post_purchase" template="talkable/socialreferrals/post_purchase.phtml" />
         </reference>
     </checkout_multishipping_success>
 
     <socialreferrals_index_index>
+        <remove name="talkable.socialreferrals.floating_widget_popup" />
+
         <reference name="root">
             <action method="setTemplate"><template>page/1column.phtml</template></action>
         </reference>
 
         <reference name="content">
-            <block type="socialreferrals/affiliate" name="talkable.socialreferrals.affiliate" template="talkable/socialreferrals/invite.phtml" />
+            <block type="core/template" name="talkable.socialreferrals.invite" template="talkable/socialreferrals/invite.phtml" />
         </reference>
     </socialreferrals_index_index>
 
     <customer_dashboard_index>
+        <remove name="talkable.socialreferrals.floating_widget_popup" />
         <update handle="customer_account"/>
 
         <reference name="my.account.wrapper">
-            <block type="socialreferrals/customer_dashboard" name="talkable.socialreferrals.customer_dashboard" template="talkable/socialreferrals/dashboard.phtml" />
+            <block type="core/template" name="talkable.socialreferrals.advocate_dashboard" template="talkable/socialreferrals/advocate_dashboard.phtml" />
         </reference>
     </customer_dashboard_index>
 
diff --git a/app/design/frontend/base/default/template/talkable/socialreferrals/advocate_dashboard.phtml b/app/design/frontend/base/default/template/talkable/socialreferrals/advocate_dashboard.phtml
new file mode 100644
index 0000000..9c06d3e
--- /dev/null
+++ b/app/design/frontend/base/default/template/talkable/socialreferrals/advocate_dashboard.phtml
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Talkable SocialReferrals for Magento
+ *
+ * @package     Talkable_SocialReferrals
+ * @author      Talkable (http://www.talkable.com/)
+ * @copyright   Copyright (c) 2015 Talkable (http://www.talkable.com/)
+ * @license     MIT
+ */
+?>
+
+<?php $_helper = $this->helper("socialreferrals") ?>
+
+<?php if ($_helper->isAdvocateDashboardEnabled()): ?>
+    <!-- Begin Talkable integration code -->
+
+    <?php if ($_helper->getSiteId() == ""): ?>
+        <!-- Talkable Site ID is blank, check your Talkable extension settings -->
+    <?php else: ?>
+        <div id="talkable-dashboard"></div>
+        <script type="text/javascript">
+        //<![CDATA[
+          _talkableq.push(["register_affiliate", {
+            campaign_template: { name: "dashboard" }
+          }]);
+        //]]>
+        </script>
+    <?php endif ?>
+
+    <!-- End Talkable integration code -->
+<?php endif ?>
diff --git a/app/design/frontend/base/default/template/talkable/socialreferrals/floating_widget_popup.phtml b/app/design/frontend/base/default/template/talkable/socialreferrals/floating_widget_popup.phtml
new file mode 100644
index 0000000..1593743
--- /dev/null
+++ b/app/design/frontend/base/default/template/talkable/socialreferrals/floating_widget_popup.phtml
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Talkable SocialReferrals for Magento
+ *
+ * @package     Talkable_SocialReferrals
+ * @author      Talkable (http://www.talkable.com/)
+ * @copyright   Copyright (c) 2015 Talkable (http://www.talkable.com/)
+ * @license     MIT
+ */
+?>
+
+<?php $_helper = $this->helper("socialreferrals") ?>
+
+<?php if ($_helper->isFloatingWidgetPopupEnabled()): ?>
+    <!-- Begin Talkable integration code -->
+
+    <?php if ($_helper->getSiteId() == ""): ?>
+        <!-- Talkable Site ID is blank, check your Talkable extension settings -->
+    <?php else: ?>
+        <script type="text/javascript">
+        //<![CDATA[
+          _talkableq.push(["register_affiliate", {
+            campaign_template: {
+              name: "popup-trigger",
+              path: document.location.pathname
+            }
+          }]);
+        //]]>
+        </script>
+    <?php endif ?>
+
+    <!-- End Talkable integration code -->
+<?php endif ?>
diff --git a/app/design/frontend/base/default/template/talkable/socialreferrals/dashboard.phtml b/app/design/frontend/base/default/template/talkable/socialreferrals/head.phtml
similarity index 62%
rename from app/design/frontend/base/default/template/talkable/socialreferrals/dashboard.phtml
rename to app/design/frontend/base/default/template/talkable/socialreferrals/head.phtml
index c7d3fe1..e4a47b5 100644
--- a/app/design/frontend/base/default/template/talkable/socialreferrals/dashboard.phtml
+++ b/app/design/frontend/base/default/template/talkable/socialreferrals/head.phtml
@@ -11,25 +11,20 @@
 
 <?php $_helper = $this->helper("socialreferrals") ?>
 
-<?php if ($_helper->isDashboardEnabled()): ?>
+<?php if ($_helper->isEnabled()): ?>
     <!-- Begin Talkable integration code -->
 
     <?php if ($_helper->getSiteId() == ""): ?>
         <!-- Talkable Site ID is blank, check your Talkable extension settings -->
     <?php else: ?>
-        <div id="talkable-container"></div>
         <script type="text/javascript">
         //<![CDATA[
           var _talkableq = _talkableq || [];
           _talkableq.push(["init", {
-            site_id: "<?php echo $_helper->getSiteId() ?>",
-            server: "https://www.talkable.com"
+            site_id: "<?php echo $_helper->getSiteId() ?>"
           }]);
 
-          <?php $_event_data = array_merge($_helper->getAffiliateData(), $_helper->getDashboardIframeOptions()) ?>
-          <?php $_event_data["campaign_tags"] = $_helper->getDashboardCampaignTags() ?>
-
-          _talkableq.push(["register_affiliate", <?php echo Mage::helper("core")->jsonEncode($_event_data) ?>]);
+          _talkableq.push(["authenticate_customer", <?php echo Mage::helper("core")->jsonEncode($_helper->getCustomerData()) ?>]);
         //]]>
         </script>
         <script type="text/javascript" src="<?php echo $_helper->getIntegrationJsUrl() ?>"></script>
diff --git a/app/design/frontend/base/default/template/talkable/socialreferrals/invite.phtml b/app/design/frontend/base/default/template/talkable/socialreferrals/invite.phtml
index 7f27c93..41eddce 100644
--- a/app/design/frontend/base/default/template/talkable/socialreferrals/invite.phtml
+++ b/app/design/frontend/base/default/template/talkable/socialreferrals/invite.phtml
@@ -11,28 +11,20 @@
 
 <?php $_helper = $this->helper("socialreferrals") ?>
 
-<?php if ($_helper->isAffiliateEnabled()): ?>
+<?php if ($_helper->isInviteEnabled()): ?>
     <!-- Begin Talkable integration code -->
 
     <?php if ($_helper->getSiteId() == ""): ?>
         <!-- Talkable Site ID is blank, check your Talkable extension settings -->
     <?php else: ?>
-        <div id="talkable-container"></div>
+        <div id="talkable-invite"></div>
         <script type="text/javascript">
         //<![CDATA[
-          var _talkableq = _talkableq || [];
-          _talkableq.push(["init", {
-            site_id: "<?php echo $_helper->getSiteId() ?>",
-            server: "https://www.talkable.com"
+          _talkableq.push(["register_affiliate", {
+            campaign_template: { name: "invite" }
           }]);
-
-          <?php $_event_data = array_merge($_helper->getAffiliateData(), $_helper->getAffiliateIframeOptions()) ?>
-          <?php $_event_data["campaign_tags"] = $_helper->getAffiliateCampaignTags() ?>
-
-          _talkableq.push(["register_affiliate", <?php echo Mage::helper("core")->jsonEncode($_event_data) ?>]);
         //]]>
         </script>
-        <script type="text/javascript" src="<?php echo $_helper->getIntegrationJsUrl() ?>"></script>
     <?php endif ?>
 
     <!-- End Talkable integration code -->
diff --git a/app/design/frontend/base/default/template/talkable/socialreferrals/post_purchase.phtml b/app/design/frontend/base/default/template/talkable/socialreferrals/post_purchase.phtml
index 3dc8332..c5de6f2 100644
--- a/app/design/frontend/base/default/template/talkable/socialreferrals/post_purchase.phtml
+++ b/app/design/frontend/base/default/template/talkable/socialreferrals/post_purchase.phtml
@@ -11,7 +11,7 @@
 
 <?php $_helper = $this->helper("socialreferrals") ?>
 
-<?php if ($_helper->isPurchaseEnabled()): ?>
+<?php if ($_helper->isPostPurchaseEnabled()): ?>
     <!-- Begin Talkable integration code -->
 
     <?php if ($_helper->getSiteId() == ""): ?>
@@ -20,21 +20,13 @@
         <?php if ($_order = $this->getCheckoutOrder()): ?>
             <script type="text/javascript">
             //<![CDATA[
-              var _talkableq = _talkableq || [];
-              _talkableq.push(["init", {
-                site_id: "<?php echo $_helper->getSiteId() ?>",
-                server: "https://www.talkable.com"
-              }]);
-
               <?php $_event_data = $_helper->getPurchaseData($_order) ?>
-              <?php $_event_data["responsive"] = true ?>
               <?php $_event_data["traffic_source"] = "Post-checkout" ?>
-              <?php $_event_data["campaign_tags"] = $_helper->getPurchaseCampaignTags() ?>
+              <?php $_event_data["campaign_template"] = array("name" => "post-purchase") ?>
 
               _talkableq.push(["register_purchase", <?php echo Mage::helper("core")->jsonEncode($_event_data) ?>]);
             //]]>
             </script>
-            <script type="text/javascript" src="<?php echo $_helper->getIntegrationJsUrl() ?>"></script>
         <?php else: ?>
             <!-- Order could not be found -->
         <?php endif ?>
diff --git a/package.xml b/package.xml
index 876d7fc..bcbb6ce 100755
--- a/package.xml
+++ b/package.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <package>
     <name>talkable</name>
-    <version>0.1.8</version>
+    <version>1.0.0</version>
     <stability>stable</stability>
     <license uri="http://opensource.org/licenses/mit-license.php">MIT License</license>
     <channel>community</channel>
@@ -15,13 +15,16 @@ Using Talkable, you help your customers drive more referral sales per dollar tha
 &#xD;
 See more at Talkable.com</description>
     <notes>Extension provides:&#xD;
-- Post-Checkout Integration&#xD;
-- Standalone Integration&#xD;
-- Customer Dashboard Integration</notes>
+- Invite Integration&#xD;
+- Post Purchase Integration&#xD;
+- Advocate Dashboard Integration&#xD;
+- Floating Widget Popup Integration&#xD;
+&#xD;
+Note: Extension version 1.0 works with Talkable Integration library version 2.1 or higher.</notes>
     <authors><author><name>Talkable</name><user>talkable</user><email>sub@talkable.com</email></author></authors>
-    <date>2015-12-08</date>
-    <time>15:03:45</time>
-    <contents><target name="magecommunity"><dir name="Talkable"><dir name="SocialReferrals"><dir name="Block"><file name="Affiliate.php" hash="e5cf1648f2aab8c8894fd1311ae865b8"/><dir name="Customer"><file name="Dashboard.php" hash="78d93dcf31455b09117506a78d3b7797"/></dir><dir name="Multishipping"><file name="Purchase.php" hash="6eaab3557bdf97f40a77c7b6e040e483"/></dir><file name="Purchase.php" hash="5cd37269372b88cec4657bf85077c1a4"/></dir><dir name="Helper"><file name="Data.php" hash="01fdc77f9c0e94df7c03228c74b5e8f0"/></dir><dir name="Model"><file name="Observer.php" hash="c5ebe37375fb3d6b40d8d440b790ee8b"/></dir><dir name="controllers"><dir name="Customer"><file name="DashboardController.php" hash="fb89ba06fed8cb3329a941d59bd67b7c"/></dir><file name="IndexController.php" hash="41a785b074c529b65a3f82ca3573662e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3f86a3e4bf980fa36aba8c0e33737e59"/><file name="config.xml" hash="cd60d5427ffb0109f27ddfa115e9378e"/><file name="system.xml" hash="403d3059ec5cf53e2494d920f159a3ca"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="talkable"><file name="socialreferrals.xml" hash="87e9f62d2d649e5da197e7a93c47c986"/></dir></dir><dir name="template"><dir name="talkable"><dir name="socialreferrals"><file name="dashboard.phtml" hash="8f500eda3d530a023463f8ebd190d2ef"/><file name="invite.phtml" hash="26f2536cc57b16919409064af76f1551"/><file name="post_purchase.phtml" hash="7cefca2596c5f8da483cd728a0e4d018"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Talkable_SocialReferrals.xml" hash="ed1152e3c169ac8e9d33219e5ec9fb47"/></dir></target></contents>
+    <date>2016-02-02</date>
+    <time>16:56:35</time>
+    <contents><target name="magecommunity"><dir name="Talkable"><dir name="SocialReferrals"><dir name="Block"><dir name="Multishipping"><file name="Purchase.php" hash="6eaab3557bdf97f40a77c7b6e040e483"/></dir><file name="Purchase.php" hash="5cd37269372b88cec4657bf85077c1a4"/></dir><dir name="Helper"><file name="Data.php" hash="9c25df7d29303a12026c8c689ccdc6bb"/></dir><dir name="Model"><file name="Observer.php" hash="b9e5a92a24b018b14ccc64658326e92e"/></dir><dir name="controllers"><dir name="Customer"><file name="DashboardController.php" hash="3f715ff823d8b2709d3b6ee106685513"/></dir><file name="IndexController.php" hash="c08758b6a50bbc95ce09773818a6a7c4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3f86a3e4bf980fa36aba8c0e33737e59"/><file name="config.xml" hash="7f0a9593eaec1e19c587d746c15340a7"/><file name="system.xml" hash="24f2eab492ee493224ecd5dd198f3a1f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="talkable"><file name="socialreferrals.xml" hash="c4731fc832bf3cdbe4fec6f6cd336549"/></dir></dir><dir name="template"><dir name="talkable"><dir name="socialreferrals"><file name="advocate_dashboard.phtml" hash="8cd2009d81fc41b844d67e3720f052d1"/><file name="floating_widget_popup.phtml" hash="a6fbbdc319fb39f16d423009aa0c980b"/><file name="head.phtml" hash="4e159f767e7e615b7d0f45617e242e9b"/><file name="invite.phtml" hash="4dc8f89254afd20c229433fd4e633bc1"/><file name="post_purchase.phtml" hash="30f45c14f6b45d92fcd9d26fdb6bbeae"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Talkable_SocialReferrals.xml" hash="ed1152e3c169ac8e9d33219e5ec9fb47"/></dir></target></contents>
     <compatible/>
     <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
 </package>