yuzu - Version 1.0.0

Version Notes

Official Yuzu plugin for Magento

Download this release

Release Info

Developer Jonathan Martin
Extension yuzu
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (27) hide show
  1. app/code/community/Yuzu/Tags/Block/Abstract.php +28 -0
  2. app/code/community/Yuzu/Tags/Block/Checkout.php +118 -0
  3. app/code/community/Yuzu/Tags/Block/Email.php +28 -0
  4. app/code/community/Yuzu/Tags/Block/Tags.php +67 -0
  5. app/code/community/Yuzu/Tags/Helper/Data.php +21 -0
  6. app/code/community/Yuzu/Tags/Model/Data.php +110 -0
  7. app/code/community/Yuzu/Tags/Model/Event.php +32 -0
  8. app/code/community/Yuzu/Tags/Model/Feed.php +102 -0
  9. app/code/community/Yuzu/Tags/Model/Notifier.php +22 -0
  10. app/code/community/Yuzu/Tags/Model/Observer.php +136 -0
  11. app/code/community/Yuzu/Tags/Model/System/Config/Source/Nb.php +23 -0
  12. app/code/community/Yuzu/Tags/controllers/CheckController.php +31 -0
  13. app/code/community/Yuzu/Tags/etc/adminhtml.xml +23 -0
  14. app/code/community/Yuzu/Tags/etc/config.xml +94 -0
  15. app/code/community/Yuzu/Tags/etc/system.xml +188 -0
  16. app/design/frontend/base/default/layout/yuzu_tags.xml +51 -0
  17. app/design/frontend/base/default/template/yuzu_tags/async_tag.phtml +46 -0
  18. app/design/frontend/base/default/template/yuzu_tags/email/invoice/items.phtml +26 -0
  19. app/design/frontend/base/default/template/yuzu_tags/email/offers.phtml +26 -0
  20. app/design/frontend/base/default/template/yuzu_tags/email/order/items.phtml +50 -0
  21. app/design/frontend/base/default/template/yuzu_tags/email/shipment/items.phtml +25 -0
  22. app/design/frontend/base/default/template/yuzu_tags/event.phtml +83 -0
  23. app/design/frontend/base/default/template/yuzu_tags/iframewrap.phtml +12 -0
  24. app/design/frontend/base/default/template/yuzu_tags/init.phtml +10 -0
  25. app/design/frontend/base/default/template/yuzu_tags/post_purchase.phtml +4 -0
  26. app/etc/modules/Yuzu_Tags.xml +9 -0
  27. package.xml +18 -0
app/code/community/Yuzu/Tags/Block/Abstract.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract block
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ abstract class Yuzu_Tags_Block_Abstract extends Mage_Core_Block_Template
13
+ {
14
+ public function isEnabled()
15
+ {
16
+ return Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/enable');
17
+ }
18
+
19
+ public function getMerchantKey()
20
+ {
21
+ return Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/merchant_key');
22
+ }
23
+
24
+ public function getApiUrl()
25
+ {
26
+ return Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/tag_url_collect');
27
+ }
28
+ }
app/code/community/Yuzu/Tags/Block/Checkout.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Checkout block
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Block_Checkout extends Yuzu_Tags_Block_Abstract
13
+ {
14
+ public function getEvent()
15
+ {
16
+ try {
17
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
18
+ if ($orderId) {
19
+ $order = Mage::getModel('sales/order')->load($orderId);
20
+
21
+ //Order data
22
+ $yuOrder = array(
23
+ 'id' => $order->getIncrementId(),
24
+ 'discount' => number_format($order->getDiscountAmount(), 2, ".", ""),
25
+ 'subtotal' => number_format($order->getSubtotal(), 2, ".", ""),
26
+ 'shipping' => number_format($order->getShippingAmount(), 2, ".", ""),
27
+ 'tax' => number_format($order->getTaxAmount(), 2, ".", ""),
28
+ 'paymentType' => $order->getPayment() ? $order->getPayment()->getMethodInstance()->getTitle() : 'unknown',
29
+ 'shippingMethod' => $order->getShippingDescription(),
30
+ 'total' => number_format($order->getGrandTotal(), 2, ".", ""),
31
+ 'currency' => $order->getOrderCurrencyCode(),
32
+ 'coupon' => $order->getCouponCode()
33
+ );
34
+ $event = $yuOrder;
35
+
36
+ //Products data
37
+ $yuItems = array();
38
+ foreach ($order->getAllVisibleItems() as $item) {
39
+
40
+ $options = $item->getProductOptions();
41
+ $itemOptions = array();
42
+ if(isset($options['attributes_info']))
43
+ {
44
+ foreach ($options['attributes_info'] as $option)
45
+ {
46
+ $itemOptions[strtolower($option['label'])] = $option['value'];
47
+ }
48
+ }
49
+
50
+ $yuItems[] = array(
51
+ 'productId' => $item->getProductId(),
52
+ 'quantity' => number_format($item->getQtyOrdered(), 0, ".", ""),
53
+ 'price' => number_format($item->getRowTotal(), 2, ".", ""),
54
+ 'discount' => number_format($item->getDiscountAmount(), 2, ".", ""),
55
+ 'options' => $itemOptions,
56
+ 'name' => $item->getName()
57
+ );
58
+
59
+ }
60
+ $event['lines'] = $yuItems;
61
+
62
+ //Customer data
63
+ $yuCustomer = array(
64
+ 'id' => ($order->getCustomerId()) ? $order->getCustomerId() : '0',
65
+ 'lastName' => $order->getCustomerLastname(),
66
+ 'firstName' => $order->getCustomerFirstname(),
67
+ 'email' => $order->getCustomerEmail(),
68
+ 'gender' => $this->getGender($order->getCustomerGender()),
69
+ 'birthday' => $order->getCustomerDob(),
70
+ 'addresses' => array()
71
+ );
72
+
73
+ //Shipping Address
74
+ $shippingAddress = Mage::getModel('sales/order_address')->load($order->getShippingAddressId());
75
+ $shipping = array();
76
+ $shipping['street'][] = $shippingAddress->getStreet1();
77
+ if ($shippingAddress->getStreet2()) {
78
+ $shipping['street'][] = $shippingAddress->getStreet2();
79
+ }
80
+ $shipping['postalCode'] = $shippingAddress->getPostcode();
81
+ $shipping['city'] = $shippingAddress->getCity();
82
+ $shipping['state'] = $shippingAddress->getRegion();
83
+ $shipping['country'] = $shippingAddress->getCountry();
84
+ $shipping['type'] = 'shipping';
85
+ $yuCustomer['addresses'][] = $shipping;
86
+
87
+ //Billing Address
88
+ $billingAddress = Mage::getModel('sales/order_address')->load($order->getBillingAddressId());
89
+ $billing = array();
90
+ $billing['street'][] = $billingAddress->getStreet1();
91
+ if ($billingAddress->getStreet2()) {
92
+ $billing['street'][] = $billingAddress->getStreet2();
93
+ }
94
+ $billing['postalCode'] = $billingAddress->getPostcode();
95
+ $billing['city'] = $billingAddress->getCity();
96
+ $billing['state'] = $billingAddress->getRegion();
97
+ $billing['country'] = $billingAddress->getCountry();
98
+ $billing['type'] = 'billing';
99
+ $yuCustomer['addresses'][] = $billing;
100
+
101
+ $event['customer'] = $yuCustomer;
102
+
103
+ return json_encode($event);
104
+ }
105
+ } catch (Exception $e) {
106
+ return false;
107
+ }
108
+
109
+ return false;
110
+ }
111
+
112
+ private function getGender($rawGender)
113
+ {
114
+ $gender = array('1' => 'm', '2' => 'f');
115
+
116
+ return (isset($gender[$rawGender])) ? $gender[$rawGender] : '';
117
+ }
118
+ }
app/code/community/Yuzu/Tags/Block/Email.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract block
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Block_Email extends Yuzu_Tags_Block_Abstract
13
+ {
14
+ public function getMaxOffers()
15
+ {
16
+ return Mage::helper('yuzu_tags')->getConfig('yuzu_tags/offers/nb');
17
+ }
18
+
19
+ public function getBaseUrl()
20
+ {
21
+ $baseUrl = Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/tag_url_collect');
22
+ if (preg_match('#^\/\/#', $baseUrl)) {
23
+ $baseUrl = 'http:'.$baseUrl;
24
+ }
25
+
26
+ return $baseUrl;
27
+ }
28
+ }
app/code/community/Yuzu/Tags/Block/Tags.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Tags block
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Block_Tags extends Yuzu_Tags_Block_Abstract
13
+ {
14
+ private $mca;
15
+
16
+ public function __construct()
17
+ {
18
+ $this->mca = $this->getRequest()->getModuleName()."-".$this->getRequest()->getControllerName()."-".$this->getRequest()->getActionName();
19
+ }
20
+
21
+ public function getuser()
22
+ {
23
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
24
+ return Mage::getSingleton('customer/session')->getCustomer();
25
+ }
26
+
27
+ return false;
28
+ }
29
+
30
+ public function getEvent()
31
+ {
32
+ return Mage::getModel('yuzu_tags/event')->resolveEventName($this->mca);
33
+ }
34
+
35
+ public function hasEventsAction()
36
+ {
37
+ switch ($this->getEvent()) {
38
+ case 'product' :
39
+ return true;
40
+ break;
41
+ default:
42
+ return false;
43
+ break;
44
+ }
45
+ }
46
+
47
+ public function getContext()
48
+ {
49
+ $locale = Mage::app()->getLocale()->getLocaleCode() ? Mage::app()->getLocale()->getLocaleCode() : 'en_US';
50
+ $locale = explode('_', $locale);
51
+
52
+ $context = array(
53
+ 'country' => $locale[1],
54
+ 'language' => $locale[0],
55
+ 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() ? Mage::app()->getStore()->getCurrentCurrencyCode() : "",
56
+ );
57
+
58
+ return json_encode($context);
59
+ }
60
+
61
+ public function getDatas()
62
+ {
63
+ $datas = Mage::getModel('yuzu_tags/data')->getDatas($this->mca, $this->getLayout());
64
+
65
+ return json_encode($datas);
66
+ }
67
+ }
app/code/community/Yuzu/Tags/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Data Helper
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Helper_Data extends Mage_Core_Helper_Abstract
13
+ {
14
+ public function getConfig($key, $store = false)
15
+ {
16
+ if (!$store) {
17
+ $store = Mage::app()->getStore();
18
+ }
19
+ return Mage::getStoreConfig($key, $store);
20
+ }
21
+ }
app/code/community/Yuzu/Tags/Model/Data.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Data Model
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_Data extends Mage_Core_Model_Abstract
13
+ {
14
+ private $data;
15
+ private $layout;
16
+
17
+ public function getDatas($mca, $layout)
18
+ {
19
+ $this->layout = $layout;
20
+ try {
21
+
22
+ switch ($mca) {
23
+ case 'cms-index-index': $this->pageHome();
24
+ break;
25
+ case 'catalog-product-view': $this->pageProduct();
26
+ break;
27
+ case 'catalog-category-view': $this->pageCategory();
28
+ break;
29
+ case 'catalogsearch-result-index': $this->pageSearch();
30
+ break;
31
+ case 'checkout-cart-index': $this->pageCart();
32
+ break;
33
+ default: return false;
34
+ break;
35
+ }
36
+ } catch (Exception $e) {
37
+ return false;
38
+ }
39
+
40
+ return $this->data;
41
+ }
42
+
43
+ private function pageHome()
44
+ {
45
+ }
46
+
47
+ private function pageProduct()
48
+ {
49
+ $product = Mage::registry('product');
50
+
51
+ if ($product) {
52
+ $this->data['id'] = $product->getId();
53
+ }
54
+ }
55
+
56
+ private function pageCategory()
57
+ {
58
+ $category = Mage::registry('current_category');
59
+
60
+ if ($category) {
61
+ $this->data['id'] = $category->getId();
62
+ }
63
+ }
64
+
65
+ private function pageSearch()
66
+ {
67
+ $this->data['query'] = Mage::helper('catalogsearch')->getEscapedQueryText() ? Mage::helper('catalogsearch')->getEscapedQueryText() : "";
68
+ $this->data['count'] = count(Mage::helper('catalogsearch')->getSuggestCollection()) ? count(Mage::helper('catalogsearch')->getSuggestCollection()) : "";
69
+ }
70
+
71
+ private function pageCart()
72
+ {
73
+ //cart data
74
+ $cart = Mage::getModel('checkout/cart')->getQuote();
75
+ $yuCart = array(
76
+ 'id' => $cart->getEntityId(),
77
+ 'total' => number_format($cart->getGrandTotal(), 2, ".", ""),
78
+ 'coupon' => $cart->getCouponCode()
79
+ );
80
+ $this->data = $yuCart;
81
+
82
+ //Products data
83
+ $yuItems = array();
84
+ foreach ($cart->getAllItems() as $item) {
85
+
86
+ if ($item->getParentItemId()) {
87
+ continue;
88
+ }
89
+
90
+ $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
91
+ $itemOptions = array();
92
+ if(isset($options['attributes_info']))
93
+ {
94
+ foreach ($options['attributes_info'] as $option)
95
+ {
96
+ $itemOptions[strtolower($option['label'])] = $option['value'];
97
+ }
98
+ }
99
+
100
+ $yuItems[] = array(
101
+ 'productId' => $item->getProductId(),
102
+ 'quantity' => number_format($item->getQty(), 0, ".", ""),
103
+ 'price' => number_format($item->getRowTotal(), 2, ".", ""),
104
+ 'discount' => number_format($item->getDiscountAmount(), 2, ".", ""),
105
+ 'options' => $itemOptions
106
+ );
107
+ }
108
+ $this->data['lines'] = $yuItems;
109
+ }
110
+ }
app/code/community/Yuzu/Tags/Model/Event.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event Model
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_Event extends Mage_Core_Model_Abstract
13
+ {
14
+ public function resolveEventName($mca)
15
+ {
16
+ switch ($mca) {
17
+ case 'cms-index-index': return 'home';
18
+ break;
19
+ case 'catalog-product-view': return 'product';
20
+ break;
21
+ case 'catalog-category-view': return 'category';
22
+ break;
23
+ case 'catalogsearch-result-index': return 'search';
24
+ break;
25
+ case 'checkout-cart-index': return 'cart';
26
+ break;
27
+ default:
28
+ return false;
29
+ break;
30
+ }
31
+ }
32
+ }
app/code/community/Yuzu/Tags/Model/Feed.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Feed Model
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_Feed extends Mage_AdminNotification_Model_Feed
13
+ {
14
+ const XML_FEED_URL_PATH = 'yuzu_tags/feed_url';
15
+
16
+ protected $_FeedUrl;
17
+
18
+ public function checkUpdate()
19
+ {
20
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
21
+ return $this;
22
+ }
23
+
24
+ $feedData = array();
25
+ $feedXml = $this->getFeedData();
26
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
27
+ foreach ($feedXml->channel->item as $item) {
28
+ $feedData[] = array(
29
+ 'severity' => (int)$item->severity,
30
+ 'date_added' => $this->getDate((string)$item->pubDate),
31
+ 'title' => (string)$item->title,
32
+ 'description' => (string)$item->description,
33
+ 'url' => (string)$item->link,
34
+ );
35
+ }
36
+
37
+ if ($feedData) {
38
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
39
+ }
40
+ }
41
+
42
+ $this->setLastUpdate();
43
+
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Retrieve Last update time
49
+ *
50
+ * @return int
51
+ */
52
+ public function getLastUpdate()
53
+ {
54
+ return Mage::app()->loadCache('yuzu_tags_notifications_lastcheck');
55
+ }
56
+
57
+ /**
58
+ * Set last update time (now)
59
+ *
60
+ * @return Mage_AdminNotification_Model_Feed
61
+ */
62
+ public function setLastUpdate()
63
+ {
64
+ Mage::app()->saveCache(time(), 'yuzu_tags_notifications_lastcheck');
65
+ return $this;
66
+ }
67
+
68
+ public function getFeedUrl()
69
+ {
70
+ if (is_null($this->_FeedUrl)) {
71
+ $this->_FeedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
72
+ . Mage::getStoreConfig(self::XML_FEED_URL_PATH);
73
+ }
74
+ return $this->_FeedUrl;
75
+ }
76
+
77
+ public function getFeedData()
78
+ {
79
+ $curl = new Varien_Http_Adapter_Curl();
80
+ $curl->setConfig(array(
81
+ 'timeout' => 3
82
+ ));
83
+
84
+ $curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
85
+ $data = $curl->read();
86
+
87
+ if ($data === false) {
88
+ return false;
89
+ }
90
+ $data = preg_split('/^\r?$/m', $data, 2);
91
+ $data = trim($data[1]);
92
+ $curl->close();
93
+ try {
94
+ $xml = new SimpleXMLElement($data);
95
+ }
96
+ catch (Exception $e) {
97
+ return false;
98
+ }
99
+
100
+ return $xml;
101
+ }
102
+ }
app/code/community/Yuzu/Tags/Model/Notifier.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Notifier Model
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_Notifier
13
+ {
14
+ public function preDispatch(Varien_Event_Observer $observer)
15
+ {
16
+ if (Mage::getSingleton('admin/session')->isLoggedIn())
17
+ {
18
+ $feedModel = Mage::getModel('yuzu_tags/feed');
19
+ $feedModel->checkUpdate();
20
+ }
21
+ }
22
+ }
app/code/community/Yuzu/Tags/Model/Observer.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Observer Model
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_Observer
13
+ {
14
+ /**
15
+ * @param $observer
16
+ */
17
+ public function handleSaveConfig($observer)
18
+ {
19
+ $secretKey = Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/secret_key');
20
+
21
+ if ($secretKey) {
22
+ $roleId = $this->getOrCreateRole();
23
+ $this->getOrCreateUser($roleId, $secretKey);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Retrieve or create Role Api Yuzu
29
+ *
30
+ * @return int RoleId
31
+ */
32
+ private function getOrCreateRole()
33
+ {
34
+ $yuzuRole = Mage::getModel('api/role')->getCollection()
35
+ ->addfieldToSelect('*')
36
+ ->addFieldToFilter('role_name', array('like' => 'yuzu'))
37
+ ->getFirstItem();
38
+
39
+ if (!$yuzuRole->getRoleId()) {
40
+
41
+ $resource = array(
42
+ "giftmessage",
43
+ "core",
44
+ "core/magento",
45
+ "core/magento/info",
46
+ "core/store",
47
+ "core/store/list",
48
+ "catalog",
49
+ "catalog/product",
50
+ "catalog/product/info",
51
+ "catalog/product/attributes",
52
+ "catalog/product/attribute",
53
+ "catalog/product/attribute/info",
54
+ "catalog/product/attribute/option",
55
+ "catalog/product/attribute/types",
56
+ "catalog/product/attribute/read",
57
+ "catalog/product/media",
58
+ "catalog/category",
59
+ "catalog/category/info",
60
+ "catalog/category/attributes",
61
+ "catalog/category/tree",
62
+ "sales",
63
+ "sales/order",
64
+ "sales/order/creditmemo",
65
+ "sales/order/creditmemo/list",
66
+ "sales/order/creditmemo/info",
67
+ "sales/order/invoice",
68
+ "sales/order/invoice/info",
69
+ "sales/order/invoice/void",
70
+ "sales/order/invoice/comment",
71
+ "sales/order/shipment",
72
+ "sales/order/shipment/info",
73
+ "sales/order/shipment/track",
74
+ "sales/order/info",
75
+ "customer",
76
+ "customer/info",
77
+ "customer/address",
78
+ "customer/address/info",
79
+ "cataloginventory",
80
+ "cataloginventory/info",
81
+ "directory",
82
+ "directory/region",
83
+ "directory/country",
84
+ );
85
+
86
+ $role = Mage::getModel('api/roles');
87
+
88
+ $role = $role
89
+ ->setName("yuzu")
90
+ ->setPid(false)
91
+ ->setRoleType('G')
92
+ ->save();
93
+
94
+ Mage::getModel("api/rules")
95
+ ->setRoleId($role->getId())
96
+ ->setResources($resource)
97
+ ->saveRel();
98
+
99
+ return $role->getId();
100
+ }
101
+
102
+ return $yuzuRole->getRoleId();
103
+ }
104
+
105
+ /**
106
+ * create api user if not exist
107
+ *
108
+ * @param $roleId
109
+ * @param $secretKey
110
+ */
111
+ public function getOrCreateUser($roleId, $secretKey)
112
+ {
113
+ $yuzuUser = Mage::getModel('api/user')->getCollection()
114
+ ->addfieldToSelect('*')
115
+ ->addFieldToFilter('username', array('like' => 'yuzu'))
116
+ ->getFirstItem();
117
+
118
+ if (!$yuzuUser->getUserId()) {
119
+ $user = Mage::getModel('api/user')->setData(array(
120
+ 'username' => 'yuzu',
121
+ 'firstname' => 'yuzu',
122
+ 'lastname' => 'api',
123
+ 'email' => 'hello@yuzu.co',
124
+ 'api_key' => $secretKey,
125
+ 'api_key_confirmation' => $secretKey,
126
+ 'is_active' => 1,
127
+ 'user_roles' => '',
128
+ 'assigned_user_role' => '',
129
+ 'role_name' => 'yuzu',
130
+ 'roles' => array($roleId)
131
+ ));
132
+ $user->save();
133
+ $user->setRoleIds(array($roleId))->setRoleUserId($user->getUserId())->saveRelations();
134
+ }
135
+ }
136
+ }
app/code/community/Yuzu/Tags/Model/System/Config/Source/Nb.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * System Config Source Nb
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_Model_System_Config_Source_Nb
13
+ {
14
+ public function toOptionArray()
15
+ {
16
+ return array(
17
+ '2' => '2',
18
+ '4' => '4',
19
+ '6' => '6',
20
+ '8' => '8'
21
+ );
22
+ }
23
+ }
app/code/community/Yuzu/Tags/controllers/CheckController.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Check controller
5
+ *
6
+ * @category Yuzu
7
+ * @package Yuzu_Tags
8
+ * @version 1.0.0
9
+ * @copyright Copyright (c) 2015 Yuzu (http://www.yuzu.co)
10
+ * @author Jonathan Martin <jonathan@yuzu.co>
11
+ */
12
+ class Yuzu_Tags_CheckController extends Mage_Core_Controller_Front_Action
13
+ {
14
+ public function statusAction()
15
+ {
16
+ $merchantKey = Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/merchant_key');
17
+ $secretKey = Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/secret_key');
18
+ $enabled = Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/enable');
19
+
20
+ $response = array(
21
+ 'mage_version' => Mage::getVersion(),
22
+ 'php_version' => phpversion(),
23
+ 'merchant_key' => ($merchantKey) ? true : false,
24
+ 'secret_key' => ($secretKey) ? true : false,
25
+ 'enabled' => ($enabled) ? true : false
26
+ );
27
+
28
+ $this->getResponse()->setHeader('Content-type', 'application/json');
29
+ $this->getResponse()->setBody(json_encode($response));
30
+ }
31
+ }
app/code/community/Yuzu/Tags/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <yuzu_tags translate="title" module="yuzu_tags">
12
+ <title>Yuzu</title>
13
+ <sort_order>100</sort_order>
14
+ </yuzu_tags>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Yuzu/Tags/etc/config.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yuzu_Tags>
5
+ <version>1.0.0</version>
6
+ </Yuzu_Tags>
7
+ </modules>
8
+
9
+ <global>
10
+ <helpers>
11
+ <yuzu_tags>
12
+ <class>Yuzu_Tags_Helper</class>
13
+ </yuzu_tags>
14
+ </helpers>
15
+ <blocks>
16
+ <yuzu_tags>
17
+ <class>Yuzu_Tags_Block</class>
18
+ </yuzu_tags>
19
+ </blocks>
20
+ <models>
21
+ <yuzu_tags>
22
+ <class>Yuzu_Tags_Model</class>
23
+ </yuzu_tags>
24
+ </models>
25
+ <events>
26
+ <admin_system_config_changed_section_yuzu_tags>
27
+ <observers>
28
+ <Yuzu_Tags_Observer>
29
+ <type>singleton</type>
30
+ <class>Yuzu_Tags_Model_Observer</class>
31
+ <method>handleSaveConfig</method>
32
+ </Yuzu_Tags_Observer>
33
+ </observers>
34
+ </admin_system_config_changed_section_yuzu_tags>
35
+ </events>
36
+ </global>
37
+
38
+ <frontend>
39
+ <layout>
40
+ <updates>
41
+ <yuzu_tags>
42
+ <file>yuzu_tags.xml</file>
43
+ </yuzu_tags>
44
+ </updates>
45
+ </layout>
46
+ <routers>
47
+ <yuzu>
48
+ <use>standard</use>
49
+ <args>
50
+ <module>Yuzu_Tags</module>
51
+ <frontName>yuzu</frontName>
52
+ </args>
53
+ </yuzu>
54
+ </routers>
55
+ </frontend>
56
+
57
+ <adminhtml>
58
+ <events>
59
+ <controller_action_predispatch>
60
+ <observers>
61
+ <yuzu_tags_controller_action_predispatch>
62
+ <class>Yuzu_Tags_Model_Notifier</class>
63
+ <method>preDispatch</method>
64
+ </yuzu_tags_controller_action_predispatch>
65
+ </observers>
66
+ </controller_action_predispatch>
67
+ </events>
68
+ </adminhtml>
69
+
70
+ <default>
71
+ <yuzu_tags>
72
+ <feed_url>my.yuzu.co/mage-notifications.rss</feed_url>
73
+ <general>
74
+ <tag_url_js>//cs.yuzu.co/js/collect/yuzu-0.0.3.js</tag_url_js>
75
+ <tag_url_collect>//cs.yuzu.co</tag_url_collect>
76
+ <enable>0</enable>
77
+ </general>
78
+ <offers>
79
+ <nb>4</nb>
80
+ <in_checkout>1</in_checkout>
81
+ <in_order_detail>1</in_order_detail>
82
+ <in_email_confirmation_order>1</in_email_confirmation_order>
83
+ <in_email_invoice>1</in_email_invoice>
84
+ <in_email_shipment>1</in_email_shipment>
85
+ </offers>
86
+ <events>
87
+ <product_addcart_form_selector>#product_addtocart_form</product_addcart_form_selector>
88
+ <product_addcart_button_selector>#product_addtocart_form .add-to-cart-buttons button</product_addcart_button_selector>
89
+ <product_addwishlist_button_selector>a.link-wishlist</product_addwishlist_button_selector>
90
+ <product_addcompare_button_selector>a.link-compare</product_addcompare_button_selector>
91
+ </events>
92
+ </yuzu_tags>
93
+ </default>
94
+ </config>
app/code/community/Yuzu/Tags/etc/system.xml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <yuzu translate="label" module="yuzu_tags">
5
+ <label>Yuzu</label>
6
+ <sort_order>600</sort_order>
7
+ <show_in_default>1</show_in_default>
8
+ <show_in_website>1</show_in_website>
9
+ <show_in_store>1</show_in_store>
10
+ </yuzu>
11
+ </tabs>
12
+ <sections>
13
+ <yuzu_tags translate="label" module="yuzu_tags">
14
+ <label>Yuzu API</label>
15
+ <tab>yuzu</tab>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>100</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <groups>
22
+ <general translate="label">
23
+ <comment>&lt;div style='background-color: none;margin-bottom: 10px;'&gt; &lt;img style='width: 205px;' src='http://www.yuzu.co/img/yuzu-logo@2x.png' /&gt; &lt;/div&gt; &lt;u&gt;Contact your account manager for support if you have questions on the fields below.&lt;/u&gt;</comment>
24
+ <label>General</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>0</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <fields>
31
+ <enable translate="label">
32
+ <label>Enable</label>
33
+ <comment>
34
+ <![CDATA[<span class="notice">Enable/Disable this plugin</span>]]>
35
+ </comment>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </enable>
43
+ <merchant_key translate="label">
44
+ <label>Yuzu Api Key</label>
45
+ <comment>
46
+ <![CDATA[<span class="notice">Don't have your API key yet? <br/><strong><a href="https://my.yuzu.co/register?from=magento" target="_blank">Create your Yuzu account in minutes!</a></strong></span>]]>
47
+ </comment>
48
+ <tooltip>Your Yuzu Api Key provided in my.yuzu.co</tooltip>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>2</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </merchant_key>
55
+ <secret_key translate="label">
56
+ <label>Yuzu Secret Key</label>
57
+ <tooltip>Your Yuzu Secret Key provided in my.yuzu.co</tooltip>
58
+ <frontend_type>password</frontend_type>
59
+ <sort_order>3</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </secret_key>
64
+
65
+ </fields>
66
+ </general>
67
+ <offers>
68
+ <label>Display offers</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>1</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ <fields>
75
+ <in_checkout translate="label">
76
+ <label>Display in checkout success</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <sort_order>2</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </in_checkout>
84
+ <in_order_detail translate="label">
85
+ <label>Display in order show</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>3</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ </in_order_detail>
93
+ <in_email_confirmation_order translate="label">
94
+ <label>Display in order confirmation email</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_yesno</source_model>
97
+ <sort_order>4</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </in_email_confirmation_order>
102
+ <in_email_invoice translate="label">
103
+ <label>Display in invoice email</label>
104
+ <frontend_type>select</frontend_type>
105
+ <source_model>adminhtml/system_config_source_yesno</source_model>
106
+ <sort_order>5</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ </in_email_invoice>
111
+ <in_email_shipment translate="label">
112
+ <label>Display in shipment email</label>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>adminhtml/system_config_source_yesno</source_model>
115
+ <sort_order>6</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ </in_email_shipment>
120
+ <nb translate="label">
121
+ <label>Nb offers to display in emails</label>
122
+ <frontend_type>select</frontend_type>
123
+ <source_model>yuzu_tags/system_config_source_nb</source_model>
124
+ <sort_order>7</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ </nb>
129
+ </fields>
130
+ </offers>
131
+ <events>
132
+ <label>Tag selectors</label>
133
+ <frontend_type>text</frontend_type>
134
+ <sort_order>2</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ <fields>
139
+ <product_addcart_form_selector translate="label">
140
+ <label>Product - "Add To cart" form css selector</label>
141
+ <comment>
142
+ <![CDATA[<span class="notice">Product Page - "Add to cart" form css selector</span>]]>
143
+ </comment>
144
+ <frontend_type>text</frontend_type>
145
+ <sort_order>10</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ </product_addcart_form_selector>
150
+ <product_addcart_button_selector translate="label">
151
+ <label>Product - "Add To cart" button css selector</label>
152
+ <comment>
153
+ <![CDATA[<span class="notice">Product Page - "Add to cart" button css selector</span>]]>
154
+ </comment>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>15</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ </product_addcart_button_selector>
161
+ <product_addwishlist_button_selector translate="label">
162
+ <label>Product - "Add To wishlist" button css selector</label>
163
+ <comment>
164
+ <![CDATA[<span class="notice">Product Page - "Add to wishlist" button css selector</span>]]>
165
+ </comment>
166
+ <frontend_type>text</frontend_type>
167
+ <sort_order>20</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>1</show_in_website>
170
+ <show_in_store>1</show_in_store>
171
+ </product_addwishlist_button_selector>
172
+ <product_addcompare_button_selector translate="label">
173
+ <label>Product - "Add To compare" button css selector</label>
174
+ <comment>
175
+ <![CDATA[<span class="notice">Product Page - "Add to compare" button css selector</span>]]>
176
+ </comment>
177
+ <frontend_type>text</frontend_type>
178
+ <sort_order>25</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ </product_addcompare_button_selector>
183
+ </fields>
184
+ </events>
185
+ </groups>
186
+ </yuzu_tags>
187
+ </sections>
188
+ </config>
app/design/frontend/base/default/layout/yuzu_tags.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+
3
+ <default>
4
+ <reference name="head">
5
+ <block type="yuzu_tags/tags" template="yuzu_tags/async_tag.phtml"/>
6
+ </reference>
7
+ <reference name="after_body_start">
8
+ <block type="yuzu_tags/tags" name="yuzu_init" template="yuzu_tags/init.phtml" />
9
+ <block type="yuzu_tags/tags" name="yuzu_event" template="yuzu_tags/event.phtml" after="yuzu_init" />
10
+ </reference>
11
+ </default>
12
+
13
+ <sales_order_view>
14
+ <block type="yuzu_tags/checkout" name="yuzu_post_purchase" template="yuzu_tags/post_purchase.phtml"/>
15
+ <reference name="my.account.wrapper">
16
+ <action method="append" ifconfig="yuzu_tags/offers/in_order_detail"><block>yuzu_post_purchase</block></action>
17
+ </reference>
18
+ </sales_order_view>
19
+
20
+ <checkout_onepage_success>
21
+ <block type="yuzu_tags/checkout" name="yuzu_wrap" template="yuzu_tags/iframewrap.phtml"/>
22
+ <reference name="content">
23
+ <action method="append" ifconfig="yuzu_tags/offers/in_checkout"><block>yuzu_wrap</block></action>
24
+ </reference>
25
+ </checkout_onepage_success>
26
+
27
+ <sales_email_order_items>
28
+ <block type="yuzu_tags/email" name="yuzu_offers" template="yuzu_tags/email/offers.phtml"/>
29
+ <reference name="items">
30
+ <action method="setTemplate" ifconfig="yuzu_tags/offers/in_email_confirmation_order"><template>yuzu_tags/email/order/items.phtml</template></action>
31
+ <action method="append" ifconfig="yuzu_tags/offers/in_email_confirmation_order"><block>yuzu_offers</block></action>
32
+ </reference>
33
+ </sales_email_order_items>
34
+
35
+ <sales_email_order_invoice_items>
36
+ <block type="yuzu_tags/email" name="yuzu_offers" template="yuzu_tags/email/offers.phtml"/>
37
+ <reference name="items">
38
+ <action method="setTemplate" ifconfig="yuzu_tags/offers/in_email_invoice"><template>yuzu_tags/email/invoice/items.phtml</template></action>
39
+ <action method="append" ifconfig="yuzu_tags/offers/in_email_invoice"><block>yuzu_offers</block></action>
40
+ </reference>
41
+ </sales_email_order_invoice_items>
42
+
43
+ <sales_email_order_shipment_items>
44
+ <block type="yuzu_tags/email" name="yuzu_offers" template="yuzu_tags/email/offers.phtml"/>
45
+ <reference name="items">
46
+ <action method="setTemplate" ifconfig="yuzu_tags/offers/in_email_shipment"><template>yuzu_tags/email/shipment/items.phtml</template></action>
47
+ <action method="append" ifconfig="yuzu_tags/offers/in_email_shipment"><block>yuzu_offers</block></action>
48
+ </reference>
49
+ </sales_email_order_shipment_items>
50
+
51
+ </layout>
app/design/frontend/base/default/template/yuzu_tags/async_tag.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->isEnabled()): ?>
2
+ <script type="text/javascript">
3
+ function addEvent(elem, event, fn) {
4
+ function listenHandler(e) {
5
+ var ret = fn.apply(this, arguments);
6
+ if (ret === false) {
7
+ e.stopPropagation();
8
+ e.preventDefault();
9
+ }
10
+ return(ret);
11
+ }
12
+
13
+ function attachHandler() {
14
+ var ret = fn.call(elem, window.event);
15
+ if (ret === false) {
16
+ window.event.returnValue = false;
17
+ window.event.cancelBubble = true;
18
+ }
19
+ return(ret);
20
+ }
21
+
22
+ if (elem.addEventListener) {
23
+ elem.addEventListener(event, listenHandler, false);
24
+ } else {
25
+ elem.attachEvent("on" + event, attachHandler);
26
+ }
27
+ }
28
+
29
+ var Yuzu = Yuzu || {configure: function(e) {
30
+ this._cf = e
31
+ }, addEvent: function(c, d, a) {
32
+ this._eq = this._eq || [], this._eq.push([c,d,a])
33
+ }, setCustomerId: function(i) {
34
+ this._mp = i
35
+ }, setL10n: function(l10n) {
36
+ this._l10n = l10n
37
+ }};
38
+ (function() {
39
+ var e = document.createElement("script");
40
+ e.type = "text/javascript", e.async = !0, e.src = ("https:" == document.location.protocol ? "https:" : "http:") + "<?php echo Mage::helper('yuzu_tags')->getConfig('yuzu_tags/general/tag_url_js'); ?>";
41
+
42
+ var t = document.getElementsByTagName("script")[0];
43
+ t.parentNode.insertBefore(e, t)
44
+ })();
45
+ </script>
46
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/email/invoice/items.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_invoice = $this->getInvoice() ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <?php if ($_invoice && $_order): ?>
4
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
5
+ <thead>
6
+ <tr>
7
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
8
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
9
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
10
+ <th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <?php $i=0; foreach ($_invoice->getAllItems() as $_item): ?>
15
+ <?php if($_item->getOrderItem()->getParentItem()) continue; else $i++; ?>
16
+ <tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
17
+ <?php echo $this->getItemHtml($_item) ?>
18
+ </tbody>
19
+ <?php endforeach; ?>
20
+
21
+ <tfoot>
22
+ <?php echo $this->getChildHtml('invoice_totals')?>
23
+ <?php echo $this->getChildHtml('yuzu_offers')?>
24
+ </tfoot>
25
+ </table>
26
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/email/offers.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_order = $this->getOrder() ?>
2
+ <?php $totalOffers = $this->getMaxOffers(); ?>
3
+ <?php $customerId = ($_order->getCustomerId()) ? $_order->getCustomerId() : 0; ?>
4
+ <?php $urlLink = $this->getBaseUrl().DS."click".DS.$this->getMerchantKey().DS.$customerId.DS.$_order->getIncrementId();?>
5
+ <?php $imgLink = $this->getBaseUrl().DS."ban".DS.$this->getMerchantKey().DS.$customerId.DS.$_order->getIncrementId();?>
6
+ <?php if ($_order): ?>
7
+ <tr>
8
+ <td colspan="8" align="center" style="padding: 10px;">
9
+ <a href="<?php echo $urlLink.DS."0";?>">
10
+ <img src="<?php echo $imgLink.DS."0.png"; ?>" alt="offer 0"/>
11
+ </a>
12
+ <table cellspacing="0" cellpadding="0" style="width: 100%; margin-top: 10px;">
13
+ <tr>
14
+ <?php for($i=1; $i <= $totalOffers; $i++ ) : ?>
15
+ <td align="center">
16
+ <a href="<?php echo $urlLink.DS.$i;?>">
17
+ <img src="<?php echo $imgLink.DS.$i.".png"; ?>" alt="offer <?php echo $i; ?>"/>
18
+ </a>
19
+ </td>
20
+ <?php if($i%2 == 0 && $i < $totalOffers): ?></tr><tr><?php endif; ?>
21
+ <?php endfor; ?>
22
+ </tr>
23
+ </table>
24
+ </td>
25
+ </tr>
26
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/email/order/items.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_order = $this->getOrder() ?>
2
+ <?php if ($_order): ?>
3
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
4
+ <thead>
5
+ <tr>
6
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
7
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
8
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
9
+ <th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <?php $i=0; foreach ($_order->getAllItems() as $_item): ?>
14
+ <?php if($_item->getParentItem()) continue; else $i++; ?>
15
+ <tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
16
+ <?php echo $this->getItemHtml($_item) ?>
17
+ </tbody>
18
+ <?php endforeach; ?>
19
+
20
+ <tbody>
21
+ <?php echo $this->getChildHtml('order_totals') ?>
22
+ <?php echo $this->getChildHtml('yuzu_offers') ?>
23
+ </tbody>
24
+
25
+ </table>
26
+ <?php if ($this->helper('giftmessage/message')->isMessagesAvailable('order', $_order, $_order->getStore()) && $_order->getGiftMessageId()): ?>
27
+ <?php $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_order->getGiftMessageId()); ?>
28
+ <?php if ($_giftMessage): ?>
29
+ <br />
30
+ <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #EAEAEA;">
31
+ <thead>
32
+ <tr>
33
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><strong><?php echo $this->__('Gift Message for this Order') ?></strong></th>
34
+ </tr>
35
+ </thead>
36
+
37
+ <tbody>
38
+
39
+ <tr>
40
+ <td colspan="4" align="left" style="padding:3px 9px">
41
+ <strong><?php echo $this->__('From:'); ?></strong> <?php echo $this->escapeHtml($_giftMessage->getSender()) ?>
42
+ <br /><strong><?php echo $this->__('To:'); ?></strong> <?php echo $this->escapeHtml($_giftMessage->getRecipient()) ?>
43
+ <br /><strong><?php echo $this->__('Message:'); ?></strong><br /> <?php echo $this->escapeHtml($_giftMessage->getMessage()) ?>
44
+ </td>
45
+ </tr>
46
+ </tbody>
47
+ </table>
48
+ <?php endif; ?>
49
+ <?php endif; ?>
50
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/email/shipment/items.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_shipment = $this->getShipment() ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <?php if ($_shipment && $_order): ?>
4
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
5
+ <thead>
6
+ <tr>
7
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
8
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
9
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <?php $i=0; foreach ($_shipment->getAllItems() as $_item): ?>
14
+ <?php if($_item->getOrderItem()->getParentItem()) continue; else $i++; ?>
15
+ <tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
16
+ <?php echo $this->getItemHtml($_item) ?>
17
+ </tbody>
18
+ <?php endforeach; ?>
19
+
20
+ <tfoot>
21
+ <?php echo $this->getChildHtml('yuzu_offers')?>
22
+ </tfoot>
23
+
24
+ </table>
25
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/event.phtml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $helper = Mage::helper('yuzu_tags'); ?>
2
+
3
+ <?php if ($this->isEnabled()): ?>
4
+
5
+ <?php $event = $this->getEvent(); ?>
6
+ <?php $user = $this->getUser(); ?>
7
+ <?php $l10n = $this->getContext(); ?>
8
+
9
+ <script type="text/javascript">
10
+ Yuzu.setL10n(<?php echo $l10n; ?>);
11
+ <?php if ($user): ?>
12
+ Yuzu.setCustomerId("<?php echo $user->getId(); ?>");
13
+ <?php endif; ?>
14
+ </script>
15
+
16
+ <?php if ($event): ?>
17
+ <script type="text/javascript">
18
+ Yuzu.addEvent("<?php echo $this->getEvent(); ?>", <?php echo $this->getDatas(); ?>);
19
+ </script>
20
+ <?php endif; ?>
21
+
22
+ <?php if ($this->hasEventsAction()) : ?>
23
+ <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/sizzle/1.10.19/sizzle.min.js"></script>
24
+ <script type="text/javascript">
25
+ (function(){
26
+ var yuzuAddToCart = function(){
27
+ var form = Sizzle('<?php echo $helper->getConfig('yuzu_tags/general/product_addcart_form_selector'); ?>');
28
+ var url = form[0].getAttribute('action');
29
+ var matches = url.match('\/product\/([0-9]+)\/');
30
+ var data = {
31
+ productId: matches[1]
32
+ };
33
+ yuzuAddGeneric(data, 'add-basket');
34
+ };
35
+
36
+ var yuzuAddToWishlist = function(event) {
37
+ var url = event.currentTarget.getAttribute('href');
38
+ var matches = url.match('\/product\/([0-9]+)\/');
39
+ var data = {
40
+ productId: matches[1]
41
+ };
42
+
43
+ yuzuAddGeneric(data, 'add-wishlist');
44
+ };
45
+
46
+ var yuzuAddToCompare = function(event) {
47
+ var url = event.currentTarget.getAttribute('href');
48
+ var matches = url.match('\/product\/([0-9]+)\/');
49
+ var data = {
50
+ productId: matches[1]
51
+ };
52
+
53
+ yuzuAddGeneric(data, 'add-compare');
54
+ };
55
+
56
+ var yuzuAddGeneric = function(data, action) {
57
+ if (typeof Yuzu != "undefined"){
58
+ Yuzu.addEvent('product', data, action)
59
+ }
60
+ };
61
+
62
+ var yuzuLoadCallback = function() {
63
+ var ele = Sizzle('<?php echo $helper->getConfig('yuzu_tags/general/product_addcart_button_selector'); ?>');
64
+ if (ele.length > 0){
65
+ addEvent(ele[0], 'click', yuzuAddToCart);
66
+ }
67
+
68
+ var ele2 = Sizzle('<?php echo $helper->getConfig('yuzu_tags/general/product_addwishlist_button_selector'); ?>');
69
+ if (ele2.length > 0){
70
+ addEvent(ele2[0], 'click', yuzuAddToWishlist);
71
+ }
72
+
73
+ var ele3 = Sizzle('<?php echo $helper->getConfig('yuzu_tags/general/product_addcompare_button_selector'); ?>');
74
+ if (ele3.length > 0){
75
+ addEvent(ele3[0], 'click', yuzuAddToCompare);
76
+ }
77
+ };
78
+ addEvent(window, 'load', yuzuLoadCallback);
79
+ })();
80
+ </script>
81
+ <?php endif; ?>
82
+
83
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/iframewrap.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isEnabled()): ?>
2
+
3
+ <?php $event = $this->getEvent(); ?>
4
+
5
+ <?php if ($event): ?>
6
+ <div id="yuzuwrap"></div>
7
+ <script type="text/javascript">
8
+ Yuzu.addEvent("order", <?php echo $event; ?>);
9
+ </script>
10
+ <?php endif; ?>
11
+
12
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/init.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isEnabled()): ?>
2
+ <script type="text/javascript">
3
+ (function(){
4
+ Yuzu.configure({
5
+ merchantKey: "<?php echo $this->getMerchantKey(); ?>",
6
+ yuzuUrl: "<?php echo $this->getApiUrl(); ?>"
7
+ });
8
+ })();
9
+ </script>
10
+ <?php endif; ?>
app/design/frontend/base/default/template/yuzu_tags/post_purchase.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php if ($this->isEnabled()): ?>
2
+ <?php $_order = Mage::registry('current_order'); ?>
3
+ <div id="yuzuwrap" data-zone="order_view" data-customer="<?php echo $_order->getCustomerId(); ?>" data-order="<?php echo $_order->getIncrementId(); ?>"></div>
4
+ <?php endif; ?>
app/etc/modules/Yuzu_Tags.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yuzu_Tags>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Yuzu_Tags>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>yuzu</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.yuzu.co">Custom licence</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Yuzu</summary>
10
+ <description>Yuzu</description>
11
+ <notes>Official Yuzu plugin for Magento</notes>
12
+ <authors><author><name>Jonathan Martin</name><user>jmartin</user><email>jonathan@yuzu.co</email></author></authors>
13
+ <date>2015-02-09</date>
14
+ <time>17:25:53</time>
15
+ <contents><target name="magecommunity"><dir name="Yuzu"><dir name="Tags"><dir name="Block"><file name="Abstract.php" hash="1f88a40352e1b0192a4e8a9835ca79ad"/><file name="Checkout.php" hash="a52c4c134ea9d0c3818c79f34f5c013e"/><file name="Email.php" hash="472fb0038d3d8171b8209ca76018b4ef"/><file name="Tags.php" hash="9803f9d837bed1e3da7c4b42b3996f89"/></dir><dir name="Helper"><file name="Data.php" hash="77f09db03a5aae09be0e9cc801ebd412"/></dir><dir name="Model"><file name="Data.php" hash="38a8a695ca9a61a2160dd2ea48cc6b6d"/><file name="Event.php" hash="192c6918f478d676d3260de461501d82"/><file name="Feed.php" hash="40278b4837036fcd88641af6d2888fee"/><file name="Notifier.php" hash="beaa0f9aa9bcccb7e6402740c460d4ae"/><file name="Observer.php" hash="a9038e22f48354c5b1a6f706f7e993db"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Nb.php" hash="1e1bf27b4749a2f3caa9bed5c45c7bf7"/></dir></dir></dir></dir><dir name="controllers"><file name="CheckController.php" hash="aeb20ad798dfa91cb5168e56a8a98cd4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1402ebcefa884063791db10144f314a3"/><file name="config.xml" hash="a75571aec0220df574846236e102ce84"/><file name="system.xml" hash="71eedce33809fcb50ff760c5a59ef43a"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yuzu_tags.xml" hash="41a0c1814174885fd3d21eaf0612fe9e"/></dir><dir name="template"><dir name="yuzu_tags"><file name="async_tag.phtml" hash="6d64dc98d0886411a7833de6e9a76ccf"/><dir><dir name="email"><dir name="invoice"><file name="items.phtml" hash="a69e17038115272fc4b1f2f7318f7c35"/></dir><file name="offers.phtml" hash="83ad1604a5d6029af17083f0ff3ddaa0"/><dir name="order"><file name="items.phtml" hash="7e604a8b4b29183499f2673d28daba55"/></dir><dir name="shipment"><file name="items.phtml" hash="997065e2d6a6fec7704c99a743521731"/></dir></dir></dir><file name="event.phtml" hash="04de9167cd5165aff94d86e1df0c33af"/><file name="iframewrap.phtml" hash="8d0c1cf0ef68b8262cb3ac96d2359776"/><file name="init.phtml" hash="c13aad83caeec260587c16a8ff0c71de"/><file name="post_purchase.phtml" hash="6e95f079b990cde565931a02cfe5e98b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yuzu_Tags.xml" hash="966c25c3c7f93c697b07295201bb460c"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
18
+ </package>