firecart_integration - Version 1.0.0

Version Notes

This is a first release of firecart. Please use support to contact in case of queries.

Download this release

Release Info

Developer Canvass Tech
Extension firecart_integration
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Firecart/FirecartIntegration/Helper/Data.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Firecart_FirecartIntegration_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
6
+ class Firecart_FirecartIntegration_Model_Observer
7
+ {
8
+ public function placeCustomJs()
9
+ {
10
+
11
+ $roleId = Mage::getSingleton('customer/session')->getCustomerGroupId();
12
+ $role = Mage::getSingleton('customer/group')->load($roleId)->getData('customer_group_code');
13
+ $role = strtolower($role);
14
+
15
+ $headBlock = Mage::app()->getLayout()->getBlock('head');
16
+ //if($headBlock && $role=='wholesale')
17
+ if($headBlock)
18
+ {
19
+ $headBlock->addJs('test/myScript.js');
20
+ }
21
+ return $this;
22
+ }
23
+ }
24
+ ?>
app/code/community/Firecart/FirecartIntegration/Model/Api2/Customer/Rest/Admin/V1.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Rohit Shinde. http://firecart.io
5
+ */
6
+
7
+ class Firecart_FirecartIntegration_Model_Api2_Customer_Rest_Admin_V1 extends Mage_Customer_Model_Api2_Customer_Rest {
8
+
9
+ /**
10
+ * Retrieve information about customer
11
+ * Add last logged in datetime
12
+ *
13
+ * @throws Mage_Api2_Exception
14
+ * @return array
15
+ */
16
+ protected function _retrieve() {
17
+ /** @var $log Mage_Log_Model_Customer */
18
+ $log = Mage::getModel('log/customer');
19
+ $log->loadByCustomer($this->getRequest()->getParam('id'));
20
+
21
+ $data = parent::_retrieve();
22
+ $data['is_confirmed'] = (int) !(isset($data['confirmation']) && $data['confirmation']);
23
+
24
+ $lastLoginAt = $log->getLoginAt();
25
+ if (null !== $lastLoginAt) {
26
+ $data['last_logged_in'] = $lastLoginAt;
27
+ }
28
+ return $data;
29
+ }
30
+
31
+ /**
32
+ * Get customers list
33
+ *
34
+ * @return array
35
+ */
36
+ protected function _retrieveCollection() {
37
+ // $data = $this->_getCollectionForRetrieve()->load()->toArray();
38
+ $data = $this->_getCollectionForRetrieve();
39
+
40
+
41
+ $customersData = array();
42
+ foreach ($data->getItems() as $customer) {
43
+ if ($customer) { //check if the customer exists or is not guest
44
+ $gender = $customer->getGender(); //this will return some id
45
+ $genderText = $customer->getResource()
46
+ ->getAttribute('gender')
47
+ ->getSource()
48
+ ->getOptionText($customer->getData('gender')); //you get the label of the gender
49
+ $customer['gender'] = $genderText;
50
+ }
51
+ $customersData[$customer->getId()] = $customer->toArray();
52
+ }
53
+
54
+ $cust_arr = array();
55
+ foreach ($data as $custId => $customer) {
56
+ array_push($cust_arr, $custId);
57
+ }
58
+ $orderCollection = Mage::getModel('sales/order')
59
+ ->getCollection()
60
+ ->addFieldToFilter('customer_id', array('in' => $cust_arr))
61
+ ->addAttributeToSelect('customer_id');
62
+
63
+ $orderCollection->getSelect()
64
+ ->columns('SUM(grand_total) as total_amount, COUNT(*) as total_orders, MAX(entity_id) as last_order_id')
65
+ ->group('customer_id');
66
+ $orderCollection->load();
67
+ $order_arr = $orderCollection->toArray();
68
+
69
+ $ordersData = array();
70
+ foreach ($order_arr['items'] as $order) {
71
+ $ordersData[$order['customer_id']] = $order;
72
+ }
73
+
74
+ if ($customersData) {
75
+ foreach ($customersData as $custId => $customer) {
76
+ foreach ($ordersData as $ord_cust_id => $order) {
77
+ if ($custId == $ord_cust_id):
78
+ $customersData[$custId]['total_amount_spent'] = $order['total_amount'];
79
+ $customersData[$custId]['orders_count'] = $order['total_orders'];
80
+ $customersData[$custId]['last_order_id'] = $order['last_order_id'];
81
+ endif;
82
+ }
83
+ }
84
+ }
85
+
86
+ return $customersData;
87
+ }
88
+
89
+ }
app/code/community/Firecart/FirecartIntegration/Model/Api2/Order/Rest/Admin/V1.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Rohit Shinde. http://firecart.io
5
+ */
6
+
7
+ class Firecart_FirecartIntegration_Model_Api2_Order_Rest_Admin_V1 extends Mage_Sales_Model_Api2_Order_Rest {
8
+
9
+ /**
10
+ * Retrieve information about specified order item
11
+ *
12
+ * @throws Mage_Api2_Exception
13
+ * @return array
14
+ */
15
+ protected function _retrieve() {
16
+ $orderId = $this->getRequest()->getParam('id');
17
+ $collection = $this->_getCollectionForSingleRetrieve($orderId);
18
+
19
+ if ($this->_isPaymentMethodAllowed()) {
20
+ $this->_addPaymentMethodInfo($collection);
21
+ }
22
+ if ($this->_isGiftMessageAllowed()) {
23
+ $this->_addGiftMessageInfo($collection);
24
+ }
25
+ $this->_addTaxInfo($collection);
26
+
27
+ $order = $collection->getItemById($orderId);
28
+
29
+ if (!$order) {
30
+ $this->_critical(self::RESOURCE_NOT_FOUND);
31
+ }
32
+ $orderData = $order->getData();
33
+ $addresses = $this->_getAddresses(array($orderId));
34
+ $items = $this->_getItems(array($orderId));
35
+ $comments = $this->_getComments(array($orderId));
36
+
37
+ if ($addresses) {
38
+ $orderData['addresses'] = $addresses[$orderId];
39
+ }
40
+ if ($items) {
41
+ $itemsArray = array();
42
+ $modifiedItems = array();
43
+ foreach ($items as $_items) {
44
+ foreach ($_items as $item) {
45
+ $product = Mage::getModel('catalog/product')->load($item['item_id']);
46
+ if ($product):
47
+ $url = $product->getProductUrl();
48
+ $imageUrl = $product->getSmallImageUrl();
49
+ $item['product_url'] = $url;
50
+ $item['image_url'] = $imageUrl;
51
+ endif;
52
+ array_push($modifiedItems, $item);
53
+ }
54
+ }
55
+ $itemsArray = array($orderId => $modifiedItems);
56
+ $orderData['order_items'] = $itemsArray[$orderId];
57
+ }
58
+ if ($comments) {
59
+ $orderData['order_comments'] = $comments[$orderId];
60
+ }
61
+ return $orderData;
62
+ }
63
+
64
+ /**
65
+ * Retrieve list of coupon codes.
66
+ *
67
+ * @return array
68
+ */
69
+ protected function _retrieveCollection() {
70
+ $cust_type = $this->getRequest()->getParam('cust_type');
71
+ if ($cust_type == "GUEST") {
72
+ $collection = Mage::getModel('sales/order')->getCollection()
73
+ ->addAttributeToSelect('*')
74
+ ->addAttributeToFilter('customer_group_id', Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
75
+ $this->_applyCollectionModifiers($collection);
76
+ } else {
77
+ $collection = $this->_getCollectionForRetrieve();
78
+ }
79
+
80
+ if ($this->_isPaymentMethodAllowed()) {
81
+ $this->_addPaymentMethodInfo($collection);
82
+ }
83
+ if ($this->_isGiftMessageAllowed()) {
84
+ $this->_addGiftMessageInfo($collection);
85
+ }
86
+ $this->_addTaxInfo($collection);
87
+
88
+ $ordersData = array();
89
+
90
+ foreach ($collection->getItems() as $order) {
91
+ $ordersData[$order->getId()] = $order->toArray();
92
+ }
93
+ if ($ordersData) {
94
+ foreach ($this->_getAddresses(array_keys($ordersData)) as $orderId => $addresses) {
95
+ $ordersData[$orderId]['addresses'] = $addresses;
96
+ }
97
+
98
+ foreach ($this->_getItems(array_keys($ordersData)) as $orderId => $items) {
99
+ $modifiedItems = array();
100
+ foreach ($items as $item) {
101
+ $product = Mage::getModel('catalog/product');
102
+ $product->load($product->getIdBySku($item['sku']));
103
+ if ($product):
104
+ $url = $product->getProductUrl();
105
+ $imageUrl = $product->getSmallImageUrl();
106
+ $item['product_url'] = $url;
107
+ $item['image_url'] = $imageUrl;
108
+ endif;
109
+ array_push($modifiedItems, $item);
110
+ }
111
+ $ordersData[$orderId]['order_items'] = $modifiedItems;
112
+ }
113
+
114
+ }
115
+ return $ordersData;
116
+ }
117
+
118
+ }
app/code/community/Firecart/FirecartIntegration/Model/Observer.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Firecart_FirecartIntegration_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
6
+
7
+ class Firecart_FirecartIntegration_Model_Observer {
8
+
9
+ public function logCartRemove(Varien_Event_Observer $observer) {
10
+ $product = $observer->getQuoteItem()->getProduct();
11
+ if (!$product->getId()) {
12
+ return;
13
+ }
14
+ Mage::getModel('core/session')->setProductToShoppingCart(
15
+ new Varien_Object(array(
16
+ 'id' => $product->getId(),
17
+ 'name' => $product->getName(),
18
+ 'price' => $product->getPrice(),
19
+ 'product_url' => $product->getProductUrl(),
20
+ 'product_img' => $product->getSmallImageUrl(),
21
+ 'category_name' => Mage::getModel('catalog/category')->load($categories[0])->getName(),
22
+ ))
23
+ );
24
+ }
25
+
26
+ public function logCartAdd(Varien_Event_Observer $observer) {
27
+ $product = Mage::getModel('catalog/product')
28
+ ->load($observer->getData('controller_action')->getRequest()->getParam('product', 0));
29
+
30
+ if (!$product->getId()) {
31
+ return;
32
+ }
33
+
34
+ $categories = $product->getCategoryIds();
35
+ Mage::getModel('core/session')->setProductToShoppingCart(
36
+ new Varien_Object(array(
37
+ 'id' => $product->getId(),
38
+ 'qty' => $observer->getData('controller_action')->getRequest()->getParam('qty', 1),
39
+ 'name' => $product->getName(),
40
+ 'price' => $product->getPrice(),
41
+ 'product_url' => $product->getProductUrl(),
42
+ 'product_img' => $product->getSmallImageUrl(),
43
+ 'category_name' => Mage::getModel('catalog/category')->load($categories[0])->getName(),
44
+ ))
45
+ );
46
+ }
47
+
48
+ public function placeCustomJs(Varien_Event_Observer $observer) {
49
+ $event = $observer->getEvent();
50
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
51
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
52
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
53
+ $name = $customer->getFirstname() . ' ' . $customer->getLastname();
54
+ $isActive = $customer->getIsActive();
55
+ $email = $customer->getEmail();
56
+ $mobile = "";
57
+ if ($customer->getPrimaryBillingAddress() != NULL) {
58
+ $mobile = $customer->getPrimaryBillingAddress()->getTelephone();
59
+ }
60
+ }
61
+
62
+ $layout = $observer->getEvent()->getLayout();
63
+ $update = $layout->getUpdate();
64
+
65
+ $action = $observer->getEvent()->getAction();
66
+ $fullActionName = $action->getFullActionName();
67
+
68
+ if ($action instanceof Mage_Checkout_OnepageController && $action->getRequest()->getRequestedActionName() == 'success') {
69
+ $update->addHandle('conversion_tracking_handle');
70
+ } else {
71
+ $update->addHandle('non_conversion_tracking_handle');
72
+ }
73
+
74
+ return $this;
75
+ }
76
+
77
+ }
78
+
79
+ ?>
app/code/community/Firecart/FirecartIntegration/Model/Sales/Api2/Order/Rest.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Abstract API2 class for order item
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sales
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ abstract class Mage_Sales_Model_Api2_Order_Rest extends Mage_Sales_Model_Api2_Order
35
+ {
36
+ /**
37
+ * Retrieve information about specified order item
38
+ *
39
+ * @throws Mage_Api2_Exception
40
+ * @return array
41
+ */
42
+ protected function _retrieve()
43
+ {
44
+ $orderId = $this->getRequest()->getParam('id');
45
+ $collection = $this->_getCollectionForSingleRetrieve($orderId);
46
+
47
+ if ($this->_isPaymentMethodAllowed()) {
48
+ $this->_addPaymentMethodInfo($collection);
49
+ }
50
+ if ($this->_isGiftMessageAllowed()) {
51
+ $this->_addGiftMessageInfo($collection);
52
+ }
53
+ $this->_addTaxInfo($collection);
54
+
55
+ $order = $collection->getItemById($orderId);
56
+
57
+ if (!$order) {
58
+ $this->_critical(self::RESOURCE_NOT_FOUND);
59
+ }
60
+ $orderData = $order->getData();
61
+ $addresses = $this->_getAddresses(array($orderId));
62
+ $items = $this->_getItems(array($orderId));
63
+ $comments = $this->_getComments(array($orderId));
64
+
65
+ if ($addresses) {
66
+ $orderData['addresses'] = $addresses[$orderId];
67
+ }
68
+ if ($items) {
69
+ $orderData['order_items'] = $items[$orderId];
70
+ }
71
+ if ($comments) {
72
+ $orderData['order_comments'] = $comments[$orderId];
73
+ }
74
+ return $orderData;
75
+ }
76
+
77
+ /**
78
+ * Get orders list
79
+ *
80
+ * @return array
81
+ */
82
+ protected function _retrieveCollection()
83
+ {
84
+ $collection = $this->_getCollectionForRetrieve();
85
+
86
+ if ($this->_isPaymentMethodAllowed()) {
87
+ $this->_addPaymentMethodInfo($collection);
88
+ }
89
+ if ($this->_isGiftMessageAllowed()) {
90
+ $this->_addGiftMessageInfo($collection);
91
+ }
92
+ $this->_addTaxInfo($collection);
93
+
94
+ $ordersData = array();
95
+
96
+ foreach ($collection->getItems() as $order) {
97
+ $ordersData[$order->getId()] = $order->toArray();
98
+ }
99
+ if ($ordersData) {
100
+ foreach ($this->_getAddresses(array_keys($ordersData)) as $orderId => $addresses) {
101
+ $ordersData[$orderId]['addresses'] = $addresses;
102
+ }
103
+ foreach ($this->_getItems(array_keys($ordersData)) as $orderId => $items) {
104
+ $ordersData[$orderId]['order_items'] = $items;
105
+ }
106
+ foreach ($this->_getComments(array_keys($ordersData)) as $orderId => $comments) {
107
+ $ordersData[$orderId]['order_comments'] = $comments;
108
+ }
109
+ }
110
+ return $ordersData;
111
+ }
112
+ }
app/code/community/Firecart/FirecartIntegration/Model/Sales/Api2/Order/Rest/Admin/V1.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * API2 class for orders (admin)
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Sales
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Firecart_FirecartIntegration_Model_Sales_Api2_Order_Rest_Admin_V1 extends Mage_Sales_Model_Api2_Order_Rest
35
+ {
36
+ /**
37
+ * Retrieve information about specified order item
38
+ *
39
+ * @throws Mage_Api2_Exception
40
+ * @return array
41
+ */
42
+ protected function _retrieve()
43
+ {
44
+ $orderId = $this->getRequest()->getParam('id');
45
+ $collection = $this->_getCollectionForSingleRetrieve($orderId);
46
+
47
+ if ($this->_isPaymentMethodAllowed()) {
48
+ $this->_addPaymentMethodInfo($collection);
49
+ }
50
+ if ($this->_isGiftMessageAllowed()) {
51
+ $this->_addGiftMessageInfo($collection);
52
+ }
53
+ $this->_addTaxInfo($collection);
54
+
55
+ $order = $collection->getItemById($orderId);
56
+
57
+ if (!$order) {
58
+ $this->_critical(self::RESOURCE_NOT_FOUND);
59
+ }
60
+ $orderData = $order->getData();
61
+ $addresses = $this->_getAddresses(array($orderId));
62
+ $items = $this->_getItems(array($orderId));
63
+ $comments = $this->_getComments(array($orderId));
64
+
65
+ if ($addresses) {
66
+ $orderData['addresses'] = $addresses[$orderId];
67
+ }
68
+ if ($items) {
69
+ $orderData['order_items'] = $items[$orderId];
70
+ }
71
+ if ($comments) {
72
+ $orderData['order_comments'] = $comments[$orderId];
73
+ }
74
+ return $orderData;
75
+ }
76
+
77
+ /**
78
+ * Get orders list
79
+ *
80
+ * @return array
81
+ */
82
+ protected function _retrieveCollection()
83
+ {
84
+ $collection = $this->_getCollectionForRetrieve();
85
+
86
+ if ($this->_isPaymentMethodAllowed()) {
87
+ $this->_addPaymentMethodInfo($collection);
88
+ }
89
+ if ($this->_isGiftMessageAllowed()) {
90
+ $this->_addGiftMessageInfo($collection);
91
+ }
92
+ $this->_addTaxInfo($collection);
93
+
94
+ $ordersData = array();
95
+
96
+ foreach ($collection->getItems() as $order) {
97
+ $ordersData[$order->getId()] = $order->toArray();
98
+ }
99
+ if ($ordersData) {
100
+ foreach ($this->_getAddresses(array_keys($ordersData)) as $orderId => $addresses) {
101
+ $ordersData[$orderId]['addresses'] = $addresses;
102
+ }
103
+ foreach ($this->_getItems(array_keys($ordersData)) as $orderId => $items) {
104
+ $ordersData[$orderId]['order_items'] = $items;
105
+ }
106
+ foreach ($this->_getComments(array_keys($ordersData)) as $orderId => $comments) {
107
+ $ordersData[$orderId]['order_comments'] = $comments;
108
+ }
109
+ }
110
+ return $ordersData;
111
+ }
112
+ }
app/code/community/Firecart/FirecartIntegration/Model/Settings.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Firecart_FirecartIntegration_Model_Settings extends Mage_Core_Model_Config_Data {
4
+
5
+ public function save() {
6
+ // $accessKey = Mage::getStoreConfig('firecart_options/messages/access_key');
7
+ $accessKey = $this->getValue();
8
+ // $fax = $this->getValue(); //get the value from our config
9
+ // $fax = preg_replace('#[^0-9]#','',$fax); //strip non numeric
10
+ // if(strlen($fax) < 10) //exit if we're less than 10 digits long
11
+ // {
12
+ // Mage::throwException("Fax Numbers need 10 digits. For American Numbers. Programming
13
+ //examples are horribly US-ethnocentric sometimes.");
14
+ // }
15
+
16
+ return parent::save(); //call original save method so whatever happened
17
+ //before still happens (the value saves)
18
+ }
19
+
20
+ //
21
+ }
22
+
23
+ //class Firecart_FirecartIntegration_Block_Adminhtml_System_Config_Wrapper extends Mage_Adminhtml_Block_System_Config_Form_Field
24
+ //{
25
+ //
26
+ // /**
27
+ // * Ajax Validate the api credentials.
28
+ // *
29
+ // * @param Varien_Data_Form_Element_Abstract $element
30
+ // *
31
+ // * @return string
32
+ // */
33
+ // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
+ // {
35
+ // $element->setData('onchange', "apiValidation(this.form, this);");
36
+ //
37
+ // $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
38
+ //
39
+ // $element->setData('after_element_html', "
40
+ // <script>
41
+ // document.observe('dom:loaded', function(){
42
+ // apiValidation();
43
+ // });
44
+ // function apiValidation(form, element) {
45
+ // var api_username = $('connector_api_credentials_api_username');
46
+ // var api_password = $('connector_api_credentials_api_password');
47
+ // var reloadurl = '{$url}';
48
+ // var encoded = btoa(api_password.value);
49
+ // if(api_username.value && api_password.value){
50
+ // new Ajax.Request(reloadurl, {
51
+ // method: 'post',
52
+ // parameters: {'api_username' : api_username.value, 'api_password' : encoded},
53
+ // onComplete: function(transport) {
54
+ // Element.hide('loadingmask');
55
+ // if(transport.responseText == '\"Credentials Valid.\"'){
56
+ // api_username.setStyle({
57
+ // fontWeight: 'bold',
58
+ // color: 'green' ,
59
+ // background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
60
+ // })
61
+ // }else{
62
+ // api_username.setStyle({
63
+ // fontWeight: 'bold',
64
+ // color: 'red',
65
+ // background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
66
+ // });
67
+ // }
68
+ // }
69
+ // });
70
+ // }
71
+ // return false;
72
+ // }
73
+ // </script>
74
+ // ");
75
+ //
76
+ // return parent::_getElementHtml($element);
77
+ //
78
+ // }
79
+ //}
80
+ ?>
app/code/community/Firecart/FirecartIntegration/Theme/script.html ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ var uploadPath = '<?php echo Mage::getUrl('images/upload'); ?>';
2
+ awesomePlugin.initSettings(<?php echo $jsonObject; ?>);
3
+ <?php if ($needIt) : ?>
4
+ awesomePlugin.doIt();
5
+ <?php endif ; ?>
app/code/community/Firecart/FirecartIntegration/Theme/script.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+
5
+ <script src="//s3-ap-southeast-1.amazonaws.com/ecom-new/res/integrations/firecart-integration.js"></script>
6
+
7
+
8
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
9
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
10
+ <!-- $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData(); -->
11
+ $name = $customer->getFirstname() . ' ' . $customer->getLastname();
12
+ $email = $customer->getEmail();
13
+ $mobile = $customer->getPrimaryBillingAddress()->getTelephone();
14
+ }
15
+
16
+ <script type="text/javascript">
17
+ var custObj = '<?php echo $name; ?>';
18
+ console.log(custObj);
19
+ firecartWebAPI.init("b997ff3df081a49d219077fb566786c4b6cd9b55").ready(function(){});
20
+ </script>
app/code/community/Firecart/FirecartIntegration/etc/api2.xml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <api2>
4
+ <resource_groups>
5
+ <firecartintegration translate="title" module="Firecart_FirecartIntegration">
6
+ <title>Firecart API</title>
7
+ <sort_order>10</sort_order>
8
+ </firecartintegration>
9
+ </resource_groups>
10
+ <resources>
11
+ <firecartintegration_order translate="title" module="Firecart_FirecartIntegration">
12
+ <group>firecartintegration</group>
13
+ <model>firecartintegration/api2_order</model>
14
+ <title>Firecart Order Rest API</title>
15
+ <sort_order>10</sort_order>
16
+ <privileges>
17
+ <admin>
18
+ <create>1</create>
19
+ <retrieve>1</retrieve>
20
+ </admin>
21
+ </privileges>
22
+ <attributes>
23
+ <entity_id>Order ID (internal)</entity_id>
24
+ <increment_id>Order ID</increment_id>
25
+ <created_at>Order Date</created_at>
26
+ <status>Order Status</status>
27
+ <shipping_description>Shipping Method</shipping_description>
28
+ <_payment_method>Payment Method</_payment_method>
29
+ <base_currency_code>Base Currency</base_currency_code>
30
+ <store_currency_code>Order Currency</store_currency_code>
31
+ <store_name>Store Name</store_name>
32
+ <store_to_order_rate>Store Currency to Order Currency Rate</store_to_order_rate>
33
+ <subtotal>Subtotal</subtotal>
34
+ <subtotal_incl_tax>Subtotal Including Tax</subtotal_incl_tax>
35
+ <discount_amount>Discount</discount_amount>
36
+ <base_grand_total>Grand Total to Be Charged</base_grand_total>
37
+ <grand_total>Grand Total</grand_total>
38
+ <shipping_amount>Shipping Amount</shipping_amount>
39
+ <base_discount_amount>Base Discount</base_discount_amount>
40
+ <base_subtotal>Base Subtotal</base_subtotal>
41
+ <total_paid>Total Paid</total_paid>
42
+ <customer_id>Customer ID</customer_id>
43
+ </attributes>
44
+ <force_attributes>
45
+ <admin>
46
+ <addresses>1</addresses>
47
+ <order_items>1</order_items>
48
+ </admin>
49
+ </force_attributes>
50
+ <routes>
51
+ <route_entity>
52
+ <route>/firecart/orders/:id</route>
53
+ <action_type>entity</action_type>
54
+ </route_entity>
55
+ <route_collection>
56
+ <route>/firecart/orders</route>
57
+ <action_type>collection</action_type>
58
+ </route_collection>
59
+ </routes>
60
+ <versions>1</versions>
61
+ </firecartintegration_order>
62
+ <firecartintegration_customer translate="title" module="Firecart_FirecartIntegration">
63
+ <group>firecartintegration</group>
64
+ <model>firecartintegration/api2_customer</model>
65
+ <title>Firecart Customer Rest API</title>
66
+ <sort_order>10</sort_order>
67
+ <privileges>
68
+ <admin>
69
+ <create>1</create>
70
+ <retrieve>1</retrieve>
71
+ </admin>
72
+ </privileges>
73
+ <attributes>
74
+ <entity_id>Customer ID</entity_id>
75
+ <firstname>First Name</firstname>
76
+ <lastname>Last Name</lastname>
77
+ <email>Email</email>
78
+ <gender>Gender</gender>
79
+ <website_id>Associate to Website</website_id>
80
+ <created_at>Created At</created_at>
81
+ <created_in>Created From</created_in>
82
+ <group_id>Group</group_id>
83
+ <confirmation>Is Confirmed</confirmation>
84
+ <total_amount_spent>Total Spent</total_amount_spent>
85
+ <orders_count>Orders Count</orders_count>
86
+ <last_order_id>Last Order Id</last_order_id>
87
+ </attributes>
88
+ <routes>
89
+ <route_entity>
90
+ <route>/firecart/customers/:id</route>
91
+ <action_type>entity</action_type>
92
+ </route_entity>
93
+ <route_collection>
94
+ <route>/firecart/customers</route>
95
+ <action_type>collection</action_type>
96
+ </route_collection>
97
+ </routes>
98
+ <versions>1</versions>
99
+ </firecartintegration_customer>
100
+ </resources>
101
+ </api2>
102
+ </config>
app/code/community/Firecart/FirecartIntegration/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Firecart_FirecartIntegration>
5
+ <version>0.1.0</version>
6
+ </Firecart_FirecartIntegration>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <firecartintegration>
11
+ <class>Firecart_FirecartIntegration_Helper</class>
12
+ </firecartintegration>
13
+ </helpers>
14
+ <events>
15
+ <controller_action_layout_load_before>
16
+ <!--<controller_action_layout_generate_blocks_after>-->
17
+ <observers>
18
+ <firecartintegration>
19
+ <type>singleton</type>
20
+ <class>Firecart_FirecartIntegration_Model_Observer</class>
21
+ <method>placeCustomJs</method>
22
+ </firecartintegration>
23
+ </observers>
24
+ <!--</controller_action_layout_generate_blocks_after>-->
25
+ </controller_action_layout_load_before>
26
+
27
+ <controller_action_predispatch_checkout_cart_add>
28
+ <observers>
29
+ <firecartintegration>
30
+ <type>singleton</type>
31
+ <class>Firecart_FirecartIntegration_Model_Observer</class>
32
+ <method>logCartAdd</method>
33
+ </firecartintegration>
34
+ </observers>
35
+ </controller_action_predispatch_checkout_cart_add>
36
+ <sales_quote_remove_item>
37
+ <observers>
38
+ <firecartintegration>
39
+ <type>singleton</type>
40
+ <class>Firecart_FirecartIntegration_Model_Observer</class>
41
+ <method>logCartRemove</method>
42
+ </firecartintegration>
43
+ </observers>
44
+ </sales_quote_remove_item>
45
+ </events>
46
+ <models>
47
+ <firecartintegration>
48
+ <class>Firecart_FirecartIntegration_Model</class>
49
+ </firecartintegration>
50
+ </models>
51
+ </global>
52
+ <frontend>
53
+ <layout>
54
+ <updates>
55
+ <firecart_firecartintegration module="Firecart_FirecartIntegration">
56
+ <file>firecart_firecartintegration.xml</file>
57
+ </firecart_firecartintegration>
58
+ </updates>
59
+ </layout>
60
+ </frontend>
61
+
62
+ <adminhtml>
63
+ <acl>
64
+ <resources>
65
+ <admin>
66
+ <children>
67
+ <system>
68
+ <children>
69
+ <config>
70
+ <children>
71
+ <firecart_options>
72
+ <title>Firecart Module Section</title>
73
+ </firecart_options>
74
+ </children>
75
+ </config>
76
+ </children>
77
+ </system>
78
+ </children>
79
+ </admin>
80
+ </resources>
81
+ </acl>
82
+ </adminhtml>
83
+ </config>
app/code/community/Firecart/FirecartIntegration/etc/system.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <firecartconfig translate="label" module="firecartintegration">
5
+ <label>Firecart</label>
6
+ <sort_order>99999</sort_order>
7
+ </firecartconfig>
8
+ </tabs>
9
+ <sections>
10
+ <firecart_options translate="label" module="firecartintegration">
11
+ <label>Firecart API Credentials</label>
12
+ <tab>firecartconfig</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <messages translate="label">
20
+ <label>API Credentials</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <expanded>1</expanded>
27
+ <comment><![CDATA[<a href="http://app.firecart.io" target="_blank"><button title="Sign up or Login to Firecart" type="button" class="scalable" style=""><span>Sign up or Login to Firecart</span></button></a>]]></comment>
28
+ <fields>
29
+ <access_key translate="label">
30
+ <label>Enter your firecart's access key</label>
31
+ <frontend_type>text</frontend_type>
32
+ <backend_model>firecartintegration/settings</backend_model>
33
+ <sort_order>1</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
+ </access_key>
38
+ </fields>
39
+ </messages>
40
+ </groups>
41
+ </firecart_options>
42
+ </sections>
43
+ </config>
app/design/frontend/base/default/layout/firecart_firecartintegration.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <non_conversion_tracking_handle translate="label">
5
+ <label>non_conversion_tracking_handle</label>
6
+ <reference name="head">
7
+ <block type="core/template" name="my_script1" template="firecart_firecartintegration/script.phtml">
8
+ </block>
9
+ </reference>
10
+ </non_conversion_tracking_handle>
11
+ <conversion_tracking_handle translate="label">
12
+ <label>conversion_tracking_handle</label>
13
+ <reference name="head">
14
+ <block type="core/template" name="my_script2" template="firecart_firecartintegration/purchase_info_tracking.phtml">
15
+ </block>
16
+ </reference>
17
+ </conversion_tracking_handle>
18
+ </layout>
app/design/frontend/base/default/template/firecart_firecartintegration/abandoned_cart_script.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_fc_add_to_cart_product = Mage::getModel('core/session')->getProductToShoppingCart();
3
+ if ($_fc_add_to_cart_product && $_fc_add_to_cart_product->getId()):
4
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
5
+ $cartUrl = Mage::getSingleton('checkout/session')->getCartUrl();
6
+ $cartItems = $quote->getAllVisibleItems();
7
+ $fc_00_products_arr = array();
8
+ foreach ($cartItems as $item) {
9
+ $productId = $item->getProductId();
10
+ $product = Mage::getModel('catalog/product')->load($productId);
11
+ $fc_00_product_price = $product->getPrice();
12
+ $fc_00_product_url = $product->getProductUrl();
13
+ $fc_00_product_img = $product->getSmallImageUrl();
14
+ array_push($fc_00_products_arr, array('name' => $product->getName(), 'image' => $fc_00_product_img, 'url' => $fc_00_product_url, 'price' => $fc_00_product_price));
15
+ }
16
+ ?>
17
+
18
+ <script type="text/javascript">
19
+ (function () {
20
+ firecartWebAPI.ready(function () {
21
+ var fc_cartUrl = '<?php echo $fc_00_cartUrl; ?>';
22
+ var fc_products = <?php echo json_encode($fc_00_products_arr); ?>;
23
+ if (fc_products.length > 0) {
24
+ var abandonedCartInfo = {
25
+ cartUrl: fc_cartUrl
26
+ }
27
+ var items = [];
28
+ items = fc_products;
29
+ abandonedCartInfo.items = items;
30
+ firecartWebAPI.trackCartInfo(abandonedCartInfo);
31
+ }
32
+ });
33
+ })();
34
+ </script>
35
+ <?php
36
+ Mage::getModel('core/session')->unsProductToShoppingCart();
37
+ endif;
38
+ ?>
app/design/frontend/base/default/template/firecart_firecartintegration/purchase_info_tracking.phtml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="//s3-ap-southeast-1.amazonaws.com/ecom-new/res/integrations/firecart-integration.js"></script>
2
+ <?php
3
+ $fc_00_accessKey = Mage::getStoreConfig('firecart_options/messages/access_key');
4
+ $fc_00_session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
5
+ $fc_00_session->getLastSuccessQuoteId();
6
+ $fc_00_orderId = $fc_00_session->getLastOrderId();
7
+ // If checkout onepage singleton not work then use checkout session
8
+ if (is_null($fc_00_orderId)) {
9
+ $fc_00_orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
10
+ }
11
+
12
+ if ($fc_00_orderId) {
13
+ $fc_00_order = Mage::getModel('sales/order')->load($fc_00_orderId);
14
+ if ($fc_00_order->getId()) {
15
+ //If they have no customer id, they're a guest.
16
+ if ($fc_00_order->getCustomerId() === NULL) {
17
+ $fc_00_name = $fc_00_order->getBillingAddress()->getFirstname() . ' ' . $fc_00_order->getBillingAddress()->getLastname();
18
+ $fc_00_mobile = $fc_00_order->getBillingAddress()->getTelephone();
19
+ $fc_00_email = $fc_00_order->getBillingAddress()->getEmail();
20
+ } else {
21
+ //else, they're a normal registered user.
22
+ $fc_00_customer = Mage::getModel('customer/customer')->load($fc_00_order->getCustomerId());
23
+ $fc_00_name = $fc_00_customer->getFirstname() . ' ' . $fc_00_customer->getLastname();
24
+ $fc_00_email = $fc_00_customer->getEmail();
25
+ $fc_00_mobile = '';
26
+ if ($address = $fc_00_customer->getPrimaryBillingAddress()) {
27
+ $fc_00_mobile = $address->getTelephone();
28
+ }
29
+ }
30
+
31
+ $fc_00_items = $fc_00_order->getAllVisibleItems();
32
+ $fc_00_totalPriceWidoutDiscount = $fc_00_order->getGrandTotal() + $fc_00_order->getDiscountAmount();
33
+ $fc_00_products_arr = array();
34
+ foreach ($fc_00_items as $fc_00_item) {
35
+ $fc_00_item->getName(); // product name
36
+ $fc_00_item->getPrice();
37
+ $fc_00_item->getSku();
38
+ $fc_00_item->getProductId();
39
+ $fc_00_item->getQtyOrdered();
40
+ // load product model for gettting images
41
+ $fc_00_product = Mage::getModel('catalog/product')->load($fc_00_item->getProductId());
42
+ if ($fc_00_product->getId()):
43
+ $fc_00_product_url = $fc_00_product->getProductUrl();
44
+ $fc_00_product_img = $fc_00_product->getSmallImageUrl();
45
+ array_push($fc_00_products_arr, array('name' => $fc_00_item->getName(), 'image' => $fc_00_product_img, 'url' => $fc_00_product_url));
46
+ endif;
47
+ }
48
+ }
49
+ }
50
+ ?>
51
+
52
+ <script type="text/javascript">
53
+ var fc_custName = '<?php echo $fc_00_name; ?>';
54
+ var fc_custEmail = '<?php echo $fc_00_email; ?>';
55
+ var fc_custMobile = '<?php echo $fc_00_mobile; ?>';
56
+ var fc_accessKey = '<?php echo $fc_00_accessKey; ?>';
57
+ var fc_totalPrice = '<?php echo $fc_00_totalPriceWidoutDiscount; ?>';
58
+ fc_totalPrice = fc_totalPrice ? (fc_totalPrice) : 0;
59
+
60
+ var fc_products = <?php echo json_encode($fc_00_products_arr); ?>;
61
+ if (fc_accessKey !== undefined && fc_accessKey !== '') {
62
+ firecartWebAPI.init(fc_accessKey).ready(function () {
63
+ var ME = this;
64
+ if (fc_custEmail !== undefined && fc_custEmail !== "") {
65
+ var custObj = {
66
+ name: fc_custName,
67
+ mobile: fc_custMobile,
68
+ email: fc_custEmail
69
+ }
70
+ ME.setUser(custObj, function () {
71
+ if (fc_products.length > 0) {
72
+ var purchase = {
73
+ email: fc_custEmail,
74
+ purchaseAmount: fc_totalPrice
75
+ }
76
+ var items = [];
77
+ items = fc_products;
78
+ purchase.items = items;
79
+ ME.trackPurchase(purchase);
80
+ }
81
+ });
82
+ }
83
+ });
84
+ }
85
+ </script>
app/design/frontend/base/default/template/firecart_firecartintegration/script.phtml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="//s3-ap-southeast-1.amazonaws.com/ecom-new/res/integrations/firecart-integration.js"></script>
2
+ <?php
3
+ $fc_00_accessKey = Mage::getStoreConfig('firecart_options/messages/access_key');
4
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
5
+ $fc_00_customer = Mage::getSingleton('customer/session')->getCustomer();
6
+ $fc_00_name = $fc_00_customer->getFirstname() . ' ' . $fc_00_customer->getLastname();
7
+ $fc_00_email = $fc_00_customer->getEmail();
8
+ $fc_00_mobile = '';
9
+ if ($address = $fc_00_customer->getPrimaryBillingAddress()) {
10
+ $fc_00_mobile = $address->getTelephone();
11
+ }
12
+ }
13
+
14
+
15
+ $_fc_add_to_cart_product = Mage::getModel('core/session')->getProductToShoppingCart();
16
+ $fc_00_isCartUpdated = false;
17
+ if ($_fc_add_to_cart_product && $_fc_add_to_cart_product->getId()):
18
+ $fc_00_isCartUpdated = true;
19
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
20
+ $fc_00_cartUrl = Mage::getSingleton('checkout/session')->getCartUrl();
21
+ $cartItems = $quote->getAllVisibleItems();
22
+ $fc_00_products_arr = array();
23
+ foreach ($cartItems as $item) {
24
+ $productId = $item->getProductId();
25
+ $product = Mage::getModel('catalog/product')->load($productId);
26
+ $fc_00_product_price = $product->getPrice();
27
+ $fc_00_product_url = $product->getProductUrl();
28
+ $fc_00_product_img = $product->getSmallImageUrl();
29
+ array_push($fc_00_products_arr, array('name' => $product->getName(), 'image' => $fc_00_product_img, 'url' => $fc_00_product_url, 'price' => $fc_00_product_price));
30
+ }
31
+ Mage::getModel('core/session')->unsProductToShoppingCart();
32
+ endif;
33
+ ?>
34
+
35
+ <script type="text/javascript">
36
+ (function () {
37
+ var fc_custName = '<?php echo $fc_00_name; ?>';
38
+ var fc_custEmail = '<?php echo $fc_00_email; ?>';
39
+ var fc_custMobile = '<?php echo $fc_00_mobile; ?>';
40
+ var fc_accessKey = '<?php echo $fc_00_accessKey; ?>';
41
+ var fc_cartUrl = '<?php echo $fc_00_cartUrl; ?>';
42
+ var fc_products = <?php echo json_encode($fc_00_products_arr); ?>;
43
+ var fc_isCartUpdated = <?php echo json_encode($fc_00_isCartUpdated); ?>;
44
+ if (fc_accessKey !== undefined && fc_accessKey !== '') {
45
+ firecartWebAPI.init(fc_accessKey).ready(function () {
46
+ if (fc_custEmail !== undefined && fc_custEmail !== "") {
47
+ var custObj = {
48
+ name: fc_custName,
49
+ mobile: fc_custMobile,
50
+ email: fc_custEmail
51
+ }
52
+ firecartWebAPI.setUser(custObj, function () {
53
+ if (fc_isCartUpdated) {
54
+ var abandonedCartInfo = {
55
+ email: fc_custEmail
56
+ }
57
+ if (fc_products.length > 0) {
58
+ var items = [];
59
+ items = fc_products;
60
+ abandonedCartInfo.items = items;
61
+ abandonedCartInfo.cartUrl = fc_cartUrl;
62
+ firecartWebAPI.trackCartInfo(abandonedCartInfo);
63
+ } else {
64
+ firecartWebAPI.clearCartInfo(abandonedCartInfo);
65
+ }
66
+ }
67
+ });
68
+ }
69
+ });
70
+ }
71
+ })();
72
+
73
+ </script>
app/etc/modules/Firecart_FirecartIntegration.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Firecart_FirecartIntegration>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </Firecart_FirecartIntegration>
9
+ </modules>
10
+
11
+ <frontend>
12
+ <layout>
13
+ <updates>
14
+ <Firecart_FirecartIntegration>
15
+ <file>Firecart_FirecartIntegration.xml</file>
16
+ </Firecart_FirecartIntegration>
17
+ </updates>
18
+ </layout>
19
+ </frontend>
20
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>firecart_integration</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrate your magento with Firecart. A powerful marketing automation tool.</summary>
10
+ <description>To automate sales, marketing to attract new leads, generate more revenue from current customers and grow your business leaps and bound.</description>
11
+ <notes>This is a first release of firecart. Please use support to contact in case of queries.</notes>
12
+ <authors><author><name>Canvass Tech</name><user>MAG001899698</user><email>ankur@canvass.in</email></author></authors>
13
+ <date>2016-02-08</date>
14
+ <time>04:57:03</time>
15
+ <contents><target name="magecommunity"><dir name="Firecart"><dir name="FirecartIntegration"><dir name="Helper"><file name="Data.php" hash="0a9926b49f68e7986d5e2de4d4e223a6"/></dir><dir name="Model"><dir name="Api2"><dir name="Customer"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="1ad19bb5a3e0e26c57e96d16bb2e3db6"/></dir></dir></dir><dir name="Order"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="36ddede8d759bb9a984711e682c7b462"/></dir></dir></dir></dir><file name="Observer.php" hash="7c18e34ba7982127d869c63e3a9f50f3"/><dir name="Sales"><dir name="Api2"><dir name="Order"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="bf68c19498c011fab46514ad8c751d00"/></dir></dir><file name="Rest.php" hash="171d7ebddedec4275071f1a34fd507c3"/></dir></dir></dir><file name="Settings.php" hash="b99420e2b336db95431ca27866beddd6"/></dir><dir name="Theme"><file name="script.html" hash="0cb8b8148c971fefca46ba06284ab805"/><file name="script.phtml" hash="f63c2614b6c174a5781f488407a9a973"/></dir><dir name="etc"><file name="api2.xml" hash="10e41eb9eb66972eba71a7963660452f"/><file name="config.xml" hash="8dc7096b5b02329ea84d5592b609b17b"/><file name="system.xml" hash="f8f9ad1880a7d474e0f69cda3b32b000"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Firecart_FirecartIntegration.xml" hash="b8c4d69f69deb71e03054c4d97ca4daa"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="firecart_firecartintegration"><file name="abandoned_cart_script.phtml" hash="8f7aede243e6696f60bf6b4cb4ed83e4"/><file name="purchase_info_tracking.phtml" hash="9b1a9a26218c06c4a01e60a80ec6b3a5"/><file name="script.phtml" hash="846b17b944ad7928837da44f3ada7941"/></dir></dir><dir name="layout"><file name="firecart_firecartintegration.xml" hash="684e8363131ff0c257fb9460c211c01c"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>