Version Notes
added missing files
Download this release
Release Info
Developer | Magento Core Team |
Extension | Zagzig_Integration |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/local/Zagzig/Integration/Core/ZagzigRepository.php +46 -0
- app/code/local/Zagzig/Integration/Model/CartObserver.php +22 -0
- app/code/local/Zagzig/Integration/Model/SalesObserver.php +49 -0
- app/code/local/Zagzig/Integration/controllers/IndexController.php +44 -0
- app/code/local/Zagzig/Integration/etc/config.xml +73 -0
- app/code/local/Zagzig/Integration/etc/system.xml +71 -0
- package.xml +5 -5
app/code/local/Zagzig/Integration/Core/ZagzigRepository.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ZagzigRepository
|
4 |
+
{
|
5 |
+
public static function setReferralId($referralId) {
|
6 |
+
Mage::getSingleton('core/session')->setReferralId($referralId);
|
7 |
+
}
|
8 |
+
|
9 |
+
public static function getReferralId() {
|
10 |
+
return Mage::getSingleton('core/session')->getReferralId();
|
11 |
+
}
|
12 |
+
|
13 |
+
public static function clearReferralId() {
|
14 |
+
return Mage::getSingleton('core/session')->unsReferralId();
|
15 |
+
}
|
16 |
+
|
17 |
+
public static function setDiscountCode($discountCode) {
|
18 |
+
Mage::getSingleton('core/session')->setDiscountCode($discountCode);
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function getDiscountCode() {
|
22 |
+
return Mage::getSingleton('core/session')->getDiscountCode();
|
23 |
+
}
|
24 |
+
|
25 |
+
public static function clearDiscountCode() {
|
26 |
+
return Mage::getSingleton('core/session')->unsDiscountCode();
|
27 |
+
}
|
28 |
+
|
29 |
+
public static function getUsername() {
|
30 |
+
return Mage::getStoreConfig('zagzig/zagzig_general/username', Mage::app()->getStore());
|
31 |
+
//return "pawelburzynski@moneydebtandcredit.com";
|
32 |
+
}
|
33 |
+
|
34 |
+
public static function getPassword() {
|
35 |
+
return Mage::getStoreConfig('zagzig/zagzig_general/password', Mage::app()->getStore());
|
36 |
+
//return "Password11";
|
37 |
+
}
|
38 |
+
|
39 |
+
public static function getConfirmUrl() {
|
40 |
+
return Mage::getStoreConfig('zagzig/zagzig_advanced/server_url', Mage::app()->getStore());
|
41 |
+
//return "http://zagzigwebapi/api/Referral/Confirm";
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
?>
|
app/code/local/Zagzig/Integration/Model/CartObserver.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Zagzig/Integration/Core/ZagzigRepository.php');
|
4 |
+
|
5 |
+
class Zagzig_Integration_Model_CartObserver
|
6 |
+
{
|
7 |
+
public function checkoutCartProductAddAfter($observer)
|
8 |
+
{
|
9 |
+
Mage::log('Zagzig/CartObserver/ product added to cart');
|
10 |
+
|
11 |
+
$referralId = ZagzigRepository::getReferralId();
|
12 |
+
|
13 |
+
if ($referralId != null) {
|
14 |
+
$discountCode = ZagzigRepository::getDiscountCode();
|
15 |
+
|
16 |
+
Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($discountCode)->save();
|
17 |
+
Mage::log('Zagzig/CartObserver/ coupon code applied: ' . $discountCode);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
?>
|
app/code/local/Zagzig/Integration/Model/SalesObserver.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Zagzig/Integration/Core/ZagzigRepository.php');
|
4 |
+
|
5 |
+
class Zagzig_Integration_Model_SalesObserver
|
6 |
+
{
|
7 |
+
public function salesOrderPlaceAfter($observer)
|
8 |
+
{
|
9 |
+
$referralId = ZagzigRepository::getReferralId();
|
10 |
+
Mage::log('Zagzig/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('Zagzig/SalesObserver/ sending message: ' . $message);
|
18 |
+
Mage::log('Zagzig/SalesObserver/ using server: ' . ZagzigRepository::getConfirmUrl());
|
19 |
+
|
20 |
+
$curl = curl_init();
|
21 |
+
|
22 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
23 |
+
|
24 |
+
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
25 |
+
curl_setopt($curl, CURLOPT_USERPWD, ZagzigRepository::getUsername() . ':' . ZagzigRepository::getPassword());
|
26 |
+
|
27 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $message);
|
28 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
29 |
+
|
30 |
+
curl_setopt($curl, CURLOPT_URL, ZagzigRepository::getConfirmUrl());
|
31 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
32 |
+
|
33 |
+
$result = curl_exec($curl);
|
34 |
+
|
35 |
+
if (curl_errno($curl)) {
|
36 |
+
Mage::log('Zagzig/SalesObserver zagzig update failed');
|
37 |
+
} else {
|
38 |
+
Mage::log('Zagzig/SalesObserver zagzig update success');
|
39 |
+
}
|
40 |
+
|
41 |
+
Mage::log('Zagzig/SalesObserver server response:' . $result);
|
42 |
+
}
|
43 |
+
|
44 |
+
ZagzigRepository::clearReferralId();
|
45 |
+
ZagzigRepository::clearDiscountCode();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
?>
|
app/code/local/Zagzig/Integration/controllers/IndexController.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require('app/code/local/Zagzig/Integration/Core/ZagzigRepository.php');
|
4 |
+
|
5 |
+
class Zagzig_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('Zagzig/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: ' . ZagzigRepository::getReferralId() . '<br />';
|
19 |
+
echo 'Discount: ' . ZagzigRepository::getDiscountCode() . '<br />';
|
20 |
+
|
21 |
+
die();
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($referralId != null && $url != null && $discountCode != null) {
|
25 |
+
|
26 |
+
Mage::log('Zagzig/Index/ referralId: ' . $referralId);
|
27 |
+
Mage::log('Zagzig/Index/ url: ' . $url);
|
28 |
+
Mage::log('Zagzig/Index/ discountCode: ' . $discountCode);
|
29 |
+
|
30 |
+
ZagzigRepository::setReferralId($referralId);
|
31 |
+
ZagzigRepository::setDiscountCode($discountCode);
|
32 |
+
|
33 |
+
header('HTTP/1.1 301 Moved Permanently');
|
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/Zagzig/Integration/etc/config.xml
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Zagzig_Integration>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Zagzig_Integration>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<events>
|
10 |
+
<sales_order_place_after>
|
11 |
+
<observers>
|
12 |
+
<zagzig_sales_order_observer>
|
13 |
+
<class>Zagzig_Integration_Model_SalesObserver</class>
|
14 |
+
<method>salesOrderPlaceAfter</method>
|
15 |
+
</zagzig_sales_order_observer>
|
16 |
+
</observers>
|
17 |
+
</sales_order_place_after>
|
18 |
+
<checkout_cart_product_add_after>
|
19 |
+
<observers>
|
20 |
+
<zagzig_cart_add_observer>
|
21 |
+
<class>Zagzig_Integration_Model_CartObserver</class>
|
22 |
+
<method>checkoutCartProductAddAfter</method>
|
23 |
+
</zagzig_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>Zagzig_Integration</module>
|
35 |
+
<frontName>zagzig</frontName>
|
36 |
+
</args>
|
37 |
+
</integration>
|
38 |
+
</routers>
|
39 |
+
</frontend>
|
40 |
+
|
41 |
+
<default>
|
42 |
+
<zagzig>
|
43 |
+
<zagzig_advanced>
|
44 |
+
<server_url>https://api.zagzig.co.uk/api/Referral/Confirm</server_url>
|
45 |
+
</zagzig_advanced>
|
46 |
+
</zagzig>
|
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 |
+
<zagzig>
|
62 |
+
<title>Zagzig - All</title>
|
63 |
+
</zagzig>
|
64 |
+
</children>
|
65 |
+
</config>
|
66 |
+
</children>
|
67 |
+
</system>
|
68 |
+
</children>
|
69 |
+
</admin>
|
70 |
+
</resources>
|
71 |
+
</acl>
|
72 |
+
</adminhtml>
|
73 |
+
</config>
|
app/code/local/Zagzig/Integration/etc/system.xml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
|
4 |
+
<tabs>
|
5 |
+
<zagzig translate="label">
|
6 |
+
<label>Zagzig</label>
|
7 |
+
<sort_order>100</sort_order>
|
8 |
+
</zagzig>
|
9 |
+
</tabs>
|
10 |
+
|
11 |
+
<sections>
|
12 |
+
<zagzig translate="label" >
|
13 |
+
<label>General</label>
|
14 |
+
<tab>zagzig</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 |
+
<zagzig_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>Zagzig 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>Zagzig 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 |
+
</zagzig_general>
|
49 |
+
<zagzig_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>Zagzig 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 |
+
</zagzig_advanced>
|
68 |
+
</groups>
|
69 |
+
</zagzig>
|
70 |
+
</sections>
|
71 |
+
</config>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Zagzig_Integration</name>
|
4 |
-
<version>1.0.
|
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>Zagzig integration extension for Magento.</summary>
|
10 |
<description>Zagzig Integration allows Magento users to automatically update their Zagzig Partner Portal with sales information so that no leads needs to be updated manually.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Pawel Burzynski</name><user>auto-converted</user><email>pawelburzynski@moneydebtandcredit.com</email></author></authors>
|
13 |
-
<date>2014-07-
|
14 |
-
<time>
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Zagzig_Integration.xml" hash="3b5e26fa50c9abb7034512e866ed47f6"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Zagzig_Integration</name>
|
4 |
+
<version>1.0.2</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>Zagzig integration extension for Magento.</summary>
|
10 |
<description>Zagzig Integration allows Magento users to automatically update their Zagzig Partner Portal with sales information so that no leads needs to be updated manually.</description>
|
11 |
+
<notes>added missing files</notes>
|
12 |
<authors><author><name>Pawel Burzynski</name><user>auto-converted</user><email>pawelburzynski@moneydebtandcredit.com</email></author></authors>
|
13 |
+
<date>2014-07-21</date>
|
14 |
+
<time>14:27:33</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Zagzig"><dir name="Integration"><dir name="etc"><file name="config.xml" hash="432ee4e297a257582f248c921bc4df77"/><file name="system.xml" hash="0e9535d99b35325c5babfa8a83a4439b"/></dir><dir name="Core"><file name="ZagzigRepository.php" hash="fe55459050c3196e618fbf6367f83889"/></dir><dir name="Model"><file name="CartObserver.php" hash="fb0d87896a40cbea1c97eb39921a9bfb"/><file name="SalesObserver.php" hash="4c61e8fea8efaefe93e4b8eb4d1ded28"/></dir><dir name="controllers"><file name="IndexController.php" hash="e5e5568986b18f5036a35f0c3cfe02ed"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zagzig_Integration.xml" hash="3b5e26fa50c9abb7034512e866ed47f6"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|