|
1 | 1 | <?php |
2 | 2 |
|
3 | | -class Smashmetrics_Rekko_Block_Rekko extends Mage_Core_Block_Template { |
4 | | - |
5 | | - public function getPluginEnabledStatus() { |
6 | | - return Mage::getStoreConfig('rekko_section/rekko_group/enabled', Mage::app()->getStore()); |
7 | | - } |
8 | | - |
9 | | - public function getRekkoMerchantID() { |
10 | | - return Mage::getStoreConfig('rekko_section/rekko_group/merchant_ID', Mage::app()->getStore()); |
11 | | - } |
12 | | - |
13 | | - public function getDomainName() { |
14 | | - return Mage::getStoreConfig('rekko_section/rekko_group/domain_name', Mage::app()->getStore()); |
15 | | - } |
16 | | - |
17 | | - public function email_Call_Newsletter() { |
18 | | - return Mage::getStoreConfig('rekko_section/rekko_group/email_Call_Newsletter', Mage::app()->getStore()); |
19 | | - } |
20 | | - |
21 | | - public function email_Call_User() { |
22 | | - return Mage::getStoreConfig('rekko_section/rekko_group/email_Call_User', Mage::app()->getStore()); |
23 | | - } |
24 | | - |
25 | | - |
26 | | - public function getOrderDetails() { |
27 | | - $request = $this->getRequest(); |
28 | | - $module = $request->getModuleName(); |
29 | | - $controller = $request->getControllerName(); |
30 | | - $action = $request->getActionName(); |
31 | | - $cart = Mage::getSingleton('checkout/session'); |
32 | | - |
33 | | - $quote_id = $cart->getQuoteId(); |
34 | | - if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
35 | | - Mage::log("Getting order details for checkout"); |
36 | | - $orderId = $cart->getLastOrderId(); |
37 | | - $lastOrderId = Mage::getSingleton('checkout/session') |
38 | | - ->getLastRealOrderId(); |
39 | | - $orderId = Mage::getModel('sales/order') |
40 | | - ->loadByIncrementId($lastOrderId) |
41 | | - ->getEntityId(); |
42 | | - $order = Mage::getModel('sales/order')->load($orderId); |
43 | | - $_totalData = $order->getData(); |
44 | | - |
45 | | - $orderDet['grand_total'] = $_totalData['base_grand_total']; |
46 | | - $orderDet['coupon_code'] = $_totalData['coupon_code']; |
47 | | - $orderDet['discount'] = abs($_totalData['base_discount_amount']); |
48 | | - $orderDet['tax'] = $_totalData['base_tax_amount']; |
49 | | - $orderDet['orderid'] = $_totalData['increment_id']; |
50 | | - $orderDet['shipping_total'] = $_totalData['base_shipping_amount']; |
51 | | - $orderDet['quote_id'] = 'successpage'; |
52 | | - } else { |
53 | | - Mage::log("Getting order details for checkout process"); |
54 | | - $quote_id = $cart->getQuoteId(); |
55 | | - $item_quote = Mage::getModel('sales/quote')->load($quote_id); |
56 | | - $totals = $cart->getQuote()->getTotals(); |
57 | | - |
58 | | - if (isset($totals['tax']) && $totals['tax']->getValue()) { |
59 | | - $tax = round($totals['tax']->getValue()); //Tax value if present |
60 | | - } else { |
61 | | - $tax = ''; |
62 | | - } |
63 | | - |
64 | | - $orderDet['grand_total'] = $item_quote->grand_total; |
65 | | - $orderDet['coupon_code'] = $item_quote->coupon_code; |
66 | | - $orderDet['discount'] = $item_quote->subtotal - $item_quote->subtotal_with_discount; |
67 | | - $orderDet['tax'] = $tax; |
68 | | - $orderDet['orderid'] = ''; |
69 | | - $orderDet['shipping_total'] = ''; |
70 | | - $orderDet['quote_id'] = $quote_id; |
| 3 | +class Smashmetrics_Rekko_Block_Rekko extends Mage_Core_Block_Template |
| 4 | +{ |
| 5 | + |
| 6 | + public function getPluginEnabledStatus() |
| 7 | + { |
| 8 | + return Mage::getStoreConfig('rekko_section/rekko_group/enabled', Mage::app()->getStore()); |
| 9 | + } |
| 10 | + |
| 11 | + public function getRekkoMerchantID() |
| 12 | + { |
| 13 | + return Mage::getStoreConfig('rekko_section/rekko_group/merchant_ID', |
| 14 | + Mage::app()->getStore()); |
| 15 | + } |
| 16 | + |
| 17 | + public function getDomainName() |
| 18 | + { |
| 19 | + return Mage::getStoreConfig('rekko_section/rekko_group/domain_name', |
| 20 | + Mage::app()->getStore()); |
| 21 | + } |
| 22 | + |
| 23 | + public function email_Call_Newsletter() |
| 24 | + { |
| 25 | + return Mage::getStoreConfig('rekko_section/rekko_group/email_Call_Newsletter', |
| 26 | + Mage::app()->getStore()); |
| 27 | + } |
| 28 | + |
| 29 | + public function email_Call_User() |
| 30 | + { |
| 31 | + return Mage::getStoreConfig('rekko_section/rekko_group/email_Call_User', |
| 32 | + Mage::app()->getStore()); |
71 | 33 | } |
72 | 34 |
|
73 | | - return $orderDet; |
74 | | - } |
75 | | - |
76 | | - public function getCustomerDetails() { |
77 | | - if ($this->helper('customer')->isLoggedIn()) { |
78 | | - Mage::log("Getting customer details for a logged in customer"); |
79 | | - $customer = Mage::getSingleton('customer/session')->getCustomer(); |
80 | | - $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData(); |
81 | | - } else { |
82 | | - Mage::log("Getting customer details for a guest"); |
83 | | - $request = $this->getRequest(); |
84 | | - $module = $request->getModuleName(); |
85 | | - $controller = $request->getControllerName(); |
86 | | - $action = $request->getActionName(); |
87 | | - $guestUser=array(); |
88 | | - if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
89 | | - Mage::log("Getting customer details for anonymouse checkout"); |
| 35 | + |
| 36 | + public function getOrderDetails() |
| 37 | + { |
| 38 | + $request = $this->getRequest(); |
| 39 | + $module = $request->getModuleName(); |
| 40 | + $controller = $request->getControllerName(); |
| 41 | + $action = $request->getActionName(); |
90 | 42 | $cart = Mage::getSingleton('checkout/session'); |
91 | | - $orderId = $cart->getLastOrderId(); |
92 | | - |
93 | | - $lastOrderId = Mage::getSingleton('checkout/session') |
94 | | - ->getLastRealOrderId(); |
95 | | - |
96 | | - $orderId = Mage::getModel('sales/order') |
97 | | - ->loadByIncrementId($lastOrderId) |
98 | | - ->getEntityId(); |
99 | | - |
100 | | - $order = Mage::getModel('sales/order')->load($orderId); |
101 | | - $_totalData = $order->getData(); |
102 | | - $guestUser['firstname']=$_totalData['customer_firstname']; |
103 | | - $guestUser['lastname']=$_totalData['customer_lastname']; |
104 | | - $guestUser['email']=$_totalData['customer_email']; |
105 | | - $guestUser['group_id']=$_totalData['customer_group_id']; |
106 | | - $customerData = $guestUser; |
107 | | - } else { |
108 | | - Mage::log("Couldn't get customer details returning null"); |
109 | | - $customerData = Null; |
110 | | - } |
| 43 | + |
| 44 | + $quote_id = $cart->getQuoteId(); |
| 45 | + if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
| 46 | + Mage::log("Getting order details for checkout"); |
| 47 | + $orderId = $cart->getLastOrderId(); |
| 48 | + $lastOrderId = Mage::getSingleton('checkout/session') |
| 49 | + ->getLastRealOrderId(); |
| 50 | + $orderId = Mage::getModel('sales/order') |
| 51 | + ->loadByIncrementId($lastOrderId) |
| 52 | + ->getEntityId(); |
| 53 | + $order = Mage::getModel('sales/order')->load($orderId); |
| 54 | + $_totalData = $order->getData(); |
| 55 | + |
| 56 | + $orderDet['grand_total'] = $_totalData['base_grand_total']; |
| 57 | + $orderDet['coupon_code'] = $_totalData['coupon_code']; |
| 58 | + $orderDet['discount'] = abs($_totalData['base_discount_amount']); |
| 59 | + $orderDet['tax'] = $_totalData['base_tax_amount']; |
| 60 | + $orderDet['orderid'] = $_totalData['increment_id']; |
| 61 | + $orderDet['shipping_total'] = $_totalData['base_shipping_amount']; |
| 62 | + $orderDet['quote_id'] = 'successpage'; |
| 63 | + } else { |
| 64 | + Mage::log("Getting order details for checkout process"); |
| 65 | + $quote_id = $cart->getQuoteId(); |
| 66 | + $item_quote = Mage::getModel('sales/quote')->load($quote_id); |
| 67 | + $totals = $cart->getQuote()->getTotals(); |
| 68 | + |
| 69 | + if (isset($totals['tax']) && $totals['tax']->getValue()) { |
| 70 | + $tax = round($totals['tax']->getValue()); //Tax value if present |
| 71 | + } else { |
| 72 | + $tax = ''; |
| 73 | + } |
| 74 | + |
| 75 | + $orderDet['grand_total'] = $item_quote->grand_total; |
| 76 | + $orderDet['coupon_code'] = $item_quote->coupon_code; |
| 77 | + $orderDet['discount'] = $item_quote->subtotal - $item_quote->subtotal_with_discount; |
| 78 | + $orderDet['tax'] = $tax; |
| 79 | + $orderDet['orderid'] = ''; |
| 80 | + $orderDet['shipping_total'] = ''; |
| 81 | + $orderDet['quote_id'] = $quote_id; |
| 82 | + } |
| 83 | + |
| 84 | + return $orderDet; |
111 | 85 | } |
112 | | - |
113 | | - return $customerData; |
114 | | - } |
115 | | - |
116 | | - public function getCartItems() { |
117 | | - $request = $this->getRequest(); |
118 | | - $module = $request->getModuleName(); |
119 | | - $controller = $request->getControllerName(); |
120 | | - $action = $request->getActionName(); |
121 | | - $cart = Mage::getSingleton('checkout/session'); |
122 | | - $product = array(); |
123 | | - if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
124 | | - Mage::log("Getting cart items for a checkout"); |
125 | | - $orderId = $cart->getLastOrderId(); |
126 | | - $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); |
127 | | - $order = Mage::getModel('sales/order')->load($orderId); |
128 | | - $ordered_items = $order->getAllItems(); |
129 | | - $i = 0; |
130 | | - foreach ($ordered_items as $item) { |
131 | | - $product[$i]['productId'] = $item->getProductId(); |
132 | | - $product[$i]['sku'] = $item->getSku(); |
133 | | - $product[$i]['name'] = $item->getName(); |
134 | | - $product[$i]['qty'] = $item->getQtyOrdered(); |
135 | | - $product[$i]['price'] = $item->getPrice(); |
136 | | - $_product = Mage::getModel('catalog/product')->load($product[$i]['productId']); |
137 | | - $category = array(); |
138 | | - $catIds = $_product->getCategoryIds(); |
139 | | - foreach ($catIds AS $cid) { |
140 | | - $category[] = Mage::getModel('catalog/category')->load($cid)->getName(); |
| 86 | + |
| 87 | + public function getCustomerDetails() |
| 88 | + { |
| 89 | + if ($this->helper('customer')->isLoggedIn()) { |
| 90 | + Mage::log("Getting customer details for a logged in customer"); |
| 91 | + $customer = Mage::getSingleton('customer/session')->getCustomer(); |
| 92 | + $customerData = |
| 93 | + Mage::getModel('customer/customer')->load($customer->getId())->getData(); |
| 94 | + } else { |
| 95 | + Mage::log("Getting customer details for a guest"); |
| 96 | + $request = $this->getRequest(); |
| 97 | + $module = $request->getModuleName(); |
| 98 | + $controller = $request->getControllerName(); |
| 99 | + $action = $request->getActionName(); |
| 100 | + $guestUser = array(); |
| 101 | + if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
| 102 | + Mage::log("Getting customer details for anonymouse checkout"); |
| 103 | + $cart = Mage::getSingleton('checkout/session'); |
| 104 | + $orderId = $cart->getLastOrderId(); |
| 105 | + |
| 106 | + $lastOrderId = Mage::getSingleton('checkout/session') |
| 107 | + ->getLastRealOrderId(); |
| 108 | + |
| 109 | + $orderId = Mage::getModel('sales/order') |
| 110 | + ->loadByIncrementId($lastOrderId) |
| 111 | + ->getEntityId(); |
| 112 | + |
| 113 | + $order = Mage::getModel('sales/order')->load($orderId); |
| 114 | + $_totalData = $order->getData(); |
| 115 | + $guestUser['firstname'] = $_totalData['customer_firstname']; |
| 116 | + $guestUser['lastname'] = $_totalData['customer_lastname']; |
| 117 | + $guestUser['email'] = $_totalData['customer_email']; |
| 118 | + $guestUser['group_id'] = $_totalData['customer_group_id']; |
| 119 | + $customerData = $guestUser; |
| 120 | + } else { |
| 121 | + Mage::log("Couldn't get customer details returning null"); |
| 122 | + $customerData = Null; |
| 123 | + } |
141 | 124 | } |
142 | | - $product[$i]['category'] = implode(',', $category); |
143 | | - |
144 | | - $i++; |
145 | | - } |
146 | | - } else { |
147 | | - Mage::log("Getting order details for a checkout process"); |
148 | | - $i = 0; |
149 | | - foreach ($cart->getQuote()->getAllItems() as $item) { |
150 | | - $product[$i]['productId'] = $item->getProductId(); |
151 | | - $product[$i]['sku'] = $item->getSku(); |
152 | | - $product[$i]['name'] = $item->getName(); |
153 | | - $product[$i]['qty'] = $item->getQty(); |
154 | | - $product[$i]['price'] = $item->getPrice(); |
155 | | - $catIds = $item->getProduct()->getCategoryIds(); |
156 | | - $category = array(); |
157 | | - foreach ($catIds AS $cid) { |
158 | | - $category[] = Mage::getModel('catalog/category')->load($cid)->getName(); |
| 125 | + |
| 126 | + return $customerData; |
| 127 | + } |
| 128 | + |
| 129 | + public function getCartItems() |
| 130 | + { |
| 131 | + $request = $this->getRequest(); |
| 132 | + $module = $request->getModuleName(); |
| 133 | + $controller = $request->getControllerName(); |
| 134 | + $action = $request->getActionName(); |
| 135 | + $cart = Mage::getSingleton('checkout/session'); |
| 136 | + $product = array(); |
| 137 | + if ($module == 'checkout' && $controller == 'onepage' && $action == 'success') { |
| 138 | + Mage::log("Getting cart items for a checkout"); |
| 139 | + $orderId = $cart->getLastOrderId(); |
| 140 | + $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); |
| 141 | + $order = Mage::getModel('sales/order')->load($orderId); |
| 142 | + $ordered_items = $order->getAllItems(); |
| 143 | + $i = 0; |
| 144 | + foreach ($ordered_items as $item) { |
| 145 | + $product[$i]['productId'] = $item->getProductId(); |
| 146 | + $product[$i]['sku'] = $item->getSku(); |
| 147 | + $product[$i]['name'] = $item->getName(); |
| 148 | + $product[$i]['qty'] = $item->getQtyOrdered(); |
| 149 | + $product[$i]['price'] = $item->getPrice(); |
| 150 | + $_product = Mage::getModel('catalog/product')->load($product[$i]['productId']); |
| 151 | + $category = array(); |
| 152 | + $catIds = $_product->getCategoryIds(); |
| 153 | + foreach ($catIds AS $cid) { |
| 154 | + $category[] = Mage::getModel('catalog/category')->load($cid)->getName(); |
| 155 | + } |
| 156 | + $product[$i]['category'] = implode(',', $category); |
| 157 | + |
| 158 | + $i++; |
| 159 | + } |
| 160 | + } else { |
| 161 | + Mage::log("Getting order details for a checkout process"); |
| 162 | + $i = 0; |
| 163 | + foreach ($cart->getQuote()->getAllItems() as $item) { |
| 164 | + $product[$i]['productId'] = $item->getProductId(); |
| 165 | + $product[$i]['sku'] = $item->getSku(); |
| 166 | + $product[$i]['name'] = $item->getName(); |
| 167 | + $product[$i]['qty'] = $item->getQty(); |
| 168 | + $product[$i]['price'] = $item->getPrice(); |
| 169 | + $catIds = $item->getProduct()->getCategoryIds(); |
| 170 | + $category = array(); |
| 171 | + foreach ($catIds AS $cid) { |
| 172 | + $category[] = Mage::getModel('catalog/category')->load($cid)->getName(); |
| 173 | + } |
| 174 | + $product[$i]['category'] = implode(',', $category); |
| 175 | + $i++; |
| 176 | + } |
159 | 177 | } |
160 | | - $product[$i]['category'] = implode(',', $category); |
161 | | - $i++; |
162 | | - } |
| 178 | + return $product; |
163 | 179 | } |
164 | | - return $product; |
165 | | - } |
166 | 180 |
|
167 | 181 | } |
0 commit comments