Version Notes
1.8.1.0
Download this release
Release Info
Developer | Magento Core Team |
Extension | Mage_Core_Modules |
Version | 1.8.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.8.0.0 to 1.8.1.0
- app/Mage.php +2 -1
- app/code/core/Mage/Api/Model/Server/Adapter/Soap.php +4 -2
- app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php +59 -8
- app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php +12 -10
- app/code/core/Mage/Bundle/Model/Product/Price.php +133 -68
- app/code/core/Mage/Catalog/Block/Product/Abstract.php +23 -7
- app/code/core/Mage/Catalog/Block/Product/Price.php +42 -1
- app/code/core/Mage/Catalog/Block/Product/View.php +9 -2
- app/code/core/Mage/Catalog/Helper/Product/Compare.php +2 -1
- app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php +2 -1
- app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php +3 -3
- app/code/core/Mage/Catalog/Model/Resource/Product/Status.php +6 -10
- app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable.php +1 -1
- app/code/core/Mage/Catalog/controllers/Product/CompareController.php +5 -0
- app/code/core/Mage/Catalog/etc/wsi.xml +2 -2
- app/code/core/Mage/CatalogInventory/Model/Observer.php +18 -8
- app/code/core/Mage/CatalogRule/Model/Resource/Rule.php +1 -1
- app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php +3 -1
- app/code/core/Mage/CatalogSearch/Helper/Data.php +19 -2
- app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php +4 -1
- app/code/core/Mage/Checkout/Helper/Data.php +55 -29
- app/code/core/Mage/Checkout/Model/Cart/Product/Api.php +11 -12
- app/code/core/Mage/Checkout/controllers/CartController.php +5 -0
- app/code/core/Mage/Checkout/controllers/MultishippingController.php +30 -6
- app/code/core/Mage/Cms/Model/Resource/Page.php +3 -0
- app/code/core/Mage/Cms/Model/Resource/Page/Service.php +3 -2
- app/code/core/Mage/{GoogleCheckout/Block/Form.php → Cms/data/cms_setup/data-upgrade-1.6.0.0.1-1.6.0.0.2.php} +13 -20
- app/code/core/Mage/Cms/etc/config.xml +1 -1
- app/code/core/Mage/Core/Block/Abstract.php +65 -32
- app/code/core/Mage/Core/Helper/Cookie.php +15 -0
- app/code/core/Mage/Core/Model/Design/Package.php +3 -0
- app/code/core/Mage/Core/Model/Locale.php +23 -4
- app/code/core/Mage/Core/Model/Resource/Design.php +20 -30
- app/code/core/Mage/Core/Model/Store.php +57 -5
- app/code/core/Mage/Core/etc/config.xml +1 -1
- app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php +1 -1
- app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php → Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php} +12 -7
- app/code/core/Mage/Customer/Helper/Address.php +1 -1
- app/code/core/Mage/Customer/Model/Address/Abstract.php +58 -10
- app/code/core/Mage/Customer/controllers/AccountController.php +6 -2
- app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.3-0.7.4.php → Customer/data/customer_setup/data-upgrade-1.6.2.0.2-1.6.2.0.3.php} +12 -9
- app/code/core/Mage/Customer/etc/config.xml +1 -1
- app/code/core/Mage/Customer/etc/wsdl.xml +6 -0
- app/code/core/Mage/Customer/etc/wsi.xml +6 -0
- app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.2.php +82 -0
- app/code/core/Mage/Directory/Model/Currency.php +72 -23
- app/code/core/Mage/Directory/Model/Resource/Region/Collection.php +1 -1
- app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-install-0.7.0.php → Directory/sql/directory_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php} +27 -14
- app/code/core/Mage/{GoogleCheckout/Model/Resource/Api/Debug.php → Eav/Model/Attribute/Data/Datetime.php} +29 -7
- app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php +29 -2
- app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php +2 -2
- app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option.php +2 -2
- app/code/core/Mage/Eav/etc/config.xml +1 -1
- app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.2-0.7.3.php → Eav/sql/eav_setup/upgrade-1.6.0.0-1.6.0.1.php} +7 -5
- app/code/core/Mage/GoogleAnalytics/Block/Ga.php +14 -1
- app/code/core/Mage/GoogleAnalytics/Helper/Data.php +14 -2
- app/code/core/Mage/GoogleAnalytics/Model/Observer.php +0 -39
- app/code/core/Mage/GoogleAnalytics/etc/config.xml +0 -8
- app/code/core/Mage/GoogleAnalytics/etc/system.xml +9 -0
- app/code/core/Mage/GoogleCheckout/Block/Adminhtml/Shipping/Applicable/Countries.php +0 -65
- app/code/core/Mage/GoogleCheckout/Block/Adminhtml/Shipping/Merchant.php +0 -181
- app/code/core/Mage/GoogleCheckout/Block/Link.php +0 -108
- app/code/core/Mage/GoogleCheckout/Exception.php +0 -30
- app/code/core/Mage/GoogleCheckout/Helper/Data.php +0 -192
- app/code/core/Mage/GoogleCheckout/Model/Api.php +0 -233
- app/code/core/Mage/GoogleCheckout/Model/Api/Debug.php +0 -52
- app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Abstract.php +0 -245
- app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php +0 -1107
- app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php +0 -1143
- app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Order.php +0 -181
- app/code/core/Mage/GoogleCheckout/Model/Mysql4/Api/Debug.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Mysql4/Api/Debug/Collection.php +0 -38
- app/code/core/Mage/GoogleCheckout/Model/Mysql4/Notification.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Mysql4/Tax.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Notification.php +0 -129
- app/code/core/Mage/GoogleCheckout/Model/Observer.php +0 -105
- app/code/core/Mage/GoogleCheckout/Model/Payment.php +31 -85
- app/code/core/Mage/GoogleCheckout/Model/Resource/Notification.php +0 -109
- app/code/core/Mage/GoogleCheckout/Model/Resource/Setup.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Resource/Tax.php +0 -76
- app/code/core/Mage/GoogleCheckout/Model/Shipping.php +0 -76
- app/code/core/Mage/GoogleCheckout/Model/Source/Checkout/Image.php +0 -55
- app/code/core/Mage/GoogleCheckout/Model/Source/Locale.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Source/Shipping/Carrier.php +0 -59
- app/code/core/Mage/GoogleCheckout/Model/Source/Shipping/Category.php +0 -37
- app/code/core/Mage/GoogleCheckout/Model/Source/Shipping/Units.php +0 -36
- app/code/core/Mage/GoogleCheckout/Model/Source/Shipping/Virtual/Method.php +0 -38
- app/code/core/Mage/GoogleCheckout/controllers/ApiController.php +0 -44
- app/code/core/Mage/GoogleCheckout/controllers/RedirectController.php +0 -181
- app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml +0 -48
- app/code/core/Mage/GoogleCheckout/etc/config.xml +0 -136
- app/code/core/Mage/GoogleCheckout/etc/system.xml +0 -483
- app/code/core/Mage/GoogleCheckout/etc/wsdl.xml +0 -15
- app/code/core/Mage/GoogleCheckout/etc/wsi.xml +0 -18
- app/code/core/Mage/GoogleCheckout/sql/googlecheckout_setup/install-1.6.0.0.php +0 -83
- app/code/core/Mage/GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.0-0.7.1.php +0 -64
- app/code/core/Mage/GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.1-0.7.2.php +0 -46
- app/code/core/Mage/GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +0 -62
- app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +0 -1
- app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +155 -6
- app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php +19 -13
- app/code/core/Mage/ImportExport/Model/Import/Proxy/Product.php +10 -0
- app/code/core/Mage/Oauth/Model/Server.php +0 -2
- app/code/core/Mage/Page/Block/Html/Breadcrumbs.php +27 -2
- app/code/core/Mage/{GoogleCheckout/Block/Redirect.php → Page/Block/Html/CookieNotice.php} +17 -17
- app/code/core/Mage/Page/Block/Template/Links.php +19 -2
- app/code/core/Mage/Payment/Model/Method/Abstract.php +11 -0
- app/code/core/Mage/Payment/Model/Observer.php +50 -1
- app/code/core/Mage/Payment/etc/config.xml +10 -2
- app/code/core/Mage/Paypal/Model/Api/Nvp.php +43 -2
- app/code/core/Mage/Paypal/Model/Cart.php +15 -0
- app/code/core/Mage/Paypal/Model/Method/Agreement.php +4 -2
- app/code/core/Mage/Paypal/controllers/IpnController.php +1 -0
- app/code/core/Mage/{GoogleCheckout/Model/Resource/Api/Debug/Collection.php → PaypalUk/Model/Api/Express/Nvp.php} +13 -12
- app/code/core/Mage/PaypalUk/Model/Api/Nvp.php +53 -1
- app/code/core/Mage/PaypalUk/Model/Express.php +3 -2
- app/code/core/Mage/PaypalUk/Model/Express/Checkout.php +1 -1
- app/code/core/Mage/{GoogleCheckout/Model/Api/Xml/Calculate.php → PaypalUk/Model/Express/Pro.php} +9 -7
- app/code/core/Mage/Persistent/Model/Observer.php +2 -4
- app/code/core/Mage/Persistent/controllers/IndexController.php +1 -1
- app/code/core/Mage/Persistent/etc/config.xml +0 -8
- app/code/core/Mage/ProductAlert/Block/Email/Abstract.php +15 -0
- app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php +33 -3
- app/code/core/Mage/Review/controllers/ProductController.php +6 -0
- app/code/core/Mage/Sales/Block/Guest/Links.php +2 -2
- app/code/core/Mage/Sales/Helper/Guest.php +4 -4
- app/code/core/Mage/Sales/Model/Order.php +26 -17
- app/code/core/Mage/Sales/Model/Order/Config.php +34 -3
- app/code/core/Mage/Sales/Model/Order/Creditmemo.php +15 -0
- app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php +3 -3
- app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php +2 -1
- app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Tax.php +19 -8
- app/code/core/Mage/Sales/Model/Order/Invoice/Total/Discount.php +12 -2
- app/code/core/Mage/Sales/Model/Order/Invoice/Total/Subtotal.php +7 -2
- app/code/core/Mage/Sales/Model/Order/Item.php +40 -0
- app/code/core/Mage/Sales/Model/Order/Payment.php +9 -2
- app/code/core/Mage/Sales/Model/Order/Shipment.php +2 -1
- app/code/core/Mage/Sales/Model/Order/Shipment/Track.php +10 -1
- app/code/core/Mage/Sales/Model/Quote/Item.php +41 -37
- app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php +21 -5
- app/code/core/Mage/Sales/Model/Resource/Order/Status/Collection.php +14 -0
- app/code/core/Mage/Sales/etc/config.xml +0 -7
- app/code/core/Mage/Sales/etc/widget.xml +5 -0
- app/code/core/Mage/SalesRule/Model/Validator.php +138 -65
- app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php +70 -16
- app/code/core/Mage/Tax/Block/Adminhtml/Notifications.php +36 -0
- app/code/core/Mage/Tax/Block/Checkout/Tax.php +6 -3
- app/code/core/Mage/Tax/Block/Sales/Order/Tax.php +13 -4
- app/code/core/Mage/Tax/Helper/Data.php +164 -66
- app/code/core/Mage/Tax/Model/Calculation.php +178 -33
- app/code/core/Mage/Tax/Model/Calculation/Rate.php +33 -2
- app/code/core/Mage/Tax/Model/Calculation/Rule.php +70 -1
- app/code/core/Mage/Tax/Model/Config.php +28 -19
- app/code/core/Mage/Tax/Model/Resource/Calculation/Rule.php +26 -0
- app/code/core/Mage/Tax/Model/Sales/Total/Quote/Shipping.php +24 -14
- app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php +337 -245
- app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php +796 -420
- app/code/core/Mage/Tax/Model/System/Config/Source/Tax/Region.php +26 -6
- app/code/core/Mage/Tax/etc/config.xml +1 -1
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +0 -4
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php +0 -8
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php +2 -2
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php +6 -6
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php +8 -2
- app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +7 -7
- app/code/core/Mage/Weee/Block/Renderer/Weee/Tax.php +105 -20
- app/code/core/Mage/Weee/Helper/Data.php +292 -17
- app/code/core/Mage/{GoogleCheckout/Model/Source/Shipping/Virtual/Schedule.php → Weee/Model/Config/Source/Fpt/Tax.php} +24 -6
- app/code/core/Mage/Weee/Model/Observer.php +68 -25
- app/code/core/Mage/Weee/Model/Tax.php +75 -7
- app/code/core/Mage/Weee/Model/Total/Creditmemo/Weee.php +33 -8
- app/code/core/Mage/Weee/Model/Total/Invoice/Weee.php +13 -0
- app/code/core/Mage/Weee/Model/Total/Quote/Weee.php +135 -43
- app/code/core/Mage/Weee/etc/config.xml +18 -3
- app/code/core/Mage/Weee/etc/system.xml +2 -2
- app/code/core/Mage/Wishlist/Controller/Abstract.php +17 -4
- app/code/core/Mage/Wishlist/Helper/Data.php +1 -1
- cron.php +3 -0
- errors/design.xml +5 -5
- package.xml +5 -5
app/Mage.php
CHANGED
@@ -39,6 +39,7 @@ if (defined('COMPILER_INCLUDE_PATH')) {
|
|
39 |
/**
|
40 |
* Set include path
|
41 |
*/
|
|
|
42 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
|
43 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
|
44 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
|
@@ -169,7 +170,7 @@ final class Mage
|
|
169 |
return array(
|
170 |
'major' => '1',
|
171 |
'minor' => '8',
|
172 |
-
'revision' => '
|
173 |
'patch' => '0',
|
174 |
'stability' => '',
|
175 |
'number' => '',
|
39 |
/**
|
40 |
* Set include path
|
41 |
*/
|
42 |
+
$paths = array();
|
43 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
|
44 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
|
45 |
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
|
170 |
return array(
|
171 |
'major' => '1',
|
172 |
'minor' => '8',
|
173 |
+
'revision' => '1',
|
174 |
'patch' => '0',
|
175 |
'stability' => '',
|
176 |
'number' => '',
|
app/code/core/Mage/Api/Model/Server/Adapter/Soap.php
CHANGED
@@ -208,12 +208,14 @@ class Mage_Api_Model_Server_Adapter_Soap
|
|
208 |
? $urlModel->getUrl('*/*/*', array('_current' => true, '_query' => $params))
|
209 |
: $urlModel->getUrl('*/*/*');
|
210 |
|
211 |
-
if( $withAuth ) {
|
212 |
$phpAuthUser = $this->getController()->getRequest()->getServer('PHP_AUTH_USER', false);
|
213 |
$phpAuthPw = $this->getController()->getRequest()->getServer('PHP_AUTH_PW', false);
|
|
|
214 |
|
215 |
if ($phpAuthUser && $phpAuthPw) {
|
216 |
-
$wsdlUrl = sprintf("
|
|
|
217 |
}
|
218 |
}
|
219 |
|
208 |
? $urlModel->getUrl('*/*/*', array('_current' => true, '_query' => $params))
|
209 |
: $urlModel->getUrl('*/*/*');
|
210 |
|
211 |
+
if ( $withAuth ) {
|
212 |
$phpAuthUser = $this->getController()->getRequest()->getServer('PHP_AUTH_USER', false);
|
213 |
$phpAuthPw = $this->getController()->getRequest()->getServer('PHP_AUTH_PW', false);
|
214 |
+
$scheme = $this->getController()->getRequest()->getScheme();
|
215 |
|
216 |
if ($phpAuthUser && $phpAuthPw) {
|
217 |
+
$wsdlUrl = sprintf("%s://%s:%s@%s", $scheme, $phpAuthUser, $phpAuthPw,
|
218 |
+
str_replace($scheme . '://', '', $wsdlUrl));
|
219 |
}
|
220 |
}
|
221 |
|
app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php
CHANGED
@@ -34,7 +34,18 @@
|
|
34 |
*/
|
35 |
class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Block_Product_View_Abstract
|
36 |
{
|
|
|
|
|
|
|
|
|
|
|
37 |
protected $_optionRenderers = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
protected $_options = null;
|
39 |
|
40 |
/**
|
@@ -44,6 +55,18 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
44 |
*/
|
45 |
protected $_mapRenderer = 'msrp_item';
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
public function getOptions()
|
48 |
{
|
49 |
if (!$this->_options) {
|
@@ -66,6 +89,11 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
66 |
return $this->_options;
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
public function hasOptions()
|
70 |
{
|
71 |
$this->getOptions();
|
@@ -92,7 +120,8 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
92 |
/* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */
|
93 |
$bundlePriceModel = Mage::getModel('bundle/product_price');
|
94 |
|
95 |
-
|
|
|
96 |
$preConfiguredValues = $currentProduct->getPreconfiguredValues();
|
97 |
$defaultValues = array();
|
98 |
}
|
@@ -122,9 +151,15 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
122 |
// recalculate currency
|
123 |
$tierPrices = $_selection->getTierPrice();
|
124 |
foreach ($tierPrices as &$tierPriceInfo) {
|
|
|
|
|
|
|
|
|
125 |
$tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false);
|
126 |
-
$tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true
|
127 |
-
|
|
|
|
|
128 |
}
|
129 |
unset($tierPriceInfo); // break the reference with the last element
|
130 |
|
@@ -137,12 +172,16 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
137 |
/* @var $taxHelper Mage_Tax_Helper_Data */
|
138 |
$taxHelper = Mage::helper('tax');
|
139 |
|
140 |
-
$_priceInclTax = $taxHelper->getPrice($_selection, $itemPrice, true
|
141 |
-
|
|
|
|
|
142 |
|
143 |
if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) {
|
144 |
-
$_priceInclTax = $taxHelper->getPrice($currentProduct, $itemPrice, true
|
145 |
-
|
|
|
|
|
146 |
}
|
147 |
|
148 |
$selection = array (
|
@@ -158,7 +197,7 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
158 |
'plusDisposition' => 0,
|
159 |
'minusDisposition' => 0,
|
160 |
'canApplyMAP' => $canApplyMAP,
|
161 |
-
'tierPriceHtml' => $this->getTierPriceHtml($_selection),
|
162 |
);
|
163 |
|
164 |
$responseObject = new Varien_Object();
|
@@ -208,11 +247,23 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Bl
|
|
208 |
return $coreHelper->jsonEncode($config);
|
209 |
}
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
public function addRenderer($type, $block)
|
212 |
{
|
213 |
$this->_optionRenderers[$type] = $block;
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
public function getOptionHtml($option)
|
217 |
{
|
218 |
if (!isset($this->_optionRenderers[$option->getType()])) {
|
34 |
*/
|
35 |
class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle extends Mage_Catalog_Block_Product_View_Abstract
|
36 |
{
|
37 |
+
/**
|
38 |
+
* Renderers for bundle product options
|
39 |
+
*
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
protected $_optionRenderers = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Bundle product options
|
46 |
+
*
|
47 |
+
* @var array
|
48 |
+
*/
|
49 |
protected $_options = null;
|
50 |
|
51 |
/**
|
55 |
*/
|
56 |
protected $_mapRenderer = 'msrp_item';
|
57 |
|
58 |
+
/**
|
59 |
+
* Tier price template
|
60 |
+
*
|
61 |
+
* @var string
|
62 |
+
*/
|
63 |
+
protected $_tierPriceDefaultTemplate = 'bundle/catalog/product/view/option_tierprices.phtml';
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Return an array of bundle product options
|
67 |
+
*
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
public function getOptions()
|
71 |
{
|
72 |
if (!$this->_options) {
|
89 |
return $this->_options;
|
90 |
}
|
91 |
|
92 |
+
/**
|
93 |
+
* Whether the bundle product has any option
|
94 |
+
*
|
95 |
+
* @return boolean
|
96 |
+
*/
|
97 |
public function hasOptions()
|
98 |
{
|
99 |
$this->getOptions();
|
120 |
/* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */
|
121 |
$bundlePriceModel = Mage::getModel('bundle/product_price');
|
122 |
|
123 |
+
$preConfiguredFlag = $currentProduct->hasPreconfiguredValues();
|
124 |
+
if ($preConfiguredFlag) {
|
125 |
$preConfiguredValues = $currentProduct->getPreconfiguredValues();
|
126 |
$defaultValues = array();
|
127 |
}
|
151 |
// recalculate currency
|
152 |
$tierPrices = $_selection->getTierPrice();
|
153 |
foreach ($tierPrices as &$tierPriceInfo) {
|
154 |
+
$tierPriceInfo['price'] =
|
155 |
+
$bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['price']);
|
156 |
+
$tierPriceInfo['website_price'] =
|
157 |
+
$bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['website_price']);
|
158 |
$tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false);
|
159 |
+
$tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true,
|
160 |
+
null, null, null, null, null, false);
|
161 |
+
$tierPriceInfo['priceExclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], false,
|
162 |
+
null, null, null, null, null, false);
|
163 |
}
|
164 |
unset($tierPriceInfo); // break the reference with the last element
|
165 |
|
172 |
/* @var $taxHelper Mage_Tax_Helper_Data */
|
173 |
$taxHelper = Mage::helper('tax');
|
174 |
|
175 |
+
$_priceInclTax = $taxHelper->getPrice($_selection, $itemPrice, true,
|
176 |
+
null, null, null, null, null, false);
|
177 |
+
$_priceExclTax = $taxHelper->getPrice($_selection, $itemPrice, false,
|
178 |
+
null, null, null, null, null, false);
|
179 |
|
180 |
if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) {
|
181 |
+
$_priceInclTax = $taxHelper->getPrice($currentProduct, $itemPrice, true,
|
182 |
+
null, null, null, null, null, false);
|
183 |
+
$_priceExclTax = $taxHelper->getPrice($currentProduct, $itemPrice, false,
|
184 |
+
null, null, null, null, null, false);
|
185 |
}
|
186 |
|
187 |
$selection = array (
|
197 |
'plusDisposition' => 0,
|
198 |
'minusDisposition' => 0,
|
199 |
'canApplyMAP' => $canApplyMAP,
|
200 |
+
'tierPriceHtml' => $this->getTierPriceHtml($_selection, $currentProduct),
|
201 |
);
|
202 |
|
203 |
$responseObject = new Varien_Object();
|
247 |
return $coreHelper->jsonEncode($config);
|
248 |
}
|
249 |
|
250 |
+
/**
|
251 |
+
* Add renderer for an option type, e.g., select, radio button, etc.
|
252 |
+
*
|
253 |
+
* @param string $type
|
254 |
+
* @param string $block
|
255 |
+
*/
|
256 |
public function addRenderer($type, $block)
|
257 |
{
|
258 |
$this->_optionRenderers[$type] = $block;
|
259 |
}
|
260 |
|
261 |
+
/**
|
262 |
+
* Get option html
|
263 |
+
*
|
264 |
+
* @param Mage_Catalog_Model_Product_Option $option
|
265 |
+
* @return string
|
266 |
+
*/
|
267 |
public function getOptionHtml($option)
|
268 |
{
|
269 |
if (!isset($this->_optionRenderers[$option->getType()])) {
|
app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
CHANGED
@@ -81,17 +81,17 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bun
|
|
81 |
->getData('bundle_option_qty/' . $_option->getId());
|
82 |
|
83 |
if (empty($selectedOptions) && $_default) {
|
84 |
-
$_defaultQty = $_default->getSelectionQty()*1;
|
85 |
$_canChangeQty = $_default->getSelectionCanChangeQty();
|
86 |
} elseif (!$inPreConfigured && $selectedOptions && is_numeric($selectedOptions)) {
|
87 |
$selectedSelection = $_option->getSelectionById($selectedOptions);
|
88 |
-
$_defaultQty = $selectedSelection->getSelectionQty()*1;
|
89 |
$_canChangeQty = $selectedSelection->getSelectionCanChangeQty();
|
90 |
} elseif (!$this->_showSingle() || $inPreConfigured) {
|
91 |
$_defaultQty = $this->_getSelectedQty();
|
92 |
$_canChangeQty = (bool)$_defaultQty;
|
93 |
} else {
|
94 |
-
$_defaultQty = $_selections[0]->getSelectionQty()*1;
|
95 |
$_canChangeQty = $_selections[0]->getSelectionCanChangeQty();
|
96 |
}
|
97 |
|
@@ -176,17 +176,24 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bun
|
|
176 |
return $this->getData('product');
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
public function getSelectionQtyTitlePrice($_selection, $includeContainer = true)
|
180 |
{
|
181 |
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection);
|
182 |
$this->setFormatProduct($_selection);
|
183 |
-
$priceTitle = $_selection->getSelectionQty()*1 . ' x ' . $this->escapeHtml($_selection->getName());
|
184 |
|
185 |
$priceTitle .= ' ' . ($includeContainer ? '<span class="price-notice">' : '')
|
186 |
. '+' . $this->formatPriceString($price, $includeContainer)
|
187 |
. ($includeContainer ? '</span>' : '');
|
188 |
|
189 |
-
return
|
190 |
}
|
191 |
|
192 |
/**
|
@@ -218,11 +225,6 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bun
|
|
218 |
public function getSelectionTitlePrice($_selection, $includeContainer = true)
|
219 |
{
|
220 |
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection, 1);
|
221 |
-
$tierPrice = $_selection->getTierPrice();
|
222 |
-
if (!empty($tierPrice)) {
|
223 |
-
$qty = $_selection->getSelectionQty();
|
224 |
-
$price = $qty * (float) $_selection->getPriceModel()->getTierPrice($qty, $_selection);
|
225 |
-
}
|
226 |
$this->setFormatProduct($_selection);
|
227 |
$priceTitle = $this->escapeHtml($_selection->getName());
|
228 |
$priceTitle .= ' ' . ($includeContainer ? '<span class="price-notice">' : '')
|
81 |
->getData('bundle_option_qty/' . $_option->getId());
|
82 |
|
83 |
if (empty($selectedOptions) && $_default) {
|
84 |
+
$_defaultQty = $_default->getSelectionQty() * 1;
|
85 |
$_canChangeQty = $_default->getSelectionCanChangeQty();
|
86 |
} elseif (!$inPreConfigured && $selectedOptions && is_numeric($selectedOptions)) {
|
87 |
$selectedSelection = $_option->getSelectionById($selectedOptions);
|
88 |
+
$_defaultQty = $selectedSelection->getSelectionQty() * 1;
|
89 |
$_canChangeQty = $selectedSelection->getSelectionCanChangeQty();
|
90 |
} elseif (!$this->_showSingle() || $inPreConfigured) {
|
91 |
$_defaultQty = $this->_getSelectedQty();
|
92 |
$_canChangeQty = (bool)$_defaultQty;
|
93 |
} else {
|
94 |
+
$_defaultQty = $_selections[0]->getSelectionQty() * 1;
|
95 |
$_canChangeQty = $_selections[0]->getSelectionCanChangeQty();
|
96 |
}
|
97 |
|
176 |
return $this->getData('product');
|
177 |
}
|
178 |
|
179 |
+
/**
|
180 |
+
* Returns the formatted string for the quantity chosen for the given selection
|
181 |
+
*
|
182 |
+
* @param Mage_Catalog_Model_Proudct $_selection
|
183 |
+
* @param bool $includeContainer
|
184 |
+
* @return string
|
185 |
+
*/
|
186 |
public function getSelectionQtyTitlePrice($_selection, $includeContainer = true)
|
187 |
{
|
188 |
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection);
|
189 |
$this->setFormatProduct($_selection);
|
190 |
+
$priceTitle = $_selection->getSelectionQty() * 1 . ' x ' . $this->escapeHtml($_selection->getName());
|
191 |
|
192 |
$priceTitle .= ' ' . ($includeContainer ? '<span class="price-notice">' : '')
|
193 |
. '+' . $this->formatPriceString($price, $includeContainer)
|
194 |
. ($includeContainer ? '</span>' : '');
|
195 |
|
196 |
+
return $priceTitle;
|
197 |
}
|
198 |
|
199 |
/**
|
225 |
public function getSelectionTitlePrice($_selection, $includeContainer = true)
|
226 |
{
|
227 |
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection, 1);
|
|
|
|
|
|
|
|
|
|
|
228 |
$this->setFormatProduct($_selection);
|
229 |
$priceTitle = $this->escapeHtml($_selection->getName());
|
230 |
$priceTitle .= ' ' . ($includeContainer ? '<span class="price-notice">' : '')
|
app/code/core/Mage/Bundle/Model/Product/Price.php
CHANGED
@@ -36,12 +36,12 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
36 |
/**
|
37 |
* Fixed price type
|
38 |
*/
|
39 |
-
const PRICE_TYPE_FIXED
|
40 |
|
41 |
/**
|
42 |
* Dynamic price type
|
43 |
*/
|
44 |
-
const PRICE_TYPE_DYNAMIC
|
45 |
|
46 |
/**
|
47 |
* Flag which indicates - is min/max prices have been calculated by index
|
@@ -112,7 +112,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
112 |
/**
|
113 |
* Get product final price
|
114 |
*
|
115 |
-
* @param double
|
116 |
* @param Mage_Catalog_Model_Product $product
|
117 |
* @return double
|
118 |
*/
|
@@ -138,9 +138,9 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
138 |
* Returns final price of a child product
|
139 |
*
|
140 |
* @param Mage_Catalog_Model_Product $product
|
141 |
-
* @param float
|
142 |
* @param Mage_Catalog_Model_Product $childProduct
|
143 |
-
* @param float
|
144 |
* @return decimal
|
145 |
*/
|
146 |
public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty)
|
@@ -155,7 +155,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
155 |
* @see Mage_Bundle_Model_Product_Price::getTotalPrices()
|
156 |
*
|
157 |
* @param Mage_Catalog_Model_Product $product
|
158 |
-
* @param string
|
159 |
* @return decimal|array
|
160 |
*/
|
161 |
public function getPrices($product, $which = null)
|
@@ -170,8 +170,8 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
170 |
* @see Mage_Bundle_Model_Product_Price::getTotalPrices()
|
171 |
*
|
172 |
* @param Mage_Catalog_Model_Product $product
|
173 |
-
* @param string
|
174 |
-
* @param bool|null
|
175 |
* @return decimal|array
|
176 |
*/
|
177 |
public function getPricesDependingOnTax($product, $which = null, $includeTax = null)
|
@@ -183,9 +183,9 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
183 |
* Retrieve Price considering tier price
|
184 |
*
|
185 |
* @param Mage_Catalog_Model_Product $product
|
186 |
-
* @param string|null
|
187 |
-
* @param bool|null
|
188 |
-
* @param bool
|
189 |
* @return decimal|array
|
190 |
*/
|
191 |
public function getTotalPrices($product, $which = null, $includeTax = null, $takeTierPrice = true)
|
@@ -195,15 +195,18 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
195 |
$taxHelper = $this->_getHelperData('tax');
|
196 |
|
197 |
if ($this->_isPricesCalculatedByIndex && !$includeTax) {
|
198 |
-
$minimalPrice = $taxHelper->getPrice($product, $product->getData('min_price'), $includeTax
|
199 |
-
|
|
|
|
|
200 |
} else {
|
201 |
/**
|
202 |
* Check if product price is fixed
|
203 |
*/
|
204 |
$finalPrice = $product->getFinalPrice();
|
205 |
if ($isPriceFixedType) {
|
206 |
-
$minimalPrice = $maximalPrice = $taxHelper->getPrice($product, $finalPrice, $includeTax
|
|
|
207 |
} else { // PRICE_TYPE_DYNAMIC
|
208 |
$minimalPrice = $maximalPrice = 0;
|
209 |
}
|
@@ -227,6 +230,9 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
227 |
}
|
228 |
}
|
229 |
|
|
|
|
|
|
|
230 |
if ('max' == $which) {
|
231 |
return $maximalPrice;
|
232 |
} elseif ('min' == $which) {
|
@@ -248,8 +254,10 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
248 |
{
|
249 |
$options = $this->getOptions($product);
|
250 |
$minimalPrice = 0;
|
|
|
251 |
$hasRequiredOptions = $this->_hasRequiredOptions($product);
|
252 |
$selectionMinimalPrices = array();
|
|
|
253 |
|
254 |
if (!$options) {
|
255 |
return $minimalPrice;
|
@@ -257,20 +265,41 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
257 |
|
258 |
foreach ($options as $option) {
|
259 |
/* @var $option Mage_Bundle_Model_Option */
|
260 |
-
|
|
|
261 |
|
262 |
if (count($selectionPrices)) {
|
263 |
-
$selectionMinPrice = min($selectionPrices);
|
|
|
|
|
264 |
if ($option->getRequired()) {
|
265 |
$minimalPrice += $selectionMinPrice;
|
|
|
266 |
} elseif (!$hasRequiredOptions) {
|
267 |
$selectionMinimalPrices[] = $selectionMinPrice;
|
|
|
268 |
}
|
269 |
}
|
270 |
}
|
271 |
// condition is TRUE when all product options are NOT required
|
272 |
if (!$hasRequiredOptions) {
|
273 |
$minimalPrice = min($selectionMinimalPrices);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
return $minimalPrice;
|
276 |
}
|
@@ -316,6 +345,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
316 |
{
|
317 |
$selectionPrices = array();
|
318 |
$taxHelper = $this->_getHelperData('tax');
|
|
|
319 |
$isPriceFixedType = ($product->getPriceType() == self::PRICE_TYPE_FIXED);
|
320 |
|
321 |
$selections = $option->getSelections();
|
@@ -334,11 +364,20 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
334 |
|
335 |
$item = $isPriceFixedType ? $product : $selection;
|
336 |
|
337 |
-
$
|
338 |
-
$
|
339 |
-
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
}
|
343 |
return $selectionPrices;
|
344 |
}
|
@@ -396,8 +435,8 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
396 |
*
|
397 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
398 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
399 |
-
* @param float|null
|
400 |
-
* @param null|bool
|
401 |
* @return float
|
402 |
*/
|
403 |
public function getSelectionPrice($bundleProduct, $selectionProduct, $selectionQty = null, $multiplyQty = true)
|
@@ -410,7 +449,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
410 |
*
|
411 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
412 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
413 |
-
* @param decimal
|
414 |
* @return decimal
|
415 |
*/
|
416 |
public function getSelectionPreFinalPrice($bundleProduct, $selectionProduct, $qty = null)
|
@@ -426,13 +465,13 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
426 |
*
|
427 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
428 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
429 |
-
* @param decimal
|
430 |
-
* @param decimal
|
431 |
-
* @param bool
|
432 |
* @return decimal
|
433 |
*/
|
434 |
public function getSelectionFinalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty = null,
|
435 |
-
|
436 |
{
|
437 |
return $this->getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty,
|
438 |
$multiplyQty);
|
@@ -444,14 +483,14 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
444 |
*
|
445 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
446 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
447 |
-
* @param
|
448 |
-
* @param
|
449 |
-
* @param bool
|
450 |
-
* @param bool
|
451 |
-
* @return
|
452 |
*/
|
453 |
public function getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty,
|
454 |
-
|
455 |
{
|
456 |
if (is_null($selectionQty)) {
|
457 |
$selectionQty = $selectionProduct->getSelectionQty();
|
@@ -474,11 +513,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
474 |
}
|
475 |
}
|
476 |
|
477 |
-
$price =
|
478 |
-
$this->_applyGroupPrice($bundleProduct, $price),
|
479 |
-
$this->_applyTierPrice($bundleProduct, $bundleQty, $price),
|
480 |
-
$this->_applySpecialPrice($bundleProduct, $price)
|
481 |
-
);
|
482 |
|
483 |
if ($multiplyQty) {
|
484 |
$price *= $selectionQty;
|
@@ -487,6 +522,24 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
487 |
return $price;
|
488 |
}
|
489 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
/**
|
491 |
* Apply group price for bundle product
|
492 |
*
|
@@ -501,6 +554,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
501 |
|
502 |
if (is_numeric($groupPrice)) {
|
503 |
$groupPrice = $finalPrice - ($finalPrice * ($groupPrice / 100));
|
|
|
504 |
$result = min($finalPrice, $groupPrice);
|
505 |
}
|
506 |
|
@@ -547,8 +601,8 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
547 |
* Apply tier price for bundle
|
548 |
*
|
549 |
* @param Mage_Catalog_Model_Product $product
|
550 |
-
* @param decimal
|
551 |
-
* @param decimal
|
552 |
* @return decimal
|
553 |
*/
|
554 |
protected function _applyTierPrice($product, $qty, $finalPrice)
|
@@ -557,10 +611,11 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
557 |
return $finalPrice;
|
558 |
}
|
559 |
|
560 |
-
$tierPrice
|
561 |
|
562 |
if (is_numeric($tierPrice)) {
|
563 |
$tierPrice = $finalPrice - ($finalPrice * ($tierPrice / 100));
|
|
|
564 |
$finalPrice = min($finalPrice, $tierPrice);
|
565 |
}
|
566 |
|
@@ -570,7 +625,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
570 |
/**
|
571 |
* Get product tier price by qty
|
572 |
*
|
573 |
-
* @param decimal
|
574 |
* @param Mage_Catalog_Model_Product $product
|
575 |
* @return decimal
|
576 |
*/
|
@@ -589,13 +644,13 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
589 |
|
590 |
if (is_null($prices) || !is_array($prices)) {
|
591 |
if (!is_null($qty)) {
|
592 |
-
return
|
593 |
}
|
594 |
return array(array(
|
595 |
-
'price'
|
596 |
-
'website_price' =>
|
597 |
-
'price_qty'
|
598 |
-
'cust_group'
|
599 |
));
|
600 |
}
|
601 |
|
@@ -624,9 +679,9 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
624 |
}
|
625 |
|
626 |
if ($price['website_price'] > $prevPrice) {
|
627 |
-
$prevPrice
|
628 |
-
$prevQty
|
629 |
-
$prevGroup
|
630 |
}
|
631 |
}
|
632 |
|
@@ -656,18 +711,18 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
656 |
/**
|
657 |
* Calculate product price based on special price data and price rules
|
658 |
*
|
659 |
-
* @param float
|
660 |
-
* @param float
|
661 |
-
* @param string
|
662 |
-
* @param string
|
663 |
* @param float|null|false $rulePrice
|
664 |
-
* @param mixed
|
665 |
-
* @param mixed
|
666 |
-
* @param null|int
|
667 |
* @return float
|
668 |
*/
|
669 |
public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
|
670 |
-
|
671 |
{
|
672 |
$resource = Mage::getResourceSingleton('bundle/bundle');
|
673 |
$selectionResource = Mage::getResourceSingleton('bundle/selection');
|
@@ -717,7 +772,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
717 |
$result['final_price'] = $selectionResource->getPriceFromIndex($result['product_id'], $qty, $store,
|
718 |
$gId);
|
719 |
|
720 |
-
$selectionPrice = $result['final_price']
|
721 |
|
722 |
if (isset($options[$result['option_id']])) {
|
723 |
$options[$result['option_id']] = min($options[$result['option_id']], $selectionPrice);
|
@@ -732,7 +787,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
732 |
continue;
|
733 |
}
|
734 |
if ($result['selection_price_type']) {
|
735 |
-
$selectionPrice = $basePrice
|
736 |
} else {
|
737 |
$selectionPrice = $result['selection_price_value'];
|
738 |
}
|
@@ -745,7 +800,7 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
745 |
$qty = $result['selection_qty'];
|
746 |
}
|
747 |
|
748 |
-
$selectionPrice = $selectionPrice
|
749 |
|
750 |
if (isset($options[$result['option_id']])) {
|
751 |
$options[$result['option_id']] = min($options[$result['option_id']], $selectionPrice);
|
@@ -801,20 +856,20 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
801 |
/**
|
802 |
* Calculate and apply special price
|
803 |
*
|
804 |
-
* @param float
|
805 |
-
* @param float
|
806 |
* @param string $specialPriceFrom
|
807 |
* @param string $specialPriceTo
|
808 |
-
* @param mixed
|
809 |
* @return float
|
810 |
*/
|
811 |
public static function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
|
812 |
-
|
813 |
{
|
814 |
if (!is_null($specialPrice) && $specialPrice != false) {
|
815 |
if (Mage::app()->getLocale()->isStoreDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
|
816 |
-
$specialPrice
|
817 |
-
$finalPrice
|
818 |
}
|
819 |
}
|
820 |
|
@@ -842,6 +897,16 @@ class Mage_Bundle_Model_Product_Price extends Mage_Catalog_Model_Product_Type_Pr
|
|
842 |
return Mage::helper($name);
|
843 |
}
|
844 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
845 |
/**
|
846 |
* Check if product has required options
|
847 |
*
|
36 |
/**
|
37 |
* Fixed price type
|
38 |
*/
|
39 |
+
const PRICE_TYPE_FIXED = 1;
|
40 |
|
41 |
/**
|
42 |
* Dynamic price type
|
43 |
*/
|
44 |
+
const PRICE_TYPE_DYNAMIC = 0;
|
45 |
|
46 |
/**
|
47 |
* Flag which indicates - is min/max prices have been calculated by index
|
112 |
/**
|
113 |
* Get product final price
|
114 |
*
|
115 |
+
* @param double $qty
|
116 |
* @param Mage_Catalog_Model_Product $product
|
117 |
* @return double
|
118 |
*/
|
138 |
* Returns final price of a child product
|
139 |
*
|
140 |
* @param Mage_Catalog_Model_Product $product
|
141 |
+
* @param float $productQty
|
142 |
* @param Mage_Catalog_Model_Product $childProduct
|
143 |
+
* @param float $childProductQty
|
144 |
* @return decimal
|
145 |
*/
|
146 |
public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty)
|
155 |
* @see Mage_Bundle_Model_Product_Price::getTotalPrices()
|
156 |
*
|
157 |
* @param Mage_Catalog_Model_Product $product
|
158 |
+
* @param string $which
|
159 |
* @return decimal|array
|
160 |
*/
|
161 |
public function getPrices($product, $which = null)
|
170 |
* @see Mage_Bundle_Model_Product_Price::getTotalPrices()
|
171 |
*
|
172 |
* @param Mage_Catalog_Model_Product $product
|
173 |
+
* @param string $which
|
174 |
+
* @param bool|null $includeTax
|
175 |
* @return decimal|array
|
176 |
*/
|
177 |
public function getPricesDependingOnTax($product, $which = null, $includeTax = null)
|
183 |
* Retrieve Price considering tier price
|
184 |
*
|
185 |
* @param Mage_Catalog_Model_Product $product
|
186 |
+
* @param string|null $which
|
187 |
+
* @param bool|null $includeTax
|
188 |
+
* @param bool $takeTierPrice
|
189 |
* @return decimal|array
|
190 |
*/
|
191 |
public function getTotalPrices($product, $which = null, $includeTax = null, $takeTierPrice = true)
|
195 |
$taxHelper = $this->_getHelperData('tax');
|
196 |
|
197 |
if ($this->_isPricesCalculatedByIndex && !$includeTax) {
|
198 |
+
$minimalPrice = $taxHelper->getPrice($product, $product->getData('min_price'), $includeTax,
|
199 |
+
null, null, null, null, null, false);
|
200 |
+
$maximalPrice = $taxHelper->getPrice($product, $product->getData('max_price'), $includeTax,
|
201 |
+
null, null, null, null, null, false);
|
202 |
} else {
|
203 |
/**
|
204 |
* Check if product price is fixed
|
205 |
*/
|
206 |
$finalPrice = $product->getFinalPrice();
|
207 |
if ($isPriceFixedType) {
|
208 |
+
$minimalPrice = $maximalPrice = $taxHelper->getPrice($product, $finalPrice, $includeTax,
|
209 |
+
null, null, null, null, null, false);
|
210 |
} else { // PRICE_TYPE_DYNAMIC
|
211 |
$minimalPrice = $maximalPrice = 0;
|
212 |
}
|
230 |
}
|
231 |
}
|
232 |
|
233 |
+
$minimalPrice = $product->getStore()->roundPrice($minimalPrice);
|
234 |
+
$maximalPrice = $product->getStore()->roundPrice($maximalPrice);
|
235 |
+
|
236 |
if ('max' == $which) {
|
237 |
return $maximalPrice;
|
238 |
} elseif ('min' == $which) {
|
254 |
{
|
255 |
$options = $this->getOptions($product);
|
256 |
$minimalPrice = 0;
|
257 |
+
$minimalPriceWithTax = 0;
|
258 |
$hasRequiredOptions = $this->_hasRequiredOptions($product);
|
259 |
$selectionMinimalPrices = array();
|
260 |
+
$selectionMinimalPricesWithTax = array();
|
261 |
|
262 |
if (!$options) {
|
263 |
return $minimalPrice;
|
265 |
|
266 |
foreach ($options as $option) {
|
267 |
/* @var $option Mage_Bundle_Model_Option */
|
268 |
+
$selectionPrices = $this->_getSelectionPrices($product, $option, $takeTierPrice, $includeTax);
|
269 |
+
$selectionPricesWithTax = $this->_getSelectionPrices($product, $option, $takeTierPrice, true);
|
270 |
|
271 |
if (count($selectionPrices)) {
|
272 |
+
$selectionMinPrice = is_array($selectionPrices) ? min($selectionPrices) : $selectionPrices;
|
273 |
+
$selectMinPriceWithTax = is_array($selectionPricesWithTax) ?
|
274 |
+
min($selectionPricesWithTax) : $selectionPricesWithTax;
|
275 |
if ($option->getRequired()) {
|
276 |
$minimalPrice += $selectionMinPrice;
|
277 |
+
$minimalPriceWithTax += $selectMinPriceWithTax;
|
278 |
} elseif (!$hasRequiredOptions) {
|
279 |
$selectionMinimalPrices[] = $selectionMinPrice;
|
280 |
+
$selectionMinimalPricesWithTax[] = $selectMinPriceWithTax;
|
281 |
}
|
282 |
}
|
283 |
}
|
284 |
// condition is TRUE when all product options are NOT required
|
285 |
if (!$hasRequiredOptions) {
|
286 |
$minimalPrice = min($selectionMinimalPrices);
|
287 |
+
$minimalPriceWithTax = min($selectionMinimalPricesWithTax);
|
288 |
+
}
|
289 |
+
|
290 |
+
$taxConfig = $this->_getHelperData('tax')->getConfig();
|
291 |
+
|
292 |
+
//In the case of total base calculation we round the tax first and
|
293 |
+
//deduct the tax from the price including tax
|
294 |
+
if ($taxConfig->priceIncludesTax($product->getStore())
|
295 |
+
&& Mage_Tax_Model_Calculation::CALC_TOTAL_BASE ==
|
296 |
+
$taxConfig->getAlgorithm($product->getStore())
|
297 |
+
&& ($minimalPriceWithTax > $minimalPrice)
|
298 |
+
) {
|
299 |
+
//We convert the value to string to maintain the precision
|
300 |
+
$tax = (String)($minimalPriceWithTax - $minimalPrice);
|
301 |
+
$roundedTax = $this->_getApp()->getStore()->roundPrice($tax);
|
302 |
+
$minimalPrice = $minimalPriceWithTax - $roundedTax;
|
303 |
}
|
304 |
return $minimalPrice;
|
305 |
}
|
345 |
{
|
346 |
$selectionPrices = array();
|
347 |
$taxHelper = $this->_getHelperData('tax');
|
348 |
+
$taxCalcMethod = $taxHelper->getConfig()->getAlgorithm($product->getStore());
|
349 |
$isPriceFixedType = ($product->getPriceType() == self::PRICE_TYPE_FIXED);
|
350 |
|
351 |
$selections = $option->getSelections();
|
364 |
|
365 |
$item = $isPriceFixedType ? $product : $selection;
|
366 |
|
367 |
+
$selectionUnitPrice = $this->getSelectionFinalTotalPrice(
|
368 |
+
$product, $selection, 1, null, false, $takeTierPrice);
|
369 |
+
$selectionQty = $selection->getSelectionQty();
|
370 |
+
if ($isPriceFixedType || $taxCalcMethod == Mage_Tax_Model_Calculation::CALC_TOTAL_BASE) {
|
371 |
+
$selectionPrice = $selectionQty * $taxHelper->getPrice($item, $selectionUnitPrice, $includeTax,
|
372 |
+
null, null, null, null, null, false);
|
373 |
+
$selectionPrices[] = $selectionPrice;
|
374 |
+
} else if ($taxCalcMethod == Mage_Tax_Model_Calculation::CALC_ROW_BASE) {
|
375 |
+
$selectionPrice = $taxHelper->getPrice($item, $selectionUnitPrice * $selectionQty, $includeTax);
|
376 |
+
$selectionPrices[] = $selectionPrice;
|
377 |
+
} else { //dynamic price and Mage_Tax_Model_Calculation::CALC_UNIT_BASE
|
378 |
+
$selectionPrice = $taxHelper->getPrice($item, $selectionUnitPrice, $includeTax) * $selectionQty;
|
379 |
+
$selectionPrices[] = $selectionPrice;
|
380 |
+
}
|
381 |
}
|
382 |
return $selectionPrices;
|
383 |
}
|
435 |
*
|
436 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
437 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
438 |
+
* @param float|null $selectionQty
|
439 |
+
* @param null|bool $multiplyQty Whether to multiply selection's price by its quantity
|
440 |
* @return float
|
441 |
*/
|
442 |
public function getSelectionPrice($bundleProduct, $selectionProduct, $selectionQty = null, $multiplyQty = true)
|
449 |
*
|
450 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
451 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
452 |
+
* @param decimal $qty
|
453 |
* @return decimal
|
454 |
*/
|
455 |
public function getSelectionPreFinalPrice($bundleProduct, $selectionProduct, $qty = null)
|
465 |
*
|
466 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
467 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
468 |
+
* @param decimal $bundleQty
|
469 |
+
* @param decimal $selectionQty
|
470 |
+
* @param bool $multiplyQty
|
471 |
* @return decimal
|
472 |
*/
|
473 |
public function getSelectionFinalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty = null,
|
474 |
+
$multiplyQty = true)
|
475 |
{
|
476 |
return $this->getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty,
|
477 |
$multiplyQty);
|
483 |
*
|
484 |
* @param Mage_Catalog_Model_Product $bundleProduct
|
485 |
* @param Mage_Catalog_Model_Product $selectionProduct
|
486 |
+
* @param float $bundleQty
|
487 |
+
* @param float $selectionQty
|
488 |
+
* @param bool $multiplyQty
|
489 |
+
* @param bool $takeTierPrice
|
490 |
+
* @return float
|
491 |
*/
|
492 |
public function getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty,
|
493 |
+
$multiplyQty = true, $takeTierPrice = true)
|
494 |
{
|
495 |
if (is_null($selectionQty)) {
|
496 |
$selectionQty = $selectionProduct->getSelectionQty();
|
513 |
}
|
514 |
}
|
515 |
|
516 |
+
$price = $this->getLowestPrice($bundleProduct, $price, $bundleQty);
|
|
|
|
|
|
|
|
|
517 |
|
518 |
if ($multiplyQty) {
|
519 |
$price *= $selectionQty;
|
522 |
return $price;
|
523 |
}
|
524 |
|
525 |
+
/**
|
526 |
+
* Returns the lowest price after applying any applicable bundle discounts
|
527 |
+
*
|
528 |
+
* @param Mage_Catalog_Model_Product $bundleProduct
|
529 |
+
* @param float|string $price
|
530 |
+
* @param int $bundleQty
|
531 |
+
* @return float
|
532 |
+
*/
|
533 |
+
public function getLowestPrice($bundleProduct, $price, $bundleQty = 1)
|
534 |
+
{
|
535 |
+
$price *= 1;
|
536 |
+
return min($this->_getApp()->getStore()->roundPrice($price),
|
537 |
+
$this->_applyGroupPrice($bundleProduct, $price),
|
538 |
+
$this->_applyTierPrice($bundleProduct, $bundleQty, $price),
|
539 |
+
$this->_applySpecialPrice($bundleProduct, $price)
|
540 |
+
);
|
541 |
+
}
|
542 |
+
|
543 |
/**
|
544 |
* Apply group price for bundle product
|
545 |
*
|
554 |
|
555 |
if (is_numeric($groupPrice)) {
|
556 |
$groupPrice = $finalPrice - ($finalPrice * ($groupPrice / 100));
|
557 |
+
$groupPrice = $this->_getApp()->getStore()->roundPrice($groupPrice);
|
558 |
$result = min($finalPrice, $groupPrice);
|
559 |
}
|
560 |
|
601 |
* Apply tier price for bundle
|
602 |
*
|
603 |
* @param Mage_Catalog_Model_Product $product
|
604 |
+
* @param decimal $qty
|
605 |
+
* @param decimal $finalPrice
|
606 |
* @return decimal
|
607 |
*/
|
608 |
protected function _applyTierPrice($product, $qty, $finalPrice)
|
611 |
return $finalPrice;
|
612 |
}
|
613 |
|
614 |
+
$tierPrice = $product->getTierPrice($qty);
|
615 |
|
616 |
if (is_numeric($tierPrice)) {
|
617 |
$tierPrice = $finalPrice - ($finalPrice * ($tierPrice / 100));
|
618 |
+
$tierPrice = $this->_getApp()->getStore()->roundPrice($tierPrice);
|
619 |
$finalPrice = min($finalPrice, $tierPrice);
|
620 |
}
|
621 |
|
625 |
/**
|
626 |
* Get product tier price by qty
|
627 |
*
|
628 |
+
* @param decimal $qty
|
629 |
* @param Mage_Catalog_Model_Product $product
|
630 |
* @return decimal
|
631 |
*/
|
644 |
|
645 |
if (is_null($prices) || !is_array($prices)) {
|
646 |
if (!is_null($qty)) {
|
647 |
+
return 0;
|
648 |
}
|
649 |
return array(array(
|
650 |
+
'price' => 0,
|
651 |
+
'website_price' => 0,
|
652 |
+
'price_qty' => 1,
|
653 |
+
'cust_group' => $allGroups
|
654 |
));
|
655 |
}
|
656 |
|
679 |
}
|
680 |
|
681 |
if ($price['website_price'] > $prevPrice) {
|
682 |
+
$prevPrice = $price['website_price'];
|
683 |
+
$prevQty = $price['price_qty'];
|
684 |
+
$prevGroup = $price['cust_group'];
|
685 |
}
|
686 |
}
|
687 |
|
711 |
/**
|
712 |
* Calculate product price based on special price data and price rules
|
713 |
*
|
714 |
+
* @param float $basePrice
|
715 |
+
* @param float $specialPrice
|
716 |
+
* @param string $specialPriceFrom
|
717 |
+
* @param string $specialPriceTo
|
718 |
* @param float|null|false $rulePrice
|
719 |
+
* @param mixed $wId
|
720 |
+
* @param mixed $gId
|
721 |
+
* @param null|int $productId
|
722 |
* @return float
|
723 |
*/
|
724 |
public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
|
725 |
+
$rulePrice = false, $wId = null, $gId = null, $productId = null)
|
726 |
{
|
727 |
$resource = Mage::getResourceSingleton('bundle/bundle');
|
728 |
$selectionResource = Mage::getResourceSingleton('bundle/selection');
|
772 |
$result['final_price'] = $selectionResource->getPriceFromIndex($result['product_id'], $qty, $store,
|
773 |
$gId);
|
774 |
|
775 |
+
$selectionPrice = $result['final_price'] * $qty;
|
776 |
|
777 |
if (isset($options[$result['option_id']])) {
|
778 |
$options[$result['option_id']] = min($options[$result['option_id']], $selectionPrice);
|
787 |
continue;
|
788 |
}
|
789 |
if ($result['selection_price_type']) {
|
790 |
+
$selectionPrice = $basePrice * $result['selection_price_value'] / 100;
|
791 |
} else {
|
792 |
$selectionPrice = $result['selection_price_value'];
|
793 |
}
|
800 |
$qty = $result['selection_qty'];
|
801 |
}
|
802 |
|
803 |
+
$selectionPrice = $selectionPrice * $qty;
|
804 |
|
805 |
if (isset($options[$result['option_id']])) {
|
806 |
$options[$result['option_id']] = min($options[$result['option_id']], $selectionPrice);
|
856 |
/**
|
857 |
* Calculate and apply special price
|
858 |
*
|
859 |
+
* @param float $finalPrice
|
860 |
+
* @param float $specialPrice
|
861 |
* @param string $specialPriceFrom
|
862 |
* @param string $specialPriceTo
|
863 |
+
* @param mixed $store
|
864 |
* @return float
|
865 |
*/
|
866 |
public static function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
|
867 |
+
$store = null)
|
868 |
{
|
869 |
if (!is_null($specialPrice) && $specialPrice != false) {
|
870 |
if (Mage::app()->getLocale()->isStoreDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
|
871 |
+
$specialPrice = Mage::app()->getStore()->roundPrice($finalPrice * $specialPrice / 100);
|
872 |
+
$finalPrice = min($finalPrice, $specialPrice);
|
873 |
}
|
874 |
}
|
875 |
|
897 |
return Mage::helper($name);
|
898 |
}
|
899 |
|
900 |
+
/**
|
901 |
+
* Get Magento App instance
|
902 |
+
*
|
903 |
+
* @return Mage_Core_Model_App
|
904 |
+
*/
|
905 |
+
protected function _getApp()
|
906 |
+
{
|
907 |
+
return Mage::app();
|
908 |
+
}
|
909 |
+
|
910 |
/**
|
911 |
* Check if product has required options
|
912 |
*
|
app/code/core/Mage/Catalog/Block/Product/Abstract.php
CHANGED
@@ -60,7 +60,7 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ
|
|
60 |
*
|
61 |
* @var string
|
62 |
*/
|
63 |
-
protected $_tierPriceDefaultTemplate
|
64 |
|
65 |
/**
|
66 |
* Price types
|
@@ -198,7 +198,7 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ
|
|
198 |
$stockItem = $product->getStockItem();
|
199 |
if ($stockItem) {
|
200 |
return ($stockItem->getMinSaleQty()
|
201 |
-
|
202 |
}
|
203 |
return null;
|
204 |
}
|
@@ -377,13 +377,15 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ
|
|
377 |
|
378 |
return $this->getData('tier_price_template');
|
379 |
}
|
|
|
380 |
/**
|
381 |
* Returns product tier price block html
|
382 |
*
|
383 |
-
* @param Mage_Catalog_Model_Product $product
|
|
|
384 |
* @return string
|
385 |
*/
|
386 |
-
public function getTierPriceHtml($product = null)
|
387 |
{
|
388 |
if (is_null($product)) {
|
389 |
$product = $this->getProduct();
|
@@ -391,8 +393,22 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ
|
|
391 |
return $this->_getPriceBlock($product->getTypeId())
|
392 |
->setTemplate($this->getTierPriceTemplate())
|
393 |
->setProduct($product)
|
394 |
-
->setInGrouped($
|
395 |
-
->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
}
|
397 |
|
398 |
/**
|
@@ -406,7 +422,7 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ
|
|
406 |
if (is_null($product)) {
|
407 |
$product = $this->getProduct();
|
408 |
}
|
409 |
-
$prices
|
410 |
|
411 |
$res = array();
|
412 |
if (is_array($prices)) {
|
60 |
*
|
61 |
* @var string
|
62 |
*/
|
63 |
+
protected $_tierPriceDefaultTemplate = 'catalog/product/view/tierprices.phtml';
|
64 |
|
65 |
/**
|
66 |
* Price types
|
198 |
$stockItem = $product->getStockItem();
|
199 |
if ($stockItem) {
|
200 |
return ($stockItem->getMinSaleQty()
|
201 |
+
&& $stockItem->getMinSaleQty() > 0 ? $stockItem->getMinSaleQty() * 1 : null);
|
202 |
}
|
203 |
return null;
|
204 |
}
|
377 |
|
378 |
return $this->getData('tier_price_template');
|
379 |
}
|
380 |
+
|
381 |
/**
|
382 |
* Returns product tier price block html
|
383 |
*
|
384 |
+
* @param null|Mage_Catalog_Model_Product $product
|
385 |
+
* @param null|Mage_Catalog_Model_Product $parent
|
386 |
* @return string
|
387 |
*/
|
388 |
+
public function getTierPriceHtml($product = null, $parent = null)
|
389 |
{
|
390 |
if (is_null($product)) {
|
391 |
$product = $this->getProduct();
|
393 |
return $this->_getPriceBlock($product->getTypeId())
|
394 |
->setTemplate($this->getTierPriceTemplate())
|
395 |
->setProduct($product)
|
396 |
+
->setInGrouped($product->isGrouped())
|
397 |
+
->setParent($parent)
|
398 |
+
->callParentToHtml();
|
399 |
+
}
|
400 |
+
|
401 |
+
/*
|
402 |
+
* Calls the object's to Html method.
|
403 |
+
* This method exists to make the code more testable.
|
404 |
+
* By having a protected wrapper for the final method toHtml, we can 'mock' out this method
|
405 |
+
* when unit testing
|
406 |
+
*
|
407 |
+
* @return string
|
408 |
+
*/
|
409 |
+
protected function callParentToHtml()
|
410 |
+
{
|
411 |
+
return $this->toHtml();
|
412 |
}
|
413 |
|
414 |
/**
|
422 |
if (is_null($product)) {
|
423 |
$product = $this->getProduct();
|
424 |
}
|
425 |
+
$prices = $product->getFormatedTierPrice();
|
426 |
|
427 |
$res = array();
|
428 |
if (is_array($prices)) {
|
app/code/core/Mage/Catalog/Block/Product/Price.php
CHANGED
@@ -33,7 +33,18 @@
|
|
33 |
*/
|
34 |
class Mage_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Abstract
|
35 |
{
|
|
|
|
|
|
|
|
|
|
|
36 |
protected $_priceDisplayType = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
protected $_idSuffix = '';
|
38 |
|
39 |
/**
|
@@ -50,17 +61,33 @@ class Mage_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Abstra
|
|
50 |
return $product;
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
public function getDisplayMinimalPrice()
|
54 |
{
|
55 |
return $this->_getData('display_minimal_price');
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
public function setIdSuffix($idSuffix)
|
59 |
{
|
60 |
$this->_idSuffix = $idSuffix;
|
61 |
return $this;
|
62 |
}
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
public function getIdSuffix()
|
65 |
{
|
66 |
return $this->_idSuffix;
|
@@ -70,15 +97,22 @@ class Mage_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Abstra
|
|
70 |
* Get tier prices (formatted)
|
71 |
*
|
72 |
* @param Mage_Catalog_Model_Product $product
|
|
|
73 |
* @return array
|
74 |
*/
|
75 |
-
public function getTierPrices($product = null)
|
76 |
{
|
77 |
if (is_null($product)) {
|
78 |
$product = $this->getProduct();
|
79 |
}
|
80 |
$prices = $product->getFormatedTierPrice();
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
$res = array();
|
83 |
if (is_array($prices)) {
|
84 |
foreach ($prices as $price) {
|
@@ -96,8 +130,15 @@ class Mage_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Abstra
|
|
96 |
}
|
97 |
|
98 |
if ($price['price'] < $productPrice) {
|
|
|
99 |
$price['savePercent'] = ceil(100 - ((100 / $productPrice) * $price['price']));
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
$tierPrice = Mage::app()->getStore()->convertPrice(
|
102 |
Mage::helper('tax')->getPrice($product, $price['website_price'])
|
103 |
);
|
33 |
*/
|
34 |
class Mage_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Abstract
|
35 |
{
|
36 |
+
/**
|
37 |
+
* Price display type
|
38 |
+
*
|
39 |
+
* @var int
|
40 |
+
*/
|
41 |
protected $_priceDisplayType = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* The id suffix
|
45 |
+
*
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
protected $_idSuffix = '';
|
49 |
|
50 |
/**
|
61 |
return $product;
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* Returns the product's minimal price
|
66 |
+
*
|
67 |
+
* @return float
|
68 |
+
*/
|
69 |
public function getDisplayMinimalPrice()
|
70 |
{
|
71 |
return $this->_getData('display_minimal_price');
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
+
* Sets the id suffix
|
76 |
+
*
|
77 |
+
* @param string $idSuffix
|
78 |
+
* @return Mage_Catalog_Block_Product_Price
|
79 |
+
*/
|
80 |
public function setIdSuffix($idSuffix)
|
81 |
{
|
82 |
$this->_idSuffix = $idSuffix;
|
83 |
return $this;
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* Returns the id suffix
|
88 |
+
*
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
public function getIdSuffix()
|
92 |
{
|
93 |
return $this->_idSuffix;
|
97 |
* Get tier prices (formatted)
|
98 |
*
|
99 |
* @param Mage_Catalog_Model_Product $product
|
100 |
+
* @param Mage_Catalog_Model_Product $parent
|
101 |
* @return array
|
102 |
*/
|
103 |
+
public function getTierPrices($product = null, $parent = null)
|
104 |
{
|
105 |
if (is_null($product)) {
|
106 |
$product = $this->getProduct();
|
107 |
}
|
108 |
$prices = $product->getFormatedTierPrice();
|
109 |
|
110 |
+
// if our parent is a bundle, then we need to further adjust our tier prices
|
111 |
+
if (isset($parent) && $parent->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
112 |
+
/* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */
|
113 |
+
$bundlePriceModel = Mage::getModel('bundle/product_price');
|
114 |
+
}
|
115 |
+
|
116 |
$res = array();
|
117 |
if (is_array($prices)) {
|
118 |
foreach ($prices as $price) {
|
130 |
}
|
131 |
|
132 |
if ($price['price'] < $productPrice) {
|
133 |
+
// use the original prices to determine the percent savings
|
134 |
$price['savePercent'] = ceil(100 - ((100 / $productPrice) * $price['price']));
|
135 |
|
136 |
+
// if applicable, adjust the tier prices
|
137 |
+
if (isset($bundlePriceModel)) {
|
138 |
+
$price['price'] = $bundlePriceModel->getLowestPrice($parent, $price['price']);
|
139 |
+
$price['website_price'] = $bundlePriceModel->getLowestPrice($parent, $price['website_price']);
|
140 |
+
}
|
141 |
+
|
142 |
$tierPrice = Mage::app()->getStore()->convertPrice(
|
143 |
Mage::helper('tax')->getPrice($product, $price['website_price'])
|
144 |
);
|
app/code/core/Mage/Catalog/Block/Product/View.php
CHANGED
@@ -153,8 +153,15 @@ class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstrac
|
|
153 |
|
154 |
$_regularPrice = $product->getPrice();
|
155 |
$_finalPrice = $product->getFinalPrice();
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
$_tierPrices = array();
|
159 |
$_tierPricesInclTax = array();
|
160 |
foreach ($product->getTierPrice() as $tierPrice) {
|
153 |
|
154 |
$_regularPrice = $product->getPrice();
|
155 |
$_finalPrice = $product->getFinalPrice();
|
156 |
+
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
157 |
+
$_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true,
|
158 |
+
null, null, null, null, null, false);
|
159 |
+
$_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, false,
|
160 |
+
null, null, null, null, null, false);
|
161 |
+
} else {
|
162 |
+
$_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true);
|
163 |
+
$_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice);
|
164 |
+
}
|
165 |
$_tierPrices = array();
|
166 |
$_tierPricesInclTax = array();
|
167 |
foreach ($product->getTierPrice() as $tierPrice) {
|
app/code/core/Mage/Catalog/Helper/Product/Compare.php
CHANGED
@@ -102,7 +102,8 @@ class Mage_Catalog_Helper_Product_Compare extends Mage_Core_Helper_Url
|
|
102 |
{
|
103 |
return array(
|
104 |
'product' => $product->getId(),
|
105 |
-
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
|
|
|
106 |
);
|
107 |
}
|
108 |
|
102 |
{
|
103 |
return array(
|
104 |
'product' => $product->getId(),
|
105 |
+
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl(),
|
106 |
+
Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
|
107 |
);
|
108 |
}
|
109 |
|
app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
CHANGED
@@ -211,7 +211,8 @@ class Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source
|
|
211 |
'pvs.entity_id = pvd.entity_id AND pvs.attribute_id = pvd.attribute_id'
|
212 |
. ' AND pvs.store_id=cs.store_id',
|
213 |
array('value' => $productValueExpression))
|
214 |
-
->where('pvd.store_id=?',
|
|
|
215 |
->where('cs.store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
|
216 |
->where('pvd.attribute_id IN(?)', $attrIds);
|
217 |
|
211 |
'pvs.entity_id = pvd.entity_id AND pvs.attribute_id = pvd.attribute_id'
|
212 |
. ' AND pvs.store_id=cs.store_id',
|
213 |
array('value' => $productValueExpression))
|
214 |
+
->where('pvd.store_id=?',
|
215 |
+
$adapter->getIfNullSql('pvs.store_id', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID))
|
216 |
->where('cs.store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
|
217 |
->where('pvd.attribute_id IN(?)', $attrIds);
|
218 |
|
app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php
CHANGED
@@ -227,7 +227,7 @@ class Mage_Catalog_Model_Resource_Product_Option_Value extends Mage_Core_Model_R
|
|
227 |
}
|
228 |
} else if ($object->getData('scope', 'title')) {
|
229 |
$where = array(
|
230 |
-
'option_type_id = ?' => (int)$
|
231 |
'store_id = ?' => (int)$object->getStoreId()
|
232 |
);
|
233 |
$this->_getWriteAdapter()->delete($titleTable, $where);
|
@@ -317,7 +317,7 @@ class Mage_Catalog_Model_Resource_Product_Option_Value extends Mage_Core_Model_R
|
|
317 |
foreach ($valueCond as $oldTypeId => $newTypeId) {
|
318 |
// price
|
319 |
$priceTable = $this->getTable('catalog/product_option_type_price');
|
320 |
-
$columns= array(
|
321 |
new Zend_Db_Expr($newTypeId),
|
322 |
'store_id', 'price', 'price_type'
|
323 |
);
|
@@ -332,7 +332,7 @@ class Mage_Catalog_Model_Resource_Product_Option_Value extends Mage_Core_Model_R
|
|
332 |
|
333 |
// title
|
334 |
$titleTable = $this->getTable('catalog/product_option_type_title');
|
335 |
-
$columns= array(
|
336 |
new Zend_Db_Expr($newTypeId),
|
337 |
'store_id', 'title'
|
338 |
);
|
227 |
}
|
228 |
} else if ($object->getData('scope', 'title')) {
|
229 |
$where = array(
|
230 |
+
'option_type_id = ?' => (int)$object->getId(),
|
231 |
'store_id = ?' => (int)$object->getStoreId()
|
232 |
);
|
233 |
$this->_getWriteAdapter()->delete($titleTable, $where);
|
317 |
foreach ($valueCond as $oldTypeId => $newTypeId) {
|
318 |
// price
|
319 |
$priceTable = $this->getTable('catalog/product_option_type_price');
|
320 |
+
$columns = array(
|
321 |
new Zend_Db_Expr($newTypeId),
|
322 |
'store_id', 'price', 'price_type'
|
323 |
);
|
332 |
|
333 |
// title
|
334 |
$titleTable = $this->getTable('catalog/product_option_type_title');
|
335 |
+
$columns = array(
|
336 |
new Zend_Db_Expr($newTypeId),
|
337 |
'store_id', 'title'
|
338 |
);
|
app/code/core/Mage/Catalog/Model/Resource/Product/Status.php
CHANGED
@@ -70,7 +70,8 @@ class Mage_Catalog_Model_Resource_Product_Status extends Mage_Core_Model_Resourc
|
|
70 |
protected function _getProductAttribute($attribute)
|
71 |
{
|
72 |
if (empty($this->_productAttributes[$attribute])) {
|
73 |
-
$this->_productAttributes[$attribute] =
|
|
|
74 |
}
|
75 |
return $this->_productAttributes[$attribute];
|
76 |
}
|
@@ -129,12 +130,6 @@ class Mage_Catalog_Model_Resource_Product_Status extends Mage_Core_Model_Resourc
|
|
129 |
->where('store_id = :store_id')
|
130 |
->where('entity_id = :product_id');
|
131 |
|
132 |
-
$binds = array(
|
133 |
-
'attribute_id' => $statusAttributeId,
|
134 |
-
'store_id' => $storeId,
|
135 |
-
'product_id' => $productId
|
136 |
-
);
|
137 |
-
|
138 |
$row = $adapter->fetchRow($select);
|
139 |
|
140 |
if ($row) {
|
@@ -189,11 +184,12 @@ class Mage_Catalog_Model_Resource_Product_Status extends Mage_Core_Model_Resourc
|
|
189 |
$select = $adapter->select()
|
190 |
->from(
|
191 |
array('t1' => $attributeTable),
|
192 |
-
array('value' => $valueCheckSql))
|
193 |
->joinLeft(
|
194 |
array('t2' => $attributeTable),
|
195 |
-
't1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id = '
|
196 |
-
|
|
|
197 |
)
|
198 |
->where('t1.store_id = ?', Mage_Core_Model_App::ADMIN_STORE_ID)
|
199 |
->where('t1.attribute_id = ?', $attribute->getAttributeId())
|
70 |
protected function _getProductAttribute($attribute)
|
71 |
{
|
72 |
if (empty($this->_productAttributes[$attribute])) {
|
73 |
+
$this->_productAttributes[$attribute] =
|
74 |
+
Mage::getSingleton('catalog/product')->getResource()->getAttribute($attribute);
|
75 |
}
|
76 |
return $this->_productAttributes[$attribute];
|
77 |
}
|
130 |
->where('store_id = :store_id')
|
131 |
->where('entity_id = :product_id');
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
$row = $adapter->fetchRow($select);
|
134 |
|
135 |
if ($row) {
|
184 |
$select = $adapter->select()
|
185 |
->from(
|
186 |
array('t1' => $attributeTable),
|
187 |
+
array('entity_id' => 't1.entity_id', 'value' => $valueCheckSql))
|
188 |
->joinLeft(
|
189 |
array('t2' => $attributeTable),
|
190 |
+
't1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id = '
|
191 |
+
. (int)$storeId,
|
192 |
+
array('')
|
193 |
)
|
194 |
->where('t1.store_id = ?', Mage_Core_Model_App::ADMIN_STORE_ID)
|
195 |
->where('t1.attribute_id = ?', $attribute->getAttributeId())
|
app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable.php
CHANGED
@@ -220,7 +220,7 @@ class Mage_Catalog_Model_Resource_Product_Type_Configurable extends Mage_Core_Mo
|
|
220 |
array()
|
221 |
)->where('super_attribute.product_id = ?', $product->getId());
|
222 |
|
223 |
-
$attributesOptionsData[$superAttribute->getAttributeId()] = $this->_getReadAdapter()->
|
224 |
}
|
225 |
return $attributesOptionsData;
|
226 |
}
|
220 |
array()
|
221 |
)->where('super_attribute.product_id = ?', $product->getId());
|
222 |
|
223 |
+
$attributesOptionsData[$superAttribute->getAttributeId()] = $this->_getReadAdapter()->fetchAll($select);
|
224 |
}
|
225 |
return $attributesOptionsData;
|
226 |
}
|
app/code/core/Mage/Catalog/controllers/Product/CompareController.php
CHANGED
@@ -74,6 +74,11 @@ class Mage_Catalog_Product_CompareController extends Mage_Core_Controller_Front_
|
|
74 |
*/
|
75 |
public function addAction()
|
76 |
{
|
|
|
|
|
|
|
|
|
|
|
77 |
$productId = (int) $this->getRequest()->getParam('product');
|
78 |
if ($productId
|
79 |
&& (Mage::getSingleton('log/visitor')->getId() || Mage::getSingleton('customer/session')->isLoggedIn())
|
74 |
*/
|
75 |
public function addAction()
|
76 |
{
|
77 |
+
if (!$this->_validateFormKey()) {
|
78 |
+
$this->_redirectReferer();
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
$productId = (int) $this->getRequest()->getParam('product');
|
83 |
if ($productId
|
84 |
&& (Mage::getSingleton('log/visitor')->getId() || Mage::getSingleton('customer/session')->isLoggedIn())
|
app/code/core/Mage/Catalog/etc/wsi.xml
CHANGED
@@ -347,8 +347,8 @@
|
|
347 |
</xsd:complexType>
|
348 |
<xsd:complexType name="catalogProductAttributeFrontendLabelEntity">
|
349 |
<xsd:sequence>
|
350 |
-
<element name="store_id" type="xsd:string"
|
351 |
-
<element name="label" type="xsd:string"
|
352 |
</xsd:sequence>
|
353 |
</xsd:complexType>
|
354 |
<xsd:complexType name="catalogProductAttributeFrontendLabelArray">
|
347 |
</xsd:complexType>
|
348 |
<xsd:complexType name="catalogProductAttributeFrontendLabelEntity">
|
349 |
<xsd:sequence>
|
350 |
+
<xsd:element name="store_id" type="xsd:string"/>
|
351 |
+
<xsd:element name="label" type="xsd:string"/>
|
352 |
</xsd:sequence>
|
353 |
</xsd:complexType>
|
354 |
<xsd:complexType name="catalogProductAttributeFrontendLabelArray">
|
app/code/core/Mage/CatalogInventory/Model/Observer.php
CHANGED
@@ -50,6 +50,11 @@ class Mage_CatalogInventory_Model_Observer
|
|
50 |
*/
|
51 |
protected $_checkedQuoteItems = array();
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
protected $_itemsForReindex = array();
|
54 |
|
55 |
/**
|
@@ -174,9 +179,10 @@ class Mage_CatalogInventory_Model_Observer
|
|
174 |
'use_config_min_sale_qty' => 1,
|
175 |
'use_config_max_sale_qty' => 1,
|
176 |
'use_config_backorders' => 1,
|
177 |
-
'use_config_notify_stock_qty'=> 1
|
178 |
);
|
179 |
-
|
|
|
180 |
$stockData += array(
|
181 |
'use_config_enable_qty_inc' => $currentStockItem->getData('use_config_enable_qty_inc'),
|
182 |
'enable_qty_increments' => $currentStockItem->getData('enable_qty_increments'),
|
@@ -339,7 +345,8 @@ class Mage_CatalogInventory_Model_Observer
|
|
339 |
/**
|
340 |
* Check item for options
|
341 |
*/
|
342 |
-
|
|
|
343 |
$qty = $quoteItem->getProduct()->getTypeInstance(true)->prepareQuoteItemQty($qty, $quoteItem->getProduct());
|
344 |
$quoteItem->setData('qty', $qty);
|
345 |
|
@@ -367,6 +374,7 @@ class Mage_CatalogInventory_Model_Observer
|
|
367 |
}
|
368 |
}
|
369 |
|
|
|
370 |
foreach ($options as $option) {
|
371 |
$optionValue = $option->getValue();
|
372 |
/* @var $option Mage_Sales_Model_Quote_Item_Option */
|
@@ -426,6 +434,7 @@ class Mage_CatalogInventory_Model_Observer
|
|
426 |
|
427 |
if ($result->getHasError()) {
|
428 |
$option->setHasError(true);
|
|
|
429 |
|
430 |
$quoteItem->addErrorInfo(
|
431 |
'cataloginventory',
|
@@ -439,7 +448,7 @@ class Mage_CatalogInventory_Model_Observer
|
|
439 |
Mage_CatalogInventory_Helper_Data::ERROR_QTY,
|
440 |
$result->getQuoteMessage()
|
441 |
);
|
442 |
-
}
|
443 |
// Delete error from item and its quote, if it was set due to qty lack
|
444 |
$this->_removeErrorsFromQuoteAndItem($quoteItem, Mage_CatalogInventory_Helper_Data::ERROR_QTY);
|
445 |
}
|
@@ -727,7 +736,7 @@ class Mage_CatalogInventory_Model_Observer
|
|
727 |
}
|
728 |
}
|
729 |
|
730 |
-
if(
|
731 |
Mage::getResourceSingleton('cataloginventory/indexer_stock')->reindexProducts($productIds);
|
732 |
}
|
733 |
|
@@ -773,8 +782,8 @@ class Mage_CatalogInventory_Model_Observer
|
|
773 |
$items[$item->getProductId()]['qty'] += $qty;
|
774 |
} else {
|
775 |
$items[$item->getProductId()] = array(
|
776 |
-
'qty'
|
777 |
-
'item'=> null,
|
778 |
);
|
779 |
}
|
780 |
}
|
@@ -795,7 +804,8 @@ class Mage_CatalogInventory_Model_Observer
|
|
795 |
$children = $item->getChildrenItems();
|
796 |
$qty = $item->getQtyOrdered() - max($item->getQtyShipped(), $item->getQtyInvoiced()) - $item->getQtyCanceled();
|
797 |
|
798 |
-
|
|
|
799 |
Mage::getSingleton('cataloginventory/stock')->backItemQty($productId, $qty);
|
800 |
}
|
801 |
|
50 |
*/
|
51 |
protected $_checkedQuoteItems = array();
|
52 |
|
53 |
+
/**
|
54 |
+
* Array of items that need to be reindexed
|
55 |
+
*
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
protected $_itemsForReindex = array();
|
59 |
|
60 |
/**
|
179 |
'use_config_min_sale_qty' => 1,
|
180 |
'use_config_max_sale_qty' => 1,
|
181 |
'use_config_backorders' => 1,
|
182 |
+
'use_config_notify_stock_qty' => 1
|
183 |
);
|
184 |
+
$currentStockItem = $currentProduct->getStockItem();
|
185 |
+
if ($currentStockItem) {
|
186 |
$stockData += array(
|
187 |
'use_config_enable_qty_inc' => $currentStockItem->getData('use_config_enable_qty_inc'),
|
188 |
'enable_qty_increments' => $currentStockItem->getData('enable_qty_increments'),
|
345 |
/**
|
346 |
* Check item for options
|
347 |
*/
|
348 |
+
$options = $quoteItem->getQtyOptions();
|
349 |
+
if ($options && $qty > 0) {
|
350 |
$qty = $quoteItem->getProduct()->getTypeInstance(true)->prepareQuoteItemQty($qty, $quoteItem->getProduct());
|
351 |
$quoteItem->setData('qty', $qty);
|
352 |
|
374 |
}
|
375 |
}
|
376 |
|
377 |
+
$quoteItemHasErrors = false;
|
378 |
foreach ($options as $option) {
|
379 |
$optionValue = $option->getValue();
|
380 |
/* @var $option Mage_Sales_Model_Quote_Item_Option */
|
434 |
|
435 |
if ($result->getHasError()) {
|
436 |
$option->setHasError(true);
|
437 |
+
$quoteItemHasErrors = true;
|
438 |
|
439 |
$quoteItem->addErrorInfo(
|
440 |
'cataloginventory',
|
448 |
Mage_CatalogInventory_Helper_Data::ERROR_QTY,
|
449 |
$result->getQuoteMessage()
|
450 |
);
|
451 |
+
} elseif (!$quoteItemHasErrors) {
|
452 |
// Delete error from item and its quote, if it was set due to qty lack
|
453 |
$this->_removeErrorsFromQuoteAndItem($quoteItem, Mage_CatalogInventory_Helper_Data::ERROR_QTY);
|
454 |
}
|
736 |
}
|
737 |
}
|
738 |
|
739 |
+
if (count($productIds)) {
|
740 |
Mage::getResourceSingleton('cataloginventory/indexer_stock')->reindexProducts($productIds);
|
741 |
}
|
742 |
|
782 |
$items[$item->getProductId()]['qty'] += $qty;
|
783 |
} else {
|
784 |
$items[$item->getProductId()] = array(
|
785 |
+
'qty' => $qty,
|
786 |
+
'item' => null,
|
787 |
);
|
788 |
}
|
789 |
}
|
804 |
$children = $item->getChildrenItems();
|
805 |
$qty = $item->getQtyOrdered() - max($item->getQtyShipped(), $item->getQtyInvoiced()) - $item->getQtyCanceled();
|
806 |
|
807 |
+
$productId = $item->getProductId();
|
808 |
+
if ($item->getId() && $productId && empty($children) && $qty) {
|
809 |
Mage::getSingleton('cataloginventory/stock')->backItemQty($productId, $qty);
|
810 |
}
|
811 |
|
app/code/core/Mage/CatalogRule/Model/Resource/Rule.php
CHANGED
@@ -246,7 +246,7 @@ class Mage_CatalogRule_Model_Resource_Rule extends Mage_Rule_Model_Resource_Abst
|
|
246 |
));
|
247 |
|
248 |
if (count($productIds) > 0) {
|
249 |
-
$selectByStore->where('p.entity_id IN (?)', $productIds);
|
250 |
}
|
251 |
|
252 |
$selects = $write->selectsByRange('entity_id', $selectByStore, self::RANGE_PRODUCT_STEP);
|
246 |
));
|
247 |
|
248 |
if (count($productIds) > 0) {
|
249 |
+
$selectByStore->where('p.entity_id IN (?)', array_keys($productIds));
|
250 |
}
|
251 |
|
252 |
$selects = $write->selectsByRange('entity_id', $selectByStore, self::RANGE_PRODUCT_STEP);
|
app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php
CHANGED
@@ -89,11 +89,13 @@ class Mage_CatalogRule_Model_Rule_Condition_Product extends Mage_Rule_Model_Cond
|
|
89 |
*/
|
90 |
protected function _getAttributeValue($object)
|
91 |
{
|
|
|
92 |
$storeId = $object->getStoreId();
|
93 |
$defaultStoreId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
94 |
$productValues = isset($this->_entityAttributeValues[$object->getId()])
|
95 |
? $this->_entityAttributeValues[$object->getId()] : array();
|
96 |
-
$defaultValue = isset($productValues[$defaultStoreId])
|
|
|
97 |
$value = isset($productValues[$storeId]) ? $productValues[$storeId] : $defaultValue;
|
98 |
|
99 |
$value = $this->_prepareDatetimeValue($value, $object);
|
89 |
*/
|
90 |
protected function _getAttributeValue($object)
|
91 |
{
|
92 |
+
$attrCode = $this->getAttribute();
|
93 |
$storeId = $object->getStoreId();
|
94 |
$defaultStoreId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
95 |
$productValues = isset($this->_entityAttributeValues[$object->getId()])
|
96 |
? $this->_entityAttributeValues[$object->getId()] : array();
|
97 |
+
$defaultValue = isset($productValues[$defaultStoreId])
|
98 |
+
? $productValues[$defaultStoreId] : $object->getData($attrCode);
|
99 |
$value = isset($productValues[$storeId]) ? $productValues[$storeId] : $defaultValue;
|
100 |
|
101 |
$value = $this->_prepareDatetimeValue($value, $object);
|
app/code/core/Mage/CatalogSearch/Helper/Data.php
CHANGED
@@ -31,7 +31,14 @@
|
|
31 |
*/
|
32 |
class Mage_CatalogSearch_Helper_Data extends Mage_Core_Helper_Abstract
|
33 |
{
|
|
|
|
|
|
|
34 |
const QUERY_VAR_NAME = 'q';
|
|
|
|
|
|
|
|
|
35 |
const MAX_QUERY_LEN = 200;
|
36 |
|
37 |
/**
|
@@ -166,7 +173,7 @@ class Mage_CatalogSearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
166 |
{
|
167 |
return $this->_getUrl('catalogsearch/result', array(
|
168 |
'_query' => array(self::QUERY_VAR_NAME => $query),
|
169 |
-
'_secure' =>
|
170 |
));
|
171 |
}
|
172 |
|
@@ -178,10 +185,20 @@ class Mage_CatalogSearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
178 |
public function getSuggestUrl()
|
179 |
{
|
180 |
return $this->_getUrl('catalogsearch/ajax/suggest', array(
|
181 |
-
'_secure' =>
|
182 |
));
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
/**
|
186 |
* Retrieve search term url
|
187 |
*
|
31 |
*/
|
32 |
class Mage_CatalogSearch_Helper_Data extends Mage_Core_Helper_Abstract
|
33 |
{
|
34 |
+
/**
|
35 |
+
* Query variable name
|
36 |
+
*/
|
37 |
const QUERY_VAR_NAME = 'q';
|
38 |
+
|
39 |
+
/*
|
40 |
+
* Maximum query length
|
41 |
+
*/
|
42 |
const MAX_QUERY_LEN = 200;
|
43 |
|
44 |
/**
|
173 |
{
|
174 |
return $this->_getUrl('catalogsearch/result', array(
|
175 |
'_query' => array(self::QUERY_VAR_NAME => $query),
|
176 |
+
'_secure' => $this->_getApp()->getFrontController()->getRequest()->isSecure()
|
177 |
));
|
178 |
}
|
179 |
|
185 |
public function getSuggestUrl()
|
186 |
{
|
187 |
return $this->_getUrl('catalogsearch/ajax/suggest', array(
|
188 |
+
'_secure' => $this->_getApp()->getStore()->isCurrentlySecure()
|
189 |
));
|
190 |
}
|
191 |
|
192 |
+
/**
|
193 |
+
* Get App
|
194 |
+
*
|
195 |
+
* @return Mage_Core_Model_App
|
196 |
+
*/
|
197 |
+
protected function _getApp()
|
198 |
+
{
|
199 |
+
return Mage::app();
|
200 |
+
}
|
201 |
+
|
202 |
/**
|
203 |
* Retrieve search term url
|
204 |
*
|
app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
CHANGED
@@ -442,6 +442,9 @@ class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
|
|
442 |
*/
|
443 |
public function getCacheTags()
|
444 |
{
|
445 |
-
|
|
|
|
|
|
|
446 |
}
|
447 |
}
|
442 |
*/
|
443 |
public function getCacheTags()
|
444 |
{
|
445 |
+
$tags = $this->getProduct()->getCacheIdTags();
|
446 |
+
$tags = is_array($tags) ? $tags : array();
|
447 |
+
|
448 |
+
return array_merge(parent::getCacheTags(), $tags);
|
449 |
}
|
450 |
}
|
app/code/core/Mage/Checkout/Helper/Data.php
CHANGED
@@ -93,6 +93,7 @@ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
|
|
93 |
|
94 |
/**
|
95 |
* Get sales item (quote item, order item etc) price including tax based on row total and tax amount
|
|
|
96 |
*
|
97 |
* @param Varien_Object $item
|
98 |
* @return float
|
@@ -103,9 +104,9 @@ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
|
|
103 |
return $item->getPriceInclTax();
|
104 |
}
|
105 |
$qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
|
106 |
-
|
107 |
-
|
108 |
-
return
|
109 |
}
|
110 |
|
111 |
/**
|
@@ -119,21 +120,46 @@ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
|
|
119 |
if ($item->getRowTotalInclTax()) {
|
120 |
return $item->getRowTotalInclTax();
|
121 |
}
|
122 |
-
|
|
|
|
|
|
|
123 |
return $item->getRowTotal() + $tax;
|
124 |
}
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
public function getBasePriceInclTax($item)
|
127 |
{
|
128 |
$qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
|
129 |
-
|
130 |
-
|
131 |
-
return Mage::app()->getStore()->roundPrice($price);
|
132 |
}
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
public function getBaseSubtotalInclTax($item)
|
135 |
{
|
136 |
-
$tax = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation()
|
|
|
137 |
return $item->getBaseRowTotal()+$tax;
|
138 |
}
|
139 |
|
@@ -193,32 +219,32 @@ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
|
|
193 |
foreach ($checkout->getAllVisibleItems() as $_item) {
|
194 |
/* @var $_item Mage_Sales_Model_Quote_Item */
|
195 |
$items .= $_item->getProduct()->getName() . ' x '. $_item->getQty() . ' '
|
196 |
-
|
197 |
-
|
198 |
}
|
199 |
$total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
|
200 |
|
201 |
foreach ($sendTo as $recipient) {
|
202 |
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
|
203 |
->sendTransactional(
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
}
|
223 |
|
224 |
$translate->setTranslateInline(true);
|
@@ -255,7 +281,7 @@ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
|
|
255 |
&& (($quote->getItemsSummaryQty() - $quote->getItemVirtualQty()) > 0)
|
256 |
&& ($quote->getItemsSummaryQty() <= $maximunQty)
|
257 |
&& !$quote->hasNominalItems()
|
258 |
-
|
259 |
}
|
260 |
|
261 |
/**
|
93 |
|
94 |
/**
|
95 |
* Get sales item (quote item, order item etc) price including tax based on row total and tax amount
|
96 |
+
* excluding weee tax
|
97 |
*
|
98 |
* @param Varien_Object $item
|
99 |
* @return float
|
104 |
return $item->getPriceInclTax();
|
105 |
}
|
106 |
$qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
|
107 |
+
|
108 |
+
//Unit price is rowtotal/qty
|
109 |
+
return $qty > 0 ? $this->getSubtotalInclTax($item)/$qty :0;
|
110 |
}
|
111 |
|
112 |
/**
|
120 |
if ($item->getRowTotalInclTax()) {
|
121 |
return $item->getRowTotalInclTax();
|
122 |
}
|
123 |
+
//Since tax amount contains weee tax
|
124 |
+
$tax = $item->getTaxAmount() + $item->getDiscountTaxCompensation()
|
125 |
+
- $this->_getWeeeHelper()->getTotalRowTaxAppliedForWeeeTax($item);;
|
126 |
+
|
127 |
return $item->getRowTotal() + $tax;
|
128 |
}
|
129 |
|
130 |
+
/**
|
131 |
+
* Returns the helper for weee
|
132 |
+
*
|
133 |
+
* @return Mage_Weee_Helper_Data
|
134 |
+
*/
|
135 |
+
protected function _getWeeeHelper()
|
136 |
+
{
|
137 |
+
return Mage::helper('weee');
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Get the base price of the item including tax , excluding weee
|
142 |
+
*
|
143 |
+
* @param Varien_Object $item
|
144 |
+
* @return float
|
145 |
+
*/
|
146 |
public function getBasePriceInclTax($item)
|
147 |
{
|
148 |
$qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
|
149 |
+
|
150 |
+
return $qty > 0 ? $this->getBaseSubtotalInclTax($item) / $qty : 0;
|
|
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
+
* Get sales item (quote item, order item etc) row total price including tax excluding wee
|
155 |
+
*
|
156 |
+
* @param Varien_Object $item
|
157 |
+
* @return float
|
158 |
+
*/
|
159 |
public function getBaseSubtotalInclTax($item)
|
160 |
{
|
161 |
+
$tax = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation()
|
162 |
+
- $this->_getWeeeHelper()->getBaseTotalRowTaxAppliedForWeeeTax($item);
|
163 |
return $item->getBaseRowTotal()+$tax;
|
164 |
}
|
165 |
|
219 |
foreach ($checkout->getAllVisibleItems() as $_item) {
|
220 |
/* @var $_item Mage_Sales_Model_Quote_Item */
|
221 |
$items .= $_item->getProduct()->getName() . ' x '. $_item->getQty() . ' '
|
222 |
+
. $checkout->getStoreCurrencyCode() . ' '
|
223 |
+
. $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
|
224 |
}
|
225 |
$total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
|
226 |
|
227 |
foreach ($sendTo as $recipient) {
|
228 |
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
|
229 |
->sendTransactional(
|
230 |
+
$template,
|
231 |
+
Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
|
232 |
+
$recipient['email'],
|
233 |
+
$recipient['name'],
|
234 |
+
array(
|
235 |
+
'reason' => $message,
|
236 |
+
'checkoutType' => $checkoutType,
|
237 |
+
'dateAndTime' => Mage::app()->getLocale()->date(),
|
238 |
+
'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(),
|
239 |
+
'customerEmail' => $checkout->getCustomerEmail(),
|
240 |
+
'billingAddress' => $checkout->getBillingAddress(),
|
241 |
+
'shippingAddress' => $checkout->getShippingAddress(),
|
242 |
+
'shippingMethod' => Mage::getStoreConfig('carriers/'.$shippingMethod.'/title'),
|
243 |
+
'paymentMethod' => Mage::getStoreConfig('payment/'.$paymentMethod.'/title'),
|
244 |
+
'items' => nl2br($items),
|
245 |
+
'total' => $total
|
246 |
+
)
|
247 |
+
);
|
248 |
}
|
249 |
|
250 |
$translate->setTranslateInline(true);
|
281 |
&& (($quote->getItemsSummaryQty() - $quote->getItemVirtualQty()) > 0)
|
282 |
&& ($quote->getItemsSummaryQty() <= $maximunQty)
|
283 |
&& !$quote->hasNominalItems()
|
284 |
+
;
|
285 |
}
|
286 |
|
287 |
/**
|
app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
CHANGED
@@ -31,7 +31,6 @@
|
|
31 |
* @package Mage_Checkout
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
-
|
35 |
class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resource_Product
|
36 |
{
|
37 |
/**
|
@@ -51,7 +50,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
51 |
* @param $store
|
52 |
* @return bool
|
53 |
*/
|
54 |
-
public function add($quoteId, $productsData, $store=null)
|
55 |
{
|
56 |
$quote = $this->_getQuote($quoteId, $store);
|
57 |
if (empty($store)) {
|
@@ -91,7 +90,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
91 |
|
92 |
try {
|
93 |
$quote->collectTotals()->save();
|
94 |
-
} catch(Exception $e) {
|
95 |
$this->_fault("add_product_quote_save_fault", $e->getMessage());
|
96 |
}
|
97 |
|
@@ -104,7 +103,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
104 |
* @param $store
|
105 |
* @return bool
|
106 |
*/
|
107 |
-
public function update($quoteId, $productsData, $store=null)
|
108 |
{
|
109 |
$quote = $this->_getQuote($quoteId, $store);
|
110 |
if (empty($store)) {
|
@@ -145,8 +144,8 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
145 |
}
|
146 |
|
147 |
try {
|
148 |
-
$quote->save();
|
149 |
-
} catch(Exception $e) {
|
150 |
$this->_fault("update_product_quote_save_fault", $e->getMessage());
|
151 |
}
|
152 |
|
@@ -159,7 +158,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
159 |
* @param $store
|
160 |
* @return bool
|
161 |
*/
|
162 |
-
public function remove($quoteId, $productsData, $store=null)
|
163 |
{
|
164 |
$quote = $this->_getQuote($quoteId, $store);
|
165 |
if (empty($store)) {
|
@@ -201,8 +200,8 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
201 |
}
|
202 |
|
203 |
try {
|
204 |
-
$quote->save();
|
205 |
-
} catch(Exception $e) {
|
206 |
$this->_fault("remove_product_quote_save_fault", $e->getMessage());
|
207 |
}
|
208 |
|
@@ -249,7 +248,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
249 |
* @param $store
|
250 |
* @return bool
|
251 |
*/
|
252 |
-
public function moveToCustomerQuote($quoteId, $productsData, $store=null)
|
253 |
{
|
254 |
$quote = $this->_getQuote($quoteId, $store);
|
255 |
|
@@ -281,7 +280,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
281 |
}
|
282 |
|
283 |
$errors = array();
|
284 |
-
foreach($productsData as $key => $productItem){
|
285 |
if (isset($productItem['product_id'])) {
|
286 |
$productByItem = $this->_getProduct($productItem['product_id'], $store, "id");
|
287 |
} else if (isset($productItem['sku'])) {
|
@@ -295,7 +294,7 @@ class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resou
|
|
295 |
/** @var $quoteItem Mage_Sales_Model_Quote_Item */
|
296 |
$quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem,
|
297 |
$this->_getProductRequest($productItem));
|
298 |
-
if($quoteItem && $quoteItem->getId()){
|
299 |
$newQuoteItem = clone $quoteItem;
|
300 |
$newQuoteItem->setId(null);
|
301 |
$customerQuote->addItem($newQuoteItem);
|
31 |
* @package Mage_Checkout
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
|
|
34 |
class Mage_Checkout_Model_Cart_Product_Api extends Mage_Checkout_Model_Api_Resource_Product
|
35 |
{
|
36 |
/**
|
50 |
* @param $store
|
51 |
* @return bool
|
52 |
*/
|
53 |
+
public function add($quoteId, $productsData, $store = null)
|
54 |
{
|
55 |
$quote = $this->_getQuote($quoteId, $store);
|
56 |
if (empty($store)) {
|
90 |
|
91 |
try {
|
92 |
$quote->collectTotals()->save();
|
93 |
+
} catch (Exception $e) {
|
94 |
$this->_fault("add_product_quote_save_fault", $e->getMessage());
|
95 |
}
|
96 |
|
103 |
* @param $store
|
104 |
* @return bool
|
105 |
*/
|
106 |
+
public function update($quoteId, $productsData, $store = null)
|
107 |
{
|
108 |
$quote = $this->_getQuote($quoteId, $store);
|
109 |
if (empty($store)) {
|
144 |
}
|
145 |
|
146 |
try {
|
147 |
+
$quote->collectTotals()->save();
|
148 |
+
} catch (Exception $e) {
|
149 |
$this->_fault("update_product_quote_save_fault", $e->getMessage());
|
150 |
}
|
151 |
|
158 |
* @param $store
|
159 |
* @return bool
|
160 |
*/
|
161 |
+
public function remove($quoteId, $productsData, $store = null)
|
162 |
{
|
163 |
$quote = $this->_getQuote($quoteId, $store);
|
164 |
if (empty($store)) {
|
200 |
}
|
201 |
|
202 |
try {
|
203 |
+
$quote->collectTotals()->save();
|
204 |
+
} catch (Exception $e) {
|
205 |
$this->_fault("remove_product_quote_save_fault", $e->getMessage());
|
206 |
}
|
207 |
|
248 |
* @param $store
|
249 |
* @return bool
|
250 |
*/
|
251 |
+
public function moveToCustomerQuote($quoteId, $productsData, $store = null)
|
252 |
{
|
253 |
$quote = $this->_getQuote($quoteId, $store);
|
254 |
|
280 |
}
|
281 |
|
282 |
$errors = array();
|
283 |
+
foreach ($productsData as $key => $productItem) {
|
284 |
if (isset($productItem['product_id'])) {
|
285 |
$productByItem = $this->_getProduct($productItem['product_id'], $store, "id");
|
286 |
} else if (isset($productItem['sku'])) {
|
294 |
/** @var $quoteItem Mage_Sales_Model_Quote_Item */
|
295 |
$quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem,
|
296 |
$this->_getProductRequest($productItem));
|
297 |
+
if ($quoteItem && $quoteItem->getId()) {
|
298 |
$newQuoteItem = clone $quoteItem;
|
299 |
$newQuoteItem->setId(null);
|
300 |
$customerQuote->addItem($newQuoteItem);
|
app/code/core/Mage/Checkout/controllers/CartController.php
CHANGED
@@ -397,6 +397,11 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
|
|
397 |
*/
|
398 |
public function updatePostAction()
|
399 |
{
|
|
|
|
|
|
|
|
|
|
|
400 |
$updateAction = (string)$this->getRequest()->getParam('update_cart_action');
|
401 |
|
402 |
switch ($updateAction) {
|
397 |
*/
|
398 |
public function updatePostAction()
|
399 |
{
|
400 |
+
if (!$this->_validateFormKey()) {
|
401 |
+
$this->_redirect('*/*/');
|
402 |
+
return;
|
403 |
+
}
|
404 |
+
|
405 |
$updateAction = (string)$this->getRequest()->getParam('update_cart_action');
|
406 |
|
407 |
switch ($updateAction) {
|
app/code/core/Mage/Checkout/controllers/MultishippingController.php
CHANGED
@@ -267,6 +267,9 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
267 |
}
|
268 |
}
|
269 |
|
|
|
|
|
|
|
270 |
public function backToAddressesAction()
|
271 |
{
|
272 |
$this->_getState()->setActiveStep(
|
@@ -292,6 +295,11 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
292 |
$this->_redirect('*/*/addresses');
|
293 |
}
|
294 |
|
|
|
|
|
|
|
|
|
|
|
295 |
protected function _validateMinimumAmount()
|
296 |
{
|
297 |
if (!$this->_getCheckout()->validateMinimumAmount()) {
|
@@ -326,6 +334,9 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
326 |
$this->renderLayout();
|
327 |
}
|
328 |
|
|
|
|
|
|
|
329 |
public function backToShippingAction()
|
330 |
{
|
331 |
$this->_getState()->setActiveStep(
|
@@ -337,6 +348,9 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
337 |
$this->_redirect('*/*/shipping');
|
338 |
}
|
339 |
|
|
|
|
|
|
|
340 |
public function shippingPostAction()
|
341 |
{
|
342 |
$shippingMethods = $this->getRequest()->getPost('shipping_method');
|
@@ -354,7 +368,7 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
354 |
);
|
355 |
$this->_redirect('*/*/billing');
|
356 |
}
|
357 |
-
catch (Exception $e){
|
358 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
359 |
$this->_redirect('*/*/shipping');
|
360 |
}
|
@@ -402,6 +416,9 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
402 |
return true;
|
403 |
}
|
404 |
|
|
|
|
|
|
|
405 |
public function backToBillingAction()
|
406 |
{
|
407 |
$this->_getState()->setActiveStep(
|
@@ -453,8 +470,16 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
453 |
}
|
454 |
}
|
455 |
|
|
|
|
|
|
|
456 |
public function overviewPostAction()
|
457 |
{
|
|
|
|
|
|
|
|
|
|
|
458 |
if (!$this->_validateMinimumAmount()) {
|
459 |
return;
|
460 |
}
|
@@ -489,7 +514,7 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
489 |
$this->_redirect('*/*/success');
|
490 |
} catch (Mage_Payment_Model_Info_Exception $e) {
|
491 |
$message = $e->getMessage();
|
492 |
-
if( !empty($message) ) {
|
493 |
$this->_getCheckoutSession()->addError($message);
|
494 |
}
|
495 |
$this->_redirect('*/*/billing');
|
@@ -500,12 +525,12 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
500 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
501 |
$this->_redirect('*/cart');
|
502 |
}
|
503 |
-
catch (Mage_Core_Exception $e){
|
504 |
Mage::helper('checkout')
|
505 |
->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
|
506 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
507 |
$this->_redirect('*/*/billing');
|
508 |
-
} catch (Exception $e){
|
509 |
Mage::logException($e);
|
510 |
Mage::helper('checkout')
|
511 |
->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
|
@@ -515,7 +540,7 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
515 |
}
|
516 |
|
517 |
/**
|
518 |
-
* Multishipping checkout
|
519 |
*/
|
520 |
public function successAction()
|
521 |
{
|
@@ -533,7 +558,6 @@ class Mage_Checkout_MultishippingController extends Mage_Checkout_Controller_Act
|
|
533 |
|
534 |
/**
|
535 |
* Redirect to login page
|
536 |
-
*
|
537 |
*/
|
538 |
public function redirectLogin()
|
539 |
{
|
267 |
}
|
268 |
}
|
269 |
|
270 |
+
/**
|
271 |
+
* Multishipping checkout action to go back to addresses page
|
272 |
+
*/
|
273 |
public function backToAddressesAction()
|
274 |
{
|
275 |
$this->_getState()->setActiveStep(
|
295 |
$this->_redirect('*/*/addresses');
|
296 |
}
|
297 |
|
298 |
+
/**
|
299 |
+
* Returns whether the minimum amount has been reached
|
300 |
+
*
|
301 |
+
* @return bool
|
302 |
+
*/
|
303 |
protected function _validateMinimumAmount()
|
304 |
{
|
305 |
if (!$this->_getCheckout()->validateMinimumAmount()) {
|
334 |
$this->renderLayout();
|
335 |
}
|
336 |
|
337 |
+
/**
|
338 |
+
* Multishipping checkout action to go back to shipping
|
339 |
+
*/
|
340 |
public function backToShippingAction()
|
341 |
{
|
342 |
$this->_getState()->setActiveStep(
|
348 |
$this->_redirect('*/*/shipping');
|
349 |
}
|
350 |
|
351 |
+
/**
|
352 |
+
* Multishipping checkout after the shipping page
|
353 |
+
*/
|
354 |
public function shippingPostAction()
|
355 |
{
|
356 |
$shippingMethods = $this->getRequest()->getPost('shipping_method');
|
368 |
);
|
369 |
$this->_redirect('*/*/billing');
|
370 |
}
|
371 |
+
catch (Exception $e) {
|
372 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
373 |
$this->_redirect('*/*/shipping');
|
374 |
}
|
416 |
return true;
|
417 |
}
|
418 |
|
419 |
+
/**
|
420 |
+
* Multishipping checkout action to go back to billing
|
421 |
+
*/
|
422 |
public function backToBillingAction()
|
423 |
{
|
424 |
$this->_getState()->setActiveStep(
|
470 |
}
|
471 |
}
|
472 |
|
473 |
+
/**
|
474 |
+
* Multishipping checkout after the overview page
|
475 |
+
*/
|
476 |
public function overviewPostAction()
|
477 |
{
|
478 |
+
if (!$this->_validateFormKey()) {
|
479 |
+
$this->_forward('backToAddresses');
|
480 |
+
return;
|
481 |
+
}
|
482 |
+
|
483 |
if (!$this->_validateMinimumAmount()) {
|
484 |
return;
|
485 |
}
|
514 |
$this->_redirect('*/*/success');
|
515 |
} catch (Mage_Payment_Model_Info_Exception $e) {
|
516 |
$message = $e->getMessage();
|
517 |
+
if ( !empty($message) ) {
|
518 |
$this->_getCheckoutSession()->addError($message);
|
519 |
}
|
520 |
$this->_redirect('*/*/billing');
|
525 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
526 |
$this->_redirect('*/cart');
|
527 |
}
|
528 |
+
catch (Mage_Core_Exception $e) {
|
529 |
Mage::helper('checkout')
|
530 |
->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
|
531 |
$this->_getCheckoutSession()->addError($e->getMessage());
|
532 |
$this->_redirect('*/*/billing');
|
533 |
+
} catch (Exception $e) {
|
534 |
Mage::logException($e);
|
535 |
Mage::helper('checkout')
|
536 |
->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
|
540 |
}
|
541 |
|
542 |
/**
|
543 |
+
* Multishipping checkout success page
|
544 |
*/
|
545 |
public function successAction()
|
546 |
{
|
558 |
|
559 |
/**
|
560 |
* Redirect to login page
|
|
|
561 |
*/
|
562 |
public function redirectLogin()
|
563 |
{
|
app/code/core/Mage/Cms/Model/Resource/Page.php
CHANGED
@@ -147,6 +147,9 @@ class Mage_Cms_Model_Resource_Page extends Mage_Core_Model_Resource_Db_Abstract
|
|
147 |
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
148 |
}
|
149 |
|
|
|
|
|
|
|
150 |
return parent::_afterSave($object);
|
151 |
}
|
152 |
|
147 |
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
148 |
}
|
149 |
|
150 |
+
//Mark layout cache as invalidated
|
151 |
+
Mage::app()->getCacheInstance()->invalidateType('layout');
|
152 |
+
|
153 |
return parent::_afterSave($object);
|
154 |
}
|
155 |
|
app/code/core/Mage/Cms/Model/Resource/Page/Service.php
CHANGED
@@ -43,7 +43,7 @@ class Mage_Cms_Model_Resource_Page_Service extends Mage_Core_Model_Resource_Db_A
|
|
43 |
/**
|
44 |
* Unlinks from $fromStoreId store pages that have same identifiers as pages in $byStoreId
|
45 |
*
|
46 |
-
* Routine is
|
47 |
* to prevent duplication of url keys
|
48 |
*
|
49 |
* Resolved $byLinkTable can be provided when restoring links from some backup table
|
@@ -81,6 +81,7 @@ class Mage_Cms_Model_Resource_Page_Service extends Mage_Core_Model_Resource_Db_A
|
|
81 |
$readAdapter->quoteInto('by_link.page_id = by_entity.page_id AND by_link.store_id = ?', $byStoreId),
|
82 |
array()
|
83 |
);
|
|
|
84 |
$pageIds = $readAdapter->fetchCol($select);
|
85 |
|
86 |
// Unlink found pages
|
@@ -88,7 +89,7 @@ class Mage_Cms_Model_Resource_Page_Service extends Mage_Core_Model_Resource_Db_A
|
|
88 |
$writeAdapter = $this->_getWriteAdapter();
|
89 |
$where = array(
|
90 |
'page_id IN (?)' => $pageIds,
|
91 |
-
'
|
92 |
);
|
93 |
$writeAdapter->delete($linkTable, $where);
|
94 |
}
|
43 |
/**
|
44 |
* Unlinks from $fromStoreId store pages that have same identifiers as pages in $byStoreId
|
45 |
*
|
46 |
+
* Routine is intended to be used before linking pages of some store ($byStoreId) to other store ($fromStoreId)
|
47 |
* to prevent duplication of url keys
|
48 |
*
|
49 |
* Resolved $byLinkTable can be provided when restoring links from some backup table
|
81 |
$readAdapter->quoteInto('by_link.page_id = by_entity.page_id AND by_link.store_id = ?', $byStoreId),
|
82 |
array()
|
83 |
);
|
84 |
+
|
85 |
$pageIds = $readAdapter->fetchCol($select);
|
86 |
|
87 |
// Unlink found pages
|
89 |
$writeAdapter = $this->_getWriteAdapter();
|
90 |
$where = array(
|
91 |
'page_id IN (?)' => $pageIds,
|
92 |
+
'store_id = ?' => $fromStoreId
|
93 |
);
|
94 |
$writeAdapter->delete($linkTable, $where);
|
95 |
}
|
app/code/core/Mage/{GoogleCheckout/Block/Form.php → Cms/data/cms_setup/data-upgrade-1.6.0.0.1-1.6.0.0.2.php}
RENAMED
@@ -19,28 +19,21 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
class Mage_GoogleCheckout_Block_Form extends Mage_Payment_Block_Form
|
35 |
-
{
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Varien constructor
|
39 |
-
*/
|
40 |
-
protected function _construct()
|
41 |
-
{
|
42 |
-
$this->setTemplate('googlecheckout/form.phtml');
|
43 |
-
parent::_construct();
|
44 |
-
}
|
45 |
|
46 |
-
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Cms
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
+
$content = "<p>This website requires cookies to provide all of its features. For more " .
|
27 |
+
"information on what data is contained in the cookies, please see our " .
|
28 |
+
"<a href=\"{{store direct_url=\"privacy-policy-cookie-restriction-mode\"}}\">Privacy Policy page</a>. " .
|
29 |
+
"To accept cookies from this site, please click the Allow button below.</p>";
|
30 |
|
31 |
+
$cmsBlock = array(
|
32 |
+
'title' => 'Cookie restriction notice',
|
33 |
+
'identifier' => 'cookie_restriction_notice_block',
|
34 |
+
'content' => $content,
|
35 |
+
'is_active' => 1,
|
36 |
+
'stores' => 0
|
37 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
Mage::getModel('cms/block')->setData($cmsBlock)->save();
|
app/code/core/Mage/Cms/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Cms>
|
31 |
-
<version>1.6.0.0.
|
32 |
</Mage_Cms>
|
33 |
</modules>
|
34 |
<frontend>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Cms>
|
31 |
+
<version>1.6.0.0.2</version>
|
32 |
</Mage_Cms>
|
33 |
</modules>
|
34 |
<frontend>
|
app/code/core/Mage/Core/Block/Abstract.php
CHANGED
@@ -86,28 +86,28 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
86 |
*
|
87 |
* @var array
|
88 |
*/
|
89 |
-
protected $_children
|
90 |
|
91 |
/**
|
92 |
* Sorted children list
|
93 |
*
|
94 |
* @var array
|
95 |
*/
|
96 |
-
protected $_sortedChildren
|
97 |
|
98 |
/**
|
99 |
* Children blocks HTML cache array
|
100 |
*
|
101 |
* @var array
|
102 |
*/
|
103 |
-
protected $_childrenHtmlCache
|
104 |
|
105 |
/**
|
106 |
* Arbitrary groups of child blocks
|
107 |
*
|
108 |
* @var array
|
109 |
*/
|
110 |
-
protected $_childGroups
|
111 |
|
112 |
/**
|
113 |
* Request object
|
@@ -121,14 +121,14 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
121 |
*
|
122 |
* @var Mage_Core_Block_Messages
|
123 |
*/
|
124 |
-
protected $_messagesBlock
|
125 |
|
126 |
/**
|
127 |
* Whether this block was not explicitly named
|
128 |
*
|
129 |
* @var boolean
|
130 |
*/
|
131 |
-
protected $_isAnonymous
|
132 |
|
133 |
/**
|
134 |
* Parent block
|
@@ -175,6 +175,13 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
175 |
*/
|
176 |
protected $_factory;
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
/**
|
179 |
* Initialize factory instance
|
180 |
*
|
@@ -182,7 +189,12 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
182 |
*/
|
183 |
public function __construct(array $args = array())
|
184 |
{
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
186 |
parent::__construct($args);
|
187 |
}
|
188 |
|
@@ -199,6 +211,26 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
199 |
*/
|
200 |
}
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
/**
|
203 |
* Retrieve request object
|
204 |
*
|
@@ -207,7 +239,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
207 |
*/
|
208 |
public function getRequest()
|
209 |
{
|
210 |
-
$controller =
|
211 |
if ($controller) {
|
212 |
$this->_request = $controller->getRequest();
|
213 |
} else {
|
@@ -245,7 +277,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
245 |
*/
|
246 |
public function getAction()
|
247 |
{
|
248 |
-
return
|
249 |
}
|
250 |
|
251 |
/**
|
@@ -478,10 +510,10 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
478 |
{
|
479 |
$child = $this->getChild($alias);
|
480 |
if ($child) {
|
481 |
-
$args
|
482 |
-
$alias
|
483 |
$callback = array_shift($args);
|
484 |
-
$result
|
485 |
if (!is_array($params)) {
|
486 |
$params = $args;
|
487 |
}
|
@@ -500,7 +532,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
500 |
*/
|
501 |
public function unsetChildren()
|
502 |
{
|
503 |
-
$this->_children
|
504 |
$this->_sortedChildren = array();
|
505 |
return $this;
|
506 |
}
|
@@ -655,7 +687,8 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
655 |
* if we don't have block - don't throw exception because
|
656 |
* block can simply removed using layout method remove
|
657 |
*/
|
658 |
-
//Mage::throwException(Mage::helper('core')
|
|
|
659 |
return $this;
|
660 |
}
|
661 |
if ($block->getIsAnonymous()) {
|
@@ -711,7 +744,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
711 |
}
|
712 |
$this->_sortInstructions[$name][2] = true;
|
713 |
|
714 |
-
$index
|
715 |
$siblingKey = array_search($siblingName, $this->_sortedChildren);
|
716 |
|
717 |
if ($index === false || $siblingKey === false) {
|
@@ -896,7 +929,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
896 |
* Check framing options
|
897 |
*/
|
898 |
if ($this->_frameOpenTag) {
|
899 |
-
$html = '<'
|
900 |
}
|
901 |
|
902 |
/**
|
@@ -907,7 +940,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
907 |
}
|
908 |
self::$_transportObject->setHtml($html);
|
909 |
Mage::dispatchEvent('core_block_abstract_to_html_after',
|
910 |
-
|
911 |
$html = self::$_transportObject->getHtml();
|
912 |
|
913 |
return $html;
|
@@ -1060,7 +1093,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1060 |
* @param bool $showTime
|
1061 |
* @return string
|
1062 |
*/
|
1063 |
-
public function formatDate($date = null, $format =
|
1064 |
{
|
1065 |
return $this->helper('core')->formatDate($date, $format, $showTime);
|
1066 |
}
|
@@ -1073,7 +1106,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1073 |
* @param bool $showDate
|
1074 |
* @return string
|
1075 |
*/
|
1076 |
-
public function formatTime($time = null, $format =
|
1077 |
{
|
1078 |
return $this->helper('core')->formatTime($time, $format, $showDate);
|
1079 |
}
|
@@ -1104,7 +1137,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1104 |
$args = func_get_args();
|
1105 |
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getModuleName());
|
1106 |
array_unshift($args, $expr);
|
1107 |
-
return
|
1108 |
}
|
1109 |
|
1110 |
/**
|
@@ -1212,8 +1245,8 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1212 |
*/
|
1213 |
protected function _beforeCacheUrl()
|
1214 |
{
|
1215 |
-
if (
|
1216 |
-
|
1217 |
}
|
1218 |
return $this;
|
1219 |
}
|
@@ -1226,8 +1259,8 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1226 |
*/
|
1227 |
protected function _afterCacheUrl($html)
|
1228 |
{
|
1229 |
-
if (
|
1230 |
-
|
1231 |
Varien_Profiler::start('CACHE_URL');
|
1232 |
$html = Mage::getSingleton($this->_getUrlModelClass())->sessionUrlVar($html);
|
1233 |
Varien_Profiler::stop('CACHE_URL');
|
@@ -1264,7 +1297,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1264 |
*/
|
1265 |
$key = $this->getCacheKeyInfo();
|
1266 |
//ksort($key); // ignore order
|
1267 |
-
$key = array_values($key);
|
1268 |
$key = implode('|', $key);
|
1269 |
$key = sha1($key);
|
1270 |
return $key;
|
@@ -1277,7 +1310,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1277 |
*/
|
1278 |
public function getCacheTags()
|
1279 |
{
|
1280 |
-
$tagsCache =
|
1281 |
if ($tagsCache) {
|
1282 |
$tags = json_decode($tagsCache);
|
1283 |
}
|
@@ -1341,13 +1374,13 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1341 |
*/
|
1342 |
protected function _loadCache()
|
1343 |
{
|
1344 |
-
if (is_null($this->getCacheLifetime()) ||
|
1345 |
return false;
|
1346 |
}
|
1347 |
$cacheKey = $this->getCacheKey();
|
1348 |
/** @var $session Mage_Core_Model_Session */
|
1349 |
$session = Mage::getSingleton('core/session');
|
1350 |
-
$cacheData =
|
1351 |
if ($cacheData) {
|
1352 |
$cacheData = str_replace(
|
1353 |
$this->_getSidPlaceholder($cacheKey),
|
@@ -1366,7 +1399,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1366 |
*/
|
1367 |
protected function _saveCache($data)
|
1368 |
{
|
1369 |
-
if (is_null($this->getCacheLifetime()) ||
|
1370 |
return false;
|
1371 |
}
|
1372 |
$cacheKey = $this->getCacheKey();
|
@@ -1380,8 +1413,8 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1380 |
|
1381 |
$tags = $this->getCacheTags();
|
1382 |
|
1383 |
-
|
1384 |
-
|
1385 |
json_encode($tags),
|
1386 |
$this->_getTagsCacheKey($cacheKey),
|
1387 |
$tags,
|
@@ -1429,7 +1462,7 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object
|
|
1429 |
{
|
1430 |
$tags = array();
|
1431 |
/** @var $item Mage_Core_Model_Abstract */
|
1432 |
-
foreach($items as $item) {
|
1433 |
$itemTags = $item->getCacheIdTags();
|
1434 |
if (false === $itemTags) {
|
1435 |
continue;
|
86 |
*
|
87 |
* @var array
|
88 |
*/
|
89 |
+
protected $_children = array();
|
90 |
|
91 |
/**
|
92 |
* Sorted children list
|
93 |
*
|
94 |
* @var array
|
95 |
*/
|
96 |
+
protected $_sortedChildren = array();
|
97 |
|
98 |
/**
|
99 |
* Children blocks HTML cache array
|
100 |
*
|
101 |
* @var array
|
102 |
*/
|
103 |
+
protected $_childrenHtmlCache = array();
|
104 |
|
105 |
/**
|
106 |
* Arbitrary groups of child blocks
|
107 |
*
|
108 |
* @var array
|
109 |
*/
|
110 |
+
protected $_childGroups = array();
|
111 |
|
112 |
/**
|
113 |
* Request object
|
121 |
*
|
122 |
* @var Mage_Core_Block_Messages
|
123 |
*/
|
124 |
+
protected $_messagesBlock = null;
|
125 |
|
126 |
/**
|
127 |
* Whether this block was not explicitly named
|
128 |
*
|
129 |
* @var boolean
|
130 |
*/
|
131 |
+
protected $_isAnonymous = false;
|
132 |
|
133 |
/**
|
134 |
* Parent block
|
175 |
*/
|
176 |
protected $_factory;
|
177 |
|
178 |
+
/**
|
179 |
+
* Application instance
|
180 |
+
*
|
181 |
+
* @var Mage_Core_Model_App
|
182 |
+
*/
|
183 |
+
protected $_app;
|
184 |
+
|
185 |
/**
|
186 |
* Initialize factory instance
|
187 |
*
|
189 |
*/
|
190 |
public function __construct(array $args = array())
|
191 |
{
|
192 |
+
if (!empty($args['core_factory']) && ($args['core_factory'] instanceof Mage_Core_Model_Factory)) {
|
193 |
+
$this->_factory = $args['core_factory'];
|
194 |
+
}
|
195 |
+
if (!empty($args['app']) && ($args['app'] instanceof Mage_Core_Model_App)) {
|
196 |
+
$this->_app = $args['app'];
|
197 |
+
}
|
198 |
parent::__construct($args);
|
199 |
}
|
200 |
|
211 |
*/
|
212 |
}
|
213 |
|
214 |
+
/**
|
215 |
+
* Retrieve factory instance
|
216 |
+
*
|
217 |
+
* @return Mage_Core_Model_Factory
|
218 |
+
*/
|
219 |
+
protected function _getFactory()
|
220 |
+
{
|
221 |
+
return is_null($this->_factory) ? Mage::getSingleton('core/factory') : $this->_factory;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Retrieve application instance
|
226 |
+
*
|
227 |
+
* @return Mage_Core_Model_App
|
228 |
+
*/
|
229 |
+
protected function _getApp()
|
230 |
+
{
|
231 |
+
return is_null($this->_app) ? Mage::app() : $this->_app;
|
232 |
+
}
|
233 |
+
|
234 |
/**
|
235 |
* Retrieve request object
|
236 |
*
|
239 |
*/
|
240 |
public function getRequest()
|
241 |
{
|
242 |
+
$controller = $this->_getApp()->getFrontController();
|
243 |
if ($controller) {
|
244 |
$this->_request = $controller->getRequest();
|
245 |
} else {
|
277 |
*/
|
278 |
public function getAction()
|
279 |
{
|
280 |
+
return $this->_getApp()->getFrontController()->getAction();
|
281 |
}
|
282 |
|
283 |
/**
|
510 |
{
|
511 |
$child = $this->getChild($alias);
|
512 |
if ($child) {
|
513 |
+
$args = func_get_args();
|
514 |
+
$alias = array_shift($args);
|
515 |
$callback = array_shift($args);
|
516 |
+
$result = (string)array_shift($args);
|
517 |
if (!is_array($params)) {
|
518 |
$params = $args;
|
519 |
}
|
532 |
*/
|
533 |
public function unsetChildren()
|
534 |
{
|
535 |
+
$this->_children = array();
|
536 |
$this->_sortedChildren = array();
|
537 |
return $this;
|
538 |
}
|
687 |
* if we don't have block - don't throw exception because
|
688 |
* block can simply removed using layout method remove
|
689 |
*/
|
690 |
+
//Mage::throwException(Mage::helper('core')
|
691 |
+
// ->__('Invalid block name to set child %s: %s', $alias, $block));
|
692 |
return $this;
|
693 |
}
|
694 |
if ($block->getIsAnonymous()) {
|
744 |
}
|
745 |
$this->_sortInstructions[$name][2] = true;
|
746 |
|
747 |
+
$index = array_search($name, $this->_sortedChildren);
|
748 |
$siblingKey = array_search($siblingName, $this->_sortedChildren);
|
749 |
|
750 |
if ($index === false || $siblingKey === false) {
|
929 |
* Check framing options
|
930 |
*/
|
931 |
if ($this->_frameOpenTag) {
|
932 |
+
$html = '<' . $this->_frameOpenTag . '>' . $html . '<' . $this->_frameCloseTag . '>';
|
933 |
}
|
934 |
|
935 |
/**
|
940 |
}
|
941 |
self::$_transportObject->setHtml($html);
|
942 |
Mage::dispatchEvent('core_block_abstract_to_html_after',
|
943 |
+
array('block' => $this, 'transport' => self::$_transportObject));
|
944 |
$html = self::$_transportObject->getHtml();
|
945 |
|
946 |
return $html;
|
1093 |
* @param bool $showTime
|
1094 |
* @return string
|
1095 |
*/
|
1096 |
+
public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false)
|
1097 |
{
|
1098 |
return $this->helper('core')->formatDate($date, $format, $showTime);
|
1099 |
}
|
1106 |
* @param bool $showDate
|
1107 |
* @return string
|
1108 |
*/
|
1109 |
+
public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showDate = false)
|
1110 |
{
|
1111 |
return $this->helper('core')->formatTime($time, $format, $showDate);
|
1112 |
}
|
1137 |
$args = func_get_args();
|
1138 |
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getModuleName());
|
1139 |
array_unshift($args, $expr);
|
1140 |
+
return $this->_getApp()->getTranslator()->translate($args);
|
1141 |
}
|
1142 |
|
1143 |
/**
|
1245 |
*/
|
1246 |
protected function _beforeCacheUrl()
|
1247 |
{
|
1248 |
+
if ($this->_getApp()->useCache(self::CACHE_GROUP)) {
|
1249 |
+
$this->_getApp()->setUseSessionVar(true);
|
1250 |
}
|
1251 |
return $this;
|
1252 |
}
|
1259 |
*/
|
1260 |
protected function _afterCacheUrl($html)
|
1261 |
{
|
1262 |
+
if ($this->_getApp()->useCache(self::CACHE_GROUP)) {
|
1263 |
+
$this->_getApp()->setUseSessionVar(false);
|
1264 |
Varien_Profiler::start('CACHE_URL');
|
1265 |
$html = Mage::getSingleton($this->_getUrlModelClass())->sessionUrlVar($html);
|
1266 |
Varien_Profiler::stop('CACHE_URL');
|
1297 |
*/
|
1298 |
$key = $this->getCacheKeyInfo();
|
1299 |
//ksort($key); // ignore order
|
1300 |
+
$key = array_values($key); // ignore array keys
|
1301 |
$key = implode('|', $key);
|
1302 |
$key = sha1($key);
|
1303 |
return $key;
|
1310 |
*/
|
1311 |
public function getCacheTags()
|
1312 |
{
|
1313 |
+
$tagsCache = $this->_getApp()->loadCache($this->_getTagsCacheKey());
|
1314 |
if ($tagsCache) {
|
1315 |
$tags = json_decode($tagsCache);
|
1316 |
}
|
1374 |
*/
|
1375 |
protected function _loadCache()
|
1376 |
{
|
1377 |
+
if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
|
1378 |
return false;
|
1379 |
}
|
1380 |
$cacheKey = $this->getCacheKey();
|
1381 |
/** @var $session Mage_Core_Model_Session */
|
1382 |
$session = Mage::getSingleton('core/session');
|
1383 |
+
$cacheData = $this->_getApp()->loadCache($cacheKey);
|
1384 |
if ($cacheData) {
|
1385 |
$cacheData = str_replace(
|
1386 |
$this->_getSidPlaceholder($cacheKey),
|
1399 |
*/
|
1400 |
protected function _saveCache($data)
|
1401 |
{
|
1402 |
+
if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
|
1403 |
return false;
|
1404 |
}
|
1405 |
$cacheKey = $this->getCacheKey();
|
1413 |
|
1414 |
$tags = $this->getCacheTags();
|
1415 |
|
1416 |
+
$this->_getApp()->saveCache($data, $cacheKey, $tags, $this->getCacheLifetime());
|
1417 |
+
$this->_getApp()->saveCache(
|
1418 |
json_encode($tags),
|
1419 |
$this->_getTagsCacheKey($cacheKey),
|
1420 |
$tags,
|
1462 |
{
|
1463 |
$tags = array();
|
1464 |
/** @var $item Mage_Core_Model_Abstract */
|
1465 |
+
foreach ($items as $item) {
|
1466 |
$itemTags = $item->getCacheIdTags();
|
1467 |
if (false === $itemTags) {
|
1468 |
continue;
|
app/code/core/Mage/Core/Helper/Cookie.php
CHANGED
@@ -48,6 +48,11 @@ class Mage_Core_Helper_Cookie extends Mage_Core_Helper_Abstract
|
|
48 |
*/
|
49 |
const XML_PATH_COOKIE_RESTRICTION_LIFETIME = 'web/cookie/cookie_restriction_lifetime';
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* Store instance
|
53 |
*
|
@@ -142,4 +147,14 @@ class Mage_Core_Helper_Cookie extends Mage_Core_Helper_Abstract
|
|
142 |
{
|
143 |
return (int)$this->_currentStore->getConfig(self::XML_PATH_COOKIE_RESTRICTION_LIFETIME);
|
144 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
48 |
*/
|
49 |
const XML_PATH_COOKIE_RESTRICTION_LIFETIME = 'web/cookie/cookie_restriction_lifetime';
|
50 |
|
51 |
+
/**
|
52 |
+
* Cookie restriction notice cms block identifier
|
53 |
+
*/
|
54 |
+
const COOKIE_RESTRICTION_NOTICE_CMS_BLOCK_IDENTIFIER = 'cookie_restriction_notice_block';
|
55 |
+
|
56 |
/**
|
57 |
* Store instance
|
58 |
*
|
147 |
{
|
148 |
return (int)$this->_currentStore->getConfig(self::XML_PATH_COOKIE_RESTRICTION_LIFETIME);
|
149 |
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Get cookie restriction notice cms block identifier
|
153 |
+
*
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
public function getCookieRestrictionNoticeCmsBlockIdentifier()
|
157 |
+
{
|
158 |
+
return self::COOKIE_RESTRICTION_NOTICE_CMS_BLOCK_IDENTIFIER;
|
159 |
+
}
|
160 |
}
|
app/code/core/Mage/Core/Model/Design/Package.php
CHANGED
@@ -819,6 +819,9 @@ class Mage_Core_Model_Design_Package
|
|
819 |
$pathParts = explode(DS, $uri);
|
820 |
$fileDirParts = explode(DS, $this->_callbackFileDir);
|
821 |
$store = $this->getStore();
|
|
|
|
|
|
|
822 |
if ($store->isAdmin()) {
|
823 |
$secure = $store->isAdminUrlSecure();
|
824 |
} else {
|
819 |
$pathParts = explode(DS, $uri);
|
820 |
$fileDirParts = explode(DS, $this->_callbackFileDir);
|
821 |
$store = $this->getStore();
|
822 |
+
if (is_int($store)) {
|
823 |
+
$store = Mage::app()->getStore($store);
|
824 |
+
}
|
825 |
if ($store->isAdmin()) {
|
826 |
$secure = $store->isAdminUrlSecure();
|
827 |
} else {
|
app/code/core/Mage/Core/Model/Locale.php
CHANGED
@@ -411,13 +411,14 @@ class Mage_Core_Model_Locale
|
|
411 |
|
412 |
/**
|
413 |
* Retrieve ISO date format
|
|
|
414 |
*
|
415 |
* @param string $type
|
416 |
* @return string
|
417 |
*/
|
418 |
public function getDateFormat($type=null)
|
419 |
{
|
420 |
-
return $this->getTranslation($type, 'date');
|
421 |
}
|
422 |
|
423 |
/**
|
@@ -431,7 +432,6 @@ class Mage_Core_Model_Locale
|
|
431 |
$this->getTranslation(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, 'date'));
|
432 |
}
|
433 |
|
434 |
-
|
435 |
/**
|
436 |
* Retrieve ISO time format
|
437 |
*
|
@@ -576,7 +576,15 @@ class Mage_Core_Model_Locale
|
|
576 |
try {
|
577 |
$currencyObject = new Zend_Currency($currency, $this->getLocale());
|
578 |
} catch (Exception $e) {
|
579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
$options['name'] = $currency;
|
581 |
$options['currency'] = $currency;
|
582 |
$options['symbol'] = $currency;
|
@@ -753,7 +761,18 @@ class Mage_Core_Model_Locale
|
|
753 |
return $this->getLocale()->getTranslation($value, $path, $this->getLocale());
|
754 |
}
|
755 |
|
756 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
* Returns the localized country name
|
758 |
*
|
759 |
* @param string $value Name to get detailed information about
|
411 |
|
412 |
/**
|
413 |
* Retrieve ISO date format
|
414 |
+
* and filter for 2 digit year format, it must be 4 digits
|
415 |
*
|
416 |
* @param string $type
|
417 |
* @return string
|
418 |
*/
|
419 |
public function getDateFormat($type=null)
|
420 |
{
|
421 |
+
return preg_replace('/(?<!y)yy(?!y)/', 'yyyy', $this->getTranslation($type, 'date'));
|
422 |
}
|
423 |
|
424 |
/**
|
432 |
$this->getTranslation(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, 'date'));
|
433 |
}
|
434 |
|
|
|
435 |
/**
|
436 |
* Retrieve ISO time format
|
437 |
*
|
576 |
try {
|
577 |
$currencyObject = new Zend_Currency($currency, $this->getLocale());
|
578 |
} catch (Exception $e) {
|
579 |
+
/**
|
580 |
+
* catch specific exceptions like "Currency 'USD' not found"
|
581 |
+
* - back end falls with specific locals as Malaysia and etc.
|
582 |
+
*
|
583 |
+
* as we can see from Zend framework ticket
|
584 |
+
* http://framework.zend.com/issues/browse/ZF-10038
|
585 |
+
* zend team is not going to change it behaviour in the near time
|
586 |
+
*/
|
587 |
+
$currencyObject = new Zend_Currency($currency);
|
588 |
$options['name'] = $currency;
|
589 |
$options['currency'] = $currency;
|
590 |
$options['symbol'] = $currency;
|
761 |
return $this->getLocale()->getTranslation($value, $path, $this->getLocale());
|
762 |
}
|
763 |
|
764 |
+
/**
|
765 |
+
* Replace all yy date format to yyyy
|
766 |
+
*
|
767 |
+
* @param $currentFormat
|
768 |
+
* @return mixed
|
769 |
+
*/
|
770 |
+
protected function _convertYearTwoDigitTo4($currentFormat)
|
771 |
+
{
|
772 |
+
return preg_replace('/(\byy\b)/', 'yyyy', $currentFormat);
|
773 |
+
}
|
774 |
+
|
775 |
+
/**
|
776 |
* Returns the localized country name
|
777 |
*
|
778 |
* @param string $value Name to get detailed information about
|
app/code/core/Mage/Core/Model/Resource/Design.php
CHANGED
@@ -52,27 +52,22 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
52 |
*/
|
53 |
public function _beforeSave(Mage_Core_Model_Abstract $object)
|
54 |
{
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
$
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
}
|
66 |
-
|
67 |
-
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo())
|
68 |
-
&& Varien_Date::toTimestamp($object->getDateFrom()) > Varien_Date::toTimestamp($object->getDateTo())) {
|
69 |
-
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
|
70 |
}
|
71 |
|
72 |
$check = $this->_checkIntersection(
|
73 |
$object->getStoreId(),
|
74 |
-
$
|
75 |
-
$
|
76 |
$object->getId()
|
77 |
);
|
78 |
|
@@ -81,11 +76,6 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
81 |
Mage::helper('core')->__('Your design change for the specified store intersects with another one, please specify another date range.'));
|
82 |
}
|
83 |
|
84 |
-
if ($object->getDateFrom() === null)
|
85 |
-
$object->setDateFrom(new Zend_Db_Expr('null'));
|
86 |
-
if ($object->getDateTo() === null)
|
87 |
-
$object->setDateTo(new Zend_Db_Expr('null'));
|
88 |
-
|
89 |
parent::_beforeSave($object);
|
90 |
}
|
91 |
|
@@ -109,7 +99,7 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
109 |
|
110 |
$dateConditions = array('date_to IS NULL AND date_from IS NULL');
|
111 |
|
112 |
-
if (!
|
113 |
$dateConditions[] = ':date_from BETWEEN date_from AND date_to';
|
114 |
$dateConditions[] = ':date_from >= date_from and date_to IS NULL';
|
115 |
$dateConditions[] = ':date_from <= date_to and date_from IS NULL';
|
@@ -117,7 +107,7 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
117 |
$dateConditions[] = 'date_from IS NULL';
|
118 |
}
|
119 |
|
120 |
-
if (!
|
121 |
$dateConditions[] = ':date_to BETWEEN date_from AND date_to';
|
122 |
$dateConditions[] = ':date_to >= date_from AND date_to IS NULL';
|
123 |
$dateConditions[] = ':date_to <= date_to AND date_from IS NULL';
|
@@ -125,18 +115,18 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
125 |
$dateConditions[] = 'date_to IS NULL';
|
126 |
}
|
127 |
|
128 |
-
if (
|
129 |
$dateConditions[] = 'date_to <= :date_to OR date_from <= :date_to';
|
130 |
}
|
131 |
|
132 |
-
if (!
|
133 |
$dateConditions[] = 'date_to >= :date_from OR date_from >= :date_from';
|
134 |
}
|
135 |
|
136 |
-
if (!
|
137 |
$dateConditions[] = 'date_from BETWEEN :date_from AND :date_to';
|
138 |
$dateConditions[] = 'date_to BETWEEN :date_from AND :date_to';
|
139 |
-
} elseif (
|
140 |
$dateConditions = array();
|
141 |
}
|
142 |
|
@@ -151,10 +141,10 @@ class Mage_Core_Model_Resource_Design extends Mage_Core_Model_Resource_Db_Abstra
|
|
151 |
'current_id' => (int)$currentId,
|
152 |
);
|
153 |
|
154 |
-
if (!
|
155 |
$bind['date_to'] = $dateTo;
|
156 |
}
|
157 |
-
if (!
|
158 |
$bind['date_from'] = $dateFrom;
|
159 |
}
|
160 |
|
52 |
*/
|
53 |
public function _beforeSave(Mage_Core_Model_Abstract $object)
|
54 |
{
|
55 |
+
$dateFrom = $object->getDateFrom();
|
56 |
+
$dateTo = $object->getDateTo();
|
57 |
+
if (!empty($dateFrom) && !empty($dateTo)) {
|
58 |
+
$validator = new Zend_Validate_Date();
|
59 |
+
if (!$validator->isValid($dateFrom) || !$validator->isValid($dateTo)) {
|
60 |
+
Mage::throwException(Mage::helper('core')->__('Invalid date'));
|
61 |
+
}
|
62 |
+
if (Varien_Date::toTimestamp($dateFrom) > Varien_Date::toTimestamp($dateTo)) {
|
63 |
+
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
|
64 |
+
}
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
$check = $this->_checkIntersection(
|
68 |
$object->getStoreId(),
|
69 |
+
$dateFrom,
|
70 |
+
$dateTo,
|
71 |
$object->getId()
|
72 |
);
|
73 |
|
76 |
Mage::helper('core')->__('Your design change for the specified store intersects with another one, please specify another date range.'));
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
79 |
parent::_beforeSave($object);
|
80 |
}
|
81 |
|
99 |
|
100 |
$dateConditions = array('date_to IS NULL AND date_from IS NULL');
|
101 |
|
102 |
+
if (!empty($dateFrom)) {
|
103 |
$dateConditions[] = ':date_from BETWEEN date_from AND date_to';
|
104 |
$dateConditions[] = ':date_from >= date_from and date_to IS NULL';
|
105 |
$dateConditions[] = ':date_from <= date_to and date_from IS NULL';
|
107 |
$dateConditions[] = 'date_from IS NULL';
|
108 |
}
|
109 |
|
110 |
+
if (!empty($dateTo)) {
|
111 |
$dateConditions[] = ':date_to BETWEEN date_from AND date_to';
|
112 |
$dateConditions[] = ':date_to >= date_from AND date_to IS NULL';
|
113 |
$dateConditions[] = ':date_to <= date_to AND date_from IS NULL';
|
115 |
$dateConditions[] = 'date_to IS NULL';
|
116 |
}
|
117 |
|
118 |
+
if (empty($dateFrom) && !empty($dateTo)) {
|
119 |
$dateConditions[] = 'date_to <= :date_to OR date_from <= :date_to';
|
120 |
}
|
121 |
|
122 |
+
if (!empty($dateFrom) && empty($dateTo)) {
|
123 |
$dateConditions[] = 'date_to >= :date_from OR date_from >= :date_from';
|
124 |
}
|
125 |
|
126 |
+
if (!empty($dateFrom) && !empty($dateTo)) {
|
127 |
$dateConditions[] = 'date_from BETWEEN :date_from AND :date_to';
|
128 |
$dateConditions[] = 'date_to BETWEEN :date_from AND :date_to';
|
129 |
+
} elseif (empty($dateFrom) && empty($dateTo)) {
|
130 |
$dateConditions = array();
|
131 |
}
|
132 |
|
141 |
'current_id' => (int)$currentId,
|
142 |
);
|
143 |
|
144 |
+
if (!empty($dateTo)) {
|
145 |
$bind['date_to'] = $dateTo;
|
146 |
}
|
147 |
+
if (!empty($dateFrom)) {
|
148 |
$bind['date_from'] = $dateFrom;
|
149 |
}
|
150 |
|
app/code/core/Mage/Core/Model/Store.php
CHANGED
@@ -52,38 +52,92 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract
|
|
52 |
* Configuration pathes
|
53 |
*/
|
54 |
const XML_PATH_STORE_STORE_NAME = 'general/store_information/name';
|
|
|
|
|
|
|
55 |
const XML_PATH_STORE_STORE_PHONE = 'general/store_information/phone';
|
|
|
|
|
|
|
56 |
const XML_PATH_STORE_IN_URL = 'web/url/use_store';
|
|
|
|
|
|
|
57 |
const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites';
|
|
|
|
|
|
|
58 |
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
|
|
|
|
|
|
|
59 |
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
|
|
|
|
|
|
|
60 |
const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
|
|
|
|
|
|
|
61 |
const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml';
|
|
|
|
|
|
|
62 |
const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
|
|
|
|
|
|
|
63 |
const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
|
|
|
|
|
|
|
64 |
const XML_PATH_OFFLOADER_HEADER = 'web/secure/offloader_header';
|
|
|
|
|
|
|
65 |
const XML_PATH_PRICE_SCOPE = 'catalog/price/scope';
|
66 |
|
67 |
/**
|
68 |
* Price scope constants
|
69 |
*/
|
70 |
const PRICE_SCOPE_GLOBAL = 0;
|
|
|
|
|
|
|
71 |
const PRICE_SCOPE_WEBSITE = 1;
|
72 |
|
73 |
/**
|
74 |
* Possible URL types
|
75 |
*/
|
76 |
const URL_TYPE_LINK = 'link';
|
|
|
|
|
|
|
77 |
const URL_TYPE_DIRECT_LINK = 'direct_link';
|
|
|
|
|
|
|
78 |
const URL_TYPE_WEB = 'web';
|
|
|
|
|
|
|
79 |
const URL_TYPE_SKIN = 'skin';
|
|
|
|
|
|
|
80 |
const URL_TYPE_JS = 'js';
|
|
|
|
|
|
|
81 |
const URL_TYPE_MEDIA = 'media';
|
82 |
|
83 |
/**
|
84 |
* Code constants
|
85 |
*/
|
86 |
const DEFAULT_CODE = 'default';
|
|
|
|
|
|
|
87 |
const ADMIN_CODE = 'admin';
|
88 |
|
89 |
/**
|
@@ -259,7 +313,7 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract
|
|
259 |
* @param string $field
|
260 |
* @return Mage_Core_Model_Store
|
261 |
*/
|
262 |
-
public function load($id, $field=null)
|
263 |
{
|
264 |
if (!is_numeric($id) && is_null($field)) {
|
265 |
$this->_getResource()->load($this, $id, 'code');
|
@@ -964,13 +1018,11 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract
|
|
964 |
$this->_priceFilter = $this->getCurrentCurrency()->getFilter();
|
965 |
$this->_priceFilter->setRate($this->getBaseCurrency()->getRate($this->getCurrentCurrency()));
|
966 |
}
|
967 |
-
elseif($this->getDefaultCurrency()) {
|
968 |
$this->_priceFilter = $this->getDefaultCurrency()->getFilter();
|
969 |
-
}
|
970 |
-
else {
|
971 |
$this->_priceFilter = new Varien_Filter_Sprintf('%s', 2);
|
972 |
}
|
973 |
-
}
|
974 |
return $this->_priceFilter;
|
975 |
}
|
976 |
|
52 |
* Configuration pathes
|
53 |
*/
|
54 |
const XML_PATH_STORE_STORE_NAME = 'general/store_information/name';
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
*/
|
58 |
const XML_PATH_STORE_STORE_PHONE = 'general/store_information/phone';
|
59 |
+
/**
|
60 |
+
*
|
61 |
+
*/
|
62 |
const XML_PATH_STORE_IN_URL = 'web/url/use_store';
|
63 |
+
/**
|
64 |
+
*
|
65 |
+
*/
|
66 |
const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites';
|
67 |
+
/**
|
68 |
+
*
|
69 |
+
*/
|
70 |
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
|
71 |
+
/**
|
72 |
+
*
|
73 |
+
*/
|
74 |
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
*/
|
78 |
const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
|
79 |
+
/**
|
80 |
+
*
|
81 |
+
*/
|
82 |
const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml';
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
*/
|
86 |
const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
|
87 |
+
/**
|
88 |
+
*
|
89 |
+
*/
|
90 |
const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
|
91 |
+
/**
|
92 |
+
*
|
93 |
+
*/
|
94 |
const XML_PATH_OFFLOADER_HEADER = 'web/secure/offloader_header';
|
95 |
+
/**
|
96 |
+
*
|
97 |
+
*/
|
98 |
const XML_PATH_PRICE_SCOPE = 'catalog/price/scope';
|
99 |
|
100 |
/**
|
101 |
* Price scope constants
|
102 |
*/
|
103 |
const PRICE_SCOPE_GLOBAL = 0;
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
*/
|
107 |
const PRICE_SCOPE_WEBSITE = 1;
|
108 |
|
109 |
/**
|
110 |
* Possible URL types
|
111 |
*/
|
112 |
const URL_TYPE_LINK = 'link';
|
113 |
+
/**
|
114 |
+
*
|
115 |
+
*/
|
116 |
const URL_TYPE_DIRECT_LINK = 'direct_link';
|
117 |
+
/**
|
118 |
+
*
|
119 |
+
*/
|
120 |
const URL_TYPE_WEB = 'web';
|
121 |
+
/**
|
122 |
+
*
|
123 |
+
*/
|
124 |
const URL_TYPE_SKIN = 'skin';
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
*/
|
128 |
const URL_TYPE_JS = 'js';
|
129 |
+
/**
|
130 |
+
*
|
131 |
+
*/
|
132 |
const URL_TYPE_MEDIA = 'media';
|
133 |
|
134 |
/**
|
135 |
* Code constants
|
136 |
*/
|
137 |
const DEFAULT_CODE = 'default';
|
138 |
+
/**
|
139 |
+
*
|
140 |
+
*/
|
141 |
const ADMIN_CODE = 'admin';
|
142 |
|
143 |
/**
|
313 |
* @param string $field
|
314 |
* @return Mage_Core_Model_Store
|
315 |
*/
|
316 |
+
public function load($id, $field = null)
|
317 |
{
|
318 |
if (!is_numeric($id) && is_null($field)) {
|
319 |
$this->_getResource()->load($this, $id, 'code');
|
1018 |
$this->_priceFilter = $this->getCurrentCurrency()->getFilter();
|
1019 |
$this->_priceFilter->setRate($this->getBaseCurrency()->getRate($this->getCurrentCurrency()));
|
1020 |
}
|
1021 |
+
} elseif ($this->getDefaultCurrency()) {
|
1022 |
$this->_priceFilter = $this->getDefaultCurrency()->getFilter();
|
1023 |
+
} else {
|
|
|
1024 |
$this->_priceFilter = new Varien_Filter_Sprintf('%s', 2);
|
1025 |
}
|
|
|
1026 |
return $this->_priceFilter;
|
1027 |
}
|
1028 |
|
app/code/core/Mage/Core/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Core>
|
31 |
-
<version>1.6.0.
|
32 |
</Mage_Core>
|
33 |
</modules>
|
34 |
<global>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Core>
|
31 |
+
<version>1.6.0.4</version>
|
32 |
</Mage_Core>
|
33 |
</modules>
|
34 |
<global>
|
app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php
CHANGED
@@ -29,7 +29,7 @@ $installer = $this;
|
|
29 |
|
30 |
$installer->startSetup();
|
31 |
|
32 |
-
$rows = $installer->_conn->fetchAll("select * from {$this->getTable('core_config_data')} where path in ('
|
33 |
|
34 |
$hlp = Mage::helper('core');
|
35 |
foreach ($rows as $r) {
|
29 |
|
30 |
$installer->startSetup();
|
31 |
|
32 |
+
$rows = $installer->_conn->fetchAll("select * from {$this->getTable('core_config_data')} where path in ('paypal/wpp/api_password', 'paypal/wpp/api_signature', 'paypal/wpp/api_username', 'paypal/wps/business_account', 'paypal/wpuk/user', 'paypal/wpuk/pwd', 'carriers/dhl/id', 'carriers/dhl/password', 'carriers/dhl/shipping_key', 'carriers/dhl/shipping_intlkey', 'carriers/fedex/account', 'carriers/ups/account_license_number', 'carriers/ups/username', 'carriers/usps/userid', 'payment/authorizenet/login', 'payment/authorizenet/trans_key', 'payment/verisign/pwd', 'payment/verisign/user')");
|
33 |
|
34 |
$hlp = Mage::helper('core');
|
35 |
foreach ($rows as $r) {
|
app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php → Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php}
RENAMED
@@ -19,17 +19,22 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
-
/* @var $installer
|
28 |
$installer = $this;
|
29 |
|
30 |
-
$installer->
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
'
|
|
|
|
|
|
|
35 |
);
|
|
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Core
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
$installer = $this;
|
29 |
|
30 |
+
$installer->startSetup();
|
31 |
+
$connection = $installer->getConnection();
|
32 |
+
|
33 |
+
$connection->delete(
|
34 |
+
$this->getTable('core_config_data'),
|
35 |
+
$connection->prepareSqlCondition('path', array(
|
36 |
+
'like' => 'google/checkout%'
|
37 |
+
))
|
38 |
);
|
39 |
+
|
40 |
+
$installer->endSetup();
|
app/code/core/Mage/Customer/Helper/Address.php
CHANGED
@@ -126,7 +126,7 @@ class Mage_Customer_Helper_Address extends Mage_Core_Helper_Abstract
|
|
126 |
if($lines <= 0) {
|
127 |
$lines = 2;
|
128 |
}
|
129 |
-
$this->_streetLines[$websiteId] = min(
|
130 |
}
|
131 |
|
132 |
return $this->_streetLines[$websiteId];
|
126 |
if($lines <= 0) {
|
127 |
$lines = 2;
|
128 |
}
|
129 |
+
$this->_streetLines[$websiteId] = min(20, $lines);
|
130 |
}
|
131 |
|
132 |
return $this->_streetLines[$websiteId];
|
app/code/core/Mage/Customer/Model/Address/Abstract.php
CHANGED
@@ -53,6 +53,13 @@ class Mage_Customer_Model_Address_Abstract extends Mage_Core_Model_Abstract
|
|
53 |
*/
|
54 |
protected $_eventObject = 'customer_address';
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
/**
|
57 |
* Directory country models
|
58 |
*
|
@@ -350,53 +357,94 @@ class Mage_Customer_Model_Address_Abstract extends Mage_Core_Model_Abstract
|
|
350 |
/**
|
351 |
* Validate address attribute values
|
352 |
*
|
353 |
-
* @return bool
|
354 |
*/
|
355 |
public function validate()
|
356 |
{
|
357 |
-
$
|
|
|
358 |
$this->implodeStreetAddress();
|
|
|
359 |
if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
|
360 |
-
$
|
361 |
}
|
362 |
|
363 |
if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
|
364 |
-
$
|
365 |
}
|
366 |
|
367 |
if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
|
368 |
-
$
|
369 |
}
|
370 |
|
371 |
if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
|
372 |
-
$
|
373 |
}
|
374 |
|
375 |
if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
|
376 |
-
$
|
377 |
}
|
378 |
|
379 |
$_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
|
380 |
if (!in_array($this->getCountryId(), $_havingOptionalZip)
|
381 |
&& !Zend_Validate::is($this->getPostcode(), 'NotEmpty')
|
382 |
) {
|
383 |
-
$
|
384 |
}
|
385 |
|
386 |
if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
|
387 |
-
$
|
388 |
}
|
389 |
|
390 |
if ($this->getCountryModel()->getRegionCollection()->getSize()
|
391 |
&& !Zend_Validate::is($this->getRegionId(), 'NotEmpty')
|
392 |
&& Mage::helper('directory')->isRegionRequired($this->getCountryId())
|
393 |
) {
|
394 |
-
$
|
395 |
}
|
396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
if (empty($errors) || $this->getShouldIgnoreValidation()) {
|
398 |
return true;
|
399 |
}
|
400 |
return $errors;
|
401 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
}
|
53 |
*/
|
54 |
protected $_eventObject = 'customer_address';
|
55 |
|
56 |
+
/**
|
57 |
+
* List of errors
|
58 |
+
*
|
59 |
+
* @var array
|
60 |
+
*/
|
61 |
+
protected $_errors = array();
|
62 |
+
|
63 |
/**
|
64 |
* Directory country models
|
65 |
*
|
357 |
/**
|
358 |
* Validate address attribute values
|
359 |
*
|
360 |
+
* @return array | bool
|
361 |
*/
|
362 |
public function validate()
|
363 |
{
|
364 |
+
$this->_resetErrors();
|
365 |
+
|
366 |
$this->implodeStreetAddress();
|
367 |
+
|
368 |
if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
|
369 |
+
$this->addError(Mage::helper('customer')->__('Please enter the first name.'));
|
370 |
}
|
371 |
|
372 |
if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
|
373 |
+
$this->addError(Mage::helper('customer')->__('Please enter the last name.'));
|
374 |
}
|
375 |
|
376 |
if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
|
377 |
+
$this->addError(Mage::helper('customer')->__('Please enter the street.'));
|
378 |
}
|
379 |
|
380 |
if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
|
381 |
+
$this->addError(Mage::helper('customer')->__('Please enter the city.'));
|
382 |
}
|
383 |
|
384 |
if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
|
385 |
+
$this->addError(Mage::helper('customer')->__('Please enter the telephone number.'));
|
386 |
}
|
387 |
|
388 |
$_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
|
389 |
if (!in_array($this->getCountryId(), $_havingOptionalZip)
|
390 |
&& !Zend_Validate::is($this->getPostcode(), 'NotEmpty')
|
391 |
) {
|
392 |
+
$this->addError(Mage::helper('customer')->__('Please enter the zip/postal code.'));
|
393 |
}
|
394 |
|
395 |
if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
|
396 |
+
$this->addError(Mage::helper('customer')->__('Please enter the country.'));
|
397 |
}
|
398 |
|
399 |
if ($this->getCountryModel()->getRegionCollection()->getSize()
|
400 |
&& !Zend_Validate::is($this->getRegionId(), 'NotEmpty')
|
401 |
&& Mage::helper('directory')->isRegionRequired($this->getCountryId())
|
402 |
) {
|
403 |
+
$this->addError(Mage::helper('customer')->__('Please enter the state/province.'));
|
404 |
}
|
405 |
|
406 |
+
Mage::dispatchEvent('customer_address_validation_after', array('address' => $this));
|
407 |
+
|
408 |
+
$errors = $this->_getErrors();
|
409 |
+
|
410 |
+
$this->_resetErrors();
|
411 |
+
|
412 |
if (empty($errors) || $this->getShouldIgnoreValidation()) {
|
413 |
return true;
|
414 |
}
|
415 |
return $errors;
|
416 |
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Add error
|
420 |
+
*
|
421 |
+
* @param $error
|
422 |
+
* @return Mage_Customer_Model_Address_Abstract
|
423 |
+
*/
|
424 |
+
public function addError($error)
|
425 |
+
{
|
426 |
+
$this->_errors[] = $error;
|
427 |
+
return $this;
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Retreive errors
|
432 |
+
*
|
433 |
+
* @return array
|
434 |
+
*/
|
435 |
+
protected function _getErrors()
|
436 |
+
{
|
437 |
+
return $this->_errors;
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Reset errors array
|
442 |
+
*
|
443 |
+
* @return Mage_Customer_Model_Address_Abstract
|
444 |
+
*/
|
445 |
+
protected function _resetErrors()
|
446 |
+
{
|
447 |
+
$this->_errors = array();
|
448 |
+
return $this;
|
449 |
+
}
|
450 |
}
|
app/code/core/Mage/Customer/controllers/AccountController.php
CHANGED
@@ -136,6 +136,11 @@ class Mage_Customer_AccountController extends Mage_Core_Controller_Front_Action
|
|
136 |
*/
|
137 |
public function loginPostAction()
|
138 |
{
|
|
|
|
|
|
|
|
|
|
|
139 |
if ($this->_getSession()->isLoggedIn()) {
|
140 |
$this->_redirect('*/*/');
|
141 |
return;
|
@@ -559,8 +564,7 @@ class Mage_Customer_AccountController extends Mage_Core_Controller_Front_Action
|
|
559 |
{
|
560 |
$session = $this->_getSession();
|
561 |
if ($session->isLoggedIn()) {
|
562 |
-
$this->
|
563 |
-
return;
|
564 |
}
|
565 |
try {
|
566 |
$id = $this->getRequest()->getParam('id', false);
|
136 |
*/
|
137 |
public function loginPostAction()
|
138 |
{
|
139 |
+
if (!$this->_validateFormKey()) {
|
140 |
+
$this->_redirect('*/*/');
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
if ($this->_getSession()->isLoggedIn()) {
|
145 |
$this->_redirect('*/*/');
|
146 |
return;
|
564 |
{
|
565 |
$session = $this->_getSession();
|
566 |
if ($session->isLoggedIn()) {
|
567 |
+
$this->_getSession()->logout()->regenerateSessionId();
|
|
|
568 |
}
|
569 |
try {
|
570 |
$id = $this->getRequest()->getParam('id', false);
|
app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.3-0.7.4.php → Customer/data/customer_setup/data-upgrade-1.6.2.0.2-1.6.2.0.3.php}
RENAMED
@@ -19,20 +19,23 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
|
|
27 |
$installer = $this;
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
PRIMARY KEY (`serial_number`)
|
36 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
|
37 |
);
|
38 |
|
|
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Customer
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
+
/** @var $installer Mage_Customer_Model_Entity_Setup */
|
28 |
$installer = $this;
|
29 |
+
$datetimeType = 'datetime';
|
30 |
+
// implementation new type for static date attributes
|
31 |
+
$installer->updateAttribute('customer', 'created_at', 'frontend_input', $datetimeType);
|
32 |
|
33 |
+
// implement new input filter for datetime type attribute
|
34 |
+
$attribute = $installer->getAttribute('customer', 'created_at');
|
35 |
+
|
36 |
+
$attributeBind = array(
|
37 |
+
'input_filter' => $datetimeType,
|
|
|
|
|
38 |
);
|
39 |
|
40 |
+
$attributeWhere = $installer->getConnection()->quoteInto('attribute_id=?', $attribute['attribute_id']);
|
41 |
+
$installer->getConnection()->update($installer->getTable('customer/eav_attribute'), $attributeBind, $attributeWhere);
|
app/code/core/Mage/Customer/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Customer>
|
31 |
-
<version>1.6.2.0.
|
32 |
</Mage_Customer>
|
33 |
</modules>
|
34 |
<admin>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Customer>
|
31 |
+
<version>1.6.2.0.3</version>
|
32 |
</Mage_Customer>
|
33 |
</modules>
|
34 |
<admin>
|
app/code/core/Mage/Customer/etc/wsdl.xml
CHANGED
@@ -11,10 +11,16 @@
|
|
11 |
<element name="email" type="xsd:string" minOccurs="0" />
|
12 |
<element name="firstname" type="xsd:string" minOccurs="0" />
|
13 |
<element name="lastname" type="xsd:string" minOccurs="0" />
|
|
|
14 |
<element name="password" type="xsd:string" minOccurs="0" />
|
15 |
<element name="website_id" type="xsd:int" minOccurs="0" />
|
16 |
<element name="store_id" type="xsd:int" minOccurs="0" />
|
17 |
<element name="group_id" type="xsd:int" minOccurs="0" />
|
|
|
|
|
|
|
|
|
|
|
18 |
</all>
|
19 |
</complexType>
|
20 |
<complexType name="customerCustomerEntity">
|
11 |
<element name="email" type="xsd:string" minOccurs="0" />
|
12 |
<element name="firstname" type="xsd:string" minOccurs="0" />
|
13 |
<element name="lastname" type="xsd:string" minOccurs="0" />
|
14 |
+
<element name="middlename" type="xsd:string" minOccurs="0" />
|
15 |
<element name="password" type="xsd:string" minOccurs="0" />
|
16 |
<element name="website_id" type="xsd:int" minOccurs="0" />
|
17 |
<element name="store_id" type="xsd:int" minOccurs="0" />
|
18 |
<element name="group_id" type="xsd:int" minOccurs="0" />
|
19 |
+
<element name="prefix" type="xsd:string" minOccurs="0" />
|
20 |
+
<element name="suffix" type="xsd:string" minOccurs="0" />
|
21 |
+
<element name="dob" type="xsd:string" minOccurs="0" />
|
22 |
+
<element name="taxvat" type="xsd:string" minOccurs="0" />
|
23 |
+
<element name="gender" type="xsd:int" minOccurs="0" />
|
24 |
</all>
|
25 |
</complexType>
|
26 |
<complexType name="customerCustomerEntity">
|
app/code/core/Mage/Customer/etc/wsi.xml
CHANGED
@@ -14,10 +14,16 @@
|
|
14 |
<xsd:element name="email" type="xsd:string" minOccurs="0" />
|
15 |
<xsd:element name="firstname" type="xsd:string" minOccurs="0" />
|
16 |
<xsd:element name="lastname" type="xsd:string" minOccurs="0" />
|
|
|
17 |
<xsd:element name="password" type="xsd:string" minOccurs="0" />
|
18 |
<xsd:element name="website_id" type="xsd:int" minOccurs="0" />
|
19 |
<xsd:element name="store_id" type="xsd:int" minOccurs="0" />
|
20 |
<xsd:element name="group_id" type="xsd:int" minOccurs="0" />
|
|
|
|
|
|
|
|
|
|
|
21 |
</xsd:sequence>
|
22 |
</xsd:complexType>
|
23 |
<xsd:complexType name="customerCustomerEntity">
|
14 |
<xsd:element name="email" type="xsd:string" minOccurs="0" />
|
15 |
<xsd:element name="firstname" type="xsd:string" minOccurs="0" />
|
16 |
<xsd:element name="lastname" type="xsd:string" minOccurs="0" />
|
17 |
+
<xsd:element name="middlename" type="xsd:string" minOccurs="0" />
|
18 |
<xsd:element name="password" type="xsd:string" minOccurs="0" />
|
19 |
<xsd:element name="website_id" type="xsd:int" minOccurs="0" />
|
20 |
<xsd:element name="store_id" type="xsd:int" minOccurs="0" />
|
21 |
<xsd:element name="group_id" type="xsd:int" minOccurs="0" />
|
22 |
+
<xsd:element name="prefix" type="xsd:string" minOccurs="0" />
|
23 |
+
<xsd:element name="suffix" type="xsd:string" minOccurs="0" />
|
24 |
+
<xsd:element name="dob" type="xsd:string" minOccurs="0" />
|
25 |
+
<xsd:element name="taxvat" type="xsd:string" minOccurs="0" />
|
26 |
+
<xsd:element name="gender" type="xsd:int" minOccurs="0" />
|
27 |
</xsd:sequence>
|
28 |
</xsd:complexType>
|
29 |
<xsd:complexType name="customerCustomerEntity">
|
app/code/core/Mage/Customer/sql/customer_setup/upgrade-1.6.2.0.1-1.6.2.0.2.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Customer
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var $this Mage_Catalog_Model_Resource_Setup
|
29 |
+
* @var $conn Varien_Db_Adapter_Interface
|
30 |
+
*/
|
31 |
+
$conn = $this->getConnection();
|
32 |
+
|
33 |
+
//get all duplicated emails
|
34 |
+
$select = $conn->select()
|
35 |
+
->from($this->getTable('customer/entity'), array('email', 'website_id', 'cnt' => 'COUNT(*)'))
|
36 |
+
->group('email')
|
37 |
+
->group('website_id')
|
38 |
+
->having('cnt > 1');
|
39 |
+
$emails = $conn->fetchAll($select);
|
40 |
+
|
41 |
+
foreach ($emails as $data) {
|
42 |
+
$email = $data['email'];
|
43 |
+
$websiteId = $data['website_id'];
|
44 |
+
|
45 |
+
$select = $conn->select()
|
46 |
+
->from($this->getTable('customer/entity'), array('entity_id'))
|
47 |
+
->where('email = ?', $email)
|
48 |
+
->where('website_id = ?', $websiteId);
|
49 |
+
$activeId = $conn->fetchOne($select);
|
50 |
+
|
51 |
+
//receive all other duplicated customer ids
|
52 |
+
$select = $conn->select()
|
53 |
+
->from($this->getTable('customer/entity'), array('entity_id', 'email'))
|
54 |
+
->where('email = ?', $email)
|
55 |
+
->where('website_id = ?', $websiteId)
|
56 |
+
->where('entity_id <> ?', $activeId);
|
57 |
+
$result = $conn->fetchAll($select);
|
58 |
+
|
59 |
+
//change email to unique value
|
60 |
+
foreach ($result as $row) {
|
61 |
+
$changedEmail = $conn->getConcatSql(array('"(duplicate"', $row['entity_id'], '")"', '"' . $row['email'] . '"'));
|
62 |
+
$conn->update(
|
63 |
+
$this->getTable('customer/entity'),
|
64 |
+
array('email' => $changedEmail),
|
65 |
+
array('entity_id =?' => $row['entity_id'])
|
66 |
+
);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add unique index for customer_entity table
|
72 |
+
*/
|
73 |
+
$conn->addIndex(
|
74 |
+
$this->getTable('customer/entity'),
|
75 |
+
$this->getIdxName(
|
76 |
+
'customer/entity',
|
77 |
+
array('email', 'website_id'),
|
78 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
79 |
+
),
|
80 |
+
array('email', 'website_id'),
|
81 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
82 |
+
);
|
app/code/core/Mage/Directory/Model/Currency.php
CHANGED
@@ -34,12 +34,21 @@
|
|
34 |
class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
35 |
{
|
36 |
/**
|
37 |
-
* CONFIG path
|
38 |
*/
|
39 |
const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow';
|
|
|
|
|
|
|
40 |
const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default';
|
|
|
|
|
|
|
41 |
const XML_PATH_CURRENCY_BASE = 'currency/options/base';
|
42 |
|
|
|
|
|
|
|
43 |
protected $_filter;
|
44 |
|
45 |
/**
|
@@ -50,6 +59,9 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
50 |
protected $_rates;
|
51 |
|
52 |
|
|
|
|
|
|
|
53 |
protected function _construct()
|
54 |
{
|
55 |
$this->_init('directory/currency');
|
@@ -65,6 +77,11 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
65 |
return $this->_getData('currency_code');
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
public function getCurrencyCode()
|
69 |
{
|
70 |
return $this->_getData('currency_code');
|
@@ -99,7 +116,7 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
99 |
* @param string $field
|
100 |
* @return Mage_Directory_Model_Currency
|
101 |
*/
|
102 |
-
public function load($id, $field=null)
|
103 |
{
|
104 |
$this->unsRate();
|
105 |
$this->setData('currency_code', $id);
|
@@ -109,8 +126,9 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
109 |
/**
|
110 |
* Get currency rate (only base=>allowed)
|
111 |
*
|
112 |
-
* @param
|
113 |
-
* @return
|
|
|
114 |
*/
|
115 |
public function getRate($toCurrency)
|
116 |
{
|
@@ -132,8 +150,9 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
132 |
/**
|
133 |
* Get currency rate (base=>allowed or allowed=>base)
|
134 |
*
|
135 |
-
* @param
|
136 |
-
* @return
|
|
|
137 |
*/
|
138 |
public function getAnyRate($toCurrency)
|
139 |
{
|
@@ -155,20 +174,24 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
155 |
/**
|
156 |
* Convert price to currency format
|
157 |
*
|
158 |
-
* @param
|
159 |
-
* @param
|
160 |
-
* @return
|
|
|
161 |
*/
|
162 |
-
public function convert($price, $toCurrency=null)
|
163 |
{
|
164 |
if (is_null($toCurrency)) {
|
165 |
return $price;
|
166 |
-
}
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
}
|
170 |
|
171 |
-
throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(),
|
|
|
172 |
}
|
173 |
|
174 |
/**
|
@@ -188,11 +211,13 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
188 |
/**
|
189 |
* Format price to currency format
|
190 |
*
|
191 |
-
* @param
|
192 |
-
* @param
|
193 |
-
* @
|
|
|
|
|
194 |
*/
|
195 |
-
public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
|
196 |
{
|
197 |
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
|
198 |
}
|
@@ -207,18 +232,27 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
207 |
* @param bool $addBrackets
|
208 |
* @return string
|
209 |
*/
|
210 |
-
public function formatPrecision($price, $precision, $options=array(), $includeContainer = true,
|
|
|
211 |
{
|
212 |
if (!isset($options['precision'])) {
|
213 |
$options['precision'] = $precision;
|
214 |
}
|
215 |
if ($includeContainer) {
|
216 |
-
return '<span class="price">' . ($addBrackets ? '[' : '') . $this->formatTxt($price, $options) .
|
|
|
217 |
}
|
218 |
return $this->formatTxt($price, $options);
|
219 |
}
|
220 |
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
{
|
223 |
if (!is_numeric($price)) {
|
224 |
$price = Mage::app()->getLocale()->getNumber($price);
|
@@ -230,19 +264,28 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
230 |
* %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
|
231 |
*/
|
232 |
$price = sprintf("%F", $price);
|
|
|
|
|
|
|
233 |
return Mage::app()->getLocale()->currency($this->getCode())->toCurrency($price, $options);
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
236 |
public function getOutputFormat()
|
237 |
{
|
238 |
$formated = $this->formatTxt(0);
|
239 |
-
$number = $this->formatTxt(0, array('display'=>Zend_Currency::NO_SYMBOL));
|
240 |
return str_replace($number, '%s', $formated);
|
241 |
}
|
242 |
|
243 |
/**
|
244 |
* Retrieve allowed currencies according to config
|
245 |
*
|
|
|
246 |
*/
|
247 |
public function getConfigAllowCurrencies()
|
248 |
{
|
@@ -264,6 +307,7 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
264 |
/**
|
265 |
* Retrieve default currencies according to config
|
266 |
*
|
|
|
267 |
*/
|
268 |
public function getConfigDefaultCurrencies()
|
269 |
{
|
@@ -272,6 +316,11 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
272 |
}
|
273 |
|
274 |
|
|
|
|
|
|
|
|
|
|
|
275 |
public function getConfigBaseCurrencies()
|
276 |
{
|
277 |
$defaultCurrencies = $this->_getResource()->getConfigCurrencies($this, self::XML_PATH_CURRENCY_BASE);
|
@@ -285,7 +334,7 @@ class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
|
285 |
* @param array $toCurrencies
|
286 |
* @return array
|
287 |
*/
|
288 |
-
public function getCurrencyRates($currency, $toCurrencies=null)
|
289 |
{
|
290 |
if ($currency instanceof Mage_Directory_Model_Currency) {
|
291 |
$currency = $currency->getCode();
|
34 |
class Mage_Directory_Model_Currency extends Mage_Core_Model_Abstract
|
35 |
{
|
36 |
/**
|
37 |
+
* CONFIG path constant: ALLOW
|
38 |
*/
|
39 |
const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow';
|
40 |
+
/**
|
41 |
+
* CONFIG path constant: DEFAULT
|
42 |
+
*/
|
43 |
const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default';
|
44 |
+
/**
|
45 |
+
* CONFIG path constant: BASE
|
46 |
+
*/
|
47 |
const XML_PATH_CURRENCY_BASE = 'currency/options/base';
|
48 |
|
49 |
+
/**
|
50 |
+
* @var Mage_Directory_Model_Currency_Filter - currency filter
|
51 |
+
*/
|
52 |
protected $_filter;
|
53 |
|
54 |
/**
|
59 |
protected $_rates;
|
60 |
|
61 |
|
62 |
+
/**
|
63 |
+
* Class constructor
|
64 |
+
*/
|
65 |
protected function _construct()
|
66 |
{
|
67 |
$this->_init('directory/currency');
|
77 |
return $this->_getData('currency_code');
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* Get currency code
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
public function getCurrencyCode()
|
86 |
{
|
87 |
return $this->_getData('currency_code');
|
116 |
* @param string $field
|
117 |
* @return Mage_Directory_Model_Currency
|
118 |
*/
|
119 |
+
public function load($id, $field = null)
|
120 |
{
|
121 |
$this->unsRate();
|
122 |
$this->setData('currency_code', $id);
|
126 |
/**
|
127 |
* Get currency rate (only base=>allowed)
|
128 |
*
|
129 |
+
* @param string|Mage_Directory_Model_Currency $toCurrency
|
130 |
+
* @return string
|
131 |
+
* @throws Mage_Core_Exception
|
132 |
*/
|
133 |
public function getRate($toCurrency)
|
134 |
{
|
150 |
/**
|
151 |
* Get currency rate (base=>allowed or allowed=>base)
|
152 |
*
|
153 |
+
* @param string|Mage_Directory_Model_Currency $toCurrency
|
154 |
+
* @return string
|
155 |
+
* @throws Mage_Core_Exception
|
156 |
*/
|
157 |
public function getAnyRate($toCurrency)
|
158 |
{
|
174 |
/**
|
175 |
* Convert price to currency format
|
176 |
*
|
177 |
+
* @param float $price
|
178 |
+
* @param null|string|Mage_Directory_Model_Currency $toCurrency
|
179 |
+
* @return float
|
180 |
+
* @throws Exception
|
181 |
*/
|
182 |
+
public function convert($price, $toCurrency = null)
|
183 |
{
|
184 |
if (is_null($toCurrency)) {
|
185 |
return $price;
|
186 |
+
} else {
|
187 |
+
$rate = $this->getRate($toCurrency);
|
188 |
+
if ($rate) {
|
189 |
+
return $price * $rate;
|
190 |
+
}
|
191 |
}
|
192 |
|
193 |
+
throw new Exception(Mage::helper('directory')->__('Undefined rate from "%s-%s".', $this->getCode(),
|
194 |
+
$toCurrency->getCode()));
|
195 |
}
|
196 |
|
197 |
/**
|
211 |
/**
|
212 |
* Format price to currency format
|
213 |
*
|
214 |
+
* @param float $price
|
215 |
+
* @param array $options
|
216 |
+
* @param bool $includeContainer
|
217 |
+
* @param bool $addBrackets
|
218 |
+
* @return string
|
219 |
*/
|
220 |
+
public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)
|
221 |
{
|
222 |
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
|
223 |
}
|
232 |
* @param bool $addBrackets
|
233 |
* @return string
|
234 |
*/
|
235 |
+
public function formatPrecision($price, $precision, $options = array(), $includeContainer = true,
|
236 |
+
$addBrackets = false)
|
237 |
{
|
238 |
if (!isset($options['precision'])) {
|
239 |
$options['precision'] = $precision;
|
240 |
}
|
241 |
if ($includeContainer) {
|
242 |
+
return '<span class="price">' . ($addBrackets ? '[' : '') . $this->formatTxt($price, $options) .
|
243 |
+
($addBrackets ? ']' : '') . '</span>';
|
244 |
}
|
245 |
return $this->formatTxt($price, $options);
|
246 |
}
|
247 |
|
248 |
+
/**
|
249 |
+
* Returns the formatted price
|
250 |
+
*
|
251 |
+
* @param float $price
|
252 |
+
* @param null|array $options
|
253 |
+
* @return string
|
254 |
+
*/
|
255 |
+
public function formatTxt($price, $options = array())
|
256 |
{
|
257 |
if (!is_numeric($price)) {
|
258 |
$price = Mage::app()->getLocale()->getNumber($price);
|
264 |
* %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
|
265 |
*/
|
266 |
$price = sprintf("%F", $price);
|
267 |
+
if ($price == -0) {
|
268 |
+
$price = 0;
|
269 |
+
}
|
270 |
return Mage::app()->getLocale()->currency($this->getCode())->toCurrency($price, $options);
|
271 |
}
|
272 |
|
273 |
+
/**
|
274 |
+
* Returns the formatting template for numbers
|
275 |
+
*
|
276 |
+
* @return string
|
277 |
+
*/
|
278 |
public function getOutputFormat()
|
279 |
{
|
280 |
$formated = $this->formatTxt(0);
|
281 |
+
$number = $this->formatTxt(0, array('display' => Zend_Currency::NO_SYMBOL));
|
282 |
return str_replace($number, '%s', $formated);
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
* Retrieve allowed currencies according to config
|
287 |
*
|
288 |
+
* @return array
|
289 |
*/
|
290 |
public function getConfigAllowCurrencies()
|
291 |
{
|
307 |
/**
|
308 |
* Retrieve default currencies according to config
|
309 |
*
|
310 |
+
* @return array
|
311 |
*/
|
312 |
public function getConfigDefaultCurrencies()
|
313 |
{
|
316 |
}
|
317 |
|
318 |
|
319 |
+
/**
|
320 |
+
* Retrieve base currencies according to config
|
321 |
+
*
|
322 |
+
* @return array
|
323 |
+
*/
|
324 |
public function getConfigBaseCurrencies()
|
325 |
{
|
326 |
$defaultCurrencies = $this->_getResource()->getConfigCurrencies($this, self::XML_PATH_CURRENCY_BASE);
|
334 |
* @param array $toCurrencies
|
335 |
* @return array
|
336 |
*/
|
337 |
+
public function getCurrencyRates($currency, $toCurrencies = null)
|
338 |
{
|
339 |
if ($currency instanceof Mage_Directory_Model_Currency) {
|
340 |
$currency = $currency->getCode();
|
app/code/core/Mage/Directory/Model/Resource/Region/Collection.php
CHANGED
@@ -180,7 +180,7 @@ class Mage_Directory_Model_Resource_Region_Collection extends Mage_Core_Model_Re
|
|
180 |
if (count($options) > 0) {
|
181 |
array_unshift($options, array(
|
182 |
'title '=> null,
|
183 |
-
'value' =>
|
184 |
'label' => Mage::helper('directory')->__('-- Please select --')
|
185 |
));
|
186 |
}
|
180 |
if (count($options) > 0) {
|
181 |
array_unshift($options, array(
|
182 |
'title '=> null,
|
183 |
+
'value' => "",
|
184 |
'label' => Mage::helper('directory')->__('-- Please select --')
|
185 |
));
|
186 |
}
|
app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-install-0.7.0.php → Directory/sql/directory_setup/mysql4-upgrade-1.6.0.1-1.6.0.2.php}
RENAMED
@@ -19,28 +19,41 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
|
|
27 |
$installer = $this;
|
28 |
-
/* @var $installer Mage_GoogleCheckout_Model_Mysql4_Setup */
|
29 |
-
|
30 |
$installer->startSetup();
|
31 |
|
32 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
-- drop table if exists {$this->getTable('googlecheckout_api_debug')};
|
35 |
-
CREATE TABLE {$this->getTable('googlecheckout_api_debug')} (
|
36 |
-
`debug_id` int(10) unsigned NOT NULL auto_increment,
|
37 |
-
`dir` enum('in', 'out'),
|
38 |
-
`url` varchar(255),
|
39 |
-
`request_body` text,
|
40 |
-
`response_body` text,
|
41 |
-
PRIMARY KEY (`debug_id`)
|
42 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
43 |
|
44 |
-
");
|
45 |
|
46 |
$installer->endSetup();
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Directory
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
$installer = $this;
|
|
|
|
|
29 |
$installer->startSetup();
|
30 |
|
31 |
+
/* @var $connection Varien_Db_Adapter_Pdo_Mysql */
|
32 |
+
$connection = $installer->getConnection();
|
33 |
+
|
34 |
+
$regionTable = $installer->getTable('directory/country_region');
|
35 |
+
|
36 |
+
/* Armed Forces changes based on USPS */
|
37 |
+
|
38 |
+
/* Armed Forces Middle East (AM) is now served by Armed Forces Europe (AE) */
|
39 |
+
$bind = array('code' => 'AE');
|
40 |
+
$where = array('code = ?' => 'AM');
|
41 |
+
|
42 |
+
$connection->update($regionTable, $bind, $where);
|
43 |
+
|
44 |
+
/* Armed Forces Canada (AC) is now served by Armed Forces Europe (AE) */
|
45 |
+
$bind = array('code' => 'AE');
|
46 |
+
$where = array('code = ?' => 'AC');
|
47 |
+
|
48 |
+
$connection->update($regionTable, $bind, $where);
|
49 |
+
|
50 |
+
|
51 |
+
/* Armed Forces Africa (AF) is now served by Armed Forces Europe (AE) */
|
52 |
+
$bind = array('code' => 'AE');
|
53 |
+
$where = array('code = ?' => 'AF');
|
54 |
+
|
55 |
+
$connection->update($regionTable, $bind, $where);
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
|
|
58 |
|
59 |
$installer->endSetup();
|
app/code/core/Mage/{GoogleCheckout/Model/Resource/Api/Debug.php → Eav/Model/Attribute/Data/Datetime.php}
RENAMED
@@ -19,27 +19,49 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
*
|
31 |
* @category Mage
|
32 |
-
* @package
|
33 |
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
*/
|
35 |
-
class
|
36 |
{
|
37 |
/**
|
38 |
-
*
|
39 |
*
|
|
|
40 |
*/
|
41 |
-
protected function
|
42 |
{
|
43 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
}
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Eav
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
|
28 |
/**
|
29 |
+
* EAV Entity Attribute Date time Data Model
|
30 |
*
|
31 |
* @category Mage
|
32 |
+
* @package Mage_Eav
|
33 |
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
*/
|
35 |
+
class Mage_Eav_Model_Attribute_Data_Datetime extends Mage_Eav_Model_Attribute_Data_Date
|
36 |
{
|
37 |
/**
|
38 |
+
* Return Data Form Input/Output Filter
|
39 |
*
|
40 |
+
* @return Varien_Data_Form_Filter_Interface|false
|
41 |
*/
|
42 |
+
protected function _getFormFilter()
|
43 |
{
|
44 |
+
$filterCode = $this->getAttribute()->getInputFilter();
|
45 |
+
if ($filterCode) {
|
46 |
+
$filterClass = 'Varien_Data_Form_Filter_' . ucfirst($filterCode);
|
47 |
+
if ($filterCode == 'datetime') {
|
48 |
+
$filter = new $filterClass(
|
49 |
+
$this->_getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
50 |
+
$this->_getLocale()->getLocale());
|
51 |
+
} else {
|
52 |
+
$filter = new $filterClass();
|
53 |
+
}
|
54 |
+
return $filter;
|
55 |
+
}
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get Locale
|
61 |
+
*
|
62 |
+
* @return Mage_Core_Model_Locale
|
63 |
+
*/
|
64 |
+
protected function _getLocale(){
|
65 |
+
return Mage::app()->getLocale();
|
66 |
}
|
67 |
}
|
app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php
CHANGED
@@ -35,6 +35,7 @@ class Mage_Eav_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Mode
|
|
35 |
{
|
36 |
/**
|
37 |
* Set created date
|
|
|
38 |
*
|
39 |
* @param Mage_Core_Model_Object $object
|
40 |
* @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
|
@@ -42,10 +43,36 @@ class Mage_Eav_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Mode
|
|
42 |
public function beforeSave($object)
|
43 |
{
|
44 |
$attributeCode = $this->getAttribute()->getAttributeCode();
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
return $this;
|
50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
35 |
{
|
36 |
/**
|
37 |
* Set created date
|
38 |
+
* Set created date in UTC time zone
|
39 |
*
|
40 |
* @param Mage_Core_Model_Object $object
|
41 |
* @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
|
43 |
public function beforeSave($object)
|
44 |
{
|
45 |
$attributeCode = $this->getAttribute()->getAttributeCode();
|
46 |
+
$date = $object->getData($attributeCode);
|
47 |
+
if (is_null($date)) {
|
48 |
+
if ($object->isObjectNew()) {
|
49 |
+
$object->setData($attributeCode, Varien_Date::now());
|
50 |
+
}
|
51 |
+
} else {
|
52 |
+
// convert to UTC
|
53 |
+
$zendDate = Mage::app()->getLocale()->utcDate(null, $date, true);
|
54 |
+
$object->setData($attributeCode, $zendDate->getIso());
|
55 |
}
|
56 |
|
57 |
return $this;
|
58 |
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Convert create date from UTC to current store time zone
|
62 |
+
*
|
63 |
+
* @param Varien_Object $object
|
64 |
+
* @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
|
65 |
+
*/
|
66 |
+
public function afterLoad($object)
|
67 |
+
{
|
68 |
+
$attributeCode = $this->getAttribute()->getAttributeCode();
|
69 |
+
$date = $object->getData($attributeCode);
|
70 |
+
|
71 |
+
$zendDate = Mage::app()->getLocale()->storeDate(null, $date, true);
|
72 |
+
$object->setData($attributeCode, $zendDate->getIso());
|
73 |
+
|
74 |
+
parent::afterLoad($object);
|
75 |
+
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
}
|
app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php
CHANGED
@@ -431,7 +431,7 @@ class Mage_Eav_Model_Resource_Entity_Attribute extends Mage_Core_Model_Resource_
|
|
431 |
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId)
|
432 |
{
|
433 |
$adapter = $this->_getReadAdapter();
|
434 |
-
$joinConditionTemplate = "%s.entity_id
|
435 |
." AND %s.entity_type_id = ".$attribute->getEntityTypeId()
|
436 |
." AND %s.attribute_id = ".$attribute->getId()
|
437 |
." AND %s.store_id = %d";
|
@@ -452,7 +452,7 @@ class Mage_Eav_Model_Resource_Entity_Attribute extends Mage_Core_Model_Resource_
|
|
452 |
array())
|
453 |
->joinLeft(
|
454 |
array('t2' => $attribute->getBackend()->getTable()),
|
455 |
-
sprintf($joinConditionTemplate, '
|
456 |
array($attribute->getAttributeCode() => $valueExpr));
|
457 |
if ($attribute->getFlatAddChildData()) {
|
458 |
$select->where("e.is_child = ?", 0);
|
431 |
public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId)
|
432 |
{
|
433 |
$adapter = $this->_getReadAdapter();
|
434 |
+
$joinConditionTemplate = "%s.entity_id = %s.entity_id"
|
435 |
." AND %s.entity_type_id = ".$attribute->getEntityTypeId()
|
436 |
." AND %s.attribute_id = ".$attribute->getId()
|
437 |
." AND %s.store_id = %d";
|
452 |
array())
|
453 |
->joinLeft(
|
454 |
array('t2' => $attribute->getBackend()->getTable()),
|
455 |
+
sprintf($joinConditionTemplate, 'e', 't2', 't2', 't2', 't2', $storeId),
|
456 |
array($attribute->getAttributeCode() => $valueExpr));
|
457 |
if ($attribute->getFlatAddChildData()) {
|
458 |
$select->where("e.is_child = ?", 0);
|
app/code/core/Mage/Eav/Model/Resource/Entity/Attribute/Option.php
CHANGED
@@ -108,7 +108,7 @@ class Mage_Eav_Model_Resource_Entity_Attribute_Option extends Mage_Core_Model_Re
|
|
108 |
$select = $adapter->select()
|
109 |
->joinLeft(array('t1' => $attributeTable), $joinCondition, array())
|
110 |
->joinLeft(array('t2' => $attributeTable),
|
111 |
-
sprintf($joinConditionTemplate, '
|
112 |
array($attributeCode => $valueExpr));
|
113 |
|
114 |
if (($attribute->getFrontend()->getInputType() != 'multiselect') && $hasValueField) {
|
@@ -122,7 +122,7 @@ class Mage_Eav_Model_Resource_Entity_Attribute_Option extends Mage_Core_Model_Re
|
|
122 |
}
|
123 |
|
124 |
if ($attribute->getFlatAddChildData()) {
|
125 |
-
$select->where(
|
126 |
}
|
127 |
|
128 |
return $select;
|
108 |
$select = $adapter->select()
|
109 |
->joinLeft(array('t1' => $attributeTable), $joinCondition, array())
|
110 |
->joinLeft(array('t2' => $attributeTable),
|
111 |
+
sprintf($joinConditionTemplate, 'e', 't2', 't2', 't2', 't2', $store),
|
112 |
array($attributeCode => $valueExpr));
|
113 |
|
114 |
if (($attribute->getFrontend()->getInputType() != 'multiselect') && $hasValueField) {
|
122 |
}
|
123 |
|
124 |
if ($attribute->getFlatAddChildData()) {
|
125 |
+
$select->where("e.is_child = ?", 0);
|
126 |
}
|
127 |
|
128 |
return $select;
|
app/code/core/Mage/Eav/etc/config.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Eav>
|
31 |
-
<version>1.6.0.
|
32 |
</Mage_Eav>
|
33 |
</modules>
|
34 |
<global>
|
28 |
<config>
|
29 |
<modules>
|
30 |
<Mage_Eav>
|
31 |
+
<version>1.6.0.1</version>
|
32 |
</Mage_Eav>
|
33 |
</modules>
|
34 |
<global>
|
app/code/core/Mage/{GoogleCheckout/sql/googlecheckout_setup/mysql4-upgrade-0.7.2-0.7.3.php → Eav/sql/eav_setup/upgrade-1.6.0.0-1.6.0.1.php}
RENAMED
@@ -19,18 +19,20 @@
|
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
-
* @package
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
|
|
27 |
$installer = $this;
|
28 |
-
/* @var $installer Mage_GoogleCheckout_Model_Mysql4_Setup */
|
29 |
|
30 |
$installer->startSetup();
|
|
|
31 |
|
32 |
-
$
|
33 |
-
'
|
34 |
-
)
|
|
|
35 |
|
36 |
$installer->endSetup();
|
19 |
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
*
|
21 |
* @category Mage
|
22 |
+
* @package Mage_Eav
|
23 |
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
$installer = $this;
|
|
|
29 |
|
30 |
$installer->startSetup();
|
31 |
+
$connection = $installer->getConnection();
|
32 |
|
33 |
+
$connection->delete(
|
34 |
+
$this->getTable('eav/attribute'),
|
35 |
+
$connection->prepareSqlCondition('attribute_code', 'enable_googlecheckout')
|
36 |
+
);
|
37 |
|
38 |
$installer->endSetup();
|
app/code/core/Mage/GoogleAnalytics/Block/Ga.php
CHANGED
@@ -92,6 +92,7 @@ class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Template
|
|
92 |
}
|
93 |
return "
|
94 |
_gaq.push(['_setAccount', '{$this->jsQuoteEscape($accountId)}']);
|
|
|
95 |
_gaq.push(['_trackPageview'{$optPageURL}]);
|
96 |
";
|
97 |
}
|
@@ -151,7 +152,19 @@ _gaq.push(['_trackPageview'{$optPageURL}]);
|
|
151 |
if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) {
|
152 |
return '';
|
153 |
}
|
154 |
-
|
155 |
return parent::_toHtml();
|
156 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
92 |
}
|
93 |
return "
|
94 |
_gaq.push(['_setAccount', '{$this->jsQuoteEscape($accountId)}']);
|
95 |
+
" . $this->_getAnonymizationCode() . "
|
96 |
_gaq.push(['_trackPageview'{$optPageURL}]);
|
97 |
";
|
98 |
}
|
152 |
if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) {
|
153 |
return '';
|
154 |
}
|
|
|
155 |
return parent::_toHtml();
|
156 |
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Render IP anonymization code for page tracking javascript code
|
160 |
+
*
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
protected function _getAnonymizationCode()
|
164 |
+
{
|
165 |
+
if (!Mage::helper('googleanalytics')->isIpAnonymizationEnabled()) {
|
166 |
+
return '';
|
167 |
+
}
|
168 |
+
return "_gaq.push (['_gat._anonymizeIp']);";
|
169 |
+
}
|
170 |
}
|
app/code/core/Mage/GoogleAnalytics/Helper/Data.php
CHANGED
@@ -36,8 +36,9 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
36 |
/**
|
37 |
* Config paths for using throughout the code
|
38 |
*/
|
39 |
-
const XML_PATH_ACTIVE
|
40 |
-
const XML_PATH_ACCOUNT
|
|
|
41 |
|
42 |
/**
|
43 |
* Whether GA is ready to use
|
@@ -50,4 +51,15 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
50 |
$accountId = Mage::getStoreConfig(self::XML_PATH_ACCOUNT, $store);
|
51 |
return $accountId && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
36 |
/**
|
37 |
* Config paths for using throughout the code
|
38 |
*/
|
39 |
+
const XML_PATH_ACTIVE = 'google/analytics/active';
|
40 |
+
const XML_PATH_ACCOUNT = 'google/analytics/account';
|
41 |
+
const XML_PATH_ANONYMIZATION = 'google/analytics/anonymization';
|
42 |
|
43 |
/**
|
44 |
* Whether GA is ready to use
|
51 |
$accountId = Mage::getStoreConfig(self::XML_PATH_ACCOUNT, $store);
|
52 |
return $accountId && Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $store);
|
53 |
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Whether GA IP Anonymization is enabled
|
57 |
+
*
|
58 |
+
* @param null $store
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function isIpAnonymizationEnabled($store = null)
|
62 |
+
{
|
63 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_ANONYMIZATION, $store);
|
64 |
+
}
|
65 |
}
|
app/code/core/Mage/GoogleAnalytics/Model/Observer.php
CHANGED
@@ -33,12 +33,6 @@
|
|
33 |
*/
|
34 |
class Mage_GoogleAnalytics_Model_Observer
|
35 |
{
|
36 |
-
/**
|
37 |
-
* Whether the google checkout inclusion link was rendered by this observer instance
|
38 |
-
* @var bool
|
39 |
-
*/
|
40 |
-
protected $_isGoogleCheckoutLinkAdded = false;
|
41 |
-
|
42 |
/**
|
43 |
* Create Google Analytics block for success page view
|
44 |
*
|
@@ -66,37 +60,4 @@ class Mage_GoogleAnalytics_Model_Observer
|
|
66 |
$block->setOrderIds($orderIds);
|
67 |
}
|
68 |
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Add google analytics tracking to google checkout shortcuts
|
72 |
-
*
|
73 |
-
* If there is at least one GC button on the page, there should be the script for GA/GC integration included
|
74 |
-
* a each shortcut should track submits to GA
|
75 |
-
* There should be no tracking if there is no GA available
|
76 |
-
* This method assumes that the observer instance is run as a "singleton" (through Mage::getSingleton())
|
77 |
-
*
|
78 |
-
* @param Varien_Event_Observer $observer
|
79 |
-
*/
|
80 |
-
public function injectAnalyticsInGoogleCheckoutLink(Varien_Event_Observer $observer)
|
81 |
-
{
|
82 |
-
$block = $observer->getEvent()->getBlock();
|
83 |
-
if (!$block || !Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) {
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
|
87 |
-
// make sure to track google checkout "onsubmit"
|
88 |
-
$onsubmitJs = $block->getOnsubmitJs();
|
89 |
-
$block->setOnsubmitJs($onsubmitJs . ($onsubmitJs ? '; ' : '') . '_gaq.push(function() {var pageTracker = _gaq._getAsyncTracker(); setUrchinInputCode(pageTracker);});');
|
90 |
-
|
91 |
-
// add a link that includes google checkout/analytics script, to the first instance of the link block
|
92 |
-
if ($this->_isGoogleCheckoutLinkAdded) {
|
93 |
-
return;
|
94 |
-
}
|
95 |
-
$beforeHtml = $block->getBeforeHtml();
|
96 |
-
$protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
|
97 |
-
$block->setBeforeHtml($beforeHtml . '<script src="' . $protocol
|
98 |
-
. '://checkout.google.com/files/digital/ga_post.js" type="text/javascript"></script>'
|
99 |
-
);
|
100 |
-
$this->_isGoogleCheckoutLinkAdded = true;
|
101 |
-
}
|
102 |
}
|
33 |
*/
|
34 |
class Mage_GoogleAnalytics_Model_Observer
|
35 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* Create Google Analytics block for success page view
|
38 |
*
|
60 |
$block->setOrderIds($orderIds);
|
61 |
}
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
app/code/core/Mage/GoogleAnalytics/etc/config.xml
CHANGED
@@ -75,14 +75,6 @@
|
|
75 |
</googleanalytics_order_success>
|
76 |
</observers>
|
77 |
</checkout_multishipping_controller_success_action>
|
78 |
-
<googlecheckout_block_link_html_before>
|
79 |
-
<observers>
|
80 |
-
<googleanalytics_googlecheckout_integration>
|
81 |
-
<class>googleanalytics/observer</class>
|
82 |
-
<method>injectAnalyticsInGoogleCheckoutLink</method>
|
83 |
-
</googleanalytics_googlecheckout_integration>
|
84 |
-
</observers>
|
85 |
-
</googlecheckout_block_link_html_before>
|
86 |
</events>
|
87 |
<layout>
|
88 |
<updates>
|
75 |
</googleanalytics_order_success>
|
76 |
</observers>
|
77 |
</checkout_multishipping_controller_success_action>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</events>
|
79 |
<layout>
|
80 |
<updates>
|
app/code/core/Mage/GoogleAnalytics/etc/system.xml
CHANGED
@@ -61,6 +61,15 @@
|
|
61 |
<show_in_website>1</show_in_website>
|
62 |
<show_in_store>1</show_in_store>
|
63 |
</account>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</fields>
|
65 |
</analytics>
|
66 |
</groups>
|
61 |
<show_in_website>1</show_in_website>
|
62 |
<show_in_store>1</show_in_store>
|
63 |
</account>
|
64 |
+
<anonymization translate="label">
|
65 |
+
<label>Enable IP anonymization</label>
|
66 |
+
<frontend_type>select</frontend_type>
|
67 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
68 |
+
<sort_order>30</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>1</show_in_store>
|
72 |
+
</anonymization>
|
73 |
</fields>
|
74 |
</analytics>
|
75 |
</groups>
|
app/code/core/Mage/GoogleCheckout/Block/Adminhtml/Shipping/Applicable/Countries.php
DELETED
@@ -1,65 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Block_Adminhtml_Shipping_Applicable_Countries
|
28 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
29 |
-
{
|
30 |
-
protected $_addRowButtonHtml = array();
|
31 |
-
protected $_removeRowButtonHtml = array();
|
32 |
-
|
33 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
34 |
-
{
|
35 |
-
$html = parent::_getElementHtml($element);
|
36 |
-
$html .= $this->_appendJs($element);
|
37 |
-
return $html;
|
38 |
-
}
|
39 |
-
|
40 |
-
protected function _appendJs($element)
|
41 |
-
{
|
42 |
-
$elId = $element->getHtmlId();
|
43 |
-
$childId = str_replace('sallowspecific', 'specificcountry', $elId);
|
44 |
-
$html = "<script type='text/javascript'>
|
45 |
-
var dwvie = function ()
|
46 |
-
{
|
47 |
-
var valueSelectId = '{$elId}';
|
48 |
-
var elementToDisableId = '{$childId}';
|
49 |
-
|
50 |
-
var source = $(valueSelectId);
|
51 |
-
var target = $(elementToDisableId);
|
52 |
-
|
53 |
-
if (source.options[source.selectedIndex].value == '0') {
|
54 |
-
target.disabled = true;
|
55 |
-
} else {
|
56 |
-
target.disabled = false;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
Event.observe('{$elId}', 'change', dwvie);
|
61 |
-
Event.observe(window, 'load', dwvie);
|
62 |
-
</script>";
|
63 |
-
return $html;
|
64 |
-
}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Block/Adminhtml/Shipping/Merchant.php
DELETED
@@ -1,181 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Block_Adminhtml_Shipping_Merchant
|
28 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
29 |
-
{
|
30 |
-
protected $_addRowButtonHtml = array();
|
31 |
-
protected $_removeRowButtonHtml = array();
|
32 |
-
|
33 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
34 |
-
{
|
35 |
-
$this->setElement($element);
|
36 |
-
|
37 |
-
$html = '<div id="merchant_allowed_methods_template" style="display:none">';
|
38 |
-
$html .= $this->_getRowTemplateHtml();
|
39 |
-
$html .= '</div>';
|
40 |
-
|
41 |
-
$html .= '<ul id="merchant_allowed_methods_container">';
|
42 |
-
if ($this->_getValue('method')) {
|
43 |
-
foreach ($this->_getValue('method') as $i => $f) {
|
44 |
-
if ($i) {
|
45 |
-
$html .= $this->_getRowTemplateHtml($i);
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
-
$html .= '</ul>';
|
50 |
-
$html .= $this->_getAddRowButtonHtml('merchant_allowed_methods_container',
|
51 |
-
'merchant_allowed_methods_template', $this->__('Add Shipping Method'));
|
52 |
-
|
53 |
-
return $html;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Retrieve html template for shipping method row
|
58 |
-
*
|
59 |
-
* @param int $rowIndex
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
protected function _getRowTemplateHtml($rowIndex = 0)
|
63 |
-
{
|
64 |
-
$html = '<li>';
|
65 |
-
$html .= '<select name="' . $this->getElement()->getName() . '[method][]" ' . $this->_getDisabled() . '>';
|
66 |
-
$html .= '<option value="">' . $this->__('* Select shipping method') . '</option>';
|
67 |
-
|
68 |
-
foreach ($this->getShippingMethods() as $carrierCode => $carrier) {
|
69 |
-
$html .= '<optgroup label="' . $this->escapeHtml($carrier['title'])
|
70 |
-
. '" style="border-top:solid 1px black; margin-top:3px;">';
|
71 |
-
|
72 |
-
foreach ($carrier['methods'] as $methodCode => $method) {
|
73 |
-
$code = $carrierCode . '/' . $methodCode;
|
74 |
-
$html .= '<option value="' . $this->escapeHtml($code) . '" '
|
75 |
-
. $this->_getSelected('method/' . $rowIndex, $code)
|
76 |
-
. ' style="background:white;">' . $this->escapeHtml($method['title']) . '</option>';
|
77 |
-
}
|
78 |
-
$html .= '</optgroup>';
|
79 |
-
}
|
80 |
-
$html .= '</select>';
|
81 |
-
|
82 |
-
$html .= '<div style="margin:5px 0 10px;">';
|
83 |
-
$html .= '<label>' . $this->__('Default price:') . '</label> ';
|
84 |
-
$html .= '<input class="input-text" style="width:70px;" name="'
|
85 |
-
. $this->getElement()->getName() . '[price][]" value="'
|
86 |
-
. $this->_getValue('price/' . $rowIndex) . '" ' . $this->_getDisabled() . '/> ';
|
87 |
-
|
88 |
-
$html .= $this->_getRemoveRowButtonHtml();
|
89 |
-
$html .= '</div>';
|
90 |
-
$html .= '</li>';
|
91 |
-
|
92 |
-
return $html;
|
93 |
-
}
|
94 |
-
|
95 |
-
protected function getShippingMethods()
|
96 |
-
{
|
97 |
-
if (!$this->hasData('shipping_methods')) {
|
98 |
-
$website = $this->getRequest()->getParam('website');
|
99 |
-
$store = $this->getRequest()->getParam('store');
|
100 |
-
|
101 |
-
$storeId = null;
|
102 |
-
if (!is_null($website)) {
|
103 |
-
$storeId = Mage::getModel('core/website')
|
104 |
-
->load($website, 'code')
|
105 |
-
->getDefaultGroup()
|
106 |
-
->getDefaultStoreId();
|
107 |
-
} elseif (!is_null($store)) {
|
108 |
-
$storeId = Mage::getModel('core/store')
|
109 |
-
->load($store, 'code')
|
110 |
-
->getId();
|
111 |
-
}
|
112 |
-
|
113 |
-
$methods = array();
|
114 |
-
$carriers = Mage::getSingleton('shipping/config')->getActiveCarriers($storeId);
|
115 |
-
foreach ($carriers as $carrierCode=>$carrierModel) {
|
116 |
-
if (!$carrierModel->isActive()) {
|
117 |
-
continue;
|
118 |
-
}
|
119 |
-
$carrierMethods = $carrierModel->getAllowedMethods();
|
120 |
-
if (!$carrierMethods) {
|
121 |
-
continue;
|
122 |
-
}
|
123 |
-
$carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/title', $storeId);
|
124 |
-
$methods[$carrierCode] = array(
|
125 |
-
'title' => $carrierTitle,
|
126 |
-
'methods' => array(),
|
127 |
-
);
|
128 |
-
foreach ($carrierMethods as $methodCode=>$methodTitle) {
|
129 |
-
$methods[$carrierCode]['methods'][$methodCode] = array(
|
130 |
-
'title' => '[' . $carrierCode . '] ' . $methodTitle,
|
131 |
-
);
|
132 |
-
}
|
133 |
-
}
|
134 |
-
$this->setData('shipping_methods', $methods);
|
135 |
-
}
|
136 |
-
return $this->getData('shipping_methods');
|
137 |
-
}
|
138 |
-
|
139 |
-
protected function _getDisabled()
|
140 |
-
{
|
141 |
-
return $this->getElement()->getDisabled() ? ' disabled' : '';
|
142 |
-
}
|
143 |
-
|
144 |
-
protected function _getValue($key)
|
145 |
-
{
|
146 |
-
return $this->getElement()->getData('value/' . $key);
|
147 |
-
}
|
148 |
-
|
149 |
-
protected function _getSelected($key, $value)
|
150 |
-
{
|
151 |
-
return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
|
152 |
-
}
|
153 |
-
|
154 |
-
protected function _getAddRowButtonHtml($container, $template, $title='Add')
|
155 |
-
{
|
156 |
-
if (!isset($this->_addRowButtonHtml[$container])) {
|
157 |
-
$this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
|
158 |
-
->setType('button')
|
159 |
-
->setClass('add ' . $this->_getDisabled())
|
160 |
-
->setLabel($this->__($title))
|
161 |
-
->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
|
162 |
-
->setDisabled($this->_getDisabled())
|
163 |
-
->toHtml();
|
164 |
-
}
|
165 |
-
return $this->_addRowButtonHtml[$container];
|
166 |
-
}
|
167 |
-
|
168 |
-
protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Remove')
|
169 |
-
{
|
170 |
-
if (!$this->_removeRowButtonHtml) {
|
171 |
-
$this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
|
172 |
-
->setType('button')
|
173 |
-
->setClass('delete v-middle ' . $this->_getDisabled())
|
174 |
-
->setLabel($this->__($title))
|
175 |
-
->setOnClick("Element.remove($(this).up('" . $selector . "'))")
|
176 |
-
->setDisabled($this->_getDisabled())
|
177 |
-
->toHtml();
|
178 |
-
}
|
179 |
-
return $this->_removeRowButtonHtml;
|
180 |
-
}
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Block/Link.php
DELETED
@@ -1,108 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Google Checkout shortcut link
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
* @package Mage_GoogleCheckout
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Mage_GoogleCheckout_Block_Link extends Mage_Core_Block_Template
|
35 |
-
{
|
36 |
-
public function getImageStyle()
|
37 |
-
{
|
38 |
-
$s = Mage::getStoreConfig('google/checkout/checkout_image');
|
39 |
-
if (!$s) {
|
40 |
-
$s = '180/46/trans';
|
41 |
-
}
|
42 |
-
return explode('/', $s);
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getImageUrl()
|
46 |
-
{
|
47 |
-
$url = 'https://checkout.google.com/buttons/checkout.gif';
|
48 |
-
$url .= '?merchant_id='.Mage::getStoreConfig('google/checkout/merchant_id');
|
49 |
-
$v = $this->getImageStyle();
|
50 |
-
$url .= '&w='.$v[0].'&h='.$v[1].'&style='.$v[2];
|
51 |
-
$url .= '&variant='.($this->getIsDisabled() ? 'disabled' : 'text');
|
52 |
-
$url .= '&loc='.Mage::getStoreConfig('google/checkout/locale');
|
53 |
-
return $url;
|
54 |
-
}
|
55 |
-
|
56 |
-
public function getCheckoutUrl()
|
57 |
-
{
|
58 |
-
return $this->getUrl('googlecheckout/redirect/checkout');
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @deprecated after 1.4.1.1
|
63 |
-
* @return bool
|
64 |
-
*/
|
65 |
-
public function getIsActiveAanalytics()
|
66 |
-
{
|
67 |
-
return false;
|
68 |
-
}
|
69 |
-
|
70 |
-
public function getImageWidth()
|
71 |
-
{
|
72 |
-
$v = $this->getImageStyle();
|
73 |
-
return $v[0];
|
74 |
-
}
|
75 |
-
|
76 |
-
public function getImageHeight()
|
77 |
-
{
|
78 |
-
$v = $this->getImageStyle();
|
79 |
-
return $v[1];
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Check whether method is available and render HTML
|
84 |
-
* @return string
|
85 |
-
*/
|
86 |
-
public function _toHtml()
|
87 |
-
{
|
88 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
89 |
-
if (Mage::getModel('googlecheckout/payment')->isAvailable($quote) && $quote->validateMinimumAmount()) {
|
90 |
-
Mage::dispatchEvent('googlecheckout_block_link_html_before', array('block' => $this));
|
91 |
-
return parent::_toHtml();
|
92 |
-
}
|
93 |
-
return '';
|
94 |
-
}
|
95 |
-
|
96 |
-
public function getIsDisabled()
|
97 |
-
{
|
98 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
99 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
100 |
-
foreach ($quote->getAllVisibleItems() as $item) {
|
101 |
-
/* @var $item Mage_Sales_Model_Quote_Item */
|
102 |
-
if (!$item->getProduct()->getEnableGooglecheckout()) {
|
103 |
-
return true;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Exception.php
DELETED
@@ -1,30 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Exception extends Mage_Core_Exception
|
28 |
-
{
|
29 |
-
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Helper/Data.php
DELETED
@@ -1,192 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* GoogleCheckout data helper
|
29 |
-
*/
|
30 |
-
class Mage_GoogleCheckout_Helper_Data extends Mage_Core_Helper_Abstract
|
31 |
-
{
|
32 |
-
/**
|
33 |
-
* Google Checkout settings
|
34 |
-
*/
|
35 |
-
const XML_PATH_REQUEST_PHONE = 'google/checkout/request_phone';
|
36 |
-
const XML_PATH_DISABLE_DEFAULT_TAX_TABLES = 'google/checkout/disable_default_tax_tables';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Google Checkout Shipping - Digital Delivery settings
|
40 |
-
*/
|
41 |
-
const XML_PATH_SHIPPING_VIRTUAL_ACTIVE = 'google/checkout_shipping_virtual/active';
|
42 |
-
const XML_PATH_SHIPPING_VIRTUAL_SCHEDULE = 'google/checkout_shipping_virtual/schedule';
|
43 |
-
const XML_PATH_SHIPPING_VIRTUAL_METHOD = 'google/checkout_shipping_virtual/method';
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Google Checkout Shipping - Carrier Calculated settings
|
47 |
-
*/
|
48 |
-
const XML_PATH_SHIPPING_CARRIER_ACTIVE = 'google/checkout_shipping_carrier/active';
|
49 |
-
const XML_PATH_SHIPPING_CARRIER_METHODS = 'google/checkout_shipping_carrier/methods';
|
50 |
-
const XML_PATH_SHIPPING_CARRIER_DEFAULT_PRICE = 'google/checkout_shipping_carrier/default_price';
|
51 |
-
const XML_PATH_SHIPPING_CARRIER_DEFAULT_WIDTH = 'google/checkout_shipping_carrier/default_width';
|
52 |
-
const XML_PATH_SHIPPING_CARRIER_DEFAULT_HEIGHT = 'google/checkout_shipping_carrier/default_height';
|
53 |
-
const XML_PATH_SHIPPING_CARRIER_DEFAULT_LENGTH = 'google/checkout_shipping_carrier/default_length';
|
54 |
-
const XML_PATH_SHIPPING_CARRIER_ADDRESS_CATEGORY = 'google/checkout_shipping_carrier/address_category';
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Google Checkout Shipping - Flat Rate settings
|
58 |
-
*/
|
59 |
-
const XML_PATH_SHIPPING_FLATRATE_ACTIVE = 'google/checkout_shipping_flatrate/active';
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Google Checkout Shipping - Merchant Calculated settings
|
63 |
-
*/
|
64 |
-
const XML_PATH_SHIPPING_MERCHANT_ACTIVE = 'google/checkout_shipping_merchant/active';
|
65 |
-
const XML_PATH_SHIPPING_MERCHANT_ALLOWED_METHODS = 'google/checkout_shipping_merchant/allowed_methods';
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Google Checkout Shipping - Pickup settings
|
69 |
-
*/
|
70 |
-
const XML_PATH_SHIPPING_PICKUP_ACTIVE = 'google/checkout_shipping_pickup/active';
|
71 |
-
const XML_PATH_SHIPPING_PICKUP_TITLE = 'google/checkout_shipping_pickup/title';
|
72 |
-
const XML_PATH_SHIPPING_PICKUP_PRICE = 'google/checkout_shipping_pickup/price';
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Check if option googlecheckout shipping carrier is enabled
|
76 |
-
*
|
77 |
-
* @param $storeId
|
78 |
-
* @return bool
|
79 |
-
*/
|
80 |
-
public function isShippingCarrierActive($storeId)
|
81 |
-
{
|
82 |
-
return (true == Mage::getStoreConfig(self::XML_PATH_SHIPPING_CARRIER_ACTIVE, $storeId));
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Convert Magento zip range to array of Google Checkout zip-patterns
|
87 |
-
* (e.g., 12000-13999 -> [12*, 13*])
|
88 |
-
*
|
89 |
-
* @param string $zipRange
|
90 |
-
* @return array
|
91 |
-
*/
|
92 |
-
public function zipRangeToZipPattern($zipRange)
|
93 |
-
{
|
94 |
-
$zipLength = 5;
|
95 |
-
$zipPattern = array();
|
96 |
-
|
97 |
-
if (!preg_match("/^(.+)-(.+)$/", $zipRange, $zipParts)) {
|
98 |
-
return array($zipRange);
|
99 |
-
}
|
100 |
-
|
101 |
-
if ($zipParts[1] == $zipParts[2]) {
|
102 |
-
return array($zipParts[1]);
|
103 |
-
}
|
104 |
-
|
105 |
-
if ($zipParts[1] > $zipParts[2]) {
|
106 |
-
list($zipParts[2], $zipParts[1]) = array($zipParts[1], $zipParts[2]);
|
107 |
-
}
|
108 |
-
|
109 |
-
$from = str_split($zipParts[1]);
|
110 |
-
$to = str_split($zipParts[2]);
|
111 |
-
|
112 |
-
$startZip = '';
|
113 |
-
$diffPosition = null;
|
114 |
-
for ($pos = 0; $pos < $zipLength; $pos++) {
|
115 |
-
if ($from[$pos] == $to[$pos]) {
|
116 |
-
$startZip .= $from[$pos];
|
117 |
-
} else {
|
118 |
-
$diffPosition = $pos;
|
119 |
-
break;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
/*
|
124 |
-
* calculate zip-patterns
|
125 |
-
*/
|
126 |
-
if (min(array_slice($to, $diffPosition)) == 9 && max(array_slice($from, $diffPosition)) == 0) {
|
127 |
-
// particular case like 11000-11999 -> 11*
|
128 |
-
return array($startZip . '*');
|
129 |
-
} else {
|
130 |
-
// calculate approximate zip-patterns
|
131 |
-
$start = $from[$diffPosition];
|
132 |
-
$finish = $to[$diffPosition];
|
133 |
-
if ($diffPosition < $zipLength - 1) {
|
134 |
-
$start++;
|
135 |
-
$finish--;
|
136 |
-
}
|
137 |
-
$end = $diffPosition < $zipLength - 1 ? '*' : '';
|
138 |
-
for ($digit = $start; $digit <= $finish; $digit++) {
|
139 |
-
$zipPattern[] = $startZip . $digit . $end;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
if ($diffPosition == $zipLength - 1) {
|
144 |
-
return $zipPattern;
|
145 |
-
}
|
146 |
-
|
147 |
-
$nextAsteriskFrom = true;
|
148 |
-
$nextAsteriskTo = true;
|
149 |
-
for ($pos = $zipLength - 1; $pos > $diffPosition; $pos--) {
|
150 |
-
// calculate zip-patterns based on $from value
|
151 |
-
if ($from[$pos] == 0 && $nextAsteriskFrom) {
|
152 |
-
$nextAsteriskFrom = true;
|
153 |
-
} else {
|
154 |
-
$subZip = '';
|
155 |
-
for ($k = $diffPosition; $k < $pos; $k++) {
|
156 |
-
$subZip .= $from[$k];
|
157 |
-
}
|
158 |
-
$delta = $nextAsteriskFrom ? 0 : 1;
|
159 |
-
$end = $pos < $zipLength - 1 ? '*' : '';
|
160 |
-
for ($i = $from[$pos] + $delta; $i <= 9; $i++) {
|
161 |
-
$zipPattern[] = $startZip . $subZip . $i . $end;
|
162 |
-
}
|
163 |
-
$nextAsteriskFrom = false;
|
164 |
-
}
|
165 |
-
|
166 |
-
// calculate zip-patterns based on $to value
|
167 |
-
if ($to[$pos] == 9 && $nextAsteriskTo) {
|
168 |
-
$nextAsteriskTo = true;
|
169 |
-
} else {
|
170 |
-
$subZip = '';
|
171 |
-
for ($k = $diffPosition; $k < $pos; $k++) {
|
172 |
-
$subZip .= $to[$k];
|
173 |
-
}
|
174 |
-
$delta = $nextAsteriskTo ? 0 : 1;
|
175 |
-
$end = $pos < $zipLength - 1 ? '*' : '';
|
176 |
-
for ($i = 0; $i <= $to[$pos] - $delta; $i++) {
|
177 |
-
$zipPattern[] = $startZip . $subZip . $i . $end;
|
178 |
-
}
|
179 |
-
$nextAsteriskTo = false;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
if ($nextAsteriskFrom) {
|
184 |
-
$zipPattern[] = $startZip . $from[$diffPosition] . '*';
|
185 |
-
}
|
186 |
-
if ($nextAsteriskTo) {
|
187 |
-
$zipPattern[] = $startZip . $to[$diffPosition] . '*';
|
188 |
-
}
|
189 |
-
|
190 |
-
return $zipPattern;
|
191 |
-
}
|
192 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api.php
DELETED
@@ -1,233 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Model_Api extends Varien_Object
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Fields that should be replaced in debug with '***'
|
31 |
-
*
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
protected $_debugReplacePrivateDataKeys = array();
|
35 |
-
|
36 |
-
protected function _getApi($area)
|
37 |
-
{
|
38 |
-
$api = Mage::getModel('googlecheckout/api_xml_' . $area)->setStoreId($this->getStoreId());
|
39 |
-
$api->setApi($this);
|
40 |
-
return $api;
|
41 |
-
}
|
42 |
-
|
43 |
-
// CHECKOUT
|
44 |
-
public function checkout(Mage_Sales_Model_Quote $quote)
|
45 |
-
{
|
46 |
-
$api = $this->_getApi('checkout')
|
47 |
-
->setQuote($quote)
|
48 |
-
->checkout();
|
49 |
-
return $api;
|
50 |
-
}
|
51 |
-
|
52 |
-
// FINANCIAL COMMANDS
|
53 |
-
public function authorize($gOrderId)
|
54 |
-
{
|
55 |
-
$api = $this->_getApi('order')
|
56 |
-
->setGoogleOrderNumber($gOrderId)
|
57 |
-
->authorize();
|
58 |
-
return $api;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function charge($gOrderId, $amount)
|
62 |
-
{
|
63 |
-
$api = $this->_getApi('order')
|
64 |
-
->setGoogleOrderNumber($gOrderId)
|
65 |
-
->charge($amount);
|
66 |
-
return $api;
|
67 |
-
}
|
68 |
-
|
69 |
-
public function refund($gOrderId, $amount, $reason, $comment = '')
|
70 |
-
{
|
71 |
-
$api = $this->_getApi('order')
|
72 |
-
->setGoogleOrderNumber($gOrderId)
|
73 |
-
->refund($amount, $reason, $comment);
|
74 |
-
return $api;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function cancel($gOrderId, $reason, $comment = '')
|
78 |
-
{
|
79 |
-
$api = $this->_getApi('order')
|
80 |
-
->setGoogleOrderNumber($gOrderId)
|
81 |
-
->cancel($reason, $comment);
|
82 |
-
return $api;
|
83 |
-
}
|
84 |
-
|
85 |
-
// FULFILLMENT COMMANDS (ORDER BASED)
|
86 |
-
|
87 |
-
public function process($gOrderId)
|
88 |
-
{
|
89 |
-
$api = $this->_getApi('order')
|
90 |
-
->setGoogleOrderNumber($gOrderId)
|
91 |
-
->process();
|
92 |
-
return $api;
|
93 |
-
}
|
94 |
-
|
95 |
-
public function deliver($gOrderId, $carrier, $trackingNo, $sendMail = true)
|
96 |
-
{
|
97 |
-
$this->setCarriers(array('dhl' => 'DHL', 'fedex' => 'FedEx', 'ups' => 'UPS', 'usps' => 'USPS'));
|
98 |
-
Mage::dispatchEvent('googlecheckout_api_deliver_carriers_array', array('api' => $this));
|
99 |
-
$gCarriers = $this->getCarriers();
|
100 |
-
$carrier = strtolower($carrier);
|
101 |
-
$carrier = isset($gCarriers[$carrier]) ? $gCarriers[$carrier] : 'Other';
|
102 |
-
|
103 |
-
$api = $this->_getApi('order')
|
104 |
-
->setGoogleOrderNumber($gOrderId)
|
105 |
-
->deliver($carrier, $trackingNo, $sendMail);
|
106 |
-
return $api;
|
107 |
-
}
|
108 |
-
|
109 |
-
public function addTrackingData($gOrderId, $carrier, $trackingNo)
|
110 |
-
{
|
111 |
-
$api = $this->_getApi('order')
|
112 |
-
->setGoogleOrderNumber($gOrderId)
|
113 |
-
->addTrackingData($carrier, $trackingNo);
|
114 |
-
return $api;
|
115 |
-
}
|
116 |
-
|
117 |
-
// FULFILLMENT COMMANDS (ITEM BASED)
|
118 |
-
|
119 |
-
public function shipItems($gOrderId, array $items)
|
120 |
-
{
|
121 |
-
$api = $this->_getApi('order')
|
122 |
-
->setGoogleOrderNumber($gOrderId)
|
123 |
-
->shipItems($items);
|
124 |
-
return $api;
|
125 |
-
}
|
126 |
-
|
127 |
-
public function backorderItems()
|
128 |
-
{
|
129 |
-
$api = $this->_getApi('order')
|
130 |
-
->setOrder($order)
|
131 |
-
->setItems($items)
|
132 |
-
->shipItems();
|
133 |
-
return $api;
|
134 |
-
}
|
135 |
-
|
136 |
-
public function returnItems()
|
137 |
-
{
|
138 |
-
$api = $this->_getApi('order')
|
139 |
-
->setOrder($order)
|
140 |
-
->setItems($items)
|
141 |
-
->shipItems();
|
142 |
-
return $api;
|
143 |
-
}
|
144 |
-
|
145 |
-
public function cancelItems()
|
146 |
-
{
|
147 |
-
$api = $this->_getApi('order')
|
148 |
-
->setOrder($order)
|
149 |
-
->setItems($items)
|
150 |
-
->shipItems();
|
151 |
-
return $api;
|
152 |
-
}
|
153 |
-
|
154 |
-
public function resetItemsShippingInformation()
|
155 |
-
{
|
156 |
-
|
157 |
-
}
|
158 |
-
|
159 |
-
public function addMerchantOrderNumber()
|
160 |
-
{
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
public function sendBuyerMessage()
|
165 |
-
{
|
166 |
-
$api = $this->_getApi('order')
|
167 |
-
->setOrder($order)
|
168 |
-
->setItems($items)
|
169 |
-
->shipItems();
|
170 |
-
return $api;
|
171 |
-
}
|
172 |
-
|
173 |
-
// OTHER ORDER COMMANDS
|
174 |
-
|
175 |
-
public function archiveOrder()
|
176 |
-
{
|
177 |
-
$api = $this->_getApi('order')
|
178 |
-
->setOrder($order)
|
179 |
-
->setItems($items)
|
180 |
-
->shipItems();
|
181 |
-
return $api;
|
182 |
-
}
|
183 |
-
|
184 |
-
public function unarchiveOrder()
|
185 |
-
{
|
186 |
-
$api = $this->_getApi('order')
|
187 |
-
->setOrder($order)
|
188 |
-
->setItems($items)
|
189 |
-
->shipItems();
|
190 |
-
return $api;
|
191 |
-
}
|
192 |
-
|
193 |
-
// WEB SERVICE SERVER PROCEDURES
|
194 |
-
|
195 |
-
public function processCallback()
|
196 |
-
{
|
197 |
-
$api = $this->_getApi('callback')->process();
|
198 |
-
return $api;
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* @deprecated after 1.4.1.0
|
203 |
-
*
|
204 |
-
*/
|
205 |
-
public function processBeacon(){}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Log debug data to file
|
209 |
-
*
|
210 |
-
* @param mixed $debugData
|
211 |
-
*/
|
212 |
-
public function debugData($debugData)
|
213 |
-
{
|
214 |
-
if ($this->getDebugFlag()) {
|
215 |
-
Mage::getModel('core/log_adapter', 'payment_googlecheckout.log')
|
216 |
-
->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
|
217 |
-
->log($debugData);
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Define if debugging is enabled
|
223 |
-
*
|
224 |
-
* @return bool
|
225 |
-
*/
|
226 |
-
public function getDebugFlag()
|
227 |
-
{
|
228 |
-
if (!$this->hasData('debug_flag')) {
|
229 |
-
$this->setData('debug_flag', Mage::getStoreConfig('google/checkout/debug', $this->getStoreId()));
|
230 |
-
}
|
231 |
-
return $this->getData('debug_flag');
|
232 |
-
}
|
233 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api/Debug.php
DELETED
@@ -1,52 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enter description here ...
|
30 |
-
*
|
31 |
-
* @method Mage_GoogleCheckout_Model_Resource_Api_Debug _getResource()
|
32 |
-
* @method Mage_GoogleCheckout_Model_Resource_Api_Debug getResource()
|
33 |
-
* @method string getDir()
|
34 |
-
* @method Mage_GoogleCheckout_Model_Api_Debug setDir(string $value)
|
35 |
-
* @method string getUrl()
|
36 |
-
* @method Mage_GoogleCheckout_Model_Api_Debug setUrl(string $value)
|
37 |
-
* @method string getRequestBody()
|
38 |
-
* @method Mage_GoogleCheckout_Model_Api_Debug setRequestBody(string $value)
|
39 |
-
* @method string getResponseBody()
|
40 |
-
* @method Mage_GoogleCheckout_Model_Api_Debug setResponseBody(string $value)
|
41 |
-
*
|
42 |
-
* @category Mage
|
43 |
-
* @package Mage_GoogleCheckout
|
44 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
45 |
-
*/
|
46 |
-
class Mage_GoogleCheckout_Model_Api_Debug extends Mage_Core_Model_Abstract
|
47 |
-
{
|
48 |
-
protected function _construct()
|
49 |
-
{
|
50 |
-
$this->_init('googlecheckout/api_debug');
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Abstract.php
DELETED
@@ -1,245 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
set_include_path(get_include_path().PS.Mage::getBaseDir('lib').DS.'googlecheckout');
|
28 |
-
|
29 |
-
require_once('googleresponse.php');
|
30 |
-
require_once('googlemerchantcalculations.php');
|
31 |
-
require_once('googleresult.php');
|
32 |
-
require_once('googlerequest.php');
|
33 |
-
|
34 |
-
abstract class Mage_GoogleCheckout_Model_Api_Xml_Abstract extends Varien_Object
|
35 |
-
{
|
36 |
-
public function log($text, $nl=true)
|
37 |
-
{
|
38 |
-
error_log(print_r($text, 1) . ($nl ? "\n" : ''), 3, Mage::getBaseDir('log') . DS . 'callback.log');
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
public function __()
|
43 |
-
{
|
44 |
-
$args = func_get_args();
|
45 |
-
$expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'Mage_GoogleCheckout');
|
46 |
-
array_unshift($args, $expr);
|
47 |
-
return Mage::app()->getTranslator()->translate($args);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getMerchantId()
|
51 |
-
{
|
52 |
-
if (!$this->hasData('merchant_id')) {
|
53 |
-
$this->setData('merchant_id', Mage::getStoreConfig('google/checkout/merchant_id', $this->getStoreId()));
|
54 |
-
}
|
55 |
-
return $this->getData('merchant_id');
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getMerchantKey()
|
59 |
-
{
|
60 |
-
if (!$this->hasData('merchant_key')) {
|
61 |
-
$this->setData('merchant_key', Mage::getStoreConfig('google/checkout/merchant_key', $this->getStoreId()));
|
62 |
-
}
|
63 |
-
return $this->getData('merchant_key');
|
64 |
-
}
|
65 |
-
|
66 |
-
public function getServerType()
|
67 |
-
{
|
68 |
-
if (!$this->hasData('server_type')) {
|
69 |
-
$this->setData(
|
70 |
-
'server_type',
|
71 |
-
Mage::getStoreConfig('google/checkout/sandbox', $this->getStoreId()) ? "sandbox" : ""
|
72 |
-
);
|
73 |
-
}
|
74 |
-
return $this->getData('server_type');
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getLocale()
|
78 |
-
{
|
79 |
-
if (!$this->hasData('locale')) {
|
80 |
-
$this->setData('locale', Mage::getStoreConfig('google/checkout/locale', $this->getStoreId()));
|
81 |
-
}
|
82 |
-
return $this->getData('locale');
|
83 |
-
}
|
84 |
-
|
85 |
-
public function getCurrency()
|
86 |
-
{
|
87 |
-
if (!$this->hasData('currency')) {
|
88 |
-
$this->setData('currency', Mage::app()->getStore()->getBaseCurrencyCode());
|
89 |
-
//$this->setData('currency', $this->getLocale()=='en_US' ? 'USD' : 'GBP');
|
90 |
-
}
|
91 |
-
return $this->getData('currency');
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Google Checkout Request instance
|
96 |
-
*
|
97 |
-
* @return GoogleRequest
|
98 |
-
*/
|
99 |
-
public function getGRequest()
|
100 |
-
{
|
101 |
-
if (!$this->hasData('g_request')) {
|
102 |
-
$this->setData('g_request', new GoogleRequest(
|
103 |
-
$this->getMerchantId(),
|
104 |
-
$this->getMerchantKey(),
|
105 |
-
$this->getServerType(),
|
106 |
-
$this->getCurrency()
|
107 |
-
));
|
108 |
-
|
109 |
-
//Setup the log file
|
110 |
-
$logDir = Mage::getBaseDir('log');
|
111 |
-
$this->getData('g_request')->SetLogFiles(
|
112 |
-
$logDir . DS . 'googleerror.log',
|
113 |
-
$logDir . DS . 'googlemessage.log',
|
114 |
-
L_ALL
|
115 |
-
);
|
116 |
-
}
|
117 |
-
return $this->getData('g_request');
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Google Checkout Response instance
|
122 |
-
*
|
123 |
-
* @return GoogleResponse
|
124 |
-
*/
|
125 |
-
public function getGResponse()
|
126 |
-
{
|
127 |
-
$merchantId = $this->getMerchantId();
|
128 |
-
$merchantKey = $this->getMerchantKey();
|
129 |
-
if (empty($merchantId) || empty($merchantKey)) {
|
130 |
-
Mage::throwException(Mage::helper('googlecheckout')->__('GoogleCheckout is not configured'));
|
131 |
-
}
|
132 |
-
if (!$this->hasData('g_response')) {
|
133 |
-
$this->setData('g_response', new GoogleResponse(
|
134 |
-
$this->getMerchantId(),
|
135 |
-
$this->getMerchantKey()
|
136 |
-
));
|
137 |
-
|
138 |
-
//Setup the log file
|
139 |
-
$logDir = Mage::getBaseDir('log');
|
140 |
-
$this->getData('g_response')->SetLogFiles(
|
141 |
-
$logDir . DS . 'googleerror.log',
|
142 |
-
$logDir . DS . 'googlemessage.log',
|
143 |
-
L_ALL
|
144 |
-
);
|
145 |
-
}
|
146 |
-
return $this->getData('g_response');
|
147 |
-
}
|
148 |
-
|
149 |
-
protected function _getBaseApiUrl()
|
150 |
-
{
|
151 |
-
$url = 'https://';
|
152 |
-
if ($this->getServerType()=='sandbox') {
|
153 |
-
$url .= 'sandbox.google.com/checkout/api/checkout/v2/';
|
154 |
-
} else {
|
155 |
-
$url .= 'checkout.google.com/api/checkout/v2/';
|
156 |
-
}
|
157 |
-
return $url;
|
158 |
-
}
|
159 |
-
|
160 |
-
abstract protected function _getApiUrl();
|
161 |
-
|
162 |
-
public function _call($xml)
|
163 |
-
{
|
164 |
-
$auth = 'Basic ' . base64_encode($this->getMerchantId() . ':' . $this->getMerchantKey());
|
165 |
-
|
166 |
-
$headers = array(
|
167 |
-
'Authorization: ' . $auth,
|
168 |
-
'Content-Type: application/xml;charset=UTF-8',
|
169 |
-
'Accept: application/xml;charset=UTF-8',
|
170 |
-
);
|
171 |
-
|
172 |
-
$url = $this->_getApiUrl();
|
173 |
-
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . $xml;
|
174 |
-
|
175 |
-
$debugData = array('request' => $xml, 'dir' => 'out');
|
176 |
-
|
177 |
-
try {
|
178 |
-
$http = new Varien_Http_Adapter_Curl();
|
179 |
-
$http->write('POST', $url, '1.1', $headers, $xml);
|
180 |
-
$response = $http->read();
|
181 |
-
$response = preg_split('/^\r?$/m', $response, 2);
|
182 |
-
$response = trim($response[1]);
|
183 |
-
$debugData['result'] = $response;
|
184 |
-
$http->close();
|
185 |
-
}
|
186 |
-
catch (Exception $e) {
|
187 |
-
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
188 |
-
$this->getApi()->debugData($debugData);
|
189 |
-
throw $e;
|
190 |
-
}
|
191 |
-
|
192 |
-
$this->getApi()->debugData($debugData);
|
193 |
-
$result = @simplexml_load_string($response);
|
194 |
-
if (!$result) {
|
195 |
-
$result = simplexml_load_string(
|
196 |
-
'<error><error-message>Invalid response from Google Checkout server</error-message></error>'
|
197 |
-
);
|
198 |
-
}
|
199 |
-
if ($result->getName() == 'error') {
|
200 |
-
$this->setError($this->__('Google Checkout: %s', (string)$result->{'error-message'}));
|
201 |
-
$this->setWarnings((array)$result->{'warning-messages'});
|
202 |
-
} else {
|
203 |
-
$this->unsError()->unsWarnings();
|
204 |
-
}
|
205 |
-
|
206 |
-
$this->setResult($result);
|
207 |
-
|
208 |
-
return $result;
|
209 |
-
}
|
210 |
-
|
211 |
-
protected function _getCallbackUrl()
|
212 |
-
{
|
213 |
-
return Mage::getUrl(
|
214 |
-
'googlecheckout/api',
|
215 |
-
array('_forced_secure'=>Mage::getStoreConfig('google/checkout/use_secure_callback_url',$this->getStoreId()))
|
216 |
-
);
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Recalculate amount to store currency
|
221 |
-
*
|
222 |
-
* @param float $amount
|
223 |
-
* @param Mage_Sales_Model_Quote $quote
|
224 |
-
* @return float
|
225 |
-
*/
|
226 |
-
protected function _reCalculateToStoreCurrency($amount, $quote)
|
227 |
-
{
|
228 |
-
if ($quote->getQuoteCurrencyCode() != $quote->getBaseCurrencyCode()) {
|
229 |
-
$amount = $amount * $quote->getStoreToQuoteRate();
|
230 |
-
$amount = Mage::app()->getStore()->roundPrice($amount);
|
231 |
-
}
|
232 |
-
return $amount;
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* Get Tax Class for Shipping option
|
237 |
-
*
|
238 |
-
* @param Mage_Sales_Model_Quote $quote
|
239 |
-
* @return mixed
|
240 |
-
*/
|
241 |
-
protected function _getTaxClassForShipping($quote)
|
242 |
-
{
|
243 |
-
return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $quote->getStoreId());
|
244 |
-
}
|
245 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php
DELETED
@@ -1,1107 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Model_Api_Xml_Callback extends Mage_GoogleCheckout_Model_Api_Xml_Abstract
|
28 |
-
{
|
29 |
-
protected $_cachedShippingInfo = array(); // Cache of possible shipping carrier-methods combinations per storeId
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Process notification from google
|
33 |
-
* @return Mage_GoogleCheckout_Model_Api_Xml_Callback
|
34 |
-
*/
|
35 |
-
public function process()
|
36 |
-
{
|
37 |
-
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
|
38 |
-
$xmlResponse = isset($GLOBALS['HTTP_RAW_POST_DATA']) ?
|
39 |
-
$GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input");
|
40 |
-
if (get_magic_quotes_gpc()) {
|
41 |
-
$xmlResponse = stripslashes($xmlResponse);
|
42 |
-
}
|
43 |
-
|
44 |
-
$debugData = array('request' => $xmlResponse, 'dir' => 'in');
|
45 |
-
|
46 |
-
if (empty($xmlResponse)) {
|
47 |
-
$this->getApi()->debugData($debugData);
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
|
51 |
-
list($root, $data) = $this->getGResponse()->GetParsedXML($xmlResponse);
|
52 |
-
|
53 |
-
$this->getGResponse()->SetMerchantAuthentication($this->getMerchantId(), $this->getMerchantKey());
|
54 |
-
$status = $this->getGResponse()->HttpAuthentication();
|
55 |
-
|
56 |
-
if (!$status || empty($data[$root])) {
|
57 |
-
exit;
|
58 |
-
}
|
59 |
-
|
60 |
-
$this->setRootName($root)->setRoot($data[$root]);
|
61 |
-
$serialNumber = $this->getData('root/serial-number');
|
62 |
-
$this->getGResponse()->setSerialNumber($serialNumber);
|
63 |
-
|
64 |
-
/*
|
65 |
-
* Prevent multiple notification processing
|
66 |
-
*/
|
67 |
-
$notification = Mage::getModel('googlecheckout/notification')
|
68 |
-
->setSerialNumber($serialNumber)
|
69 |
-
->loadNotificationData();
|
70 |
-
|
71 |
-
if ($notification->getStartedAt()) {
|
72 |
-
if ($notification->isProcessed()) {
|
73 |
-
$this->getGResponse()->SendAck();
|
74 |
-
return;
|
75 |
-
}
|
76 |
-
if ($notification->isTimeout()) {
|
77 |
-
$notification->updateProcess();
|
78 |
-
} else {
|
79 |
-
$this->getGResponse()->SendServerErrorStatus();
|
80 |
-
return;
|
81 |
-
}
|
82 |
-
} else {
|
83 |
-
$notification->startProcess();
|
84 |
-
}
|
85 |
-
|
86 |
-
$method = '_response' . uc_words($root, '', '-');
|
87 |
-
if (method_exists($this, $method)) {
|
88 |
-
ob_start();
|
89 |
-
|
90 |
-
try {
|
91 |
-
$this->$method();
|
92 |
-
$notification->stopProcess();
|
93 |
-
} catch (Exception $e) {
|
94 |
-
$this->getGResponse()->log->logError($e->__toString());
|
95 |
-
}
|
96 |
-
|
97 |
-
$debugData['result'] = ob_get_flush();
|
98 |
-
$this->getApi()->debugData($debugData);
|
99 |
-
} else {
|
100 |
-
$this->getGResponse()->SendBadRequestStatus("Invalid or not supported Message");
|
101 |
-
}
|
102 |
-
|
103 |
-
return $this;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Load quote from request and make sure the proper payment method is set
|
108 |
-
*
|
109 |
-
* @return Mage_Sales_Model_Quote
|
110 |
-
*/
|
111 |
-
protected function _loadQuote()
|
112 |
-
{
|
113 |
-
$quoteId = $this->getData('root/shopping-cart/merchant-private-data/quote-id/VALUE');
|
114 |
-
$storeId = $this->getData('root/shopping-cart/merchant-private-data/store-id/VALUE');
|
115 |
-
$quote = Mage::getModel('sales/quote')
|
116 |
-
->setStoreId($storeId)
|
117 |
-
->load($quoteId);
|
118 |
-
if ($quote->isVirtual()) {
|
119 |
-
$quote->getBillingAddress()->setPaymentMethod('googlecheckout');
|
120 |
-
} else {
|
121 |
-
$quote->getShippingAddress()->setPaymentMethod('googlecheckout');
|
122 |
-
}
|
123 |
-
return $quote;
|
124 |
-
}
|
125 |
-
|
126 |
-
protected function _getApiUrl()
|
127 |
-
{
|
128 |
-
return null;
|
129 |
-
}
|
130 |
-
|
131 |
-
protected function getGoogleOrderNumber()
|
132 |
-
{
|
133 |
-
return $this->getData('root/google-order-number/VALUE');
|
134 |
-
}
|
135 |
-
|
136 |
-
protected function _responseRequestReceived()
|
137 |
-
{
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
protected function _responseError()
|
142 |
-
{
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
protected function _responseDiagnosis()
|
147 |
-
{
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
protected function _responseCheckoutRedirect()
|
152 |
-
{
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Calculate available shipping amounts and taxes
|
158 |
-
*/
|
159 |
-
protected function _responseMerchantCalculationCallback()
|
160 |
-
{
|
161 |
-
$merchantCalculations = new GoogleMerchantCalculations($this->getCurrency());
|
162 |
-
|
163 |
-
$quote = $this->_loadQuote();
|
164 |
-
|
165 |
-
$billingAddress = $quote->getBillingAddress();
|
166 |
-
$address = $quote->getShippingAddress();
|
167 |
-
|
168 |
-
$googleAddress = $this->getData('root/calculate/addresses/anonymous-address');
|
169 |
-
|
170 |
-
$googleAddresses = array();
|
171 |
-
if ( isset( $googleAddress['id'] ) ) {
|
172 |
-
$googleAddresses[] = $googleAddress;
|
173 |
-
} else {
|
174 |
-
$googleAddresses = $googleAddress;
|
175 |
-
}
|
176 |
-
|
177 |
-
$methods = Mage::getStoreConfig('google/checkout_shipping_merchant/allowed_methods', $this->getStoreId());
|
178 |
-
$methods = unserialize($methods);
|
179 |
-
$limitCarrier = array();
|
180 |
-
foreach ($methods['method'] as $method) {
|
181 |
-
if ($method) {
|
182 |
-
list($carrierCode, $methodCode) = explode('/', $method);
|
183 |
-
$limitCarrier[$carrierCode] = $carrierCode;
|
184 |
-
}
|
185 |
-
}
|
186 |
-
$limitCarrier = array_values($limitCarrier);
|
187 |
-
|
188 |
-
foreach($googleAddresses as $googleAddress) {
|
189 |
-
$addressId = $googleAddress['id'];
|
190 |
-
$regionCode = $googleAddress['region']['VALUE'];
|
191 |
-
$countryCode = $googleAddress['country-code']['VALUE'];
|
192 |
-
$regionModel = Mage::getModel('directory/region')->loadByCode($regionCode, $countryCode);
|
193 |
-
$regionId = $regionModel->getId();
|
194 |
-
|
195 |
-
$address->setCountryId($countryCode)
|
196 |
-
->setRegion($regionCode)
|
197 |
-
->setRegionId($regionId)
|
198 |
-
->setCity($googleAddress['city']['VALUE'])
|
199 |
-
->setPostcode($googleAddress['postal-code']['VALUE'])
|
200 |
-
->setLimitCarrier($limitCarrier);
|
201 |
-
$billingAddress->setCountryId($countryCode)
|
202 |
-
->setRegion($regionCode)
|
203 |
-
->setRegionId($regionId)
|
204 |
-
->setCity($googleAddress['city']['VALUE'])
|
205 |
-
->setPostcode($googleAddress['postal-code']['VALUE'])
|
206 |
-
->setLimitCarrier($limitCarrier);
|
207 |
-
|
208 |
-
$billingAddress->collectTotals();
|
209 |
-
$shippingTaxClass = $this->_getTaxClassForShipping($quote);
|
210 |
-
|
211 |
-
$gRequestMethods = $this->getData('root/calculate/shipping/method');
|
212 |
-
if ($gRequestMethods) {
|
213 |
-
// Make stable format of $gRequestMethods for convenient usage
|
214 |
-
if (array_key_exists('VALUE', $gRequestMethods)) {
|
215 |
-
$gRequestMethods = array($gRequestMethods);
|
216 |
-
}
|
217 |
-
|
218 |
-
// Form list of mapping Google method names to applicable address rates
|
219 |
-
$rates = array();
|
220 |
-
$address->setCollectShippingRates(true)
|
221 |
-
->collectShippingRates();
|
222 |
-
foreach ($address->getAllShippingRates() as $rate) {
|
223 |
-
if ($rate instanceof Mage_Shipping_Model_Rate_Result_Error) {
|
224 |
-
continue;
|
225 |
-
}
|
226 |
-
$methodName = sprintf('%s - %s', $rate->getCarrierTitle(), $rate->getMethodTitle());
|
227 |
-
$rates[$methodName] = $rate;
|
228 |
-
}
|
229 |
-
|
230 |
-
foreach ($gRequestMethods as $method) {
|
231 |
-
$result = new GoogleResult($addressId);
|
232 |
-
$methodName = $method['name'];
|
233 |
-
|
234 |
-
if (isset($rates[$methodName])) {
|
235 |
-
$rate = $rates[$methodName];
|
236 |
-
|
237 |
-
$address->setShippingMethod($rate->getCode())
|
238 |
-
->setLimitCarrier($rate->getCarrier())
|
239 |
-
->setCollectShippingRates(true)
|
240 |
-
->collectTotals();
|
241 |
-
$shippingRate = $address->getBaseShippingAmount() - $address->getBaseShippingDiscountAmount();
|
242 |
-
$result->SetShippingDetails($methodName, $shippingRate, 'true');
|
243 |
-
|
244 |
-
if ($this->getData('root/calculate/tax/VALUE') == 'true') {
|
245 |
-
$taxAmount = $address->getBaseTaxAmount();
|
246 |
-
$taxAmount += $billingAddress->getBaseTaxAmount();
|
247 |
-
$result->setTaxDetails($taxAmount);
|
248 |
-
}
|
249 |
-
} else {
|
250 |
-
if ($shippingTaxClass &&
|
251 |
-
$this->getData('root/calculate/tax/VALUE') == 'true') {
|
252 |
-
$i = 1;
|
253 |
-
$price = Mage::getStoreConfig(
|
254 |
-
'google/checkout_shipping_flatrate/price_'.$i,
|
255 |
-
$quote->getStoreId()
|
256 |
-
);
|
257 |
-
$price = number_format($price, 2, '.','');
|
258 |
-
$price = (float) Mage::helper('tax')->getShippingPrice($price, false, false);
|
259 |
-
$address->setShippingMethod(null);
|
260 |
-
$address->setCollectShippingRates(true)->collectTotals();
|
261 |
-
$billingAddress->setCollectShippingRates(true)->collectTotals();
|
262 |
-
$address->setBaseShippingAmount($price);
|
263 |
-
$address->setShippingAmount(
|
264 |
-
$this->_reCalculateToStoreCurrency($price, $quote)
|
265 |
-
);
|
266 |
-
$this->_applyShippingTaxClass($address, $shippingTaxClass);
|
267 |
-
$taxAmount = $address->getBaseTaxAmount();
|
268 |
-
$taxAmount += $billingAddress->getBaseTaxAmount();
|
269 |
-
$result->SetShippingDetails(
|
270 |
-
$methodName,
|
271 |
-
$price - $address->getBaseShippingDiscountAmount(),
|
272 |
-
'true'
|
273 |
-
);
|
274 |
-
$result->setTaxDetails($taxAmount);
|
275 |
-
$i++;
|
276 |
-
} else {
|
277 |
-
$result->SetShippingDetails($methodName, 0, 'false');
|
278 |
-
}
|
279 |
-
}
|
280 |
-
$merchantCalculations->AddResult($result);
|
281 |
-
}
|
282 |
-
|
283 |
-
} else if ($this->getData('root/calculate/tax/VALUE') == 'true') {
|
284 |
-
$address->setShippingMethod(null);
|
285 |
-
$address->setCollectShippingRates(true)->collectTotals();
|
286 |
-
$billingAddress->setCollectShippingRates(true)->collectTotals();
|
287 |
-
if (!Mage::helper('googlecheckout')->isShippingCarrierActive($this->getStoreId())) {
|
288 |
-
$this->_applyShippingTaxClass($address, $shippingTaxClass);
|
289 |
-
}
|
290 |
-
|
291 |
-
$taxAmount = $address->getBaseTaxAmount();
|
292 |
-
$taxAmount += $billingAddress->getBaseTaxAmount();
|
293 |
-
|
294 |
-
$result = new GoogleResult($addressId);
|
295 |
-
$result->setTaxDetails($taxAmount);
|
296 |
-
$merchantCalculations->addResult($result);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
$this->getGResponse()->ProcessMerchantCalculations($merchantCalculations);
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Apply shipping tax class
|
305 |
-
*
|
306 |
-
* @param Varien_Object $qAddress
|
307 |
-
* @param mixed $shippingTaxClass
|
308 |
-
*/
|
309 |
-
protected function _applyShippingTaxClass($qAddress, $shippingTaxClass)
|
310 |
-
{
|
311 |
-
if (!$shippingTaxClass) {
|
312 |
-
return;
|
313 |
-
}
|
314 |
-
|
315 |
-
$quote = $qAddress->getQuote();
|
316 |
-
$taxCalculationModel = Mage::getSingleton('tax/calculation');
|
317 |
-
$request = $taxCalculationModel->getRateRequest($qAddress);
|
318 |
-
$rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass));
|
319 |
-
|
320 |
-
if (!Mage::helper('tax')->shippingPriceIncludesTax()) {
|
321 |
-
$shippingTax = $qAddress->getShippingAmount() * $rate/100;
|
322 |
-
$shippingBaseTax= $qAddress->getBaseShippingAmount() * $rate/100;
|
323 |
-
} else {
|
324 |
-
$shippingTax = $qAddress->getShippingTaxAmount();
|
325 |
-
$shippingBaseTax= $qAddress->getBaseShippingTaxAmount();
|
326 |
-
}
|
327 |
-
|
328 |
-
$shippingTax = $quote->getStore()->roundPrice($shippingTax);
|
329 |
-
$shippingBaseTax= $quote->getStore()->roundPrice($shippingBaseTax);
|
330 |
-
|
331 |
-
$qAddress->setTaxAmount($qAddress->getTaxAmount() + $shippingTax);
|
332 |
-
$qAddress->setBaseTaxAmount($qAddress->getBaseTaxAmount() + $shippingBaseTax);
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Process new order creation notification from google.
|
337 |
-
* Convert customer quote to order
|
338 |
-
*/
|
339 |
-
protected function _responseNewOrderNotification()
|
340 |
-
{
|
341 |
-
$this->getGResponse()->SendAck();
|
342 |
-
|
343 |
-
// LOOK FOR EXISTING ORDER TO AVOID DUPLICATES
|
344 |
-
$orders = Mage::getModel('sales/order')->getCollection()
|
345 |
-
->addAttributeToFilter('ext_order_id', $this->getGoogleOrderNumber());
|
346 |
-
if (count($orders)) {
|
347 |
-
return;
|
348 |
-
}
|
349 |
-
|
350 |
-
// IMPORT GOOGLE ORDER DATA INTO QUOTE
|
351 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
352 |
-
$quote = $this->_loadQuote();
|
353 |
-
$quote->setIsActive(true)->reserveOrderId();
|
354 |
-
|
355 |
-
Mage::dispatchEvent('googlecheckout_create_order_before', array('quote' => $quote));
|
356 |
-
if ($quote->getErrorMessage()) {
|
357 |
-
$this->getGRequest()->SendCancelOrder($this->getGoogleOrderNumber(),
|
358 |
-
$this->__('Order creation error'),
|
359 |
-
$quote->getErrorMessage()
|
360 |
-
);
|
361 |
-
return;
|
362 |
-
}
|
363 |
-
|
364 |
-
$storeId = $quote->getStoreId();
|
365 |
-
|
366 |
-
Mage::app()->setCurrentStore(Mage::app()->getStore($storeId));
|
367 |
-
if ($quote->getQuoteCurrencyCode() != $quote->getBaseCurrencyCode()) {
|
368 |
-
Mage::app()->getStore()->setCurrentCurrencyCode($quote->getQuoteCurrencyCode());
|
369 |
-
}
|
370 |
-
|
371 |
-
$billing = $this->_importGoogleAddress($this->getData('root/buyer-billing-address'));
|
372 |
-
$quote->setBillingAddress($billing);
|
373 |
-
|
374 |
-
$shipping = $this->_importGoogleAddress($this->getData('root/buyer-shipping-address'));
|
375 |
-
|
376 |
-
$quote->setShippingAddress($shipping);
|
377 |
-
|
378 |
-
$this->_importGoogleTotals($quote->getShippingAddress());
|
379 |
-
|
380 |
-
$quote->getPayment()->importData(array('method'=>'googlecheckout'));
|
381 |
-
|
382 |
-
$taxMessage = $this->_applyCustomTax($quote->getShippingAddress());
|
383 |
-
|
384 |
-
// CONVERT QUOTE TO ORDER
|
385 |
-
$convertQuote = Mage::getSingleton('sales/convert_quote');
|
386 |
-
|
387 |
-
/* @var $order Mage_Sales_Model_Order */
|
388 |
-
$order = $convertQuote->toOrder($quote);
|
389 |
-
|
390 |
-
if ($quote->isVirtual()) {
|
391 |
-
$convertQuote->addressToOrder($quote->getBillingAddress(), $order);
|
392 |
-
} else {
|
393 |
-
$convertQuote->addressToOrder($quote->getShippingAddress(), $order);
|
394 |
-
}
|
395 |
-
|
396 |
-
$order->setExtOrderId($this->getGoogleOrderNumber());
|
397 |
-
$order->setExtCustomerId($this->getData('root/buyer-id/VALUE'));
|
398 |
-
|
399 |
-
if (!$order->getCustomerEmail()) {
|
400 |
-
$order->setCustomerEmail($billing->getEmail())
|
401 |
-
->setCustomerPrefix($billing->getPrefix())
|
402 |
-
->setCustomerFirstname($billing->getFirstname())
|
403 |
-
->setCustomerMiddlename($billing->getMiddlename())
|
404 |
-
->setCustomerLastname($billing->getLastname())
|
405 |
-
->setCustomerSuffix($billing->getSuffix());
|
406 |
-
}
|
407 |
-
|
408 |
-
$order->setBillingAddress($convertQuote->addressToOrderAddress($quote->getBillingAddress()));
|
409 |
-
|
410 |
-
if (!$quote->isVirtual()) {
|
411 |
-
$order->setShippingAddress($convertQuote->addressToOrderAddress($quote->getShippingAddress()));
|
412 |
-
}
|
413 |
-
#$order->setPayment($convertQuote->paymentToOrderPayment($quote->getPayment()));
|
414 |
-
|
415 |
-
foreach ($quote->getAllItems() as $item) {
|
416 |
-
$orderItem = $convertQuote->itemToOrderItem($item);
|
417 |
-
if ($item->getParentItem()) {
|
418 |
-
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
419 |
-
}
|
420 |
-
$order->addItem($orderItem);
|
421 |
-
}
|
422 |
-
|
423 |
-
/*
|
424 |
-
* Adding transaction for correct transaction information displaying on order view at back end.
|
425 |
-
* It has no influence on api interaction logic.
|
426 |
-
*/
|
427 |
-
$payment = Mage::getModel('sales/order_payment')
|
428 |
-
->setMethod('googlecheckout')
|
429 |
-
->setTransactionId($this->getGoogleOrderNumber())
|
430 |
-
->setIsTransactionClosed(false);
|
431 |
-
$order->setPayment($payment);
|
432 |
-
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
433 |
-
$order->setCanShipPartiallyItem(false);
|
434 |
-
|
435 |
-
$emailAllowed = ($this->getData('root/buyer-marketing-preferences/email-allowed/VALUE') === 'true');
|
436 |
-
|
437 |
-
$emailStr = $emailAllowed ? $this->__('Yes') : $this->__('No');
|
438 |
-
$message = $this->__('Google Order Number: %s', '<strong>' . $this->getGoogleOrderNumber() . '</strong><br />')
|
439 |
-
. $this->__('Google Buyer ID: %s', '<strong>' . $this->getData('root/buyer-id/VALUE') . '</strong><br />')
|
440 |
-
. $this->__('Is Buyer Willing to Receive Marketing Emails: %s', '<strong>' . $emailStr . '</strong>');
|
441 |
-
if ($taxMessage) {
|
442 |
-
$message .= $this->__('<br />Warning: <strong>%s</strong><br />', $taxMessage);
|
443 |
-
}
|
444 |
-
|
445 |
-
$order->addStatusToHistory($order->getStatus(), $message);
|
446 |
-
$order->place();
|
447 |
-
$order->save();
|
448 |
-
$order->sendNewOrderEmail();
|
449 |
-
Mage::dispatchEvent('googlecheckout_save_order_after', array('order' => $order));
|
450 |
-
|
451 |
-
$quote->setIsActive(false)->save();
|
452 |
-
|
453 |
-
if ($emailAllowed) {
|
454 |
-
$customer = $quote->getCustomer();
|
455 |
-
if ($customer && $customer->getId()) {
|
456 |
-
$customer->setIsSubscribed(true);
|
457 |
-
Mage::getModel('newsletter/subscriber')->subscribeCustomer($customer);
|
458 |
-
} else {
|
459 |
-
Mage::getModel('newsletter/subscriber')->subscribe($order->getCustomerEmail());
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $quote));
|
464 |
-
|
465 |
-
$this->getGRequest()->SendMerchantOrderNumber($order->getExtOrderId(), $order->getIncrementId());
|
466 |
-
}
|
467 |
-
|
468 |
-
/**
|
469 |
-
* If tax value differs tax which is setted on magento,
|
470 |
-
* apply Google tax and recollect quote
|
471 |
-
*
|
472 |
-
* @param Varien_Object $qAddress
|
473 |
-
* @return string | false
|
474 |
-
*/
|
475 |
-
protected function _applyCustomTax($qAddress)
|
476 |
-
{
|
477 |
-
$quote = $qAddress->getQuote();
|
478 |
-
$qTaxAmount = $qAddress->getBaseTaxAmount();
|
479 |
-
$newTaxAmount = $this->getData('root/order-adjustment/total-tax/VALUE');
|
480 |
-
|
481 |
-
if ($qTaxAmount != $newTaxAmount) {
|
482 |
-
$taxQuotient = (int) $qTaxAmount ? $newTaxAmount/$qTaxAmount : $newTaxAmount;
|
483 |
-
|
484 |
-
$qAddress->setTaxAmount(
|
485 |
-
$this->_reCalculateToStoreCurrency($newTaxAmount, $quote)
|
486 |
-
);
|
487 |
-
$qAddress->setBaseTaxAmount($newTaxAmount);
|
488 |
-
|
489 |
-
$grandTotal = $qAddress->getBaseGrandTotal() - $qTaxAmount + $newTaxAmount;
|
490 |
-
$qAddress->setGrandTotal(
|
491 |
-
$this->_reCalculateToStoreCurrency($grandTotal, $quote)
|
492 |
-
);
|
493 |
-
$qAddress->setBaseGrandTotal($grandTotal);
|
494 |
-
|
495 |
-
$subtotalInclTax = $qAddress->getSubtotalInclTax() - $qTaxAmount + $newTaxAmount;
|
496 |
-
$qAddress->setSubtotalInclTax($subtotalInclTax);
|
497 |
-
|
498 |
-
foreach ($quote->getAllVisibleItems() as $item) {
|
499 |
-
if ($item->getParentItem()) {
|
500 |
-
continue;
|
501 |
-
}
|
502 |
-
if ($item->getTaxAmount()) {
|
503 |
-
$item->setTaxAmount($item->getTaxAmount()*$taxQuotient);
|
504 |
-
$item->setBaseTaxAmount($item->getBaseTaxAmount()*$taxQuotient);
|
505 |
-
$taxPercent = round(($item->getTaxAmount()/$item->getRowTotal())*100);
|
506 |
-
$item->setTaxPercent($taxPercent);
|
507 |
-
}
|
508 |
-
}
|
509 |
-
|
510 |
-
$grandTotal = $quote->getBaseGrandTotal() - $qTaxAmount + $newTaxAmount;
|
511 |
-
$quote->setGrandTotal(
|
512 |
-
$this->_reCalculateToStoreCurrency($grandTotal, $quote)
|
513 |
-
);
|
514 |
-
$quote->setBaseGrandTotal($grandTotal);
|
515 |
-
|
516 |
-
$message = $this->__('The tax amount has been applied based on the information received from Google Checkout, because tax amount received from Google Checkout is different from the calculated tax amount');
|
517 |
-
return $message;
|
518 |
-
}
|
519 |
-
|
520 |
-
return false;
|
521 |
-
}
|
522 |
-
|
523 |
-
/**
|
524 |
-
* Import address data from google request to address object
|
525 |
-
*
|
526 |
-
* @param array | Varien_Object $gAddress
|
527 |
-
* @param Varien_Object $qAddress
|
528 |
-
* @return Varien_Object
|
529 |
-
*/
|
530 |
-
protected function _importGoogleAddress($gAddress, Varien_Object $qAddress=null)
|
531 |
-
{
|
532 |
-
if (is_array($gAddress)) {
|
533 |
-
$gAddress = new Varien_Object($gAddress);
|
534 |
-
}
|
535 |
-
|
536 |
-
if (!$qAddress) {
|
537 |
-
$qAddress = Mage::getModel('sales/quote_address');
|
538 |
-
}
|
539 |
-
$nameArr = $gAddress->getData('structured-name');
|
540 |
-
if ($nameArr) {
|
541 |
-
$qAddress->setFirstname($nameArr['first-name']['VALUE'])
|
542 |
-
->setLastname($nameArr['last-name']['VALUE']);
|
543 |
-
} else {
|
544 |
-
$nameArr = explode(' ', $gAddress->getData('contact-name/VALUE'), 2);
|
545 |
-
$qAddress->setFirstname($nameArr[0]);
|
546 |
-
if (!empty($nameArr[1])) {
|
547 |
-
$qAddress->setLastname($nameArr[1]);
|
548 |
-
}
|
549 |
-
}
|
550 |
-
$region = Mage::getModel('directory/region')->loadByCode(
|
551 |
-
$gAddress->getData('region/VALUE'),
|
552 |
-
$gAddress->getData('country-code/VALUE')
|
553 |
-
);
|
554 |
-
|
555 |
-
$qAddress->setCompany($gAddress->getData('company-name/VALUE'))
|
556 |
-
->setEmail($gAddress->getData('email/VALUE'))
|
557 |
-
->setStreet(trim($gAddress->getData('address1/VALUE') . "\n" . $gAddress->getData('address2/VALUE')))
|
558 |
-
->setCity($gAddress->getData('city/VALUE'))
|
559 |
-
->setRegion($gAddress->getData('region/VALUE'))
|
560 |
-
->setRegionId($region->getId())
|
561 |
-
->setPostcode($gAddress->getData('postal-code/VALUE'))
|
562 |
-
->setCountryId($gAddress->getData('country-code/VALUE'))
|
563 |
-
->setTelephone($gAddress->getData('phone/VALUE'))
|
564 |
-
->setFax($gAddress->getData('fax/VALUE'));
|
565 |
-
|
566 |
-
return $qAddress;
|
567 |
-
}
|
568 |
-
|
569 |
-
/**
|
570 |
-
* Returns array of possible shipping methods combinations
|
571 |
-
* Includes internal GoogleCheckout shipping methods, that can be created
|
572 |
-
* after successful Google Checkout
|
573 |
-
*
|
574 |
-
* @return array
|
575 |
-
*/
|
576 |
-
protected function _getShippingInfos($storeId = null)
|
577 |
-
{
|
578 |
-
$cacheKey = ($storeId === null) ? 'nofilter' : $storeId;
|
579 |
-
if (!isset($this->_cachedShippingInfo[$cacheKey])) {
|
580 |
-
/* @var $shipping Mage_Shipping_Model_Shipping */
|
581 |
-
$shipping = Mage::getModel('shipping/shipping');
|
582 |
-
$carriers = Mage::getStoreConfig('carriers', $storeId);
|
583 |
-
$infos = array();
|
584 |
-
|
585 |
-
foreach (array_keys($carriers) as $carrierCode) {
|
586 |
-
$carrier = $shipping->getCarrierByCode($carrierCode);
|
587 |
-
if (!$carrier) {
|
588 |
-
continue;
|
589 |
-
}
|
590 |
-
|
591 |
-
if ($carrierCode == 'googlecheckout') {
|
592 |
-
// Add info about internal google checkout methods
|
593 |
-
$methods = array_merge($carrier->getAllowedMethods(), $carrier->getInternallyAllowedMethods());
|
594 |
-
$carrierName = 'Google Checkout';
|
595 |
-
} else {
|
596 |
-
$methods = $carrier->getAllowedMethods();
|
597 |
-
$carrierName = Mage::getStoreConfig('carriers/' . $carrierCode . '/title', $storeId);
|
598 |
-
}
|
599 |
-
|
600 |
-
foreach ($methods as $methodCode => $methodName) {
|
601 |
-
$code = $carrierCode . '_' . $methodCode;
|
602 |
-
$name = sprintf('%s - %s', $carrierName, $methodName);
|
603 |
-
$infos[$code] = array(
|
604 |
-
'code' => $code,
|
605 |
-
'name' => $name, // Internal name for google checkout api - to distinguish it in google requests
|
606 |
-
'carrier' => $carrierCode,
|
607 |
-
'carrier_title' => $carrierName,
|
608 |
-
'method' => $methodCode,
|
609 |
-
'method_title' => $methodName
|
610 |
-
);
|
611 |
-
}
|
612 |
-
}
|
613 |
-
$this->_cachedShippingInfo[$cacheKey] = $infos;
|
614 |
-
}
|
615 |
-
|
616 |
-
return $this->_cachedShippingInfo[$cacheKey];
|
617 |
-
}
|
618 |
-
|
619 |
-
/**
|
620 |
-
* Return shipping method code by shipping method name received from Google
|
621 |
-
*
|
622 |
-
* @param string $name
|
623 |
-
* @param int|string|Mage_Core_Model_Store $storeId
|
624 |
-
* @return string|false
|
625 |
-
*/
|
626 |
-
protected function _getShippingMethodByName($name, $storeId = null)
|
627 |
-
{
|
628 |
-
$code = false;
|
629 |
-
$infos = $this->_getShippingInfos($storeId);
|
630 |
-
foreach ($infos as $info) {
|
631 |
-
if ($info['name'] == $name) {
|
632 |
-
$code = $info['code'];
|
633 |
-
break;
|
634 |
-
}
|
635 |
-
}
|
636 |
-
return $code;
|
637 |
-
}
|
638 |
-
|
639 |
-
/**
|
640 |
-
* Creates rate by method code
|
641 |
-
* Sets shipping rate's accurate description, titles and so on,
|
642 |
-
* so it will get in order description properly
|
643 |
-
*
|
644 |
-
* @param string $code
|
645 |
-
* @return Mage_Sales_Model_Quote_Address_Rate
|
646 |
-
*/
|
647 |
-
protected function _createShippingRate($code, $storeId = null)
|
648 |
-
{
|
649 |
-
$rate = Mage::getModel('sales/quote_address_rate')
|
650 |
-
->setCode($code);
|
651 |
-
|
652 |
-
$infos = $this->_getShippingInfos($storeId);
|
653 |
-
if (isset($infos[$code])) {
|
654 |
-
$info = $infos[$code];
|
655 |
-
$rate->setCarrier($info['carrier'])
|
656 |
-
->setCarrierTitle($info['carrier_title'])
|
657 |
-
->setMethod($info['method'])
|
658 |
-
->setMethodTitle($info['method_title']);
|
659 |
-
}
|
660 |
-
|
661 |
-
return $rate;
|
662 |
-
}
|
663 |
-
|
664 |
-
/**
|
665 |
-
* Import totals information from google request to quote address
|
666 |
-
*
|
667 |
-
* @param Varien_Object $qAddress
|
668 |
-
*/
|
669 |
-
protected function _importGoogleTotals($qAddress)
|
670 |
-
{
|
671 |
-
$quote = $qAddress->getQuote();
|
672 |
-
$qAddress->setTaxAmount(
|
673 |
-
$this->_reCalculateToStoreCurrency($this->getData('root/order-adjustment/total-tax/VALUE'), $quote)
|
674 |
-
);
|
675 |
-
$qAddress->setBaseTaxAmount($this->getData('root/order-adjustment/total-tax/VALUE'));
|
676 |
-
|
677 |
-
$method = null;
|
678 |
-
$prefix = 'root/order-adjustment/shipping/';
|
679 |
-
if (null !== ($shipping = $this->getData($prefix . 'carrier-calculated-shipping-adjustment'))) {
|
680 |
-
$method = 'googlecheckout_carrier';
|
681 |
-
} else if (null !== ($shipping = $this->getData($prefix . 'merchant-calculated-shipping-adjustment'))) {
|
682 |
-
$method = 'googlecheckout_merchant';
|
683 |
-
} else if (null !== ($shipping = $this->getData($prefix . 'flat-rate-shipping-adjustment'))) {
|
684 |
-
$method = 'googlecheckout_flatrate';
|
685 |
-
} else if (null !== ($shipping = $this->getData($prefix . 'pickup-shipping-adjustment'))) {
|
686 |
-
$method = 'googlecheckout_pickup';
|
687 |
-
}
|
688 |
-
|
689 |
-
if ($method) {
|
690 |
-
Mage::getSingleton('tax/config')->setShippingPriceIncludeTax(false);
|
691 |
-
$rate = $this->_createShippingRate($method)
|
692 |
-
->setMethodTitle($shipping['shipping-name']['VALUE'])
|
693 |
-
->setPrice($shipping['shipping-cost']['VALUE']);
|
694 |
-
$qAddress->addShippingRate($rate)
|
695 |
-
->setShippingMethod($method)
|
696 |
-
->setShippingDescription($shipping['shipping-name']['VALUE']);
|
697 |
-
// We get from Google price with discounts applied via merchant calculations
|
698 |
-
$qAddress->setShippingAmountForDiscount(0);
|
699 |
-
|
700 |
-
/*if (!Mage::helper('tax')->shippingPriceIncludesTax($quote->getStore())) {
|
701 |
-
$includingTax = Mage::helper('tax')->getShippingPrice(
|
702 |
-
$excludingTax, true, $qAddress, $quote->getCustomerTaxClassId()
|
703 |
-
);
|
704 |
-
$shippingTax = $includingTax - $excludingTax;
|
705 |
-
$qAddress->setShippingTaxAmount($this->_reCalculateToStoreCurrency($shippingTax, $quote))
|
706 |
-
->setBaseShippingTaxAmount($shippingTax)
|
707 |
-
->setShippingInclTax($includingTax)
|
708 |
-
->setBaseShippingInclTax($this->_reCalculateToStoreCurrency($includingTax, $quote));
|
709 |
-
} else {
|
710 |
-
if ($method == 'googlecheckout_carrier') {
|
711 |
-
$qAddress->setShippingTaxAmount(0)
|
712 |
-
->setBaseShippingTaxAmount(0);
|
713 |
-
}
|
714 |
-
}*/
|
715 |
-
} else {
|
716 |
-
$qAddress->setShippingMethod(null);
|
717 |
-
}
|
718 |
-
|
719 |
-
|
720 |
-
$qAddress->setGrandTotal(
|
721 |
-
$this->_reCalculateToStoreCurrency($this->getData('root/order-total/VALUE'), $quote)
|
722 |
-
);
|
723 |
-
$qAddress->setBaseGrandTotal($this->getData('root/order-total/VALUE'));
|
724 |
-
}
|
725 |
-
|
726 |
-
/**
|
727 |
-
* Order getter
|
728 |
-
*
|
729 |
-
* @return Mage_Sales_Model_Order
|
730 |
-
*/
|
731 |
-
public function getOrder()
|
732 |
-
{
|
733 |
-
if (!$this->hasData('order')) {
|
734 |
-
$order = Mage::getModel('sales/order')
|
735 |
-
->loadByAttribute('ext_order_id', $this->getGoogleOrderNumber());
|
736 |
-
if (!$order->getId()) {
|
737 |
-
Mage::throwException('Invalid Order: ' . $this->getGoogleOrderNumber());
|
738 |
-
}
|
739 |
-
$this->setData('order', $order);
|
740 |
-
}
|
741 |
-
return $this->getData('order');
|
742 |
-
}
|
743 |
-
|
744 |
-
protected function _responseRiskInformationNotification()
|
745 |
-
{
|
746 |
-
$this->getGResponse()->SendAck();
|
747 |
-
|
748 |
-
$order = $this->getOrder();
|
749 |
-
$payment = $order->getPayment();
|
750 |
-
|
751 |
-
$order
|
752 |
-
->setRemoteIp($this->getData('root/risk-information/ip-address/VALUE'));
|
753 |
-
|
754 |
-
$payment
|
755 |
-
->setCcLast4($this->getData('root/risk-information/partial-cc-number/VALUE'))
|
756 |
-
->setCcAvsStatus($this->getData('root/risk-information/avs-response/VALUE'))
|
757 |
-
->setCcCidStatus($this->getData('root/risk-information/cvn-response/VALUE'));
|
758 |
-
|
759 |
-
$msg = $this->__('Google Risk Information:');
|
760 |
-
$msg .= '<br />' . $this->__('IP Address: %s', '<strong>' . $order->getRemoteIp() . '</strong>');
|
761 |
-
$msg .= '<br />' . $this->__('CC Partial: xxxx-%s', '<strong>' . $payment->getCcLast4() . '</strong>');
|
762 |
-
$msg .= '<br />' . $this->__('AVS Status: %s', '<strong>' . $payment->getCcAvsStatus() . '</strong>');
|
763 |
-
$msg .= '<br />' . $this->__('CID Status: %s', '<strong>' . $payment->getCcCidStatus() . '</strong>');
|
764 |
-
$msg .= '<br />' . $this->__('Eligible for Protection: %s', '<strong>' . ($this->getData('root/risk-information/eligible-for-protection/VALUE')=='true' ? 'Yes' : 'No') . '</strong>');
|
765 |
-
$msg .= '<br />' . $this->__('Buyer Account Age: %s days', '<strong>' . $this->getData('root/risk-information/buyer-account-age/VALUE') . '</strong>');
|
766 |
-
|
767 |
-
$order->addStatusToHistory($order->getStatus(), $msg);
|
768 |
-
$order->save();
|
769 |
-
}
|
770 |
-
|
771 |
-
/**
|
772 |
-
* Process authorization notification
|
773 |
-
*/
|
774 |
-
protected function _responseAuthorizationAmountNotification()
|
775 |
-
{
|
776 |
-
$this->getGResponse()->SendAck();
|
777 |
-
|
778 |
-
$order = $this->getOrder();
|
779 |
-
$payment = $order->getPayment();
|
780 |
-
|
781 |
-
$payment->setAmountAuthorized($this->getData('root/authorization-amount/VALUE'));
|
782 |
-
|
783 |
-
$expDate = $this->getData('root/authorization-expiration-date/VALUE');
|
784 |
-
$expDate = new Zend_Date($expDate);
|
785 |
-
$msg = $this->__('Google Authorization:');
|
786 |
-
$msg .= '<br />' . $this->__('Amount: %s', '<strong>' . $this->_formatAmount($payment->getAmountAuthorized()) . '</strong>');
|
787 |
-
$msg .= '<br />' . $this->__('Expiration: %s', '<strong>' . $expDate->toString() . '</strong>');
|
788 |
-
|
789 |
-
$order->addStatusToHistory($order->getStatus(), $msg);
|
790 |
-
|
791 |
-
$order->setPaymentAuthorizationAmount($payment->getAmountAuthorized());
|
792 |
-
$timestamp = Mage::getModel('core/date')->gmtTimestamp(
|
793 |
-
$this->getData('root/authorization-expiration-date/VALUE')
|
794 |
-
);
|
795 |
-
$order->setPaymentAuthorizationExpiration(
|
796 |
-
$timestamp ? $timestamp : Mage::getModel('core/date')->gmtTimestamp()
|
797 |
-
);
|
798 |
-
|
799 |
-
$order->save();
|
800 |
-
}
|
801 |
-
|
802 |
-
/**
|
803 |
-
* Process charge notification
|
804 |
-
*
|
805 |
-
*/
|
806 |
-
protected function _responseChargeAmountNotification()
|
807 |
-
{
|
808 |
-
$this->getGResponse()->SendAck();
|
809 |
-
|
810 |
-
$order = $this->getOrder();
|
811 |
-
$payment = $order->getPayment();
|
812 |
-
if ($payment->getMethod() !== 'googlecheckout') {
|
813 |
-
return;
|
814 |
-
}
|
815 |
-
|
816 |
-
$latestCharged = $this->getData('root/latest-charge-amount/VALUE');
|
817 |
-
$totalCharged = $this->getData('root/total-charge-amount/VALUE');
|
818 |
-
$payment->setAmountCharged($totalCharged);
|
819 |
-
$order->setIsInProcess(true);
|
820 |
-
|
821 |
-
$msg = $this->__('Google Charge:');
|
822 |
-
$msg .= '<br />' . $this->__('Latest Charge: %s', '<strong>' . $this->_formatAmount($latestCharged) . '</strong>');
|
823 |
-
$msg .= '<br />' . $this->__('Total Charged: %s', '<strong>' . $this->_formatAmount($totalCharged) . '</strong>');
|
824 |
-
|
825 |
-
if (!$order->hasInvoices() && abs($order->getBaseGrandTotal() - $latestCharged) < .0001) {
|
826 |
-
$invoice = $this->_createInvoice();
|
827 |
-
$msg .= '<br />' . $this->__('Invoice Auto-Created: %s', '<strong>' . $invoice->getIncrementId() . '</strong>');
|
828 |
-
}
|
829 |
-
|
830 |
-
$this->_addChildTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
831 |
-
|
832 |
-
$open = Mage_Sales_Model_Order_Invoice::STATE_OPEN;
|
833 |
-
foreach ($order->getInvoiceCollection() as $orderInvoice) {
|
834 |
-
if ($orderInvoice->getState() == $open && $orderInvoice->getBaseGrandTotal() == $latestCharged) {
|
835 |
-
$orderInvoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID)
|
836 |
-
->setTransactionId($this->getGoogleOrderNumber())
|
837 |
-
->save();
|
838 |
-
break;
|
839 |
-
}
|
840 |
-
}
|
841 |
-
|
842 |
-
$order->addStatusToHistory($order->getStatus(), $msg);
|
843 |
-
$order->save();
|
844 |
-
}
|
845 |
-
|
846 |
-
protected function _createInvoice()
|
847 |
-
{
|
848 |
-
$order = $this->getOrder();
|
849 |
-
|
850 |
-
$invoice = $order->prepareInvoice()
|
851 |
-
->setTransactionId($this->getGoogleOrderNumber())
|
852 |
-
->addComment(Mage::helper('googlecheckout')->__('Auto-generated from GoogleCheckout Charge'))
|
853 |
-
->register()
|
854 |
-
->pay();
|
855 |
-
|
856 |
-
$transactionSave = Mage::getModel('core/resource_transaction')
|
857 |
-
->addObject($invoice)
|
858 |
-
->addObject($invoice->getOrder());
|
859 |
-
|
860 |
-
$transactionSave->save();
|
861 |
-
|
862 |
-
return $invoice;
|
863 |
-
}
|
864 |
-
|
865 |
-
protected function _createShipment()
|
866 |
-
{
|
867 |
-
$order = $this->getOrder();
|
868 |
-
$shipment = $order->prepareShipment();
|
869 |
-
if ($shipment) {
|
870 |
-
$shipment->register();
|
871 |
-
|
872 |
-
$order->setIsInProcess(true);
|
873 |
-
|
874 |
-
$transactionSave = Mage::getModel('core/resource_transaction')
|
875 |
-
->addObject($shipment)
|
876 |
-
->addObject($shipment->getOrder())
|
877 |
-
->save();
|
878 |
-
}
|
879 |
-
|
880 |
-
return $shipment;
|
881 |
-
}
|
882 |
-
|
883 |
-
/**
|
884 |
-
* Process chargeback notification
|
885 |
-
*/
|
886 |
-
protected function _responseChargebackAmountNotification()
|
887 |
-
{
|
888 |
-
$this->getGResponse()->SendAck();
|
889 |
-
|
890 |
-
$latestChargeback = $this->getData('root/latest-chargeback-amount/VALUE');
|
891 |
-
$totalChargeback = $this->getData('root/total-chargeback-amount/VALUE');
|
892 |
-
|
893 |
-
$order = $this->getOrder();
|
894 |
-
if ($order->getBaseGrandTotal() == $totalChargeback) {
|
895 |
-
$creditmemo = Mage::getModel('sales/service_order', $order)
|
896 |
-
->prepareCreditmemo()
|
897 |
-
->setPaymentRefundDisallowed(true)
|
898 |
-
->setAutomaticallyCreated(true)
|
899 |
-
->register();
|
900 |
-
|
901 |
-
$creditmemo->addComment($this->__('Credit memo has been created automatically'));
|
902 |
-
$creditmemo->save();
|
903 |
-
}
|
904 |
-
$msg = $this->__('Google Chargeback:');
|
905 |
-
$msg .= '<br />' . $this->__('Latest Chargeback: %s', '<strong>' . $this->_formatAmount($latestChargeback) . '</strong>');
|
906 |
-
$msg .= '<br />' . $this->__('Total Chargeback: %s', '<strong>' . $this->_formatAmount($totalChargeback) . '</strong>');
|
907 |
-
|
908 |
-
$this->_addChildTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
|
909 |
-
Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
910 |
-
|
911 |
-
$order->addStatusToHistory($order->getStatus(), $msg);
|
912 |
-
$order->save();
|
913 |
-
}
|
914 |
-
|
915 |
-
/**
|
916 |
-
* Process refund notification
|
917 |
-
*/
|
918 |
-
protected function _responseRefundAmountNotification()
|
919 |
-
{
|
920 |
-
$this->getGResponse()->SendAck();
|
921 |
-
|
922 |
-
$latestRefunded = $this->getData('root/latest-refund-amount/VALUE');
|
923 |
-
$totalRefunded = $this->getData('root/total-refund-amount/VALUE');
|
924 |
-
|
925 |
-
$order = $this->getOrder();
|
926 |
-
$amountRefundLeft = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded()
|
927 |
-
- $order->getBaseAdjustmentNegative();
|
928 |
-
if (abs($amountRefundLeft) < .0001) {
|
929 |
-
return;
|
930 |
-
}
|
931 |
-
if ($amountRefundLeft < $latestRefunded) {
|
932 |
-
$latestRefunded = $amountRefundLeft;
|
933 |
-
$totalRefunded = $order->getBaseGrandTotal();
|
934 |
-
}
|
935 |
-
|
936 |
-
if ($order->getBaseTotalRefunded() > 0) {
|
937 |
-
$adjustment = array('adjustment_positive' => $latestRefunded);
|
938 |
-
} else {
|
939 |
-
$adjustment = array('adjustment_negative' => $order->getBaseGrandTotal() - $latestRefunded);
|
940 |
-
}
|
941 |
-
|
942 |
-
$creditmemo = Mage::getModel('sales/service_order', $order)
|
943 |
-
->prepareCreditmemo($adjustment)
|
944 |
-
->setPaymentRefundDisallowed(true)
|
945 |
-
->setAutomaticallyCreated(true)
|
946 |
-
->register()
|
947 |
-
->addComment($this->__('Credit memo has been created automatically'))
|
948 |
-
->save();
|
949 |
-
|
950 |
-
$msg = $this->__('Google Refund:');
|
951 |
-
$msg .= '<br />' . $this->__('Latest Refund: %s', '<strong>' . $this->_formatAmount($latestRefunded) . '</strong>');
|
952 |
-
$msg .= '<br />' . $this->__('Total Refunded: %s', '<strong>' . $this->_formatAmount($totalRefunded) . '</strong>');
|
953 |
-
|
954 |
-
$this->_addChildTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND,
|
955 |
-
Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
956 |
-
|
957 |
-
$order->addStatusToHistory($order->getStatus(), $msg);
|
958 |
-
$order->save();
|
959 |
-
}
|
960 |
-
|
961 |
-
protected function _responseOrderStateChangeNotification()
|
962 |
-
{
|
963 |
-
$this->getGResponse()->SendAck();
|
964 |
-
|
965 |
-
$prevFinancial = $this->getData('root/previous-financial-order-state/VALUE');
|
966 |
-
$newFinancial = $this->getData('root/new-financial-order-state/VALUE');
|
967 |
-
$prevFulfillment = $this->getData('root/previous-fulfillment-order-state/VALUE');
|
968 |
-
$newFulfillment = $this->getData('root/new-fulfillment-order-state/VALUE');
|
969 |
-
|
970 |
-
$msg = $this->__('Google Order Status Change:');
|
971 |
-
if ($prevFinancial!=$newFinancial) {
|
972 |
-
$msg .= "<br />" . $this->__('Financial: %s -> %s', '<strong>' . $prevFinancial . '</strong>', '<strong>' . $newFinancial . '</strong>');
|
973 |
-
}
|
974 |
-
if ($prevFulfillment!=$newFulfillment) {
|
975 |
-
$msg .= "<br />" . $this->__('Fulfillment: %s -> %s', '<strong>' . $prevFulfillment . '</strong>', '<strong>' . $newFulfillment . '</strong>');
|
976 |
-
}
|
977 |
-
$this->getOrder()
|
978 |
-
->addStatusToHistory($this->getOrder()->getStatus(), $msg)
|
979 |
-
->save();
|
980 |
-
|
981 |
-
$method = '_orderStateChangeFinancial' . uc_words(strtolower($newFinancial), '', '_');
|
982 |
-
if (method_exists($this, $method)) {
|
983 |
-
$this->$method();
|
984 |
-
}
|
985 |
-
|
986 |
-
$method = '_orderStateChangeFulfillment' . uc_words(strtolower($newFulfillment), '', '_');
|
987 |
-
if (method_exists($this, $method)) {
|
988 |
-
$this->$method();
|
989 |
-
}
|
990 |
-
}
|
991 |
-
|
992 |
-
/**
|
993 |
-
* Add transaction to payment with defined type
|
994 |
-
*
|
995 |
-
* @param string $typeTarget
|
996 |
-
* @param string $typeParent
|
997 |
-
* @return Mage_GoogleCheckout_Model_Api_Xml_Callback
|
998 |
-
*/
|
999 |
-
protected function _addChildTransaction(
|
1000 |
-
$typeTarget,
|
1001 |
-
$typeParent = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)
|
1002 |
-
{
|
1003 |
-
$payment = $this->getOrder()->getPayment();
|
1004 |
-
$googleOrderId = $this->getGoogleOrderNumber();
|
1005 |
-
$parentTransactionId = $googleOrderId;
|
1006 |
-
|
1007 |
-
if ($typeParent != Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) {
|
1008 |
-
$parentTransactionId .= '-' . $typeParent;
|
1009 |
-
} else {
|
1010 |
-
$payment->setIsTransactionClosed(false);
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
$parentTransaction = $payment->getTransaction($parentTransactionId);
|
1014 |
-
|
1015 |
-
if ($parentTransaction) {
|
1016 |
-
$payment->setParentTransactionId($parentTransactionId)
|
1017 |
-
->setTransactionId($googleOrderId . '-' . $typeTarget)
|
1018 |
-
->addTransaction($typeTarget);
|
1019 |
-
|
1020 |
-
if ($this->getOrder()->getTotalDue() < .0001) {
|
1021 |
-
$parentTransaction->setIsClosed(true)
|
1022 |
-
->save();
|
1023 |
-
}
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
return $this;
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
protected function _orderStateChangeFinancialReviewing()
|
1030 |
-
{
|
1031 |
-
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
protected function _orderStateChangeFinancialChargeable()
|
1035 |
-
{
|
1036 |
-
#$this->getGRequest()->SendProcessOrder($this->getGoogleOrderNumber());
|
1037 |
-
#$this->getGRequest()->SendChargeOrder($this->getGoogleOrderNumber(), '');
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
protected function _orderStateChangeFinancialCharging()
|
1041 |
-
{
|
1042 |
-
|
1043 |
-
}
|
1044 |
-
|
1045 |
-
protected function _orderStateChangeFinancialCharged()
|
1046 |
-
{
|
1047 |
-
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
protected function _orderStateChangeFinancialPaymentDeclined()
|
1051 |
-
{
|
1052 |
-
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
protected function _orderStateChangeFinancialCancelled()
|
1056 |
-
{
|
1057 |
-
$this->getOrder()->setBeingCanceledFromGoogleApi(true)->cancel()->save();
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
protected function _orderStateChangeFinancialCancelledByGoogle()
|
1061 |
-
{
|
1062 |
-
$this
|
1063 |
-
->getOrder()
|
1064 |
-
->setBeingCanceledFromGoogleApi(true)
|
1065 |
-
->cancel()
|
1066 |
-
->save();
|
1067 |
-
|
1068 |
-
$this
|
1069 |
-
->getGRequest()
|
1070 |
-
->SendBuyerMessage($this->getGoogleOrderNumber(), "Sorry, your order is cancelled by Google", true);
|
1071 |
-
}
|
1072 |
-
|
1073 |
-
protected function _orderStateChangeFulfillmentNew()
|
1074 |
-
{
|
1075 |
-
|
1076 |
-
}
|
1077 |
-
|
1078 |
-
protected function _orderStateChangeFulfillmentProcessing()
|
1079 |
-
{
|
1080 |
-
|
1081 |
-
}
|
1082 |
-
|
1083 |
-
protected function _orderStateChangeFulfillmentDelivered()
|
1084 |
-
{
|
1085 |
-
$shipment = $this->_createShipment();
|
1086 |
-
if (!is_null($shipment))
|
1087 |
-
$shipment->save();
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
protected function _orderStateChangeFulfillmentWillNotDeliver()
|
1091 |
-
{
|
1092 |
-
|
1093 |
-
}
|
1094 |
-
|
1095 |
-
/**
|
1096 |
-
* Format amount to be displayed
|
1097 |
-
*
|
1098 |
-
* @param mixed $amount
|
1099 |
-
* @return string
|
1100 |
-
*/
|
1101 |
-
protected function _formatAmount($amount)
|
1102 |
-
{
|
1103 |
-
// format currency in currency format, but don't enclose it into <span>
|
1104 |
-
return Mage::helper('core')->currency($amount, true, false);
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php
DELETED
@@ -1,1143 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Google Checkout XML API processing model
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
* @package Mage_GoogleCheckout
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Mage_GoogleCheckout_Model_Api_Xml_Checkout extends Mage_GoogleCheckout_Model_Api_Xml_Abstract
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* Representation value of item weight unit
|
38 |
-
*/
|
39 |
-
const ITEM_WEIGHT_UNIT = 'LB';
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Representation value of item size unit
|
43 |
-
*/
|
44 |
-
const ITEM_SIZE_UNIT = 'IN';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Google checkout namespace URI
|
48 |
-
*/
|
49 |
-
const CHECKOUT_SHOPPING_CART_XMLNS = 'http://checkout.google.com/schema/2';
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @deprecated after 0.8.16100
|
53 |
-
*
|
54 |
-
* @var string
|
55 |
-
*/
|
56 |
-
protected $_currency;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Define if shipping rates already calculated
|
60 |
-
*
|
61 |
-
* @var boolean
|
62 |
-
*/
|
63 |
-
protected $_shippingCalculated = false;
|
64 |
-
|
65 |
-
/**
|
66 |
-
* API URL getter
|
67 |
-
*
|
68 |
-
* @return string
|
69 |
-
*/
|
70 |
-
protected function _getApiUrl()
|
71 |
-
{
|
72 |
-
$url = $this->_getBaseApiUrl();
|
73 |
-
$url .= 'merchantCheckout/Merchant/' . $this->getMerchantId();
|
74 |
-
return $url;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Send checkout data to google
|
79 |
-
*
|
80 |
-
* @return Mage_GoogleCheckout_Model_Api_Xml_Checkout
|
81 |
-
*/
|
82 |
-
public function checkout()
|
83 |
-
{
|
84 |
-
$quote = $this->getQuote();
|
85 |
-
if (!($quote instanceof Mage_Sales_Model_Quote)) {
|
86 |
-
Mage::throwException('Invalid quote');
|
87 |
-
}
|
88 |
-
|
89 |
-
$xmlns = self::CHECKOUT_SHOPPING_CART_XMLNS;
|
90 |
-
$xml = <<<EOT
|
91 |
-
<checkout-shopping-cart xmlns="{$xmlns}">
|
92 |
-
<shopping-cart>
|
93 |
-
{$this->_getItemsXml()}
|
94 |
-
{$this->_getMerchantPrivateDataXml()}
|
95 |
-
{$this->_getCartExpirationXml()}
|
96 |
-
</shopping-cart>
|
97 |
-
<checkout-flow-support>
|
98 |
-
{$this->_getMerchantCheckoutFlowSupportXml()}
|
99 |
-
</checkout-flow-support>
|
100 |
-
<order-processing-support>
|
101 |
-
{$this->_getRequestInitialAuthDetailsXml()}
|
102 |
-
</order-processing-support>
|
103 |
-
</checkout-shopping-cart>
|
104 |
-
EOT;
|
105 |
-
|
106 |
-
$result = $this->_call($xml);
|
107 |
-
$this->setRedirectUrl($result->{'redirect-url'});
|
108 |
-
|
109 |
-
return $this;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Retrieve quote items in XML format
|
114 |
-
*
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
protected function _getItemsXml()
|
118 |
-
{
|
119 |
-
$xml = <<<EOT
|
120 |
-
<items>
|
121 |
-
|
122 |
-
EOT;
|
123 |
-
|
124 |
-
foreach ($this->getQuote()->getAllItems() as $item) {
|
125 |
-
if ($item->getParentItem()) {
|
126 |
-
continue;
|
127 |
-
}
|
128 |
-
$taxClass = ($item->getTaxClassId() == 0) ? 'none' : $item->getTaxClassId();
|
129 |
-
$weight = (float) $item->getWeight();
|
130 |
-
$weightUnit = self::ITEM_WEIGHT_UNIT;
|
131 |
-
|
132 |
-
$unitPrice = $item->getBaseCalculationPrice();
|
133 |
-
if (Mage::helper('weee')->includeInSubtotal()) {
|
134 |
-
$unitPrice += $item->getBaseWeeeTaxAppliedAmount();
|
135 |
-
}
|
136 |
-
|
137 |
-
$xml .= <<<EOT
|
138 |
-
<item>
|
139 |
-
<merchant-item-id><![CDATA[{$item->getSku()}]]></merchant-item-id>
|
140 |
-
<item-name><![CDATA[{$item->getName()}]]></item-name>
|
141 |
-
<item-description><![CDATA[{$item->getDescription()}]]></item-description>
|
142 |
-
<unit-price currency="{$this->getCurrency()}">{$unitPrice}</unit-price>
|
143 |
-
<quantity>{$item->getQty()}</quantity>
|
144 |
-
<item-weight unit="{$weightUnit}" value="{$weight}" />
|
145 |
-
<tax-table-selector>{$taxClass}</tax-table-selector>
|
146 |
-
{$this->_getDigitalContentXml($item->getIsVirtual())}
|
147 |
-
{$this->_getMerchantPrivateItemDataXml($item)}
|
148 |
-
</item>
|
149 |
-
|
150 |
-
EOT;
|
151 |
-
}
|
152 |
-
|
153 |
-
$billingAddress = $this->getQuote()->getBillingAddress();
|
154 |
-
$shippingAddress = $this->getQuote()->getShippingAddress();
|
155 |
-
|
156 |
-
$shippingDiscount = (float)$shippingAddress->getBaseDiscountAmount();
|
157 |
-
$billingDiscount = (float)$billingAddress->getBaseDiscountAmount();
|
158 |
-
$discount = $billingDiscount + $shippingDiscount;
|
159 |
-
|
160 |
-
// Exclude shipping discount
|
161 |
-
// Discount is negative value
|
162 |
-
$discount += $shippingAddress->getBaseShippingDiscountAmount();
|
163 |
-
|
164 |
-
$discountItem = new Varien_Object(array(
|
165 |
-
'price' => $discount,
|
166 |
-
'name' => $this->__('Cart Discount'),
|
167 |
-
'description' => $this->__('A virtual item to reflect the discount total')
|
168 |
-
));
|
169 |
-
|
170 |
-
Mage::dispatchEvent('google_checkout_discount_item_price', array(
|
171 |
-
'quote' => $this->getQuote(),
|
172 |
-
'discount_item' => $discountItem
|
173 |
-
));
|
174 |
-
|
175 |
-
$discount = $discountItem->getPrice();
|
176 |
-
if ($discount) {
|
177 |
-
$xml .= <<<EOT
|
178 |
-
<item>
|
179 |
-
<merchant-item-id>_INTERNAL_DISCOUNT_</merchant-item-id>
|
180 |
-
<item-name>{$discountItem->getName()}</item-name>
|
181 |
-
<item-description>{$discountItem->getDescription()}</item-description>
|
182 |
-
<unit-price currency="{$this->getCurrency()}">{$discount}</unit-price>
|
183 |
-
<quantity>1</quantity>
|
184 |
-
<item-weight unit="{$weightUnit}" value="0.00" />
|
185 |
-
<tax-table-selector>none</tax-table-selector>
|
186 |
-
{$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
|
187 |
-
</item>
|
188 |
-
|
189 |
-
EOT;
|
190 |
-
}
|
191 |
-
|
192 |
-
$hiddenTax = $shippingAddress->getBaseHiddenTaxAmount() + $billingAddress->getBaseHiddenTaxAmount();
|
193 |
-
if ($hiddenTax) {
|
194 |
-
$xml .= <<<EOT
|
195 |
-
<item>
|
196 |
-
<merchant-item-id>_INTERNAL_TAX_</merchant-item-id>
|
197 |
-
<item-name>{$this->__('Discount Tax')}</item-name>
|
198 |
-
<item-description>{$this->__('A virtual item to reflect the tax total')}</item-description>
|
199 |
-
<unit-price currency="{$this->getCurrency()}">{$hiddenTax}</unit-price>
|
200 |
-
<quantity>1</quantity>
|
201 |
-
<item-weight unit="{$weightUnit}" value="0.00" />
|
202 |
-
<tax-table-selector>none</tax-table-selector>
|
203 |
-
{$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
|
204 |
-
</item>
|
205 |
-
EOT;
|
206 |
-
}
|
207 |
-
$xml .= <<<EOT
|
208 |
-
</items>
|
209 |
-
EOT;
|
210 |
-
|
211 |
-
return $xml;
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Retrieve digital content XML
|
216 |
-
*
|
217 |
-
* @param boolean $isVirtual
|
218 |
-
* @return string
|
219 |
-
*/
|
220 |
-
protected function _getDigitalContentXml($isVirtual)
|
221 |
-
{
|
222 |
-
if (!$isVirtual) {
|
223 |
-
return '';
|
224 |
-
}
|
225 |
-
|
226 |
-
$storeId = $this->getQuote()->getStoreId();
|
227 |
-
$active = Mage::getStoreConfigFlag(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_VIRTUAL_ACTIVE, $storeId);
|
228 |
-
if (!$active) {
|
229 |
-
return '';
|
230 |
-
}
|
231 |
-
|
232 |
-
$schedule = Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_VIRTUAL_SCHEDULE, $storeId);
|
233 |
-
$method = Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_VIRTUAL_METHOD, $storeId);
|
234 |
-
|
235 |
-
$xml = "<display-disposition>{$schedule}</display-disposition>";
|
236 |
-
|
237 |
-
if ($method == 'email') {
|
238 |
-
$xml .= '<email-delivery>true</email-delivery>';
|
239 |
-
} elseif ($method == 'key_url') {
|
240 |
-
} elseif ($method == 'description_based') {
|
241 |
-
}
|
242 |
-
|
243 |
-
$xml = "<digital-content>{$xml}</digital-content>";
|
244 |
-
|
245 |
-
return $xml;
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Convert quote item to private item XML
|
250 |
-
*
|
251 |
-
* @param Mage_Sales_Model_Quote_Item $item
|
252 |
-
* @return string
|
253 |
-
*/
|
254 |
-
protected function _getMerchantPrivateItemDataXml($item)
|
255 |
-
{
|
256 |
-
$xml = <<<EOT
|
257 |
-
<merchant-private-item-data>
|
258 |
-
<quote-item-id>{$item->getId()}</quote-item-id>
|
259 |
-
</merchant-private-item-data>
|
260 |
-
EOT;
|
261 |
-
return $xml;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Retrieve merchant private data XML
|
266 |
-
*
|
267 |
-
* @return string
|
268 |
-
*/
|
269 |
-
protected function _getMerchantPrivateDataXml()
|
270 |
-
{
|
271 |
-
$xml = <<<EOT
|
272 |
-
<merchant-private-data>
|
273 |
-
<quote-id><![CDATA[{$this->getQuote()->getId()}]]></quote-id>
|
274 |
-
<store-id><![CDATA[{$this->getQuote()->getStoreId()}]]></store-id>
|
275 |
-
</merchant-private-data>
|
276 |
-
EOT;
|
277 |
-
return $xml;
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Retrieve quote expiration XML
|
282 |
-
*
|
283 |
-
* @return string
|
284 |
-
*/
|
285 |
-
protected function _getCartExpirationXml()
|
286 |
-
{
|
287 |
-
$xml = <<<EOT
|
288 |
-
EOT;
|
289 |
-
return $xml;
|
290 |
-
}
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Retrieve merchant checkout flow support XML
|
294 |
-
*
|
295 |
-
* @return string
|
296 |
-
*/
|
297 |
-
protected function _getMerchantCheckoutFlowSupportXml()
|
298 |
-
{
|
299 |
-
$xml = <<<EOT
|
300 |
-
<merchant-checkout-flow-support>
|
301 |
-
<edit-cart-url><![CDATA[{$this->_getEditCartUrl()}]]></edit-cart-url>
|
302 |
-
<continue-shopping-url><![CDATA[{$this->_getContinueShoppingUrl()}]]></continue-shopping-url>
|
303 |
-
{$this->_getRequestBuyerPhoneNumberXml()}
|
304 |
-
{$this->_getMerchantCalculationsXml()}
|
305 |
-
{$this->_getShippingMethodsXml()}
|
306 |
-
{$this->_getAllTaxTablesXml()}
|
307 |
-
{$this->_getParameterizedUrlsXml()}
|
308 |
-
{$this->_getPlatformIdXml()}
|
309 |
-
{$this->_getAnalyticsDataXml()}
|
310 |
-
</merchant-checkout-flow-support>
|
311 |
-
EOT;
|
312 |
-
return $xml;
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Retrieve request buyer phone number XML
|
317 |
-
*
|
318 |
-
* @return string
|
319 |
-
*/
|
320 |
-
protected function _getRequestBuyerPhoneNumberXml()
|
321 |
-
{
|
322 |
-
$requestPhone = Mage::getStoreConfig(
|
323 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_REQUEST_PHONE,
|
324 |
-
$this->getQuote()->getStoreId()
|
325 |
-
);
|
326 |
-
$requestPhone = $requestPhone ? 'true' : 'false';
|
327 |
-
$xml = <<<EOT
|
328 |
-
<request-buyer-phone-number>{$requestPhone}</request-buyer-phone-number>
|
329 |
-
EOT;
|
330 |
-
return $xml;
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Retrieve merchant calculations XML
|
335 |
-
*
|
336 |
-
* @return string
|
337 |
-
*/
|
338 |
-
protected function _getMerchantCalculationsXml()
|
339 |
-
{
|
340 |
-
$xml = <<<EOT
|
341 |
-
<merchant-calculations>
|
342 |
-
<merchant-calculations-url><![CDATA[{$this->_getCalculationsUrl()}]]></merchant-calculations-url>
|
343 |
-
</merchant-calculations>
|
344 |
-
EOT;
|
345 |
-
return $xml;
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Retrieve free shipping rate XML
|
350 |
-
*
|
351 |
-
* @return string
|
352 |
-
*/
|
353 |
-
protected function _getVirtualOrderShippingXml()
|
354 |
-
{
|
355 |
-
$title = Mage::helper('googlecheckout')->__('Free Shipping');
|
356 |
-
|
357 |
-
$xml = <<<EOT
|
358 |
-
<shipping-methods>
|
359 |
-
<flat-rate-shipping name="{$title}">
|
360 |
-
<shipping-restrictions><allowed-areas><world-area /></allowed-areas></shipping-restrictions>
|
361 |
-
<price currency="{$this->getCurrency()}">0</price>
|
362 |
-
</flat-rate-shipping>
|
363 |
-
</shipping-methods>
|
364 |
-
EOT;
|
365 |
-
return $xml;
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Retrieve shipping methods XML
|
370 |
-
*
|
371 |
-
* @return string
|
372 |
-
*/
|
373 |
-
protected function _getShippingMethodsXml()
|
374 |
-
{
|
375 |
-
if ($this->_isOrderVirtual()) {
|
376 |
-
return $this->_getVirtualOrderShippingXml();
|
377 |
-
}
|
378 |
-
|
379 |
-
$xml = <<<EOT
|
380 |
-
<shipping-methods>
|
381 |
-
{$this->_getCarrierCalculatedShippingXml()}
|
382 |
-
{$this->_getFlatRateShippingXml()}
|
383 |
-
{$this->_getMerchantCalculatedShippingXml()}
|
384 |
-
{$this->_getPickupXml()}
|
385 |
-
</shipping-methods>
|
386 |
-
EOT;
|
387 |
-
return $xml;
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
* Generate XML of calculated shipping carriers rates
|
392 |
-
*
|
393 |
-
* @return string
|
394 |
-
*/
|
395 |
-
protected function _getCarrierCalculatedShippingXml()
|
396 |
-
{
|
397 |
-
/*
|
398 |
-
* Prevent sending more then one shipping option to Google
|
399 |
-
*/
|
400 |
-
if ($this->_shippingCalculated) {
|
401 |
-
return '';
|
402 |
-
}
|
403 |
-
|
404 |
-
$storeId = $this->getQuote()->getStoreId();
|
405 |
-
$active = Mage::getStoreConfigFlag(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_ACTIVE, $storeId);
|
406 |
-
$methods = Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_METHODS, $storeId);
|
407 |
-
|
408 |
-
if (!$active || !$methods) {
|
409 |
-
return '';
|
410 |
-
}
|
411 |
-
|
412 |
-
$country = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $storeId);
|
413 |
-
$region = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_REGION_ID, $storeId);
|
414 |
-
$postcode = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $storeId);
|
415 |
-
$city = Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_CITY, $storeId);
|
416 |
-
|
417 |
-
$defPrice = (float)Mage::getStoreConfig(
|
418 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_DEFAULT_PRICE,
|
419 |
-
$storeId
|
420 |
-
);
|
421 |
-
$width = Mage::getStoreConfig(
|
422 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_DEFAULT_WIDTH,
|
423 |
-
$storeId
|
424 |
-
);
|
425 |
-
$height = Mage::getStoreConfig(
|
426 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_DEFAULT_HEIGHT,
|
427 |
-
$storeId
|
428 |
-
);
|
429 |
-
$length = Mage::getStoreConfig(
|
430 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_DEFAULT_LENGTH,
|
431 |
-
$storeId
|
432 |
-
);
|
433 |
-
$sizeUnit = self::ITEM_SIZE_UNIT;
|
434 |
-
|
435 |
-
$addressCategory = Mage::getStoreConfig(
|
436 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_CARRIER_ADDRESS_CATEGORY,
|
437 |
-
$storeId
|
438 |
-
);
|
439 |
-
$defPrice = (float) Mage::helper('tax')->getShippingPrice($defPrice, false, false);
|
440 |
-
|
441 |
-
$this->getQuote()->getShippingAddress()
|
442 |
-
->setCountryId($country)
|
443 |
-
->setCity($city)
|
444 |
-
->setPostcode($postcode)
|
445 |
-
->setRegionId($region)
|
446 |
-
->setCollectShippingRates(true);
|
447 |
-
|
448 |
-
$address = $this->getQuote()->getShippingAddress();
|
449 |
-
$address->collectShippingRates();
|
450 |
-
$shipments = $address->getGroupedAllShippingRates();
|
451 |
-
|
452 |
-
$shippingMethodsList = array();
|
453 |
-
foreach (explode(',', $methods) as $method) {
|
454 |
-
list($company, $type) = explode('/', $method);
|
455 |
-
$shippingMethodsList[$method] = array('company' => $company, 'type' => $type);
|
456 |
-
}
|
457 |
-
|
458 |
-
$freeMethodsList = array();
|
459 |
-
foreach ($this->_getGoogleCarriersMap() as $mageCode => $map) {
|
460 |
-
if (!isset($shipments[$mageCode])) {
|
461 |
-
continue;
|
462 |
-
}
|
463 |
-
$freeMethod = Mage::getStoreConfig('carriers/' . $mageCode . '/free_method', $storeId);
|
464 |
-
|
465 |
-
foreach ($shipments[$mageCode] as $rate) {
|
466 |
-
$mageRateCode = $rate->getMethod();
|
467 |
-
if ($mageRateCode != $freeMethod) {
|
468 |
-
continue;
|
469 |
-
}
|
470 |
-
|
471 |
-
$googleRateCode = isset($map['methods'][$mageRateCode]) ? $map['methods'][$mageRateCode] : false;
|
472 |
-
if (false == $googleRateCode || $rate->getPrice() != 0) {
|
473 |
-
continue;
|
474 |
-
}
|
475 |
-
|
476 |
-
$methodName = $map['googleCarrierCompany'] . '/'. $googleRateCode;
|
477 |
-
if (empty($shippingMethodsList[$methodName])) {
|
478 |
-
continue;
|
479 |
-
}
|
480 |
-
$freeMethodsList[$methodName] = array(
|
481 |
-
'company' => $map['googleCarrierCompany'],
|
482 |
-
'type' => $googleRateCode
|
483 |
-
);
|
484 |
-
unset($shippingMethodsList[$methodName]);
|
485 |
-
}
|
486 |
-
}
|
487 |
-
|
488 |
-
$xml = '';
|
489 |
-
$sendShipMethods = (bool)count($shippingMethodsList) > 0;
|
490 |
-
if ($sendShipMethods) {
|
491 |
-
$xml .= <<<EOT
|
492 |
-
<carrier-calculated-shipping>
|
493 |
-
<shipping-packages>
|
494 |
-
<shipping-package>
|
495 |
-
<ship-from id="Origin">
|
496 |
-
<city>{$city}</city>
|
497 |
-
<region>{$region}</region>
|
498 |
-
<postal-code>{$postcode}</postal-code>
|
499 |
-
<country-code>{$country}</country-code>
|
500 |
-
</ship-from>
|
501 |
-
<width unit="{$sizeUnit}" value="{$width}"/>
|
502 |
-
<height unit="{$sizeUnit}" value="{$height}"/>
|
503 |
-
<length unit="{$sizeUnit}" value="{$length}"/>
|
504 |
-
<delivery-address-category>{$addressCategory}</delivery-address-category>
|
505 |
-
</shipping-package>
|
506 |
-
</shipping-packages>
|
507 |
-
EOT;
|
508 |
-
$xml .= '<carrier-calculated-shipping-options>';
|
509 |
-
|
510 |
-
foreach ($shippingMethodsList as $method) {
|
511 |
-
$xml .= <<<EOT
|
512 |
-
<carrier-calculated-shipping-option>
|
513 |
-
<shipping-company>{$method['company']}</shipping-company>
|
514 |
-
<shipping-type>{$method['type']}</shipping-type>
|
515 |
-
<price currency="{$this->getCurrency()}">{$defPrice}</price>
|
516 |
-
</carrier-calculated-shipping-option>
|
517 |
-
EOT;
|
518 |
-
}
|
519 |
-
$xml .= '</carrier-calculated-shipping-options>';
|
520 |
-
$xml .= '</carrier-calculated-shipping>';
|
521 |
-
}
|
522 |
-
|
523 |
-
foreach ($freeMethodsList as $method) {
|
524 |
-
$xml .= <<<EOT
|
525 |
-
<flat-rate-shipping name="{$method['company']} {$method['type']}">
|
526 |
-
<price currency="{$this->getCurrency()}">0.00</price></flat-rate-shipping>
|
527 |
-
EOT;
|
528 |
-
}
|
529 |
-
|
530 |
-
$this->_shippingCalculated = true;
|
531 |
-
return $xml;
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* Generate flat rate shipping XML
|
536 |
-
*
|
537 |
-
* @return string
|
538 |
-
*/
|
539 |
-
protected function _getFlatRateShippingXml()
|
540 |
-
{
|
541 |
-
/*
|
542 |
-
* Prevent sending more then one shipping option to Google
|
543 |
-
*/
|
544 |
-
if ($this->_shippingCalculated) {
|
545 |
-
return '';
|
546 |
-
}
|
547 |
-
|
548 |
-
$storeId = $this->getQuote()->getStoreId();
|
549 |
-
if (!Mage::getStoreConfigFlag(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_FLATRATE_ACTIVE, $storeId)) {
|
550 |
-
return '';
|
551 |
-
}
|
552 |
-
|
553 |
-
// If is set Tax Class for Shipping - create ability to manage shipping rates in MerchantCalculationCallback
|
554 |
-
$nodeName = 'merchant-calculated-shipping';
|
555 |
-
if (!$this->_getTaxClassForShipping($this->getQuote())) {
|
556 |
-
$nodeName = 'flat-rate-shipping';
|
557 |
-
}
|
558 |
-
|
559 |
-
$xml = '';
|
560 |
-
for ($i = 1; $i <= 3; $i++) {
|
561 |
-
$title = Mage::getStoreConfig('google/checkout_shipping_flatrate/title_' . $i, $storeId);
|
562 |
-
$price = (float)Mage::getStoreConfig('google/checkout_shipping_flatrate/price_' . $i, $storeId);
|
563 |
-
$price = number_format($price, 2, '.', '');
|
564 |
-
$price = (float)Mage::helper('tax')->getShippingPrice($price, false, false);
|
565 |
-
$allowSpecific = Mage::getStoreConfigFlag(
|
566 |
-
'google/checkout_shipping_flatrate/sallowspecific_' . $i,
|
567 |
-
$storeId
|
568 |
-
);
|
569 |
-
$specificCountries = Mage::getStoreConfig(
|
570 |
-
'google/checkout_shipping_flatrate/specificcountry_' . $i,
|
571 |
-
$storeId
|
572 |
-
);
|
573 |
-
$allowedAreasXml = $this->_getAllowedCountries($allowSpecific, $specificCountries);
|
574 |
-
|
575 |
-
if (empty($title) || $price <= 0) {
|
576 |
-
continue;
|
577 |
-
}
|
578 |
-
|
579 |
-
$xml .= <<<EOT
|
580 |
-
<{$nodeName} name="{$title}">
|
581 |
-
<shipping-restrictions>
|
582 |
-
<allowed-areas>
|
583 |
-
{$allowedAreasXml}
|
584 |
-
</allowed-areas>
|
585 |
-
</shipping-restrictions>
|
586 |
-
<price currency="{$this->getCurrency()}">{$price}</price>
|
587 |
-
</{$nodeName}>
|
588 |
-
EOT;
|
589 |
-
}
|
590 |
-
|
591 |
-
$this->_shippingCalculated = true;
|
592 |
-
|
593 |
-
return $xml;
|
594 |
-
}
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Generate shipping allowed countries XML
|
598 |
-
*
|
599 |
-
* @param boolean $allowSpecific
|
600 |
-
* @param string $specific
|
601 |
-
* @return string
|
602 |
-
*/
|
603 |
-
protected function _getAllowedCountries($allowSpecific, $specific)
|
604 |
-
{
|
605 |
-
$xml = '';
|
606 |
-
if ($allowSpecific == 1) {
|
607 |
-
if ($specific) {
|
608 |
-
foreach (explode(',', $specific) as $country) {
|
609 |
-
$xml .= "<postal-area><country-code>{$country}</country-code></postal-area>\n";
|
610 |
-
}
|
611 |
-
}
|
612 |
-
}
|
613 |
-
if ($xml) {
|
614 |
-
return $xml;
|
615 |
-
}
|
616 |
-
|
617 |
-
return '<world-area />';
|
618 |
-
}
|
619 |
-
|
620 |
-
/**
|
621 |
-
* Retrieve merchant calculated shipping carriers rates XML
|
622 |
-
*
|
623 |
-
* @return string
|
624 |
-
*/
|
625 |
-
protected function _getMerchantCalculatedShippingXml()
|
626 |
-
{
|
627 |
-
/*
|
628 |
-
* Prevent sending more then one shipping option to Google
|
629 |
-
*/
|
630 |
-
if ($this->_shippingCalculated) {
|
631 |
-
return '';
|
632 |
-
}
|
633 |
-
|
634 |
-
$storeId = $this->getQuote()->getStoreId();
|
635 |
-
$active = Mage::getStoreConfigFlag(
|
636 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_MERCHANT_ACTIVE,
|
637 |
-
$storeId
|
638 |
-
);
|
639 |
-
$methods = Mage::getStoreConfig(
|
640 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_MERCHANT_ALLOWED_METHODS,
|
641 |
-
$storeId
|
642 |
-
);
|
643 |
-
|
644 |
-
if (!$active || !$methods) {
|
645 |
-
return '';
|
646 |
-
}
|
647 |
-
|
648 |
-
$xml = '';
|
649 |
-
$methods = unserialize($methods);
|
650 |
-
$taxHelper = Mage::helper('tax');
|
651 |
-
$shippingModel = Mage::getModel('shipping/shipping');
|
652 |
-
|
653 |
-
foreach ($methods['method'] as $i => $method) {
|
654 |
-
if (!$i || !$method) {
|
655 |
-
continue;
|
656 |
-
}
|
657 |
-
list($carrierCode, $methodCode) = explode('/', $method);
|
658 |
-
if ($carrierCode) {
|
659 |
-
$carrier = $shippingModel->getCarrierByCode($carrierCode);
|
660 |
-
if ($carrier) {
|
661 |
-
$allowedMethods = $carrier->getAllowedMethods();
|
662 |
-
|
663 |
-
if (isset($allowedMethods[$methodCode])) {
|
664 |
-
$method = Mage::getStoreConfig('carriers/' . $carrierCode . '/title', $storeId);
|
665 |
-
$method .= ' - '.$allowedMethods[$methodCode];
|
666 |
-
}
|
667 |
-
|
668 |
-
$defaultPrice = (float) $methods['price'][$i];
|
669 |
-
$defaultPrice = $taxHelper->getShippingPrice($defaultPrice, false, false);
|
670 |
-
|
671 |
-
$allowedAreasXml = $this->_getAllowedCountries(
|
672 |
-
$carrier->getConfigData('sallowspecific'),
|
673 |
-
$carrier->getConfigData('specificcountry')
|
674 |
-
);
|
675 |
-
|
676 |
-
$xml .= <<<EOT
|
677 |
-
<merchant-calculated-shipping name="{$method}">
|
678 |
-
<address-filters>
|
679 |
-
<allowed-areas>
|
680 |
-
{$allowedAreasXml}
|
681 |
-
</allowed-areas>
|
682 |
-
</address-filters>
|
683 |
-
<price currency="{$this->getCurrency()}">{$defaultPrice}</price>
|
684 |
-
</merchant-calculated-shipping>
|
685 |
-
EOT;
|
686 |
-
}
|
687 |
-
}
|
688 |
-
}
|
689 |
-
$this->_shippingCalculated = true;
|
690 |
-
|
691 |
-
return $xml;
|
692 |
-
}
|
693 |
-
|
694 |
-
/**
|
695 |
-
* Retrieve pickup XML
|
696 |
-
*
|
697 |
-
* @return string
|
698 |
-
*/
|
699 |
-
protected function _getPickupXml()
|
700 |
-
{
|
701 |
-
$storeId = $this->getQuote()->getStoreId();
|
702 |
-
if (!Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_PICKUP_ACTIVE, $storeId)) {
|
703 |
-
return '';
|
704 |
-
}
|
705 |
-
|
706 |
-
$title = Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_PICKUP_TITLE, $storeId);
|
707 |
-
$price = Mage::getStoreConfig(Mage_GoogleCheckout_Helper_Data::XML_PATH_SHIPPING_PICKUP_PRICE, $storeId);
|
708 |
-
$price = (float) Mage::helper('tax')->getShippingPrice($price, false, false);
|
709 |
-
|
710 |
-
$xml = <<<EOT
|
711 |
-
<pickup name="{$title}">
|
712 |
-
<price currency="{$this->getCurrency()}">{$price}</price>
|
713 |
-
</pickup>
|
714 |
-
EOT;
|
715 |
-
|
716 |
-
return $xml;
|
717 |
-
}
|
718 |
-
|
719 |
-
/**
|
720 |
-
* Retrieve specific tax table XML
|
721 |
-
*
|
722 |
-
* @param array|float $rules
|
723 |
-
* @param string $type
|
724 |
-
* @return string
|
725 |
-
*/
|
726 |
-
protected function _getTaxTableXml($rules, $type)
|
727 |
-
{
|
728 |
-
$xml = '';
|
729 |
-
if (is_array($rules)) {
|
730 |
-
foreach ($rules as $group => $taxRates) {
|
731 |
-
if ($type != 'default') {
|
732 |
-
$nameAttribute = "name=\"{$group}\"";
|
733 |
-
$standaloneAttribute = "standalone=\"true\"";
|
734 |
-
$rulesTag = "{$type}-tax-rules";
|
735 |
-
$shippingTaxed = false;
|
736 |
-
} else {
|
737 |
-
$nameAttribute = '';
|
738 |
-
$standaloneAttribute = '';
|
739 |
-
$rulesTag = 'tax-rules';
|
740 |
-
$shippingTaxed = true;
|
741 |
-
}
|
742 |
-
|
743 |
-
$xml .= <<<EOT
|
744 |
-
<{$type}-tax-table {$nameAttribute} {$standaloneAttribute}>
|
745 |
-
<{$rulesTag}>
|
746 |
-
EOT;
|
747 |
-
if (is_array($taxRates)) {
|
748 |
-
foreach ($taxRates as $rate) {
|
749 |
-
$xml .= <<<EOT
|
750 |
-
<{$type}-tax-rule>
|
751 |
-
<tax-areas>
|
752 |
-
|
753 |
-
EOT;
|
754 |
-
if ($rate['country'] === Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID) {
|
755 |
-
if (!empty($rate['postcode']) && $rate['postcode'] !== '*') {
|
756 |
-
$rate['postcode'] = Mage::helper('googlecheckout')
|
757 |
-
->zipRangeToZipPattern($rate['postcode']);
|
758 |
-
foreach ($rate['postcode'] as $postcode) {
|
759 |
-
$xml .= <<<EOT
|
760 |
-
<us-zip-area>
|
761 |
-
<zip-pattern>$postcode</zip-pattern>
|
762 |
-
</us-zip-area>
|
763 |
-
|
764 |
-
EOT;
|
765 |
-
}
|
766 |
-
} else if (!empty($rate['state'])) {
|
767 |
-
$xml .= <<<EOT
|
768 |
-
<us-state-area>
|
769 |
-
<state>{$rate['state']}</state>
|
770 |
-
</us-state-area>
|
771 |
-
|
772 |
-
EOT;
|
773 |
-
} else {
|
774 |
-
$xml .= <<<EOT
|
775 |
-
<us-zip-area>
|
776 |
-
<zip-pattern>*</zip-pattern>
|
777 |
-
</us-zip-area>
|
778 |
-
|
779 |
-
EOT;
|
780 |
-
}
|
781 |
-
} else {
|
782 |
-
if (!empty($rate['country'])) {
|
783 |
-
$xml .= <<<EOT
|
784 |
-
<postal-area>
|
785 |
-
<country-code>{$rate['country']}</country-code>
|
786 |
-
EOT;
|
787 |
-
if (!empty($rate['postcode']) && $rate['postcode'] !== '*') {
|
788 |
-
$xml .= <<<EOT
|
789 |
-
<postal-code-pattern>{$rate['postcode']}</postal-code-pattern>
|
790 |
-
|
791 |
-
EOT;
|
792 |
-
}
|
793 |
-
$xml .= <<<EOT
|
794 |
-
</postal-area>
|
795 |
-
|
796 |
-
EOT;
|
797 |
-
}
|
798 |
-
}
|
799 |
-
$xml .= <<<EOT
|
800 |
-
</tax-areas>
|
801 |
-
<rate>{$rate['value']}</rate>
|
802 |
-
EOT;
|
803 |
-
if ($shippingTaxed) {
|
804 |
-
$xml .= '<shipping-taxed>true</shipping-taxed>';
|
805 |
-
}
|
806 |
-
$xml .= "</{$type}-tax-rule>";
|
807 |
-
}
|
808 |
-
|
809 |
-
} else {
|
810 |
-
$taxRate = $taxRates/100;
|
811 |
-
$xml .= <<<EOT
|
812 |
-
<{$type}-tax-rule>
|
813 |
-
<tax-area>
|
814 |
-
<world-area/>
|
815 |
-
</tax-area>
|
816 |
-
<rate>{$taxRate}</rate>
|
817 |
-
EOT;
|
818 |
-
if ($shippingTaxed) {
|
819 |
-
$xml .= '<shipping-taxed>true</shipping-taxed>';
|
820 |
-
}
|
821 |
-
$xml .= "</{$type}-tax-rule>";
|
822 |
-
}
|
823 |
-
|
824 |
-
$xml .= <<<EOT
|
825 |
-
</$rulesTag>
|
826 |
-
</{$type}-tax-table>
|
827 |
-
EOT;
|
828 |
-
}
|
829 |
-
} else {
|
830 |
-
if (is_numeric($rules)) {
|
831 |
-
$taxRate = $rules / 100;
|
832 |
-
$xml .= <<<EOT
|
833 |
-
<{$type}-tax-table>
|
834 |
-
<tax-rules>
|
835 |
-
<{$type}-tax-rule>
|
836 |
-
<tax-area>
|
837 |
-
<world-area/>
|
838 |
-
</tax-area>
|
839 |
-
<rate>{$taxRate}</rate>
|
840 |
-
<shipping-taxed>true</shipping-taxed>
|
841 |
-
</{$type}-tax-rule>
|
842 |
-
</tax-rules>
|
843 |
-
</{$type}-tax-table>
|
844 |
-
EOT;
|
845 |
-
}
|
846 |
-
}
|
847 |
-
|
848 |
-
return $xml;
|
849 |
-
}
|
850 |
-
|
851 |
-
/**
|
852 |
-
* Generate all tax tables XML
|
853 |
-
*
|
854 |
-
* @return string
|
855 |
-
*/
|
856 |
-
protected function _getAllTaxTablesXml()
|
857 |
-
{
|
858 |
-
$isDefaultTaxTablesDisabled = Mage::getStoreConfigFlag(
|
859 |
-
Mage_GoogleCheckout_Helper_Data::XML_PATH_DISABLE_DEFAULT_TAX_TABLES,
|
860 |
-
$this->getQuote()->getStoreId()
|
861 |
-
);
|
862 |
-
if ($isDefaultTaxTablesDisabled) {
|
863 |
-
return '<tax-tables merchant-calculated="true" />';
|
864 |
-
}
|
865 |
-
|
866 |
-
$xml = <<<EOT
|
867 |
-
<tax-tables merchant-calculated="true">
|
868 |
-
{$this->_getTaxTableXml($this->_getShippingTaxRules(), 'default')}
|
869 |
-
|
870 |
-
<!-- default-tax-table>
|
871 |
-
<tax-rules>
|
872 |
-
<default-tax-rule>
|
873 |
-
</default-tax-rule>
|
874 |
-
</tax-rules>
|
875 |
-
</default-tax-table -->
|
876 |
-
|
877 |
-
<alternate-tax-tables>
|
878 |
-
<alternate-tax-table name="none" standalone="true">
|
879 |
-
<alternate-tax-rules>
|
880 |
-
<alternate-tax-rule>
|
881 |
-
<tax-area>
|
882 |
-
<world-area/>
|
883 |
-
</tax-area>
|
884 |
-
<rate>0</rate>
|
885 |
-
</alternate-tax-rule>
|
886 |
-
</alternate-tax-rules>
|
887 |
-
</alternate-tax-table>
|
888 |
-
{$this->_getTaxTableXml($this->_getTaxRules(), 'alternate')}
|
889 |
-
</alternate-tax-tables>
|
890 |
-
</tax-tables>
|
891 |
-
EOT;
|
892 |
-
return $xml;
|
893 |
-
}
|
894 |
-
|
895 |
-
/**
|
896 |
-
* Retrieve customer tax class id
|
897 |
-
*
|
898 |
-
* @return int
|
899 |
-
*/
|
900 |
-
protected function _getCustomerTaxClass()
|
901 |
-
{
|
902 |
-
$customerGroup = $this->getQuote()->getCustomerGroupId();
|
903 |
-
if (!$customerGroup) {
|
904 |
-
$customerGroup = Mage::helper('customer')->getDefaultCustomerGroupId($this->getQuote()->getStoreId());
|
905 |
-
}
|
906 |
-
return Mage::getModel('customer/group')->load($customerGroup)->getTaxClassId();
|
907 |
-
}
|
908 |
-
|
909 |
-
/**
|
910 |
-
* Retrieve shipping tax rules
|
911 |
-
*
|
912 |
-
* @return array
|
913 |
-
*/
|
914 |
-
protected function _getShippingTaxRules()
|
915 |
-
{
|
916 |
-
$customerTaxClass = $this->_getCustomerTaxClass();
|
917 |
-
$shippingTaxClass = Mage::getStoreConfig(
|
918 |
-
Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
|
919 |
-
$this->getQuote()->getStoreId()
|
920 |
-
);
|
921 |
-
$taxCalculationModel = Mage::getSingleton('tax/calculation');
|
922 |
-
|
923 |
-
if ($shippingTaxClass) {
|
924 |
-
if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
|
925 |
-
$request = $taxCalculationModel->getRateRequest();
|
926 |
-
$request
|
927 |
-
->setCustomerClassId($customerTaxClass)
|
928 |
-
->setProductClassId($shippingTaxClass);
|
929 |
-
|
930 |
-
return $taxCalculationModel->getRate($request);
|
931 |
-
}
|
932 |
-
$customerRules = $taxCalculationModel->getRatesByCustomerAndProductTaxClasses(
|
933 |
-
$customerTaxClass,
|
934 |
-
$shippingTaxClass
|
935 |
-
);
|
936 |
-
$rules = array();
|
937 |
-
foreach ($customerRules as $rule) {
|
938 |
-
$rules[$rule['product_class']][] = $rule;
|
939 |
-
}
|
940 |
-
|
941 |
-
return $rules;
|
942 |
-
}
|
943 |
-
|
944 |
-
return array();
|
945 |
-
}
|
946 |
-
|
947 |
-
/**
|
948 |
-
* Retrieve tax rules
|
949 |
-
*
|
950 |
-
* @return array
|
951 |
-
*/
|
952 |
-
protected function _getTaxRules()
|
953 |
-
{
|
954 |
-
$customerTaxClass = $this->_getCustomerTaxClass();
|
955 |
-
$taxCalculationModel = Mage::getSingleton('tax/calculation');
|
956 |
-
|
957 |
-
if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
|
958 |
-
$request = $taxCalculationModel->getRateRequest()->setCustomerClassId($customerTaxClass);
|
959 |
-
return $taxCalculationModel->getRatesForAllProductTaxClasses($request);
|
960 |
-
}
|
961 |
-
|
962 |
-
$customerRules = $taxCalculationModel->getRatesByCustomerTaxClass($customerTaxClass);
|
963 |
-
$rules = array();
|
964 |
-
foreach ($customerRules as $rule) {
|
965 |
-
$rules[$rule['product_class']][] = $rule;
|
966 |
-
}
|
967 |
-
|
968 |
-
return $rules;
|
969 |
-
}
|
970 |
-
|
971 |
-
/**
|
972 |
-
* Getter for request initial auth details flag XML
|
973 |
-
*
|
974 |
-
* @return string
|
975 |
-
*/
|
976 |
-
protected function _getRequestInitialAuthDetailsXml()
|
977 |
-
{
|
978 |
-
$xml = <<<EOT
|
979 |
-
<request-initial-auth-details>true</request-initial-auth-details>
|
980 |
-
EOT;
|
981 |
-
return $xml;
|
982 |
-
}
|
983 |
-
|
984 |
-
/**
|
985 |
-
* Getter for parametrized url XML
|
986 |
-
*
|
987 |
-
* @return string
|
988 |
-
*/
|
989 |
-
protected function _getParameterizedUrlsXml()
|
990 |
-
{
|
991 |
-
return '';
|
992 |
-
$xml = <<<EOT
|
993 |
-
<parameterized-urls>
|
994 |
-
<parameterized-url url="{$this->_getParameterizedUrl()}" />
|
995 |
-
</parameterized-urls>
|
996 |
-
EOT;
|
997 |
-
return $xml;
|
998 |
-
}
|
999 |
-
|
1000 |
-
/**
|
1001 |
-
* Getter for platform Id XML
|
1002 |
-
*
|
1003 |
-
* @return string
|
1004 |
-
*/
|
1005 |
-
protected function _getPlatformIdXml()
|
1006 |
-
{
|
1007 |
-
$xml = <<<EOT
|
1008 |
-
<platform-id>473325629220583</platform-id>
|
1009 |
-
EOT;
|
1010 |
-
return $xml;
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
/**
|
1014 |
-
* Retrieve analytics data XML
|
1015 |
-
*
|
1016 |
-
* @return string
|
1017 |
-
*/
|
1018 |
-
protected function _getAnalyticsDataXml()
|
1019 |
-
{
|
1020 |
-
if (!($analytics = $this->getApi()->getAnalyticsData())) {
|
1021 |
-
return '';
|
1022 |
-
}
|
1023 |
-
$xml = <<<EOT
|
1024 |
-
<analytics-data><![CDATA[{$analytics}]]></analytics-data>
|
1025 |
-
EOT;
|
1026 |
-
return $xml;
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
/**
|
1030 |
-
* Getter for cart edit url
|
1031 |
-
*
|
1032 |
-
* @return string
|
1033 |
-
*/
|
1034 |
-
protected function _getEditCartUrl()
|
1035 |
-
{
|
1036 |
-
return Mage::getUrl('googlecheckout/redirect/cart');
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
/**
|
1040 |
-
* Getter for continue shopping url
|
1041 |
-
*
|
1042 |
-
* @return string
|
1043 |
-
*/
|
1044 |
-
protected function _getContinueShoppingUrl()
|
1045 |
-
{
|
1046 |
-
return Mage::getUrl('googlecheckout/redirect/continue');
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
/**
|
1050 |
-
* Getter for notifications url
|
1051 |
-
*
|
1052 |
-
* @return string
|
1053 |
-
*/
|
1054 |
-
protected function _getNotificationsUrl()
|
1055 |
-
{
|
1056 |
-
return $this->_getCallbackUrl();
|
1057 |
-
}
|
1058 |
-
|
1059 |
-
/**
|
1060 |
-
* Getter for calculations url
|
1061 |
-
*
|
1062 |
-
* @return string
|
1063 |
-
*/
|
1064 |
-
protected function _getCalculationsUrl()
|
1065 |
-
{
|
1066 |
-
return $this->_getCallbackUrl();
|
1067 |
-
}
|
1068 |
-
|
1069 |
-
/**
|
1070 |
-
* Getter for parametrized url
|
1071 |
-
*
|
1072 |
-
* @return string
|
1073 |
-
*/
|
1074 |
-
protected function _getParameterizedUrl()
|
1075 |
-
{
|
1076 |
-
return Mage::getUrl('googlecheckout/api/beacon');
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
/**
|
1080 |
-
* Define if current quote is virtual
|
1081 |
-
*
|
1082 |
-
* @return bool
|
1083 |
-
*/
|
1084 |
-
protected function _isOrderVirtual()
|
1085 |
-
{
|
1086 |
-
foreach ($this->getQuote()->getAllItems() as $item) {
|
1087 |
-
if (!$item->getIsVirtual()) {
|
1088 |
-
return false;
|
1089 |
-
}
|
1090 |
-
}
|
1091 |
-
return true;
|
1092 |
-
}
|
1093 |
-
|
1094 |
-
/**
|
1095 |
-
* Retrieve native carriers to Google carriers map
|
1096 |
-
*
|
1097 |
-
* @return array
|
1098 |
-
*/
|
1099 |
-
protected function _getGoogleCarriersMap() {
|
1100 |
-
return array(
|
1101 |
-
'ups' => array(
|
1102 |
-
'googleCarrierCompany' => 'UPS',
|
1103 |
-
'methods' => array(
|
1104 |
-
'GND' => Mage::helper('usa')->__('Ground'),
|
1105 |
-
'1DA' => Mage::helper('usa')->__('Next Day Air'),
|
1106 |
-
'1DM' => Mage::helper('usa')->__('Next Day Air Early AM'),
|
1107 |
-
'1DP' => Mage::helper('usa')->__('Next Day Air Saver'),
|
1108 |
-
'2DA' => Mage::helper('usa')->__('2nd Day Air'),
|
1109 |
-
'2DM' => Mage::helper('usa')->__('2nd Day Air AM'),
|
1110 |
-
'3DS' => Mage::helper('usa')->__('3 Day Select'),
|
1111 |
-
'03' => Mage::helper('usa')->__('Ground'),
|
1112 |
-
'01' => Mage::helper('usa')->__('Next Day Air'),
|
1113 |
-
'14' => Mage::helper('usa')->__('Next Day Air Early AM'),
|
1114 |
-
'13' => Mage::helper('usa')->__('Next Day Air Saver'),
|
1115 |
-
'02' => Mage::helper('usa')->__('2nd Day Air'),
|
1116 |
-
'59' => Mage::helper('usa')->__('2nd Day Air AM'),
|
1117 |
-
'12' => Mage::helper('usa')->__('3 Day Select')
|
1118 |
-
)
|
1119 |
-
),
|
1120 |
-
'usps' => array(
|
1121 |
-
'googleCarrierCompany' => 'USPS',
|
1122 |
-
'methods' => array(
|
1123 |
-
'Express Mail' => Mage::helper('usa')->__('Express Mail'),
|
1124 |
-
'Priority Mail' => Mage::helper('usa')->__('Priority Mail'),
|
1125 |
-
'Parcel Post' => Mage::helper('usa')->__('Parcel Post'),
|
1126 |
-
'Media Mail' => Mage::helper('usa')->__('Media Mail')
|
1127 |
-
)
|
1128 |
-
),
|
1129 |
-
'fedex' => array(
|
1130 |
-
'googleCarrierCompany' => 'FedEx',
|
1131 |
-
'methods' => array(
|
1132 |
-
'FEDEX_GROUND' => Mage::helper('usa')->__('Ground'),
|
1133 |
-
'GROUND_HOME_DELIVERY' => Mage::helper('usa')->__('Home Delivery'),
|
1134 |
-
'FEDEX_EXPRESS_SAVER' => Mage::helper('usa')->__('Express Saver'),
|
1135 |
-
'FIRST_OVERNIGHT' => Mage::helper('usa')->__('First Overnight'),
|
1136 |
-
'PRIORITY_OVERNIGHT' => Mage::helper('usa')->__('Priority Overnight'),
|
1137 |
-
'STANDARD_OVERNIGHT' => Mage::helper('usa')->__('Standard Overnight'),
|
1138 |
-
'FEDEX_2_DAY' => Mage::helper('usa')->__('2Day')
|
1139 |
-
)
|
1140 |
-
)
|
1141 |
-
);
|
1142 |
-
}
|
1143 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Order.php
DELETED
@@ -1,181 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
class Mage_GoogleCheckout_Model_Api_Xml_Order extends Mage_GoogleCheckout_Model_Api_Xml_Abstract
|
28 |
-
{
|
29 |
-
protected function _getApiUrl()
|
30 |
-
{
|
31 |
-
$url = $this->_getBaseApiUrl();
|
32 |
-
$url .= 'request/Merchant/'.Mage::getStoreConfig('google/checkout/merchant_id', $this->getStoreId());
|
33 |
-
return $url;
|
34 |
-
}
|
35 |
-
|
36 |
-
protected function _processGResponse($response)
|
37 |
-
{
|
38 |
-
if ($response[0]===200) {
|
39 |
-
return true;
|
40 |
-
} else {
|
41 |
-
$xml = simplexml_load_string(html_entity_decode($response[1]));
|
42 |
-
if (!$xml || !$xml->{'error-message'}) {
|
43 |
-
return false;
|
44 |
-
}
|
45 |
-
Mage::throwException($this->__('Google Checkout: %s', (string)$xml->{'error-message'}));
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
// FINANCIAL
|
50 |
-
|
51 |
-
public function authorize()
|
52 |
-
{
|
53 |
-
$GRequest = $this->getGRequest();
|
54 |
-
|
55 |
-
$postargs = '<?xml version="1.0" encoding="UTF-8"?>
|
56 |
-
<authorize-order xmlns="'
|
57 |
-
. $GRequest->schema_url
|
58 |
-
. '" google-order-number="'
|
59 |
-
. $this->getGoogleOrderNumber()
|
60 |
-
. '"/>';
|
61 |
-
|
62 |
-
$response = $GRequest->SendReq($GRequest->request_url,
|
63 |
-
$GRequest->GetAuthenticationHeaders(), $postargs);
|
64 |
-
return $this->_processGResponse($response);
|
65 |
-
}
|
66 |
-
|
67 |
-
public function charge($amount)
|
68 |
-
{
|
69 |
-
$response = $this->getGRequest()
|
70 |
-
->SendChargeOrder($this->getGoogleOrderNumber(), $amount);
|
71 |
-
return $this->_processGResponse($response);
|
72 |
-
}
|
73 |
-
|
74 |
-
public function refund($amount, $reason, $comment = '')
|
75 |
-
{
|
76 |
-
$response = $this->getGRequest()
|
77 |
-
->SendRefundOrder($this->getGoogleOrderNumber(), $amount, $reason, $comment);
|
78 |
-
return $this->_processGResponse($response);
|
79 |
-
}
|
80 |
-
|
81 |
-
public function cancel($reason, $comment = '')
|
82 |
-
{
|
83 |
-
$response = $this->getGRequest()
|
84 |
-
->SendCancelOrder($this->getGoogleOrderNumber(), $reason, $comment);
|
85 |
-
return $this->_processGResponse($response);
|
86 |
-
}
|
87 |
-
|
88 |
-
// FULFILLMENT
|
89 |
-
|
90 |
-
public function process()
|
91 |
-
{
|
92 |
-
$response = $this->getGRequest()
|
93 |
-
->SendProcessOrder($this->getGoogleOrderNumber());
|
94 |
-
return $this->_processGResponse($response);
|
95 |
-
}
|
96 |
-
|
97 |
-
public function deliver($carrier, $trackingNo, $sendMail = true)
|
98 |
-
{
|
99 |
-
$response = $this->getGRequest()
|
100 |
-
->SendDeliverOrder($this->getGoogleOrderNumber(), $carrier, $trackingNo, $sendMail ? 'true' : 'false');
|
101 |
-
return $this->_processGResponse($response);
|
102 |
-
}
|
103 |
-
|
104 |
-
public function addTrackingData($carrier, $trackingNo)
|
105 |
-
{
|
106 |
-
$response = $this->getGRequest()
|
107 |
-
->SendTrackingData($this->getGoogleOrderNumber(), $carrier, $trackingNo);
|
108 |
-
return $this->_processGResponse($response);
|
109 |
-
}
|
110 |
-
|
111 |
-
public function shipItems($items, $sendMail = true)
|
112 |
-
{
|
113 |
-
$googleShipItems = array();
|
114 |
-
foreach ($items as $item) {
|
115 |
-
$googleShipItems[] = new GoogleShipItem($item);
|
116 |
-
}
|
117 |
-
|
118 |
-
$response = $this->getGRequest()
|
119 |
-
->SendShipItems($this->getGoogleOrderNumber(), $googleShipItems, $sendMail ? 'true' : 'false');
|
120 |
-
return $this->_processGResponse($response);
|
121 |
-
}
|
122 |
-
|
123 |
-
public function backorderItems($items, $sendMail = true)
|
124 |
-
{
|
125 |
-
$response = $this->getGRequest()
|
126 |
-
->SendBackorderItems($this->getGoogleOrderNumber(), $items, $sendMail ? 'true' : 'false');
|
127 |
-
return $this->_processGResponse($response);
|
128 |
-
}
|
129 |
-
|
130 |
-
public function cancelItems($items, $reason, $comment = '', $sendMail = true)
|
131 |
-
{
|
132 |
-
$response = $this->getGRequest()
|
133 |
-
->SendCancelItems($this->getGoogleOrderNumber(), $items, $reason, $comment, $sendMail ? 'true' : 'false');
|
134 |
-
return $this->_processGResponse($response);
|
135 |
-
}
|
136 |
-
|
137 |
-
public function returnItems($items, $sendMail = true)
|
138 |
-
{
|
139 |
-
$response = $this->getGRequest()
|
140 |
-
->SendReturnItems($this->getGoogleOrderNumber(), $items, $sendMail ? 'true' : 'false');
|
141 |
-
return $this->_processGResponse($response);
|
142 |
-
}
|
143 |
-
|
144 |
-
public function resetItems($items, $sendMail = true)
|
145 |
-
{
|
146 |
-
$response = $this->getGRequest()
|
147 |
-
->SendRResetItemsShippingInformation($this->getGoogleOrderNumber(), $items, $sendMail ? 'true' : 'false');
|
148 |
-
return $this->_processGResponse($response);
|
149 |
-
}
|
150 |
-
|
151 |
-
// MISC
|
152 |
-
|
153 |
-
public function archive()
|
154 |
-
{
|
155 |
-
$response = $this->getGRequest()
|
156 |
-
->SendArchiveOrder($this->getGoogleOrderNumber());
|
157 |
-
return $this->_processGResponse($response);
|
158 |
-
}
|
159 |
-
|
160 |
-
public function unarchive()
|
161 |
-
{
|
162 |
-
$response = $this->getGRequest()
|
163 |
-
->SendUnarchiveOrder($this->getGoogleOrderNumber());
|
164 |
-
return $this->_processGResponse($response);
|
165 |
-
}
|
166 |
-
|
167 |
-
public function addOrderNumber($merchantOrder)
|
168 |
-
{
|
169 |
-
$response = $this->getGRequest()
|
170 |
-
->SendMerchantOrderNumber($this->getGoogleOrderNumber(), $merchantOrder);
|
171 |
-
return $this->_processGResponse($response);
|
172 |
-
}
|
173 |
-
|
174 |
-
|
175 |
-
public function addBuyerMessage($message, $sendMail = true)
|
176 |
-
{
|
177 |
-
$response = $this->getGRequest()
|
178 |
-
->SendBuyerMessage($this->getGoogleOrderNumber(), $message, $sendMail ? 'true' : 'false');
|
179 |
-
return $this->_processGResponse($response);
|
180 |
-
}
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Mysql4/Api/Debug.php
DELETED
@@ -1,37 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enter description here ...
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Mysql4_Api_Debug extends Mage_GoogleCheckout_Model_Resource_Api_Debug
|
36 |
-
{
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Mysql4/Api/Debug/Collection.php
DELETED
@@ -1,38 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enter description here ...
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Mysql4_Api_Debug_Collection
|
36 |
-
extends Mage_GoogleCheckout_Model_Resource_Api_Debug_Collection
|
37 |
-
{
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Mysql4/Notification.php
DELETED
@@ -1,37 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Google Checkout resource notification model
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Mysql4_Notification extends Mage_GoogleCheckout_Model_Resource_Notification
|
36 |
-
{
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php
DELETED
@@ -1,37 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enter description here ...
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Mysql4_Setup extends Mage_GoogleCheckout_Model_Resource_Setup
|
36 |
-
{
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Mysql4/Tax.php
DELETED
@@ -1,37 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Enter description here ...
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Mysql4_Tax extends Mage_GoogleCheckout_Model_Resource_Tax
|
36 |
-
{
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Notification.php
DELETED
@@ -1,129 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Google Checkout notification model
|
29 |
-
*
|
30 |
-
* @method Mage_GoogleCheckout_Model_Resource_Notification _getResource()
|
31 |
-
* @method Mage_GoogleCheckout_Model_Resource_Notification getResource()
|
32 |
-
* @method string getSerialNumber()
|
33 |
-
* @method Mage_GoogleCheckout_Model_Notification setSerialNumber(string $value)
|
34 |
-
* @method string getStartedAt()
|
35 |
-
* @method Mage_GoogleCheckout_Model_Notification setStartedAt(string $value)
|
36 |
-
* @method int getStatus()
|
37 |
-
* @method Mage_GoogleCheckout_Model_Notification setStatus(int $value)
|
38 |
-
*
|
39 |
-
* @category Mage
|
40 |
-
* @package Mage_GoogleCheckout
|
41 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
42 |
-
*/
|
43 |
-
class Mage_GoogleCheckout_Model_Notification extends Mage_Core_Model_Abstract
|
44 |
-
{
|
45 |
-
const TIMEOUT_LIMIT = 3600;
|
46 |
-
const STATUS_INPROCESS = 0;
|
47 |
-
const STATUS_PROCESSED = 1;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Intialize model
|
51 |
-
*/
|
52 |
-
function _construct()
|
53 |
-
{
|
54 |
-
$this->_init('googlecheckout/notification');
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Assign previously saved notification data to model
|
59 |
-
*
|
60 |
-
* @return Mage_GoogleCheckout_Model_Notification
|
61 |
-
*/
|
62 |
-
public function loadNotificationData()
|
63 |
-
{
|
64 |
-
$data = $this->getResource()->getNotificationData($this->getSerialNumber());
|
65 |
-
if (is_array($data)) {
|
66 |
-
$this->addData($data);
|
67 |
-
}
|
68 |
-
return $this;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Check if current notification is already processed
|
73 |
-
*
|
74 |
-
* @return bool
|
75 |
-
*/
|
76 |
-
public function isProcessed()
|
77 |
-
{
|
78 |
-
return $this->getStatus() == self::STATUS_PROCESSED;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Check if current notification is time out
|
83 |
-
*
|
84 |
-
* @return bool
|
85 |
-
*/
|
86 |
-
public function isTimeout()
|
87 |
-
{
|
88 |
-
$startedTime = strtotime($this->getStartedAt());
|
89 |
-
$currentTime = time();
|
90 |
-
|
91 |
-
if ($currentTime - $startedTime > self::TIMEOUT_LIMIT) {
|
92 |
-
return true;
|
93 |
-
}
|
94 |
-
return false;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Start process of current notification
|
99 |
-
*
|
100 |
-
* @return Mage_GoogleCheckout_Model_Notification
|
101 |
-
*/
|
102 |
-
public function startProcess()
|
103 |
-
{
|
104 |
-
$this->getResource()->startProcess($this->getSerialNumber());
|
105 |
-
return $this;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Update process of current notification
|
110 |
-
*
|
111 |
-
* @return Mage_GoogleCheckout_Model_Notification
|
112 |
-
*/
|
113 |
-
public function updateProcess()
|
114 |
-
{
|
115 |
-
$this->getResource()->updateProcess($this->getSerialNumber());
|
116 |
-
return $this;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Stop process of current notification
|
121 |
-
*
|
122 |
-
* @return Mage_GoogleCheckout_Model_Notification
|
123 |
-
*/
|
124 |
-
public function stopProcess()
|
125 |
-
{
|
126 |
-
$this->getResource()->stopProcess($this->getSerialNumber());
|
127 |
-
return $this;
|
128 |
-
}
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Observer.php
DELETED
@@ -1,105 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Google Checkout Event Observer
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
*/
|
34 |
-
class Mage_GoogleCheckout_Model_Observer
|
35 |
-
{
|
36 |
-
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
37 |
-
{
|
38 |
-
$track = $observer->getEvent()->getTrack();
|
39 |
-
|
40 |
-
$order = $track->getShipment()->getOrder();
|
41 |
-
$shippingMethod = $order->getShippingMethod(); // String in format of 'carrier_method'
|
42 |
-
if (!$shippingMethod) {
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
// Process only Google Checkout internal methods
|
47 |
-
/* @var $gcCarrier Mage_GoogleCheckout_Model_Shipping */
|
48 |
-
$gcCarrier = Mage::getModel('googlecheckout/shipping');
|
49 |
-
list($carrierCode, $methodCode) = explode('_', $shippingMethod);
|
50 |
-
if ($gcCarrier->getCarrierCode() != $carrierCode) {
|
51 |
-
return;
|
52 |
-
}
|
53 |
-
$internalMethods = $gcCarrier->getInternallyAllowedMethods();
|
54 |
-
if (!isset($internalMethods[$methodCode])) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
Mage::getModel('googlecheckout/api')
|
59 |
-
->setStoreId($order->getStoreId())
|
60 |
-
->deliver($order->getExtOrderId(), $track->getCarrierCode(), $track->getNumber());
|
61 |
-
}
|
62 |
-
|
63 |
-
/*
|
64 |
-
* Performs specifical actions on Google Checkout internal shipments saving
|
65 |
-
*
|
66 |
-
* @param Varien_Event_Observer $observer
|
67 |
-
* @return void
|
68 |
-
*/
|
69 |
-
public function salesOrderShipmentSaveAfter(Varien_Event_Observer $observer)
|
70 |
-
{
|
71 |
-
$shipment = $observer->getEvent()->getShipment();
|
72 |
-
$order = $shipment->getOrder();
|
73 |
-
$shippingMethod = $order->getShippingMethod(); // String in format of 'carrier_method'
|
74 |
-
if (!$shippingMethod) {
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
// Process only Google Checkout internal methods
|
79 |
-
/* @var $gcCarrier Mage_GoogleCheckout_Model_Shipping */
|
80 |
-
$gcCarrier = Mage::getModel('googlecheckout/shipping');
|
81 |
-
list($carrierCode, $methodCode) = explode('_', $shippingMethod);
|
82 |
-
if ($gcCarrier->getCarrierCode() != $carrierCode) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
$internalMethods = $gcCarrier->getInternallyAllowedMethods();
|
86 |
-
if (!isset($internalMethods[$methodCode])) {
|
87 |
-
return;
|
88 |
-
}
|
89 |
-
|
90 |
-
// Process this saving
|
91 |
-
$items = array();
|
92 |
-
foreach ($shipment->getAllItems() as $item) {
|
93 |
-
if ($item->getOrderItem()->getParentItemId()) {
|
94 |
-
continue;
|
95 |
-
}
|
96 |
-
$items[] = $item->getSku();
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($items) {
|
100 |
-
Mage::getModel('googlecheckout/api')
|
101 |
-
->setStoreId($order->getStoreId())
|
102 |
-
->shipItems($order->getExtOrderId(), $items);
|
103 |
-
}
|
104 |
-
}
|
105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Payment.php
CHANGED
@@ -24,27 +24,15 @@
|
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
|
|
|
|
|
|
27 |
class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
28 |
{
|
29 |
-
const ACTION_AUTHORIZE = 0;
|
30 |
-
const ACTION_AUTHORIZE_CAPTURE = 1;
|
31 |
-
|
32 |
-
protected $_code = 'googlecheckout';
|
33 |
-
protected $_formBlockType = 'googlecheckout/form';
|
34 |
-
|
35 |
/**
|
36 |
-
*
|
37 |
*/
|
38 |
-
protected $
|
39 |
-
protected $_canAuthorize = true;
|
40 |
-
protected $_canCapture = true;
|
41 |
-
protected $_canCapturePartial = true;
|
42 |
-
protected $_canRefund = true;
|
43 |
-
protected $_canRefundInvoicePartial = true;
|
44 |
-
protected $_canVoid = true;
|
45 |
-
protected $_canUseInternal = false;
|
46 |
-
protected $_canUseCheckout = false;
|
47 |
-
protected $_canUseForMultishipping = false;
|
48 |
|
49 |
/**
|
50 |
* Can be edit order (renew order)
|
@@ -59,56 +47,36 @@ class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstra
|
|
59 |
/**
|
60 |
* Return Order Place Redirect URL
|
61 |
*
|
62 |
-
* @return string
|
63 |
*/
|
64 |
public function getOrderPlaceRedirectUrl()
|
65 |
{
|
66 |
-
return
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
* Authorize
|
71 |
*
|
72 |
-
* @param
|
73 |
-
* @
|
|
|
74 |
*/
|
75 |
public function authorize(Varien_Object $payment, $amount)
|
76 |
{
|
77 |
-
|
78 |
-
$api->authorize($payment->getOrder()->getExtOrderId());
|
79 |
-
|
80 |
-
return $this;
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
* Capture payment
|
85 |
*
|
86 |
-
* @param
|
87 |
-
* @
|
|
|
|
|
88 |
*/
|
89 |
public function capture(Varien_Object $payment, $amount)
|
90 |
{
|
91 |
-
|
92 |
-
try {
|
93 |
-
$this->authorize($payment, $amount);
|
94 |
-
} catch (Exception $e) {
|
95 |
-
// authorization is not expired yet
|
96 |
-
}
|
97 |
-
*/
|
98 |
-
|
99 |
-
if ($payment->getOrder()->getPaymentAuthorizationExpiration() < Mage::getModel('core/date')->gmtTimestamp()) {
|
100 |
-
try {
|
101 |
-
$this->authorize($payment, $amount);
|
102 |
-
} catch (Exception $e) {
|
103 |
-
// authorization is not expired yet
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
$api = Mage::getModel('googlecheckout/api')->setStoreId($payment->getOrder()->getStoreId());
|
108 |
-
$api->charge($payment->getOrder()->getExtOrderId(), $amount);
|
109 |
-
$payment->setForcedState(Mage_Sales_Model_Order_Invoice::STATE_OPEN);
|
110 |
-
|
111 |
-
return $this;
|
112 |
}
|
113 |
|
114 |
/**
|
@@ -116,45 +84,34 @@ class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstra
|
|
116 |
*
|
117 |
* @param Varien_Object $payment
|
118 |
* @param float $amount
|
119 |
-
*
|
120 |
-
* @return
|
121 |
*/
|
122 |
public function refund(Varien_Object $payment, $amount)
|
123 |
{
|
124 |
-
|
125 |
-
$comment = $this->getComment() ? $this->getComment() : Mage::helper('googlecheckout')->__('No Comment');
|
126 |
-
|
127 |
-
$api = Mage::getModel('googlecheckout/api')->setStoreId($payment->getOrder()->getStoreId());
|
128 |
-
$api->refund($payment->getOrder()->getExtOrderId(), $amount, $reason, $comment);
|
129 |
-
|
130 |
-
return $this;
|
131 |
}
|
132 |
|
|
|
|
|
|
|
|
|
|
|
133 |
public function void(Varien_Object $payment)
|
134 |
{
|
135 |
-
|
136 |
-
|
137 |
-
return $this;
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
* Void payment
|
142 |
*
|
143 |
* @param Varien_Object $payment
|
144 |
-
*
|
145 |
-
* @return
|
146 |
*/
|
147 |
public function cancel(Varien_Object $payment)
|
148 |
{
|
149 |
-
|
150 |
-
$reason = $this->getReason() ? $this->getReason() : Mage::helper('googlecheckout')->__('Unknown Reason');
|
151 |
-
$comment = $this->getComment() ? $this->getComment() : Mage::helper('googlecheckout')->__('No Comment');
|
152 |
-
|
153 |
-
$api = Mage::getModel('googlecheckout/api')->setStoreId($payment->getOrder()->getStoreId());
|
154 |
-
$api->cancel($payment->getOrder()->getExtOrderId(), $reason, $comment);
|
155 |
-
}
|
156 |
-
|
157 |
-
return $this;
|
158 |
}
|
159 |
|
160 |
/**
|
@@ -163,16 +120,11 @@ class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstra
|
|
163 |
* @param string $field
|
164 |
* @param int|string|null|Mage_Core_Model_Store $storeId
|
165 |
*
|
166 |
-
* @return
|
167 |
*/
|
168 |
public function getConfigData($field, $storeId = null)
|
169 |
{
|
170 |
-
|
171 |
-
$storeId = $this->getStore();
|
172 |
-
}
|
173 |
-
$path = 'google/checkout/' . $field;
|
174 |
-
|
175 |
-
return Mage::getStoreConfig($path, $storeId);
|
176 |
}
|
177 |
|
178 |
/**
|
@@ -183,12 +135,6 @@ class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstra
|
|
183 |
*/
|
184 |
public function canVoid(Varien_Object $payment)
|
185 |
{
|
186 |
-
|
187 |
-
|| $payment instanceof Mage_Sales_Model_Order_Creditmemo
|
188 |
-
) {
|
189 |
-
return false;
|
190 |
-
}
|
191 |
-
|
192 |
-
return $this->_canVoid;
|
193 |
}
|
194 |
}
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
26 |
|
27 |
+
/**
|
28 |
+
* @deprecated after 1.13.1.0
|
29 |
+
*/
|
30 |
class Mage_GoogleCheckout_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
31 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
+
* @var string
|
34 |
*/
|
35 |
+
protected $_code = 'googlecheckout';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
/**
|
38 |
* Can be edit order (renew order)
|
47 |
/**
|
48 |
* Return Order Place Redirect URL
|
49 |
*
|
50 |
+
* @return string
|
51 |
*/
|
52 |
public function getOrderPlaceRedirectUrl()
|
53 |
{
|
54 |
+
return '';
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* Authorize
|
59 |
*
|
60 |
+
* @param Varien_Object $payment
|
61 |
+
* @param float $amount
|
62 |
+
* @return Mage_GoogleCheckout_Model_Payment
|
63 |
*/
|
64 |
public function authorize(Varien_Object $payment, $amount)
|
65 |
{
|
66 |
+
Mage::throwException(Mage::helper('payment')->__('Google Checkout has been deprecated.'));
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
* Capture payment
|
71 |
*
|
72 |
+
* @param Varien_Object $payment
|
73 |
+
* @param float $amount
|
74 |
+
* @throws Exception
|
75 |
+
* @return void
|
76 |
*/
|
77 |
public function capture(Varien_Object $payment, $amount)
|
78 |
{
|
79 |
+
Mage::throwException(Mage::helper('payment')->__('Google Checkout has been deprecated.'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
/**
|
84 |
*
|
85 |
* @param Varien_Object $payment
|
86 |
* @param float $amount
|
87 |
+
* @throws Exception
|
88 |
+
* @return void
|
89 |
*/
|
90 |
public function refund(Varien_Object $payment, $amount)
|
91 |
{
|
92 |
+
Mage::throwException(Mage::helper('payment')->__('Google Checkout has been deprecated.'));
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* @param Varien_Object $payment
|
97 |
+
* @throws Exception
|
98 |
+
* @return void
|
99 |
+
*/
|
100 |
public function void(Varien_Object $payment)
|
101 |
{
|
102 |
+
Mage::throwException(Mage::helper('payment')->__('Google Checkout has been deprecated.'));
|
|
|
|
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Void payment
|
107 |
*
|
108 |
* @param Varien_Object $payment
|
109 |
+
* @throws Exception
|
110 |
+
* @return void
|
111 |
*/
|
112 |
public function cancel(Varien_Object $payment)
|
113 |
{
|
114 |
+
Mage::throwException(Mage::helper('payment')->__('Google Checkout has been deprecated.'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
/**
|
120 |
* @param string $field
|
121 |
* @param int|string|null|Mage_Core_Model_Store $storeId
|
122 |
*
|
123 |
+
* @return null
|
124 |
*/
|
125 |
public function getConfigData($field, $storeId = null)
|
126 |
{
|
127 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
/**
|
135 |
*/
|
136 |
public function canVoid(Varien_Object $payment)
|
137 |
{
|
138 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
}
|
app/code/core/Mage/GoogleCheckout/Model/Resource/Notification.php
DELETED
@@ -1,109 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Google Checkout resource notification model
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Resource_Notification extends Mage_Core_Model_Resource_Db_Abstract
|
36 |
-
{
|
37 |
-
/**
|
38 |
-
* Intialize resource model.
|
39 |
-
* Set main entity table name and primary key field name.
|
40 |
-
*
|
41 |
-
*/
|
42 |
-
protected function _construct()
|
43 |
-
{
|
44 |
-
$this->_init('googlecheckout/notification', 'serial_number');
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Return notification data by serial number
|
49 |
-
*
|
50 |
-
* @param string $serialNumber
|
51 |
-
* @return array
|
52 |
-
*/
|
53 |
-
public function getNotificationData($serialNumber)
|
54 |
-
{
|
55 |
-
$select = $this->_getReadAdapter()->select()
|
56 |
-
->from($this->getMainTable(), array('*'))
|
57 |
-
->where('serial_number = ?', $serialNumber);
|
58 |
-
|
59 |
-
return $this->_getReadAdapter()->fetchRow($select);
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Start notification processing
|
64 |
-
*
|
65 |
-
* @param string $serialNumber
|
66 |
-
* @return Mage_GoogleCheckout_Model_Resource_Notification
|
67 |
-
*/
|
68 |
-
public function startProcess($serialNumber)
|
69 |
-
{
|
70 |
-
$data = array(
|
71 |
-
'serial_number' => $serialNumber,
|
72 |
-
'started_at' => Varien_Date::now(),
|
73 |
-
'status' => Mage_GoogleCheckout_Model_Notification::STATUS_INPROCESS
|
74 |
-
);
|
75 |
-
$this->_getWriteAdapter()->insert($this->getMainTable(), $data);
|
76 |
-
return $this;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Stop notification processing
|
81 |
-
*
|
82 |
-
* @param string $serialNumber
|
83 |
-
* @return Mage_GoogleCheckout_Model_Resource_Notification
|
84 |
-
*/
|
85 |
-
public function stopProcess($serialNumber)
|
86 |
-
{
|
87 |
-
$this->_getWriteAdapter()->update($this->getMainTable(),
|
88 |
-
array('status' => Mage_GoogleCheckout_Model_Notification::STATUS_PROCESSED),
|
89 |
-
array('serial_number = ?' => $serialNumber)
|
90 |
-
);
|
91 |
-
return $this;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Update notification processing
|
96 |
-
*
|
97 |
-
* @param string $serialNumber
|
98 |
-
* @return Mage_GoogleCheckout_Model_Resource_Notification
|
99 |
-
*/
|
100 |
-
public function updateProcess($serialNumber)
|
101 |
-
{
|
102 |
-
$this->_getWriteAdapter()->update($this->getMainTable(),
|
103 |
-
array('started_at' => Varien_Date::now()),
|
104 |
-
array('serial_number = ?' => $serialNumber)
|
105 |
-
);
|
106 |
-
|
107 |
-
return $this;
|
108 |
-
}
|
109 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Resource/Setup.php
DELETED
@@ -1,37 +0,0 @@
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_GoogleCheckout
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Setup resource model
|
30 |
-
*
|
31 |
-
* @category Mage
|
32 |
-
* @package Mage_GoogleCheckout
|
33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
-
*/
|
35 |
-
class Mage_GoogleCheckout_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup
|
36 |
-
{
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/GoogleCheckout/Model/Resource/Tax.php
DELETED
@@ -1,76 +0,0 @@
|
|
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@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|