Version Notes
Fix package build
Download this release
Release Info
Developer | Michael A. Smith |
Extension | eBay_Enterprise_Affiliate_Extension |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
app/code/community/EbayEnterprise/Affiliate/Block/Beacon.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2014 eBay Enterprise, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the eBay Enterprise
|
8 |
+
* Magento Extensions End User License Agreement
|
9 |
+
* that is bundled with this package in the file LICENSE.md.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf
|
12 |
+
*
|
13 |
+
* @copyright Copyright (c) 2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
|
14 |
+
* @license http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf eBay Enterprise Magento Extensions End User License Agreement
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
|
18 |
+
class EbayEnterprise_Affiliate_Block_Beacon extends Mage_Core_Block_Template
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* The 'PID' beacon URL querystring key
|
22 |
+
*/
|
23 |
+
const KEY_PID = 'PID';
|
24 |
+
/**
|
25 |
+
* The 'OID' beacon URL querystring key
|
26 |
+
*/
|
27 |
+
const KEY_OID = 'OID';
|
28 |
+
/**
|
29 |
+
* The 'AMOUNT' beacon URL querystring key
|
30 |
+
*/
|
31 |
+
const KEY_AMOUNT = 'AMOUNT';
|
32 |
+
/**
|
33 |
+
* The 'TYPE' beacon URL querystring key
|
34 |
+
*/
|
35 |
+
const KEY_TYPE = 'TYPE';
|
36 |
+
/**
|
37 |
+
* The 'QTY' beacon URL querystring key
|
38 |
+
*/
|
39 |
+
const KEY_QTY = 'QTY';
|
40 |
+
/**
|
41 |
+
* The 'TOTALAMOUNT' beacon URL querystring key
|
42 |
+
*/
|
43 |
+
const KEY_TOTALAMOUNT = 'TOTALAMOUNT';
|
44 |
+
/**
|
45 |
+
* The 'INT' beacon URL querystring key
|
46 |
+
*/
|
47 |
+
const KEY_INT = 'INT';
|
48 |
+
/**
|
49 |
+
* The 'ITEM' beacon URL querystring key
|
50 |
+
*/
|
51 |
+
const KEY_ITEM = 'ITEM';
|
52 |
+
/**
|
53 |
+
* The 'PROMOCODE' beacon URL querystring key
|
54 |
+
*/
|
55 |
+
const KEY_PROMOCODE = 'PROMOCODE';
|
56 |
+
/**
|
57 |
+
* @var Mage_Sales_Model_Order
|
58 |
+
* @see self::_getOrder
|
59 |
+
*/
|
60 |
+
protected $_order;
|
61 |
+
/**
|
62 |
+
* Get the last order.
|
63 |
+
* @return Mage_Sales_Model_Order | null
|
64 |
+
*/
|
65 |
+
protected function _getOrder()
|
66 |
+
{
|
67 |
+
if (!($this->_order instanceof Mage_Sales_Model_Order)) {
|
68 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
69 |
+
if ($orderId) {
|
70 |
+
$this->_order = Mage::getModel('sales/order')->load($orderId);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return $this->_order;
|
74 |
+
}
|
75 |
+
/**
|
76 |
+
* Get the beacon URL.
|
77 |
+
* @return string | null
|
78 |
+
*/
|
79 |
+
public function getBeaconUrl()
|
80 |
+
{
|
81 |
+
$order = $this->_getOrder();
|
82 |
+
return ($order instanceof Mage_Sales_Model_Order) ?
|
83 |
+
Mage::helper('eems_affiliate')->buildBeaconUrl(
|
84 |
+
Mage::helper('eems_affiliate/config')->isItemizedOrders() ?
|
85 |
+
$this->_buildItemizedParams($order) : $this->_buildBasicParams($order)
|
86 |
+
) : null;
|
87 |
+
}
|
88 |
+
/**
|
89 |
+
* build common params array
|
90 |
+
* @param Mage_Sales_Model_Order $order
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
protected function _buildCommonParams(Mage_Sales_Model_Order $order)
|
94 |
+
{
|
95 |
+
$params = array(
|
96 |
+
static::KEY_PID => Mage::helper('eems_affiliate/config')->getProgramId(),
|
97 |
+
static::KEY_OID => $order->getIncrementId(),
|
98 |
+
);
|
99 |
+
$couponCode = trim($order->getCouponCode());
|
100 |
+
return ($couponCode !== '')?
|
101 |
+
array_merge($params, array(static::KEY_PROMOCODE => $couponCode)) : $params;
|
102 |
+
}
|
103 |
+
/**
|
104 |
+
* build basic params array for non itemized beacon URL
|
105 |
+
* @param Mage_Sales_Model_Order $order
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
protected function _buildBasicParams(Mage_Sales_Model_Order $order)
|
109 |
+
{
|
110 |
+
return array_merge($this->_buildCommonParams($order), array(
|
111 |
+
static::KEY_AMOUNT => number_format($order->getSubtotal() + $order->getDiscountAmount() + $order->getShippingDiscountAmount(), 2, '.', ''),
|
112 |
+
static::KEY_TYPE => Mage::helper('eems_affiliate/config')->getTransactionType()
|
113 |
+
));
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* build itemized order params array for itemized beacon URL
|
117 |
+
* @param Mage_Sales_Model_Order $order
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
+
protected function _buildItemizedParams(Mage_Sales_Model_Order $order)
|
121 |
+
{
|
122 |
+
$params = array(static::KEY_INT => Mage::helper('eems_affiliate/config')->getInt());
|
123 |
+
$increment = 1; // incrementer for the unique item keys
|
124 |
+
foreach ($order->getAllItems() as $item) {
|
125 |
+
// need to ignore the bundle parent as it will contain collected total
|
126 |
+
// for children but not discounts
|
127 |
+
$position = $this->_getDupePosition($params, $item);
|
128 |
+
// ignore the parent configurable quantity - quantity of config products
|
129 |
+
// will come from the simple used product with the same SKU
|
130 |
+
$quantity = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE ?
|
131 |
+
0 : (int) $item->getQtyOrdered();
|
132 |
+
// consider parent bundle products to be 0.00 total - total of the bundle
|
133 |
+
// is the sum of all child products which are also included in the beacon
|
134 |
+
// so including both totals would effectively double the price of the bundle
|
135 |
+
$total = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE ?
|
136 |
+
0.00 : $item->getRowTotal() - $item->getDiscountAmount();
|
137 |
+
if ($position) {
|
138 |
+
// we detected that the current item already exist in the params array
|
139 |
+
// and have the key increment position let's simply adjust
|
140 |
+
// the qty and total amount
|
141 |
+
$params[static::KEY_QTY . $position] += $quantity;
|
142 |
+
$amtKey = static::KEY_TOTALAMOUNT . $position;
|
143 |
+
$params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
|
144 |
+
} else {
|
145 |
+
$params = array_merge($params, array(
|
146 |
+
static::KEY_ITEM . $increment => $item->getSku(),
|
147 |
+
static::KEY_QTY . $increment => $quantity,
|
148 |
+
static::KEY_TOTALAMOUNT . $increment => number_format($total, 2, '.', ''),
|
149 |
+
));
|
150 |
+
$increment++; // only get incremented when a unique key have been appended
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return array_merge($this->_buildCommonParams($order), $params);
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* check if the current sku already exists in the params data if so return
|
157 |
+
* the position it is found in
|
158 |
+
* @param array $params the given array of keys needed to build the beacon URL querystring
|
159 |
+
* @param Mage_Sales_Model_Order_Item $item
|
160 |
+
* @return int the item position where dupe found otherwise zero
|
161 |
+
*/
|
162 |
+
protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
|
163 |
+
{
|
164 |
+
$key = array_search($item->getSku(), $params, true);
|
165 |
+
return ($key !== false)?
|
166 |
+
(int) str_replace(static::KEY_ITEM, '', $key) : 0;
|
167 |
+
}
|
168 |
+
/**
|
169 |
+
* Whether or not to display the beacon.
|
170 |
+
* @return bool
|
171 |
+
*/
|
172 |
+
public function showBeacon()
|
173 |
+
{
|
174 |
+
return (
|
175 |
+
Mage::helper('eems_affiliate/config')->isEnabled() &&
|
176 |
+
$this->_getOrder() instanceof Mage_Sales_Model_Order
|
177 |
+
);
|
178 |
+
}
|
179 |
+
}
|
package.xml
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eBay_Enterprise_Affiliate_Extension</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>EULA</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>eBay Enterprise Affiliate Extension</summary>
|
10 |
<description>eBay Enterprise Affiliate Extension</description>
|
11 |
-
<notes>Fix
|
12 |
-
</notes>
|
13 |
<authors><author><name>Michael A. Smith</name><user>msmith3</user><email>msmith3@ebay.com</email></author><author><name>Michael Phang</name><user>mphang</user><email>mphang@ebay.com</email></author><author><name>Scott van Brug</name><user>svanbrug</user><email>svanbrug@ebay.com</email></author><author><name>Mike West</name><user>micwest</user><email>micwest@ebay.com</email></author><author><name>Reginald Gabriel</name><user>rgabriel</user><email>rgabriel@ebay.com</email></author></authors>
|
14 |
-
<date>2014-07-
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="etc"><file name="adminhtml.xml" hash="c68a5314867507e9215b2cf3b4b87562"/><file name="config.xml" hash="b1f1980befd909a6bfe8dce4381c064b"/><file name="system.xml" hash="c01cf86be7b0a539f6d124344b5f46b4"/></dir><dir name="Exception"><file name="Configuration.php" hash="329e9296f4662b6cbf60fe1daef1acd7"/></dir><dir name="Helper"><file name="Config.php" hash="c6d5e3fd75f5c1e499f2b67ae19c0759"/><file name="Data.php" hash="12eacdc5d43a4afd8cdc1e316f2e22c6"/><file name="Map.php" hash="baa4d775c2328e0e45d2e8bc00dd8083"/><dir name="Map"><file name="Order.php" hash="27fee01d500d662be4796aa01c1270ef"/><file name="Product.php" hash="f037e9df9f5c9ef87df01a022d7706e0"/></dir></dir><dir name="Model"><file name="Observer.php" hash="ee3dba8505e43f175ee54dea3c7813cb"/><dir name="Feed"><file name="Abstract.php" hash="c34c8b875a7d6da6ab056fa12110d706"/><file name="Product.php" hash="c99bb4b79bb2483270dc2a9615ce8a0e"/><dir name="Order"><file name="Abstract.php" hash="053a2f0f719566a41903f89366f997ea"/><file name="Basic.php" hash="c9e8ce48928c68af62907b62ac692a52"/><file name="Itemized.php" hash="cf8f2f3f51e0d1f912d8e81e0338f6f7"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="3930134c53203f03ad872a6c647679b0"/><file name="Categories.php" hash="4166f8b40f0e0451cd3fce5fd3f7b23f"/><file name="Stockquantity.php" hash="cfa82a3115cf37bb4d8e76b5a627835a"/><file name="Stockyesno.php" hash="236c4532b0935e4e9f25cf99468071a5"/><file name="Transactiontype.php" hash="f929f51e0ec30364607e823cd34d0469"/><file name="Visibilityyesno.php" hash="0262dfcfd0741d217753d39db37d565e"/></dir></dir></dir></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="9df21f13bd18f28d73ce590ce8d43cf4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="a60847216c56702b48490d8603a9f94d"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="c819edb9f0938161fa2b2144b704f635"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="2c8823653d3f9c19634df8630c70628b"/></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>eBay_Enterprise_Affiliate_Extension</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>EULA</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>eBay Enterprise Affiliate Extension</summary>
|
10 |
<description>eBay Enterprise Affiliate Extension</description>
|
11 |
+
<notes>Fix package build</notes>
|
|
|
12 |
<authors><author><name>Michael A. Smith</name><user>msmith3</user><email>msmith3@ebay.com</email></author><author><name>Michael Phang</name><user>mphang</user><email>mphang@ebay.com</email></author><author><name>Scott van Brug</name><user>svanbrug</user><email>svanbrug@ebay.com</email></author><author><name>Mike West</name><user>micwest</user><email>micwest@ebay.com</email></author><author><name>Reginald Gabriel</name><user>rgabriel</user><email>rgabriel@ebay.com</email></author></authors>
|
13 |
+
<date>2014-07-22</date>
|
14 |
+
<time>21:30:51</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="etc"><file name="adminhtml.xml" hash="c68a5314867507e9215b2cf3b4b87562"/><file name="config.xml" hash="b1f1980befd909a6bfe8dce4381c064b"/><file name="system.xml" hash="c01cf86be7b0a539f6d124344b5f46b4"/></dir><dir name="Exception"><file name="Configuration.php" hash="329e9296f4662b6cbf60fe1daef1acd7"/></dir><dir name="Helper"><file name="Config.php" hash="c6d5e3fd75f5c1e499f2b67ae19c0759"/><file name="Data.php" hash="12eacdc5d43a4afd8cdc1e316f2e22c6"/><file name="Map.php" hash="baa4d775c2328e0e45d2e8bc00dd8083"/><dir name="Map"><file name="Order.php" hash="27fee01d500d662be4796aa01c1270ef"/><file name="Product.php" hash="f037e9df9f5c9ef87df01a022d7706e0"/></dir></dir><dir name="Model"><file name="Observer.php" hash="ee3dba8505e43f175ee54dea3c7813cb"/><dir name="Feed"><file name="Abstract.php" hash="c34c8b875a7d6da6ab056fa12110d706"/><file name="Product.php" hash="c99bb4b79bb2483270dc2a9615ce8a0e"/><dir name="Order"><file name="Abstract.php" hash="053a2f0f719566a41903f89366f997ea"/><file name="Basic.php" hash="c9e8ce48928c68af62907b62ac692a52"/><file name="Itemized.php" hash="cf8f2f3f51e0d1f912d8e81e0338f6f7"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="3930134c53203f03ad872a6c647679b0"/><file name="Categories.php" hash="4166f8b40f0e0451cd3fce5fd3f7b23f"/><file name="Stockquantity.php" hash="cfa82a3115cf37bb4d8e76b5a627835a"/><file name="Stockyesno.php" hash="236c4532b0935e4e9f25cf99468071a5"/><file name="Transactiontype.php" hash="f929f51e0ec30364607e823cd34d0469"/><file name="Visibilityyesno.php" hash="0262dfcfd0741d217753d39db37d565e"/></dir></dir></dir></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="9df21f13bd18f28d73ce590ce8d43cf4"/></dir></dir><dir name="Block"><file name="Beacon.php" hash="fc186c6789c5b9fc508ba28fecabb86b"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="a60847216c56702b48490d8603a9f94d"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="c819edb9f0938161fa2b2144b704f635"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="2c8823653d3f9c19634df8630c70628b"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
|
18 |
</package>
|