Version Notes
Channel updates.
Download this release
Release Info
Developer | Pawel Burzynski |
Extension | Socialicity_Integration |
Version | 3.0.0 |
Comparing to | |
See all releases |
Version 3.0.0
- app/code/local/Socialicity/Integration/Core/SocialicityRepository.php +58 -0
- app/code/local/Socialicity/Integration/Model/CartObserver.php +22 -0
- app/code/local/Socialicity/Integration/Model/SalesObserver.php +51 -0
- app/code/local/Socialicity/Integration/controllers/IndexController.php +44 -0
- app/code/local/Socialicity/Integration/etc/config.xml +73 -0
- app/code/local/Socialicity/Integration/etc/system.xml +71 -0
- app/etc/modules/Socialicity_Integration.xml +9 -0
- package.xml +18 -0
app/code/local/Socialicity/Integration/Core/SocialicityRepository.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SocialicityRepository
|
4 |
+
{
|
5 |
+
public static function setReferralId($referralId) {
|
6 |
+
SocialicityRepository::set_value('socialicity_referral_id', $referralId);
|
7 |
+
}
|
8 |
+
|
9 |
+
public static function getReferralId() {
|
10 |
+
return SocialicityRepository::get_value('socialicity_referral_id');
|
11 |
+
}
|
12 |
+
|
13 |
+
public static function clearReferralId() {
|
14 |
+
SocialicityRepository::set_value('socialicity_referral_id', null);
|
15 |
+
}
|
16 |
+
|
17 |
+
public static function setDiscountCode($discountCode) {
|
18 |
+
SocialicityRepository::set_value('socialicity_discount_code', $discountCode);
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function getDiscountCode() {
|
22 |
+
return SocialicityRepository::get_value('socialicity_discount_code');
|
23 |
+
}
|
24 |
+
|
25 |
+
public static function clearDiscountCode() {
|
26 |
+
SocialicityRepository::set_value('socialicity_discount_code', null);
|
27 |
+
}
|
28 |
+
|
29 |
+
public static function getUsername() {
|
30 |
+
return Mage::getStoreConfig('socialicity/socialicity_general/username', Mage::app()->getStore());
|
31 |
+
//return "pawelburzynski@moneydebtandcredit.com";
|
32 |
+
}
|
33 |
+
|
34 |
+
public static function getPassword() {
|
35 |
+
return Mage::getStoreConfig('socialicity/socialicity_general/password', Mage::app()->getStore());
|
36 |
+
//return "Password11";
|
37 |
+
}
|
38 |
+
|
39 |
+
public static function getConfirmUrl() {
|
40 |
+
return Mage::getStoreConfig('socialicity/socialicity_advanced/server_url', Mage::app()->getStore());
|
41 |
+
//return "http://socialicitywebapi/api/Referral/Confirm";
|
42 |
+
}
|
43 |
+
|
44 |
+
private static function get_value($key) {
|
45 |
+
return $_COOKIE[$key];
|
46 |
+
}
|
47 |
+
|
48 |
+
private static function set_value($key, $value) {
|
49 |
+
if ($value) {
|
50 |
+
setcookie($key, $value, 0, '/');
|
51 |
+
} else {
|
52 |
+
setcookie($key, '', time()-3600, '/');
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
app/code/local/Socialicity/Integration/Model/CartObserver.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Socialicity/Integration/Core/SocialicityRepository.php');
|
4 |
+
|
5 |
+
class Socialicity_Integration_Model_CartObserver
|
6 |
+
{
|
7 |
+
public function checkoutCartProductAddAfter($observer)
|
8 |
+
{
|
9 |
+
Mage::log('Socialicity/CartObserver/ product added to cart');
|
10 |
+
|
11 |
+
$referralId = SocialicityRepository::getReferralId();
|
12 |
+
|
13 |
+
if ($referralId != null) {
|
14 |
+
$discountCode = SocialicityRepository::getDiscountCode();
|
15 |
+
|
16 |
+
Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($discountCode)->save();
|
17 |
+
Mage::log('Socialicity/CartObserver/ coupon code applied: ' . $discountCode);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
?>
|
app/code/local/Socialicity/Integration/Model/SalesObserver.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Socialicity/Integration/Core/SocialicityRepository.php');
|
4 |
+
|
5 |
+
class Socialicity_Integration_Model_SalesObserver
|
6 |
+
{
|
7 |
+
public function salesOrderPlaceAfter($observer)
|
8 |
+
{
|
9 |
+
$referralId = SocialicityRepository::getReferralId();
|
10 |
+
Mage::log('Socialicity/SalesObserver/ checkout');
|
11 |
+
|
12 |
+
if ($referralId != null) {
|
13 |
+
|
14 |
+
$grandTotal = Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal();
|
15 |
+
$message = '{ "ReferralId": "' . $referralId .'", "DiscountedAmount": ' . $grandTotal . ' }';
|
16 |
+
|
17 |
+
Mage::log('Socialicity/SalesObserver/ sending message: ' . $message);
|
18 |
+
Mage::log('Socialicity/SalesObserver/ using server: ' . SocialicityRepository::getConfirmUrl());
|
19 |
+
|
20 |
+
$curl = curl_init();
|
21 |
+
|
22 |
+
curl_setopt($curl, CURLOPT_SSLVERSION,3);
|
23 |
+
|
24 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
25 |
+
|
26 |
+
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
27 |
+
curl_setopt($curl, CURLOPT_USERPWD, SocialicityRepository::getUsername() . ':' . SocialicityRepository::getPassword());
|
28 |
+
|
29 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $message);
|
30 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
31 |
+
|
32 |
+
curl_setopt($curl, CURLOPT_URL, SocialicityRepository::getConfirmUrl());
|
33 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
34 |
+
|
35 |
+
$result = curl_exec($curl);
|
36 |
+
|
37 |
+
if (curl_errno($curl)) {
|
38 |
+
Mage::log('Socialicity/SalesObserver socialicity update failed');
|
39 |
+
} else {
|
40 |
+
Mage::log('Socialicity/SalesObserver socialicity update success');
|
41 |
+
}
|
42 |
+
|
43 |
+
Mage::log('Socialicity/SalesObserver server response:' . $result);
|
44 |
+
}
|
45 |
+
|
46 |
+
SocialicityRepository::clearReferralId();
|
47 |
+
SocialicityRepository::clearDiscountCode();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
?>
|
app/code/local/Socialicity/Integration/controllers/IndexController.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Socialicity/Integration/Core/SocialicityRepository.php');
|
4 |
+
|
5 |
+
class Socialicity_Integration_IndexController extends Mage_Core_Controller_Front_Action
|
6 |
+
{
|
7 |
+
/* For more information see: http://www.drewgillson.com/blog/how-to-apply-magento-coupon-codes-automatically/ */
|
8 |
+
public function indexAction() {
|
9 |
+
|
10 |
+
Mage::log('Socialicity/Index/ landing page accessed');
|
11 |
+
|
12 |
+
$request = $this->getRequest();
|
13 |
+
$referralId = $request->getParam('referralId');
|
14 |
+
$url = $request->getParam('url');
|
15 |
+
$discountCode = $request->getParam('discountCode');
|
16 |
+
|
17 |
+
if ($request->getParam('debug') == 'true') {
|
18 |
+
echo 'ReferralId: ' . SocialicityRepository::getReferralId() . '<br />';
|
19 |
+
echo 'Discount: ' . SocialicityRepository::getDiscountCode() . '<br />';
|
20 |
+
|
21 |
+
die();
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($referralId != null && $url != null && $discountCode != null) {
|
25 |
+
|
26 |
+
Mage::log('Socialicity/Index/ referralId: ' . $referralId);
|
27 |
+
Mage::log('Socialicity/Index/ url: ' . $url);
|
28 |
+
Mage::log('Socialicity/Index/ discountCode: ' . $discountCode);
|
29 |
+
|
30 |
+
SocialicityRepository::setReferralId($referralId);
|
31 |
+
SocialicityRepository::setDiscountCode($discountCode);
|
32 |
+
|
33 |
+
header('HTTP/1.1 307 Temporary Redirect');
|
34 |
+
$gclid = $request->getParam('gclid');
|
35 |
+
|
36 |
+
header('Location: ' . $url . '?gclid=' . $gclid);
|
37 |
+
die();
|
38 |
+
} else {
|
39 |
+
$this->_redirect('/');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
?>
|
app/code/local/Socialicity/Integration/etc/config.xml
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Socialicity_Integration>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Socialicity_Integration>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<events>
|
10 |
+
<sales_order_place_after>
|
11 |
+
<observers>
|
12 |
+
<socialicity_sales_order_observer>
|
13 |
+
<class>Socialicity_Integration_Model_SalesObserver</class>
|
14 |
+
<method>salesOrderPlaceAfter</method>
|
15 |
+
</socialicity_sales_order_observer>
|
16 |
+
</observers>
|
17 |
+
</sales_order_place_after>
|
18 |
+
<checkout_cart_product_add_after>
|
19 |
+
<observers>
|
20 |
+
<socialicity_cart_add_observer>
|
21 |
+
<class>Socialicity_Integration_Model_CartObserver</class>
|
22 |
+
<method>checkoutCartProductAddAfter</method>
|
23 |
+
</socialicity_cart_add_observer>
|
24 |
+
</observers>
|
25 |
+
</checkout_cart_product_add_after>
|
26 |
+
</events>
|
27 |
+
</global>
|
28 |
+
|
29 |
+
<frontend>
|
30 |
+
<routers>
|
31 |
+
<integration>
|
32 |
+
<use>standard</use>
|
33 |
+
<args>
|
34 |
+
<module>Socialicity_Integration</module>
|
35 |
+
<frontName>socialicity</frontName>
|
36 |
+
</args>
|
37 |
+
</integration>
|
38 |
+
</routers>
|
39 |
+
</frontend>
|
40 |
+
|
41 |
+
<default>
|
42 |
+
<socialicity>
|
43 |
+
<socialicity_advanced>
|
44 |
+
<server_url>https://api.socialicity.co.uk/api/Referral/Confirm</server_url>
|
45 |
+
</socialicity_advanced>
|
46 |
+
</socialicity>
|
47 |
+
</default>
|
48 |
+
|
49 |
+
<adminhtml>
|
50 |
+
<acl>
|
51 |
+
<resources>
|
52 |
+
<all>
|
53 |
+
<title>Allow Everything</title>
|
54 |
+
</all>
|
55 |
+
<admin>
|
56 |
+
<children>
|
57 |
+
<system>
|
58 |
+
<children>
|
59 |
+
<config>
|
60 |
+
<children>
|
61 |
+
<socialicity>
|
62 |
+
<title>Socialicity - All</title>
|
63 |
+
</socialicity>
|
64 |
+
</children>
|
65 |
+
</config>
|
66 |
+
</children>
|
67 |
+
</system>
|
68 |
+
</children>
|
69 |
+
</admin>
|
70 |
+
</resources>
|
71 |
+
</acl>
|
72 |
+
</adminhtml>
|
73 |
+
</config>
|
app/code/local/Socialicity/Integration/etc/system.xml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
|
4 |
+
<tabs>
|
5 |
+
<socialicity translate="label">
|
6 |
+
<label>Socialicity</label>
|
7 |
+
<sort_order>100</sort_order>
|
8 |
+
</socialicity>
|
9 |
+
</tabs>
|
10 |
+
|
11 |
+
<sections>
|
12 |
+
<socialicity translate="label" >
|
13 |
+
<label>General</label>
|
14 |
+
<tab>socialicity</tab>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>1000</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>1</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<socialicity_general translate="label">
|
22 |
+
<label>General</label>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<sort_order>1000</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
<fields>
|
29 |
+
<username translate="label">
|
30 |
+
<label>Username: </label>
|
31 |
+
<comment>Socialicity partner username (email)</comment>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>10</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</username>
|
38 |
+
<password translate="label">
|
39 |
+
<label>Password: </label>
|
40 |
+
<frontend_type>password</frontend_type>
|
41 |
+
<comment>Socialicity partner password</comment>
|
42 |
+
<sort_order>20</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</password>
|
47 |
+
</fields>
|
48 |
+
</socialicity_general>
|
49 |
+
<socialicity_advanced translate="label">
|
50 |
+
<label>Advanced</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>2000</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
<fields>
|
57 |
+
<server_url translate="label">
|
58 |
+
<label>REST Url: </label>
|
59 |
+
<comment>Socialicity server notification url</comment>
|
60 |
+
<frontend_type>text</frontend_type>
|
61 |
+
<sort_order>30</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
+
</server_url>
|
66 |
+
</fields>
|
67 |
+
</socialicity_advanced>
|
68 |
+
</groups>
|
69 |
+
</socialicity>
|
70 |
+
</sections>
|
71 |
+
</config>
|
app/etc/modules/Socialicity_Integration.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Socialicity_Integration>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Socialicity_Integration>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Socialicity_Integration</name>
|
4 |
+
<version>3.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/GPL-3.0">GPL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Socialicity integration extension for Magento.</summary>
|
10 |
+
<description>Socialicity Integration allows Magento users to automatically update their Socialicity Partner Portal with sales information so that no leads needs to be updated manually.</description>
|
11 |
+
<notes>Channel updates.</notes>
|
12 |
+
<authors><author><name>Pawel Burzynski</name><user>pawelburzynski</user><email>pawelburzynski@moneydebtandcredit.com</email></author></authors>
|
13 |
+
<date>2014-09-26</date>
|
14 |
+
<time>11:26:49</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Socialicity"><dir name="Integration"><dir name="etc"><file name="config.xml" hash="2829d98bfb7da3667c428dac4dc884e1"/><file name="system.xml" hash="cf9a1280d2cd451fe52a9dacbdbf4674"/></dir><dir name="Core"><file name="SocialicityRepository.php" hash="16f06d1f22ba1bc11b6cfb6dfc5be119"/></dir><dir name="Model"><file name="CartObserver.php" hash="a5c73018b6f1c4587d28acac18a8e360"/><file name="SalesObserver.php" hash="01609ab7ce423c19433c5da93ac1a979"/></dir><dir name="controllers"><file name="IndexController.php" hash="d0e5d03c5e717b5683c5bd4c164c6465"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Socialicity_Integration.xml" hash="b3f123f7aa8c300f5d9c0d08e6fcacdb"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>Core</name><min>5.1.0</min><max>6.0.0</max></extension></required></dependencies>
|
18 |
+
</package>
|