Version Notes
1.5.0.0.22.1 version of package
internal svn revision #121425
Download this release
Release Info
Developer | Magento Core Team |
Extension | Magento_Mobile |
Version | 1.5.0.0.22.1 |
Comparing to | |
See all releases |
Code changes from version 1.4.2.0.22.1 to 1.5.0.0.22.1
- app/code/core/Mage/XmlConnect/Block/Cart.php +1 -1
- app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php +2 -1
- app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php +26 -13
- app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php +1 -1
- app/code/core/Mage/XmlConnect/Block/Cart/Totals.php +0 -1
- app/code/core/Mage/XmlConnect/Block/Catalog/Category.php +3 -1
- app/code/core/Mage/XmlConnect/Block/Catalog/Product.php +10 -7
- app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php +2 -2
- app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Bundle.php +1 -2
- app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Configurable.php +1 -2
- app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php +1 -2
- app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Bundle.php +12 -34
- app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php +3 -5
- app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php +39 -1
- app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php +2 -4
- app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php +3 -3
- app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php +4 -2
- app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php +23 -8
- app/code/core/Mage/XmlConnect/Block/Review/Form.php +46 -23
- app/code/core/Mage/XmlConnect/Block/Wishlist.php +15 -14
- app/code/core/Mage/XmlConnect/Helper/Data.php +4 -5
- app/code/core/Mage/XmlConnect/Helper/Image.php +2 -1
- app/code/core/Mage/XmlConnect/Model/Corefix/Checkout/Session.php +0 -137
- app/code/core/Mage/XmlConnect/Model/Corefix/Checkout/Type/Onepage.php +0 -465
- app/code/core/Mage/XmlConnect/Model/Corefix/Sales/Quote.php +0 -427
- app/code/core/Mage/XmlConnect/Model/Payment/Method/Paypal/Mecl.php +12 -0
- app/code/core/Mage/XmlConnect/Model/Paypal/Mep/Checkout.php +2 -3
- app/code/core/Mage/XmlConnect/Model/Simplexml/Element.php +6 -2
- app/code/core/Mage/XmlConnect/controllers/CartController.php +1 -1
- app/code/core/Mage/XmlConnect/controllers/CheckoutController.php +4 -4
- app/code/core/Mage/XmlConnect/controllers/Paypal/MepController.php +4 -6
- app/code/core/Mage/XmlConnect/controllers/WishlistController.php +23 -6
- app/design/adminhtml/default/default/template/xmlconnect/mobile/notification_helper.phtml +6 -6
- package.xml +5 -5
app/code/core/Mage/XmlConnect/Block/Cart.php
CHANGED
@@ -91,7 +91,7 @@ class Mage_XmlConnect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract
|
|
91 |
) {
|
92 |
$inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
|
93 |
} else {
|
94 |
-
$inclPrice
|
95 |
}
|
96 |
}
|
97 |
$exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
|
91 |
) {
|
92 |
$inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
|
93 |
} else {
|
94 |
+
$inclPrice = $_incl - $item->getWeeeTaxDisposition();
|
95 |
}
|
96 |
}
|
97 |
$exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
|
app/code/core/Mage/XmlConnect/Block/Cart/Crosssell.php
CHANGED
@@ -83,7 +83,8 @@ class Mage_XmlConnect_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Cros
|
|
83 |
}
|
84 |
|
85 |
if ($this->getChild('product_price')) {
|
86 |
-
$this->getChild('product_price')->setProduct($product)
|
|
|
87 |
->collectProductPrices();
|
88 |
}
|
89 |
|
83 |
}
|
84 |
|
85 |
if ($this->getChild('product_price')) {
|
86 |
+
$this->getChild('product_price')->setProduct($product)
|
87 |
+
->setProductXmlObj($itemXmlObj)
|
88 |
->collectProductPrices();
|
89 |
}
|
90 |
|
app/code/core/Mage/XmlConnect/Block/Cart/Item/Renderer.php
CHANGED
@@ -55,10 +55,14 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
|
|
55 |
$value = null;
|
56 |
}
|
57 |
|
58 |
-
$optionsXmlObj->addCustomChild(
|
59 |
-
'
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
}
|
64 |
|
@@ -84,7 +88,8 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
|
|
84 |
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
|
85 |
if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
|
86 |
&& $_item->getWeeeTaxAppliedAmount()) {
|
87 |
-
$exclPrice = $_item->getRowTotal()
|
|
|
88 |
+ $_item->getWeeeTaxRowDisposition();
|
89 |
} else {
|
90 |
$exclPrice = $_item->getRowTotal();
|
@@ -207,10 +212,14 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
|
|
207 |
$amount = $tax['amount'];
|
208 |
}
|
209 |
|
210 |
-
$weeeXmlObj->addCustomChild(
|
211 |
-
'
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
} elseif ($_item->getWeeeTaxAppliedAmount()
|
216 |
&& ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))
|
@@ -223,10 +232,14 @@ class Mage_XmlConnect_Block_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_
|
|
223 |
$amount = $tax['amount_incl_tax'];
|
224 |
}
|
225 |
|
226 |
-
$weeeXmlObj->addCustomChild(
|
227 |
-
'
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
}
|
232 |
|
55 |
$value = null;
|
56 |
}
|
57 |
|
58 |
+
$optionsXmlObj->addCustomChild(
|
59 |
+
'option',
|
60 |
+
$value,
|
61 |
+
array(
|
62 |
+
'label' => $this->htmlEscape($_option['label']),
|
63 |
+
'value' => $_formattedOptionValue['value']
|
64 |
+
)
|
65 |
+
);
|
66 |
}
|
67 |
}
|
68 |
|
88 |
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
|
89 |
if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')
|
90 |
&& $_item->getWeeeTaxAppliedAmount()) {
|
91 |
+
$exclPrice = $_item->getRowTotal()
|
92 |
+
+ $_item->getWeeeTaxAppliedRowAmount()
|
93 |
+ $_item->getWeeeTaxRowDisposition();
|
94 |
} else {
|
95 |
$exclPrice = $_item->getRowTotal();
|
212 |
$amount = $tax['amount'];
|
213 |
}
|
214 |
|
215 |
+
$weeeXmlObj->addCustomChild(
|
216 |
+
'item',
|
217 |
+
null,
|
218 |
+
array(
|
219 |
+
'name' => $tax['title'],
|
220 |
+
'amount' => $this->_formatPrice($amount)
|
221 |
+
)
|
222 |
+
);
|
223 |
}
|
224 |
} elseif ($_item->getWeeeTaxAppliedAmount()
|
225 |
&& ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))
|
232 |
$amount = $tax['amount_incl_tax'];
|
233 |
}
|
234 |
|
235 |
+
$weeeXmlObj->addCustomChild(
|
236 |
+
'item',
|
237 |
+
null,
|
238 |
+
array(
|
239 |
+
'name' => $tax['title'],
|
240 |
+
'amount' => $this->_formatPrice($amount)
|
241 |
+
)
|
242 |
+
);
|
243 |
}
|
244 |
}
|
245 |
|
app/code/core/Mage/XmlConnect/Block/Cart/Paypal/Mep/Totals.php
CHANGED
@@ -43,7 +43,7 @@ class Mage_XmlConnect_Block_Cart_Paypal_Mep_Totals extends Mage_Checkout_Block_C
|
|
43 |
/** @var $paypalCart Mage_Paypal_Model_Cart */
|
44 |
$paypalCart = Mage::getModel('paypal/cart', array($this->getQuote()));
|
45 |
/** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
|
46 |
-
$totalsXmlObj
|
47 |
foreach ($paypalCart->getTotals(true) as $code => $amount) {
|
48 |
$currencyAmount = $this->helper('core')->currency($amount, false, false);
|
49 |
$totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount));
|
43 |
/** @var $paypalCart Mage_Paypal_Model_Cart */
|
44 |
$paypalCart = Mage::getModel('paypal/cart', array($this->getQuote()));
|
45 |
/** @var $totalsXmlObj Mage_XmlConnect_Model_Simplexml_Element */
|
46 |
+
$totalsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<cart_totals></cart_totals>');
|
47 |
foreach ($paypalCart->getTotals(true) as $code => $amount) {
|
48 |
$currencyAmount = $this->helper('core')->currency($amount, false, false);
|
49 |
$totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount));
|
app/code/core/Mage/XmlConnect/Block/Cart/Totals.php
CHANGED
@@ -100,7 +100,6 @@ class Mage_XmlConnect_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
|
|
100 |
$title,
|
101 |
$grandTotalExlTax
|
102 |
);
|
103 |
-
|
104 |
$code = $code . '_incl_tax';
|
105 |
$title = $this->__('Grand Total (Incl. Tax)');
|
106 |
}
|
100 |
$title,
|
101 |
$grandTotalExlTax
|
102 |
);
|
|
|
103 |
$code = $code . '_incl_tax';
|
104 |
$title = $this->__('Grand Total (Incl. Tax)');
|
105 |
}
|
app/code/core/Mage/XmlConnect/Block/Catalog/Category.php
CHANGED
@@ -88,7 +88,9 @@ class Mage_XmlConnect_Block_Catalog_Category extends Mage_XmlConnect_Block_Catal
|
|
88 |
}
|
89 |
$icon = Mage::helper('xmlconnect/catalog_category_image')
|
90 |
->initialize($item, 'thumbnail')
|
91 |
-
->resize(
|
|
|
|
|
92 |
|
93 |
$iconXml = $itemXmlObj->addChild('icon', $icon);
|
94 |
|
88 |
}
|
89 |
$icon = Mage::helper('xmlconnect/catalog_category_image')
|
90 |
->initialize($item, 'thumbnail')
|
91 |
+
->resize(
|
92 |
+
Mage::helper('xmlconnect/image')->getImageSizeForContent('category')
|
93 |
+
);
|
94 |
|
95 |
$iconXml = $itemXmlObj->addChild('icon', $icon);
|
96 |
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product.php
CHANGED
@@ -61,9 +61,7 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
|
|
61 |
$propertyToResizeName = 'image';
|
62 |
}
|
63 |
|
64 |
-
$icon = clone Mage::helper('catalog/image')
|
65 |
-
->init($product, $propertyToResizeName)
|
66 |
-
->resize($imageToResize);
|
67 |
|
68 |
$iconXml = $item->addChild('icon', $icon);
|
69 |
|
@@ -97,8 +95,14 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
|
|
97 |
Mage::getModel('review/review')->getEntitySummary($product, Mage::app()->getStore()->getId());
|
98 |
}
|
99 |
|
100 |
-
$item->addChild(
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
if ($this->getChild('product_price')) {
|
104 |
$this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)
|
@@ -154,8 +158,7 @@ class Mage_XmlConnect_Block_Catalog_Product extends Mage_XmlConnect_Block_Catalo
|
|
154 |
}
|
155 |
}
|
156 |
|
157 |
-
$productOptions = $this->getChild('xmlconnect.catalog.product.options')
|
158 |
-
->getProductOptionsXmlObject($product);
|
159 |
if ($productOptions instanceof Mage_XmlConnect_Model_Simplexml_Element) {
|
160 |
$productXmlObj->appendChild($productOptions);
|
161 |
}
|
61 |
$propertyToResizeName = 'image';
|
62 |
}
|
63 |
|
64 |
+
$icon = clone Mage::helper('catalog/image')->init($product, $propertyToResizeName)->resize($imageToResize);
|
|
|
|
|
65 |
|
66 |
$iconXml = $item->addChild('icon', $icon);
|
67 |
|
95 |
Mage::getModel('review/review')->getEntitySummary($product, Mage::app()->getStore()->getId());
|
96 |
}
|
97 |
|
98 |
+
$item->addChild(
|
99 |
+
'rating_summary',
|
100 |
+
round((int)$product->getRatingSummary()->getRatingSummary() / 10)
|
101 |
+
);
|
102 |
+
$item->addChild(
|
103 |
+
'reviews_count',
|
104 |
+
$product->getRatingSummary()->getReviewsCount()
|
105 |
+
);
|
106 |
|
107 |
if ($this->getChild('product_price')) {
|
108 |
$this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)
|
158 |
}
|
159 |
}
|
160 |
|
161 |
+
$productOptions = $this->getChild('xmlconnect.catalog.product.options')->getProductOptionsXmlObject($product);
|
|
|
162 |
if ($productOptions instanceof Mage_XmlConnect_Model_Simplexml_Element) {
|
163 |
$productXmlObj->appendChild($productOptions);
|
164 |
}
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options.php
CHANGED
@@ -60,7 +60,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
|
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
* Create
|
64 |
*
|
65 |
* @param Mage_Catalog_Model_Product $product
|
66 |
* @return Mage_XmlConnect_Model_Simplexml_Element
|
@@ -179,7 +179,7 @@ class Mage_XmlConnect_Block_Catalog_Product_Options extends Mage_XmlConnect_Bloc
|
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
-
* Create
|
183 |
*
|
184 |
* @param Mage_Catalog_Model_Product $product
|
185 |
* @return Mage_XmlConnect_Model_Simplexml_Element | false
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* Create produc custom options Mage_XmlConnect_Model_Simplexml_Element object
|
64 |
*
|
65 |
* @param Mage_Catalog_Model_Product $product
|
66 |
* @return Mage_XmlConnect_Model_Simplexml_Element
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
+
* Create product custom options Mage_XmlConnect_Model_Simplexml_Element object
|
183 |
*
|
184 |
* @param Mage_Catalog_Model_Product $product
|
185 |
* @return Mage_XmlConnect_Model_Simplexml_Element | false
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Bundle.php
CHANGED
@@ -31,8 +31,7 @@
|
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
-
class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle
|
35 |
-
extends Mage_XmlConnect_Block_Catalog_Product_Options
|
36 |
{
|
37 |
/**
|
38 |
* Generate bundle product options xml
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
+
class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConnect_Block_Catalog_Product_Options
|
|
|
35 |
{
|
36 |
/**
|
37 |
* Generate bundle product options xml
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Configurable.php
CHANGED
@@ -31,8 +31,7 @@
|
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
-
class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable
|
35 |
-
extends Mage_XmlConnect_Block_Catalog_Product_Options
|
36 |
{
|
37 |
/**
|
38 |
* Generate bundle product options xml
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
+
class Mage_XmlConnect_Block_Catalog_Product_Options_Configurable extends Mage_XmlConnect_Block_Catalog_Product_Options
|
|
|
35 |
{
|
36 |
/**
|
37 |
* Generate bundle product options xml
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Options/Grouped.php
CHANGED
@@ -31,8 +31,7 @@
|
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
-
class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped
|
35 |
-
extends Mage_XmlConnect_Block_Catalog_Product_Options
|
36 |
{
|
37 |
/**
|
38 |
* Generate bundle product options xml
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
+
class Mage_XmlConnect_Block_Catalog_Product_Options_Grouped extends Mage_XmlConnect_Block_Catalog_Product_Options
|
|
|
35 |
{
|
36 |
/**
|
37 |
* Generate bundle product options xml
|
app/code/core/Mage/XmlConnect/Block/Catalog/Product/Price/Bundle.php
CHANGED
@@ -110,12 +110,10 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
|
|
110 |
}
|
111 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
112 |
$weeeItemXmlObj->addAttribute(
|
113 |
-
'name',
|
114 |
-
$weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
115 |
);
|
116 |
$weeeItemXmlObj->addAttribute(
|
117 |
-
'amount',
|
118 |
-
$_coreHelper->currency($amount, true, false)
|
119 |
);
|
120 |
}
|
121 |
}
|
@@ -142,13 +140,9 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
|
|
142 |
}
|
143 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
144 |
$weeeItemXmlObj->addAttribute(
|
145 |
-
'name',
|
146 |
-
$weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
147 |
-
);
|
148 |
-
$weeeItemXmlObj->addAttribute(
|
149 |
-
'amount',
|
150 |
-
$_coreHelper->currency($amount, true, false)
|
151 |
);
|
|
|
152 |
}
|
153 |
}
|
154 |
if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
|
@@ -182,13 +176,9 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
|
|
182 |
}
|
183 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
184 |
$weeeItemXmlObj->addAttribute(
|
185 |
-
'name',
|
186 |
-
$weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
187 |
-
);
|
188 |
-
$weeeItemXmlObj->addAttribute(
|
189 |
-
'amount',
|
190 |
-
$_coreHelper->currency($amount, true, false)
|
191 |
);
|
|
|
192 |
}
|
193 |
}
|
194 |
$priceXmlObj->addAttribute(
|
@@ -214,13 +204,9 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
|
|
214 |
}
|
215 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
216 |
$weeeItemXmlObj->addAttribute(
|
217 |
-
'name',
|
218 |
-
$weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
219 |
-
);
|
220 |
-
$weeeItemXmlObj->addAttribute(
|
221 |
-
'amount',
|
222 |
-
$_coreHelper->currency($amount, true, false)
|
223 |
);
|
|
|
224 |
}
|
225 |
}
|
226 |
if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
|
@@ -263,24 +249,16 @@ class Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
|
|
263 |
}
|
264 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
265 |
$weeeItemXmlObj->addAttribute(
|
266 |
-
'name',
|
267 |
-
$weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
268 |
-
);
|
269 |
-
$weeeItemXmlObj->addAttribute(
|
270 |
-
'amount',
|
271 |
-
$_coreHelper->currency($amount, true, false)
|
272 |
);
|
|
|
273 |
}
|
274 |
}
|
275 |
$priceXmlObj->addAttribute(
|
276 |
-
'to_including_tax',
|
277 |
-
$_coreHelper->currency($_maximalPriceInclTax, true, false)
|
278 |
);
|
279 |
} else {
|
280 |
-
$priceXmlObj->addAttribute(
|
281 |
-
'to',
|
282 |
-
$_coreHelper->currency($_maximalPriceTax, true, false)
|
283 |
-
);
|
284 |
if ($_weeeTaxAmount && $product->getPriceType() == 1
|
285 |
&& $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
|
286 |
) {
|
110 |
}
|
111 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
112 |
$weeeItemXmlObj->addAttribute(
|
113 |
+
'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
|
|
114 |
);
|
115 |
$weeeItemXmlObj->addAttribute(
|
116 |
+
'amount', $_coreHelper->currency($amount, true, false)
|
|
|
117 |
);
|
118 |
}
|
119 |
}
|
140 |
}
|
141 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
142 |
$weeeItemXmlObj->addAttribute(
|
143 |
+
'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
|
|
|
|
|
|
|
|
|
|
144 |
);
|
145 |
+
$weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency($amount, true, false));
|
146 |
}
|
147 |
}
|
148 |
if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
|
176 |
}
|
177 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
178 |
$weeeItemXmlObj->addAttribute(
|
179 |
+
'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
|
|
|
|
|
|
|
|
|
|
180 |
);
|
181 |
+
$weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency($amount, true, false));
|
182 |
}
|
183 |
}
|
184 |
$priceXmlObj->addAttribute(
|
204 |
}
|
205 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
206 |
$weeeItemXmlObj->addAttribute(
|
207 |
+
'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
|
|
|
|
|
|
|
|
|
|
208 |
);
|
209 |
+
$weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency($amount, true, false));
|
210 |
}
|
211 |
}
|
212 |
if ($_weeeHelper->typeOfDisplay($product, 2) && $_weeeTaxAmount) {
|
249 |
}
|
250 |
$weeeItemXmlObj = $weeeXmlObj->addChild('item');
|
251 |
$weeeItemXmlObj->addAttribute(
|
252 |
+
'name', $weeeItemXmlObj->escapeXml($_weeeTaxAttribute->getName())
|
|
|
|
|
|
|
|
|
|
|
253 |
);
|
254 |
+
$weeeItemXmlObj->addAttribute('amount', $_coreHelper->currency($amount, true, false));
|
255 |
}
|
256 |
}
|
257 |
$priceXmlObj->addAttribute(
|
258 |
+
'to_including_tax', $_coreHelper->currency($_maximalPriceInclTax, true, false)
|
|
|
259 |
);
|
260 |
} else {
|
261 |
+
$priceXmlObj->addAttribute('to', $_coreHelper->currency($_maximalPriceTax, true, false));
|
|
|
|
|
|
|
262 |
if ($_weeeTaxAmount && $product->getPriceType() == 1
|
263 |
&& $_weeeHelper->typeOfDisplay($product, array(2, 1, 4))
|
264 |
) {
|
app/code/core/Mage/XmlConnect/Block/Checkout/Order/Review/Info.php
CHANGED
@@ -31,8 +31,7 @@
|
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
-
class Mage_XmlConnect_Block_Checkout_Order_Review_Info
|
35 |
-
extends Mage_Checkout_Block_Onepage_Review_Info
|
36 |
{
|
37 |
/**
|
38 |
* Render order review items
|
@@ -42,7 +41,7 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info
|
|
42 |
protected function _toHtml()
|
43 |
{
|
44 |
$itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<products></products>');
|
45 |
-
$quote = Mage::getSingleton('
|
46 |
|
47 |
/* @var $item Mage_Sales_Model_Quote_Item */
|
48 |
foreach ($this->getItems() as $item) {
|
@@ -74,8 +73,7 @@ class Mage_XmlConnect_Block_Checkout_Order_Review_Info
|
|
74 |
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
|
75 |
$typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
|
76 |
if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
|
77 |
-
$exclPrice = $item->getCalculationPrice()
|
78 |
-
+ $item->getWeeeTaxAppliedAmount()
|
79 |
+ $item->getWeeeTaxDisposition();
|
80 |
} else {
|
81 |
$exclPrice = $item->getCalculationPrice();
|
31 |
* @package Mage_XmlConnect
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
+
class Mage_XmlConnect_Block_Checkout_Order_Review_Info extends Mage_Checkout_Block_Onepage_Review_Info
|
|
|
35 |
{
|
36 |
/**
|
37 |
* Render order review items
|
41 |
protected function _toHtml()
|
42 |
{
|
43 |
$itemsXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<products></products>');
|
44 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
45 |
|
46 |
/* @var $item Mage_Sales_Model_Quote_Item */
|
47 |
foreach ($this->getItems() as $item) {
|
73 |
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
|
74 |
$typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales');
|
75 |
if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) {
|
76 |
+
$exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount()
|
|
|
77 |
+ $item->getWeeeTaxDisposition();
|
78 |
} else {
|
79 |
$exclPrice = $item->getCalculationPrice();
|
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Info/Authorizenet.php
CHANGED
@@ -32,6 +32,44 @@
|
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Authorizenet
|
35 |
-
extends
|
36 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
32 |
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
class Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Authorizenet
|
35 |
+
extends Mage_Paygate_Block_Authorizenet_Info_Cc
|
36 |
{
|
37 |
+
/**
|
38 |
+
* Add Authorizenet info to order XML object
|
39 |
+
*
|
40 |
+
* @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
|
41 |
+
* @return Mage_XmlConnect_Model_Simplexml_Element
|
42 |
+
*/
|
43 |
+
public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
|
44 |
+
{
|
45 |
+
$orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
|
46 |
+
if (!$this->getHideTitle()) {
|
47 |
+
$orderItemXmlObj->addAttribute(
|
48 |
+
'title',
|
49 |
+
$orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
$cards = $this->getCards();
|
54 |
+
$showCount = count($cards) > 1;
|
55 |
+
|
56 |
+
foreach ($cards as $key => $card) {
|
57 |
+
$creditCard = $orderItemXmlObj->addCustomChild(
|
58 |
+
'item',
|
59 |
+
null,
|
60 |
+
array(
|
61 |
+
'label' => $showCount ? $this->__('Credit Card %s', $key + 1) : $this->__('Credit Card')
|
62 |
+
)
|
63 |
+
);
|
64 |
+
foreach ($card as $label => $value) {
|
65 |
+
$creditCard->addCustomChild(
|
66 |
+
'item',
|
67 |
+
implode($this->getValueAsArray($value, true), PHP_EOL),
|
68 |
+
array(
|
69 |
+
'label' => $label
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
}
|
app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/List.php
CHANGED
@@ -80,7 +80,7 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List
|
|
80 |
*/
|
81 |
public function getQuote()
|
82 |
{
|
83 |
-
return Mage::getSingleton('
|
84 |
}
|
85 |
|
86 |
/**
|
@@ -314,9 +314,7 @@ class Mage_XmlConnect_Block_Checkout_Payment_Method_List
|
|
314 |
$renderer->addPaymentFormToXmlObj($methodItemXmlObj);
|
315 |
}
|
316 |
if (!count($usedMethods)) {
|
317 |
-
Mage::throwException(
|
318 |
-
$this->__('Sorry, no payment options are available for this order at this time.')
|
319 |
-
);
|
320 |
}
|
321 |
return $methodsXmlObj->asNiceXml();
|
322 |
}
|
80 |
*/
|
81 |
public function getQuote()
|
82 |
{
|
83 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
84 |
}
|
85 |
|
86 |
/**
|
314 |
$renderer->addPaymentFormToXmlObj($methodItemXmlObj);
|
315 |
}
|
316 |
if (!count($usedMethods)) {
|
317 |
+
Mage::throwException($this->__('Sorry, no payment options are available for this order at this time.'));
|
|
|
|
|
318 |
}
|
319 |
return $methodsXmlObj->asNiceXml();
|
320 |
}
|
app/code/core/Mage/XmlConnect/Block/Checkout/Shipping/Method/Available.php
CHANGED
@@ -27,9 +27,9 @@
|
|
27 |
/**
|
28 |
* One page checkout shipping methods xml renderer
|
29 |
*
|
30 |
-
* @category
|
31 |
-
* @package
|
32 |
-
* @author
|
33 |
*/
|
34 |
class Mage_XmlConnect_Block_Checkout_Shipping_Method_Available
|
35 |
extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
|
27 |
/**
|
28 |
* One page checkout shipping methods xml renderer
|
29 |
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_XmlConnect
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
*/
|
34 |
class Mage_XmlConnect_Block_Checkout_Shipping_Method_Available
|
35 |
extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
|
app/code/core/Mage/XmlConnect/Block/Customer/Address/List.php
CHANGED
@@ -82,8 +82,10 @@ class Mage_XmlConnect_Block_Customer_Address_List extends Mage_Core_Block_Templa
|
|
82 |
* @return array
|
83 |
*/
|
84 |
public function prepareAddressData(
|
85 |
-
Mage_Customer_Model_Address $address,
|
86 |
-
|
|
|
|
|
87 |
if (!$address) {
|
88 |
return array();
|
89 |
}
|
82 |
* @return array
|
83 |
*/
|
84 |
public function prepareAddressData(
|
85 |
+
Mage_Customer_Model_Address $address,
|
86 |
+
Mage_XmlConnect_Model_Simplexml_Element $item
|
87 |
+
)
|
88 |
+
{
|
89 |
if (!$address) {
|
90 |
return array();
|
91 |
}
|
app/code/core/Mage/XmlConnect/Block/Customer/Order/List.php
CHANGED
@@ -47,11 +47,19 @@ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Template
|
|
47 |
{
|
48 |
$ordersXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<orders></orders>');
|
49 |
|
50 |
-
$orders = Mage::getResourceModel('sales/order_collection')
|
51 |
-
->
|
52 |
-
->addFieldToFilter(
|
53 |
-
'
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
$orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0);
|
57 |
$orders->load();
|
@@ -65,9 +73,16 @@ class Mage_XmlConnect_Block_Customer_Order_List extends Mage_Core_Block_Template
|
|
65 |
if ($_order->getShippingAddress()) {
|
66 |
$item->addChild('ship_to', $ordersXmlObj->escapeXml($_order->getShippingAddress()->getName()));
|
67 |
}
|
68 |
-
$item->addChild(
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
$item->addChild('status', $_order->getStatusLabel());
|
72 |
}
|
73 |
}
|
47 |
{
|
48 |
$ordersXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<orders></orders>');
|
49 |
|
50 |
+
$orders = Mage::getResourceModel('sales/order_collection')
|
51 |
+
->addFieldToSelect('*')
|
52 |
+
->addFieldToFilter(
|
53 |
+
'customer_id',
|
54 |
+
Mage::getSingleton('customer/session')->getCustomer()->getId()
|
55 |
+
)
|
56 |
+
->addFieldToFilter(
|
57 |
+
'state',
|
58 |
+
array(
|
59 |
+
'in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()
|
60 |
+
)
|
61 |
+
)
|
62 |
+
->setOrder('created_at', 'desc');
|
63 |
|
64 |
$orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0);
|
65 |
$orders->load();
|
73 |
if ($_order->getShippingAddress()) {
|
74 |
$item->addChild('ship_to', $ordersXmlObj->escapeXml($_order->getShippingAddress()->getName()));
|
75 |
}
|
76 |
+
$item->addChild(
|
77 |
+
'total',
|
78 |
+
$_order->getOrderCurrency()->formatPrecision(
|
79 |
+
$_order->getGrandTotal(),
|
80 |
+
2,
|
81 |
+
array(),
|
82 |
+
false,
|
83 |
+
false
|
84 |
+
)
|
85 |
+
);
|
86 |
$item->addChild('status', $_order->getStatusLabel());
|
87 |
}
|
88 |
}
|
app/code/core/Mage/XmlConnect/Block/Review/Form.php
CHANGED
@@ -59,15 +59,21 @@ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Template
|
|
59 |
}
|
60 |
|
61 |
if ($this->getRatings()) {
|
62 |
-
$ratingsFieldset = $xmlReview->addCustomChild(
|
63 |
-
'
|
64 |
-
|
|
|
|
|
65 |
|
66 |
foreach ($this->getRatings() as $rating) {
|
67 |
-
$ratingField = $ratingsFieldset->addField(
|
68 |
-
'
|
69 |
-
'
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
foreach ($rating->getOptions() as $option) {
|
72 |
$ratingField->addCustomChild('value', $option->getId());
|
73 |
}
|
@@ -75,19 +81,31 @@ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Template
|
|
75 |
}
|
76 |
|
77 |
$reviewFieldset = $xmlReview->addCustomChild('fieldset');
|
78 |
-
$reviewFieldset->addField(
|
79 |
-
'
|
80 |
-
'
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
)
|
87 |
-
$reviewFieldset->addField(
|
88 |
-
'
|
89 |
-
'
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
return $xmlReview->asNiceXml();
|
93 |
}
|
@@ -100,9 +118,14 @@ class Mage_XmlConnect_Block_Review_Form extends Mage_Core_Block_Template
|
|
100 |
public function getRatings()
|
101 |
{
|
102 |
if (is_null($this->_ratings)) {
|
103 |
-
$this->_ratings = Mage::getModel('rating/rating')
|
104 |
-
->
|
105 |
-
->
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
if (!$this->_ratings->getSize()) {
|
108 |
$this->_ratings = false;
|
59 |
}
|
60 |
|
61 |
if ($this->getRatings()) {
|
62 |
+
$ratingsFieldset = $xmlReview->addCustomChild(
|
63 |
+
'fieldset',
|
64 |
+
null,
|
65 |
+
array('label' => $this->__('How do you rate this product?'))
|
66 |
+
);
|
67 |
|
68 |
foreach ($this->getRatings() as $rating) {
|
69 |
+
$ratingField = $ratingsFieldset->addField(
|
70 |
+
'ratings[' . $rating->getId() . ']',
|
71 |
+
'radio',
|
72 |
+
array(
|
73 |
+
'label' => $rating->getRatingCode(),
|
74 |
+
'required' => 'true'
|
75 |
+
)
|
76 |
+
);
|
77 |
foreach ($rating->getOptions() as $option) {
|
78 |
$ratingField->addCustomChild('value', $option->getId());
|
79 |
}
|
81 |
}
|
82 |
|
83 |
$reviewFieldset = $xmlReview->addCustomChild('fieldset');
|
84 |
+
$reviewFieldset->addField(
|
85 |
+
'nickname',
|
86 |
+
'text',
|
87 |
+
array(
|
88 |
+
'label' => $this->__('Nickname'),
|
89 |
+
'required' => 'true',
|
90 |
+
'value' => $nickname
|
91 |
+
)
|
92 |
+
);
|
93 |
+
$reviewFieldset->addField(
|
94 |
+
'title',
|
95 |
+
'text',
|
96 |
+
array(
|
97 |
+
'label' => $this->__('Summary of Your Review'),
|
98 |
+
'required' => 'true'
|
99 |
+
)
|
100 |
+
);
|
101 |
+
$reviewFieldset->addField(
|
102 |
+
'detail',
|
103 |
+
'textarea',
|
104 |
+
array(
|
105 |
+
'label' => $this->__('Review'),
|
106 |
+
'required' => 'true'
|
107 |
+
)
|
108 |
+
);
|
109 |
|
110 |
return $xmlReview->asNiceXml();
|
111 |
}
|
118 |
public function getRatings()
|
119 |
{
|
120 |
if (is_null($this->_ratings)) {
|
121 |
+
$this->_ratings = Mage::getModel('rating/rating')
|
122 |
+
->getResourceCollection()
|
123 |
+
->addEntityFilter('product')
|
124 |
+
->setPositionOrder()
|
125 |
+
->addRatingPerStoreName(Mage::app()->getStore()->getId())
|
126 |
+
->setStoreFilter(Mage::app()->getStore()->getId())
|
127 |
+
->load()
|
128 |
+
->addOptionToItems();
|
129 |
|
130 |
if (!$this->_ratings->getSize()) {
|
131 |
$this->_ratings = false;
|
app/code/core/Mage/XmlConnect/Block/Wishlist.php
CHANGED
@@ -66,22 +66,23 @@ class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishli
|
|
66 |
foreach ($this->getWishlistItems() as $item) {
|
67 |
/** @var $item Mage_Wishlist_Model_Item */
|
68 |
$itemXmlObj = $wishlistXmlObj->addChild('item');
|
|
|
69 |
$itemXmlObj->addChild('item_id', $item->getWishlistItemId());
|
70 |
$itemXmlObj->addChild('entity_id', $item->getProductId());
|
71 |
-
$itemXmlObj->addChild('entity_type_id', $item->getTypeId());
|
72 |
$itemXmlObj->addChild('name', $wishlistXmlObj->escapeXml($item->getName()));
|
73 |
-
$itemXmlObj->addChild('in_stock', (int)$item->getStockItem()->getIsInStock());
|
74 |
-
$itemXmlObj->addChild('is_salable', (int)$item->isSalable());
|
75 |
/**
|
76 |
* If product type is grouped than it has options as its grouped items
|
77 |
*/
|
78 |
-
if ($item->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE
|
79 |
-
|| $item->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
|
80 |
-
$item->setHasOptions(true);
|
81 |
}
|
82 |
-
$itemXmlObj->addChild('has_options', (int)$item->getHasOptions());
|
83 |
|
84 |
-
$icon = $this->helper('catalog/image')->init($item, 'small_image')
|
85 |
->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
|
86 |
|
87 |
$iconXml = $itemXmlObj->addChild('icon', $icon);
|
@@ -89,24 +90,24 @@ class Mage_XmlConnect_Block_Wishlist extends Mage_Wishlist_Block_Customer_Wishli
|
|
89 |
$file = Mage::helper('xmlconnect')->urlToPath($icon);
|
90 |
$iconXml->addAttribute('modification_time', filemtime($file));
|
91 |
|
92 |
-
$description = $wishlistXmlObj->escapeXml($item->
|
93 |
$itemXmlObj->addChild('description', $description);
|
94 |
|
95 |
$addedDate = $wishlistXmlObj->escapeXml($this->getFormatedDate($item->getAddedAt()));
|
96 |
$itemXmlObj->addChild('added_date', $addedDate);
|
97 |
|
98 |
if ($this->getChild('product_price')) {
|
99 |
-
$this->getChild('product_price')->setProduct($item)->setProductXmlObj($itemXmlObj)
|
100 |
->collectProductPrices();
|
101 |
}
|
102 |
|
103 |
-
if (!$item->getRatingSummary()) {
|
104 |
Mage::getModel('review/review')
|
105 |
-
->getEntitySummary($item, Mage::app()->getStore()->getId());
|
106 |
}
|
107 |
-
$ratingSummary = (int)$item->getRatingSummary()->getRatingSummary();
|
108 |
$itemXmlObj->addChild('rating_summary', round($ratingSummary / 10));
|
109 |
-
$itemXmlObj->addChild('reviews_count', $item->getRatingSummary()->getReviewsCount());
|
110 |
}
|
111 |
}
|
112 |
|
66 |
foreach ($this->getWishlistItems() as $item) {
|
67 |
/** @var $item Mage_Wishlist_Model_Item */
|
68 |
$itemXmlObj = $wishlistXmlObj->addChild('item');
|
69 |
+
|
70 |
$itemXmlObj->addChild('item_id', $item->getWishlistItemId());
|
71 |
$itemXmlObj->addChild('entity_id', $item->getProductId());
|
72 |
+
$itemXmlObj->addChild('entity_type_id', $item->getProduct()->getTypeId());
|
73 |
$itemXmlObj->addChild('name', $wishlistXmlObj->escapeXml($item->getName()));
|
74 |
+
$itemXmlObj->addChild('in_stock', (int)$item->getProduct()->getStockItem()->getIsInStock());
|
75 |
+
$itemXmlObj->addChild('is_salable', (int)$item->getProduct()->isSalable());
|
76 |
/**
|
77 |
* If product type is grouped than it has options as its grouped items
|
78 |
*/
|
79 |
+
if ($item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE
|
80 |
+
|| $item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
|
81 |
+
$item->getProduct()->setHasOptions(true);
|
82 |
}
|
83 |
+
$itemXmlObj->addChild('has_options', (int)$item->getProduct()->getHasOptions());
|
84 |
|
85 |
+
$icon = $this->helper('catalog/image')->init($item->getProduct(), 'small_image')
|
86 |
->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
|
87 |
|
88 |
$iconXml = $itemXmlObj->addChild('icon', $icon);
|
90 |
$file = Mage::helper('xmlconnect')->urlToPath($icon);
|
91 |
$iconXml->addAttribute('modification_time', filemtime($file));
|
92 |
|
93 |
+
$description = $wishlistXmlObj->escapeXml($item->getDescription());
|
94 |
$itemXmlObj->addChild('description', $description);
|
95 |
|
96 |
$addedDate = $wishlistXmlObj->escapeXml($this->getFormatedDate($item->getAddedAt()));
|
97 |
$itemXmlObj->addChild('added_date', $addedDate);
|
98 |
|
99 |
if ($this->getChild('product_price')) {
|
100 |
+
$this->getChild('product_price')->setProduct($item->getProduct())->setProductXmlObj($itemXmlObj)
|
101 |
->collectProductPrices();
|
102 |
}
|
103 |
|
104 |
+
if (!$item->getProduct()->getRatingSummary()) {
|
105 |
Mage::getModel('review/review')
|
106 |
+
->getEntitySummary($item->getProduct(), Mage::app()->getStore()->getId());
|
107 |
}
|
108 |
+
$ratingSummary = (int)$item->getProduct()->getRatingSummary()->getRatingSummary();
|
109 |
$itemXmlObj->addChild('rating_summary', round($ratingSummary / 10));
|
110 |
+
$itemXmlObj->addChild('reviews_count', $item->getProduct()->getRatingSummary()->getReviewsCount());
|
111 |
}
|
112 |
}
|
113 |
|
app/code/core/Mage/XmlConnect/Helper/Data.php
CHANGED
@@ -48,7 +48,9 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
|
|
48 |
*
|
49 |
* @var array
|
50 |
*/
|
51 |
-
protected $_excludedXmlConfigKeys = array(
|
|
|
|
|
52 |
|
53 |
/**
|
54 |
* Application names array
|
@@ -276,10 +278,7 @@ class Mage_XmlConnect_Helper_Data extends Mage_Core_Helper_Abstract
|
|
276 |
Varien_Profiler::stop('TEST: ' . __METHOD__);
|
277 |
|
278 |
if (count($options)) {
|
279 |
-
$options[] = array(
|
280 |
-
'value' => 'NEW_COUNTRIES',
|
281 |
-
'label' => 'New Territories As Added'
|
282 |
-
);
|
283 |
}
|
284 |
|
285 |
return $options;
|
48 |
*
|
49 |
* @var array
|
50 |
*/
|
51 |
+
protected $_excludedXmlConfigKeys = array(
|
52 |
+
'notifications/applicationMasterSecret',
|
53 |
+
);
|
54 |
|
55 |
/**
|
56 |
* Application names array
|
278 |
Varien_Profiler::stop('TEST: ' . __METHOD__);
|
279 |
|
280 |
if (count($options)) {
|
281 |
+
$options[] = array('value' => 'NEW_COUNTRIES', 'label' => 'New Territories As Added');
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
return $options;
|
app/code/core/Mage/XmlConnect/Helper/Image.php
CHANGED
@@ -88,7 +88,8 @@ class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
|
|
88 |
try {
|
89 |
$this->_forcedConvertPng($field);
|
90 |
|
91 |
-
$uploader
|
|
|
92 |
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
|
93 |
$uploader->setAllowRenameFiles(true);
|
94 |
$uploader->save($uploadDir);
|
88 |
try {
|
89 |
$this->_forcedConvertPng($field);
|
90 |
|
91 |
+
/** @var $uploader Mage_Core_Model_File_Uploader */
|
92 |
+
$uploader = Mage::getModel('core/file_uploader', $field);
|
93 |
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
|
94 |
$uploader->setAllowRenameFiles(true);
|
95 |
$uploader->save($uploadDir);
|
app/code/core/Mage/XmlConnect/Model/Corefix/Checkout/Session.php
DELETED
@@ -1,137 +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_XmlConnect
|
23 |
-
* @copyright Copyright (c) 2010 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 |
-
* Override the original Checkout session model
|
29 |
-
* The represented methods are overridden to fix Core bug:
|
30 |
-
* Order review - no data verifying in "Billing address" and "Shiping address" fields
|
31 |
-
*
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Mage_XmlConnect_Model_Corefix_Checkout_Session extends Mage_Checkout_Model_Session
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* Get checkout quote instance by current session
|
38 |
-
* Core fix
|
39 |
-
*
|
40 |
-
* @return Mage_XmlConnect_Model_Corefix_Sales_Quote
|
41 |
-
*/
|
42 |
-
public function getQuote()
|
43 |
-
{
|
44 |
-
if ($this->_quote === null) {
|
45 |
-
$quote = Mage::getModel('xmlconnect/corefix_sales_quote')
|
46 |
-
->setStoreId(Mage::app()->getStore()->getId());
|
47 |
-
|
48 |
-
/** @var $quote Mage_XmlConnect_Model_Corefix_Sales_Quote */
|
49 |
-
if ($this->getQuoteId()) {
|
50 |
-
$quote->loadActive($this->getQuoteId());
|
51 |
-
if ($quote->getId()) {
|
52 |
-
/**
|
53 |
-
* If current currency code of quote is not equal current currency code of store,
|
54 |
-
* need recalculate totals of quote. It is possible if customer use currency switcher or
|
55 |
-
* store switcher.
|
56 |
-
*/
|
57 |
-
if ($quote->getQuoteCurrencyCode() != Mage::app()->getStore()->getCurrentCurrencyCode()) {
|
58 |
-
$quote->setStore(Mage::app()->getStore());
|
59 |
-
$quote->collectTotals()->save();
|
60 |
-
/**
|
61 |
-
* We mast to create new quote object, because collectTotals()
|
62 |
-
* can to create links with other objects.
|
63 |
-
*/
|
64 |
-
$quote = Mage::getModel('xmlconnect/corefix_sales_quote')
|
65 |
-
->setStoreId(Mage::app()->getStore()->getId());
|
66 |
-
$quote->load($this->getQuoteId());
|
67 |
-
}
|
68 |
-
} else {
|
69 |
-
$this->setQuoteId(null);
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
$customerSession = Mage::getSingleton('customer/session');
|
74 |
-
|
75 |
-
if (!$this->getQuoteId()) {
|
76 |
-
if ($customerSession->isLoggedIn()) {
|
77 |
-
$quote->loadByCustomer($customerSession->getCustomer());
|
78 |
-
$this->setQuoteId($quote->getId());
|
79 |
-
} else {
|
80 |
-
$quote->setIsCheckoutCart(true);
|
81 |
-
Mage::dispatchEvent('checkout_quote_init', array('quote' => $quote));
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
if ($this->getQuoteId()) {
|
86 |
-
if ($customerSession->isLoggedIn()) {
|
87 |
-
$quote->setCustomer($customerSession->getCustomer());
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
$quote->setStore(Mage::app()->getStore());
|
92 |
-
$this->_quote = $quote;
|
93 |
-
}
|
94 |
-
|
95 |
-
if ($remoteAddr = Mage::helper('core/http')->getRemoteAddr()) {
|
96 |
-
$this->_quote->setRemoteIp($remoteAddr);
|
97 |
-
$xForwardIp = Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR');
|
98 |
-
$this->_quote->setXForwardedFor($xForwardIp);
|
99 |
-
}
|
100 |
-
return $this->_quote;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Load data for customer quote and merge with current quote
|
105 |
-
* Core fix
|
106 |
-
*
|
107 |
-
* @return Mage_XmlConnect_Model_Corefix_Checkout_Session
|
108 |
-
*/
|
109 |
-
public function loadCustomerQuote()
|
110 |
-
{
|
111 |
-
if (!Mage::getSingleton('customer/session')->getCustomerId()) {
|
112 |
-
return $this;
|
113 |
-
}
|
114 |
-
$customerQuote = Mage::getModel('xmlconnect/corefix_sales_quote')
|
115 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
116 |
-
->loadByCustomer(Mage::getSingleton('customer/session')->getCustomerId());
|
117 |
-
|
118 |
-
if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
|
119 |
-
if ($this->getQuoteId()) {
|
120 |
-
$customerQuote->merge($this->getQuote())
|
121 |
-
->collectTotals()
|
122 |
-
->save();
|
123 |
-
}
|
124 |
-
|
125 |
-
$this->setQuoteId($customerQuote->getId());
|
126 |
-
|
127 |
-
if ($this->_quote) {
|
128 |
-
$this->_quote->delete();
|
129 |
-
}
|
130 |
-
$this->_quote = $customerQuote;
|
131 |
-
} else {
|
132 |
-
$this->getQuote()->setCustomer(Mage::getSingleton('customer/session')->getCustomer())
|
133 |
-
->save();
|
134 |
-
}
|
135 |
-
return $this;
|
136 |
-
}
|
137 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/XmlConnect/Model/Corefix/Checkout/Type/Onepage.php
DELETED
@@ -1,465 +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_XmlConnect
|
23 |
-
* @copyright Copyright (c) 2010 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 |
-
* Override the original One page checkout processing model
|
29 |
-
* The represented methods are overridden to fix Core bug:
|
30 |
-
* Order review - no data verifying in "Billing address" and "Shiping address" fields
|
31 |
-
*
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Mage_XmlConnect_Model_Corefix_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* Class constructor
|
38 |
-
* Set customer already exists message
|
39 |
-
* Core fix
|
40 |
-
*/
|
41 |
-
public function __construct()
|
42 |
-
{
|
43 |
-
$this->_helper = Mage::helper('checkout');
|
44 |
-
$this->_customerEmailExistsMessage = $this->_helper->__('There is already a customer registered using this email address. Please login using this email address or enter a different email address to register your account.');
|
45 |
-
$this->_checkoutSession = Mage::getSingleton('xmlconnect/corefix_checkout_session');
|
46 |
-
$this->_customerSession = Mage::getSingleton('customer/session');
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Save billing address information to quote
|
51 |
-
* This method is called by One Page Checkout JS (AJAX) while saving the billing information.
|
52 |
-
* Core fix
|
53 |
-
*
|
54 |
-
* @param array $data
|
55 |
-
* @param int $customerAddressId
|
56 |
-
* @return array
|
57 |
-
*/
|
58 |
-
public function saveBilling($data, $customerAddressId)
|
59 |
-
{
|
60 |
-
if (empty($data)) {
|
61 |
-
return array('error' => -1, 'message' => $this->_helper->__('Invalid data.'));
|
62 |
-
}
|
63 |
-
|
64 |
-
$address = $this->getQuote()->getBillingAddress();
|
65 |
-
/** @var $addressForm Mage_Customer_Model_Form */
|
66 |
-
$addressForm = Mage::getModel('customer/form');
|
67 |
-
$addressForm->setFormCode('customer_address_edit')
|
68 |
-
->setEntityType('customer_address')
|
69 |
-
->setIsAjaxRequest(Mage::app()->getRequest()->isAjax());
|
70 |
-
|
71 |
-
if (!empty($customerAddressId)) {
|
72 |
-
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
73 |
-
if ($customerAddress->getId()) {
|
74 |
-
if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
|
75 |
-
return array(
|
76 |
-
'error' => 1,
|
77 |
-
'message' => $this->_helper->__('Customer Address is not valid.')
|
78 |
-
);
|
79 |
-
}
|
80 |
-
|
81 |
-
$address->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
|
82 |
-
$addressForm->setEntity($address);
|
83 |
-
$addressErrors = $addressForm->validateData($address->getData());
|
84 |
-
if ($addressErrors !== true) {
|
85 |
-
return array('error' => 1, 'message' => $addressErrors);
|
86 |
-
}
|
87 |
-
}
|
88 |
-
} else {
|
89 |
-
$addressForm->setEntity($address);
|
90 |
-
// emulate request object
|
91 |
-
$addressData = $addressForm->extractData($addressForm->prepareRequest($data));
|
92 |
-
$addressErrors = $addressForm->validateData($addressData);
|
93 |
-
if ($addressErrors !== true) {
|
94 |
-
return array('error' => 1, 'message' => $addressErrors);
|
95 |
-
}
|
96 |
-
$addressForm->compactData($addressData);
|
97 |
-
|
98 |
-
// Additional form data, not fetched by extractData (as it fetches only attributes)
|
99 |
-
$address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);
|
100 |
-
}
|
101 |
-
|
102 |
-
// validate billing address
|
103 |
-
if (($validateRes = $address->validate()) !== true) {
|
104 |
-
return array('error' => 1, 'message' => $validateRes);
|
105 |
-
}
|
106 |
-
|
107 |
-
$address->implodeStreetAddress();
|
108 |
-
|
109 |
-
if (true !== ($result = $this->_validateCustomerData($data))) {
|
110 |
-
return $result;
|
111 |
-
}
|
112 |
-
|
113 |
-
if (!$this->getQuote()->getCustomerId() && self::METHOD_REGISTER == $this->getQuote()->getCheckoutMethod()) {
|
114 |
-
if ($this->_customerEmailExists($address->getEmail(), Mage::app()->getWebsite()->getId())) {
|
115 |
-
return array('error' => 1, 'message' => $this->_customerEmailExistsMessage);
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
if (!$this->getQuote()->isVirtual()) {
|
120 |
-
/**
|
121 |
-
* Billing address using otions
|
122 |
-
*/
|
123 |
-
$usingCase = isset($data['use_for_shipping']) ? (int)$data['use_for_shipping'] : 0;
|
124 |
-
|
125 |
-
switch($usingCase) {
|
126 |
-
case 0:
|
127 |
-
$shipping = $this->getQuote()->getShippingAddress();
|
128 |
-
$shipping->setSameAsBilling(0);
|
129 |
-
break;
|
130 |
-
case 1:
|
131 |
-
$billing = clone $address;
|
132 |
-
$billing->unsAddressId()->unsAddressType();
|
133 |
-
$shipping = $this->getQuote()->getShippingAddress();
|
134 |
-
$shippingMethod = $shipping->getShippingMethod();
|
135 |
-
$shipping->addData($billing->getData())
|
136 |
-
->setSameAsBilling(1)
|
137 |
-
->setSaveInAddressBook(0)
|
138 |
-
->setShippingMethod($shippingMethod)
|
139 |
-
->setCollectShippingRates(true);
|
140 |
-
$this->getCheckout()->setStepData('shipping', 'complete', true);
|
141 |
-
break;
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
$this->getQuote()->collectTotals();
|
146 |
-
$this->getQuote()->save();
|
147 |
-
|
148 |
-
$this->getCheckout()
|
149 |
-
->setStepData('billing', 'allow', true)
|
150 |
-
->setStepData('billing', 'complete', true)
|
151 |
-
->setStepData('shipping', 'allow', true);
|
152 |
-
|
153 |
-
return array();
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Validate customer data and set some its data for further usage in quote
|
158 |
-
* Will return either true or array with error messages
|
159 |
-
* Core fix
|
160 |
-
*
|
161 |
-
* @param array $data
|
162 |
-
* @return bool | array
|
163 |
-
*/
|
164 |
-
protected function _validateCustomerData(array $data)
|
165 |
-
{
|
166 |
-
/** @var $customerForm Mage_Customer_Model_Form */
|
167 |
-
$customerForm = Mage::getModel('customer/form');
|
168 |
-
$customerForm->setFormCode('checkout_register')
|
169 |
-
->setIsAjaxRequest(Mage::app()->getRequest()->isAjax());
|
170 |
-
|
171 |
-
$quote = $this->getQuote();
|
172 |
-
if ($quote->getCustomerId()) {
|
173 |
-
$customer = $quote->getCustomer();
|
174 |
-
$customerForm->setEntity($customer);
|
175 |
-
$customerData = $quote->getCustomer()->getData();
|
176 |
-
} else {
|
177 |
-
/** @var $customer Mage_Customer_Model_Customer */
|
178 |
-
$customer = Mage::getModel('customer/customer');
|
179 |
-
$customerForm->setEntity($customer);
|
180 |
-
$customerRequest = $customerForm->prepareRequest($data);
|
181 |
-
$customerData = $customerForm->extractData($customerRequest);
|
182 |
-
}
|
183 |
-
|
184 |
-
$customerErrors = $customerForm->validateData($customerData);
|
185 |
-
if ($customerErrors !== true) {
|
186 |
-
return array(
|
187 |
-
'error' => -1,
|
188 |
-
'message' => implode(', ', $customerErrors)
|
189 |
-
);
|
190 |
-
}
|
191 |
-
|
192 |
-
if ($quote->getCustomerId()) {
|
193 |
-
return true;
|
194 |
-
}
|
195 |
-
|
196 |
-
$customerForm->compactData($customerData);
|
197 |
-
|
198 |
-
if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
|
199 |
-
// set customer password
|
200 |
-
$customer->setPassword($customerRequest->getParam('customer_password'));
|
201 |
-
$customer->setConfirmation($customerRequest->getParam('confirm_password'));
|
202 |
-
} else {
|
203 |
-
// emulate customer password for quest
|
204 |
-
$password = $customer->generatePassword();
|
205 |
-
$customer->setPassword($password);
|
206 |
-
$customer->setConfirmation($password);
|
207 |
-
}
|
208 |
-
|
209 |
-
$result = $customer->validate();
|
210 |
-
if (true !== $result && is_array($result)) {
|
211 |
-
return array(
|
212 |
-
'error' => -1,
|
213 |
-
'message' => implode(', ', $result)
|
214 |
-
);
|
215 |
-
}
|
216 |
-
|
217 |
-
if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
|
218 |
-
// save customer encrypted password in quote
|
219 |
-
$quote->setPasswordHash($customer->encryptPassword($customer->getPassword()));
|
220 |
-
}
|
221 |
-
|
222 |
-
// copy customer/guest email to address
|
223 |
-
$quote->getBillingAddress()->setEmail($customer->getEmail());
|
224 |
-
|
225 |
-
// copy customer data to quote
|
226 |
-
Mage::helper('core')->copyFieldset('customer_account', 'to_quote', $customer, $quote);
|
227 |
-
|
228 |
-
return true;
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Save checkout shipping address
|
233 |
-
* Core fix
|
234 |
-
*
|
235 |
-
* @param array $data
|
236 |
-
* @param int $customerAddressId
|
237 |
-
* @return array
|
238 |
-
*/
|
239 |
-
public function saveShipping($data, $customerAddressId)
|
240 |
-
{
|
241 |
-
if (empty($data)) {
|
242 |
-
return array('error' => -1, 'message' => $this->_helper->__('Invalid data.'));
|
243 |
-
}
|
244 |
-
$address = $this->getQuote()->getShippingAddress();
|
245 |
-
|
246 |
-
/** @var $addressForm Mage_Customer_Model_Form */
|
247 |
-
$addressForm = Mage::getModel('customer/form');
|
248 |
-
$addressForm->setFormCode('customer_address_edit')
|
249 |
-
->setEntityType('customer_address')
|
250 |
-
->setIsAjaxRequest(Mage::app()->getRequest()->isAjax());
|
251 |
-
|
252 |
-
if (!empty($customerAddressId)) {
|
253 |
-
/** @var $customerAddress Mage_Customer_Model_Address */
|
254 |
-
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
255 |
-
if ($customerAddress->getId()) {
|
256 |
-
if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
|
257 |
-
return array(
|
258 |
-
'error' => 1,
|
259 |
-
'message' => $this->_helper->__('Customer Address is not valid.')
|
260 |
-
);
|
261 |
-
}
|
262 |
-
|
263 |
-
$address->importCustomerAddress($customerAddress)->setSaveInAddressBook(0);
|
264 |
-
$addressForm->setEntity($address);
|
265 |
-
$addressErrors = $addressForm->validateData($address->getData());
|
266 |
-
if ($addressErrors !== true) {
|
267 |
-
return array('error' => 1, 'message' => $addressErrors);
|
268 |
-
}
|
269 |
-
}
|
270 |
-
} else {
|
271 |
-
$addressForm->setEntity($address);
|
272 |
-
// emulate request object
|
273 |
-
$addressData = $addressForm->extractData($addressForm->prepareRequest($data));
|
274 |
-
$addressErrors = $addressForm->validateData($addressData);
|
275 |
-
if ($addressErrors !== true) {
|
276 |
-
return array('error' => 1, 'message' => $addressErrors);
|
277 |
-
}
|
278 |
-
$addressForm->compactData($addressData);
|
279 |
-
|
280 |
-
// Additional form data, not fetched by extractData (as it fetches only attributes)
|
281 |
-
$address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);
|
282 |
-
$address->setSameAsBilling(empty($data['same_as_billing']) ? 0 : 1);
|
283 |
-
}
|
284 |
-
|
285 |
-
$address->implodeStreetAddress();
|
286 |
-
$address->setCollectShippingRates(true);
|
287 |
-
|
288 |
-
if (($validateRes = $address->validate()) !== true) {
|
289 |
-
return array('error' => 1, 'message' => $validateRes);
|
290 |
-
}
|
291 |
-
|
292 |
-
$this->getQuote()->collectTotals()->save();
|
293 |
-
|
294 |
-
$this->getCheckout()
|
295 |
-
->setStepData('shipping', 'complete', true)
|
296 |
-
->setStepData('shipping_method', 'allow', true);
|
297 |
-
|
298 |
-
return array();
|
299 |
-
}
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Specify quote payment method
|
303 |
-
* Core fix
|
304 |
-
*
|
305 |
-
* @param array $data
|
306 |
-
* @return array
|
307 |
-
*/
|
308 |
-
public function savePayment($data)
|
309 |
-
{
|
310 |
-
if (empty($data)) {
|
311 |
-
return array('error' => -1, 'message' => $this->_helper->__('Invalid data.'));
|
312 |
-
}
|
313 |
-
$quote = $this->getQuote();
|
314 |
-
if ($quote->isVirtual()) {
|
315 |
-
$quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
316 |
-
} else {
|
317 |
-
$quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
318 |
-
}
|
319 |
-
|
320 |
-
// shipping totals may be affected by payment method
|
321 |
-
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
322 |
-
$quote->getShippingAddress()->setCollectShippingRates(true);
|
323 |
-
}
|
324 |
-
|
325 |
-
$payment = $quote->getPayment();
|
326 |
-
$payment->importData($data);
|
327 |
-
|
328 |
-
$quote->save();
|
329 |
-
|
330 |
-
$this->getCheckout()
|
331 |
-
->setStepData('payment', 'complete', true)
|
332 |
-
->setStepData('review', 'allow', true);
|
333 |
-
|
334 |
-
return array();
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Prepare quote for customer order submit
|
339 |
-
* Core fix
|
340 |
-
*
|
341 |
-
* @return void
|
342 |
-
*/
|
343 |
-
protected function _prepareCustomerQuote()
|
344 |
-
{
|
345 |
-
$quote = $this->getQuote();
|
346 |
-
$billing = $quote->getBillingAddress();
|
347 |
-
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
348 |
-
|
349 |
-
$customer = $this->getCustomerSession()->getCustomer();
|
350 |
-
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
351 |
-
$customerBilling = $billing->exportCustomerAddress();
|
352 |
-
$customer->addAddress($customerBilling);
|
353 |
-
$billing->setCustomerAddress($customerBilling);
|
354 |
-
}
|
355 |
-
if ($shipping && !$shipping->getSameAsBilling()
|
356 |
-
&& (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook())
|
357 |
-
) {
|
358 |
-
$customerShipping = $shipping->exportCustomerAddress();
|
359 |
-
$customer->addAddress($customerShipping);
|
360 |
-
$shipping->setCustomerAddress($customerShipping);
|
361 |
-
}
|
362 |
-
|
363 |
-
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
364 |
-
$customerBilling->setIsDefaultBilling(true);
|
365 |
-
}
|
366 |
-
if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
367 |
-
$customerShipping->setIsDefaultShipping(true);
|
368 |
-
} elseif (isset($customerBilling) && !$customer->getDefaultShipping()) {
|
369 |
-
$customerBilling->setIsDefaultShipping(true);
|
370 |
-
}
|
371 |
-
$quote->setCustomer($customer);
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Create order based on checkout type. Create customer if necessary.
|
376 |
-
*
|
377 |
-
* @return Mage_XmlConnect_Model_Corefix_Checkout_Type_Onepage
|
378 |
-
*/
|
379 |
-
public function saveOrder()
|
380 |
-
{
|
381 |
-
$this->validate();
|
382 |
-
$isNewCustomer = false;
|
383 |
-
switch ($this->getCheckoutMethod()) {
|
384 |
-
case self::METHOD_GUEST:
|
385 |
-
$this->_prepareGuestQuote();
|
386 |
-
break;
|
387 |
-
case self::METHOD_REGISTER:
|
388 |
-
$this->_prepareNewCustomerQuote();
|
389 |
-
$isNewCustomer = true;
|
390 |
-
break;
|
391 |
-
default:
|
392 |
-
$this->_prepareCustomerQuote();
|
393 |
-
break;
|
394 |
-
}
|
395 |
-
|
396 |
-
/** @var $service Mage_Sales_Model_Service_Quote */
|
397 |
-
$service = Mage::getModel('sales/service_quote', $this->getQuote());
|
398 |
-
$service->submitAll();
|
399 |
-
|
400 |
-
if ($isNewCustomer) {
|
401 |
-
try {
|
402 |
-
$this->_involveNewCustomer();
|
403 |
-
} catch (Exception $e) {
|
404 |
-
Mage::logException($e);
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
$this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
|
409 |
-
->setLastSuccessQuoteId($this->getQuote()->getId())
|
410 |
-
->clearHelperData();
|
411 |
-
|
412 |
-
$order = $service->getOrder();
|
413 |
-
if ($order) {
|
414 |
-
Mage::dispatchEvent(
|
415 |
-
'checkout_type_onepage_save_order_after',
|
416 |
-
array('order' => $order, 'quote' => $this->getQuote())
|
417 |
-
);
|
418 |
-
|
419 |
-
/**
|
420 |
-
* a flag to set that there will be redirect to third party after confirmation
|
421 |
-
* eg: paypal standard ipn
|
422 |
-
*/
|
423 |
-
$redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
|
424 |
-
/**
|
425 |
-
* we only want to send to customer about new order when there is no redirect to third party
|
426 |
-
*/
|
427 |
-
if (!$redirectUrl) {
|
428 |
-
try {
|
429 |
-
$order->sendNewOrderEmail();
|
430 |
-
} catch (Exception $e) {
|
431 |
-
Mage::logException($e);
|
432 |
-
}
|
433 |
-
}
|
434 |
-
|
435 |
-
// add order information to the session
|
436 |
-
$this->_checkoutSession->setLastOrderId($order->getId())
|
437 |
-
->setRedirectUrl($redirectUrl)
|
438 |
-
->setLastRealOrderId($order->getIncrementId());
|
439 |
-
|
440 |
-
// as well a billing agreement can be created
|
441 |
-
$agreement = $order->getPayment()->getBillingAgreement();
|
442 |
-
if ($agreement) {
|
443 |
-
$this->_checkoutSession->setLastBillingAgreementId($agreement->getId());
|
444 |
-
}
|
445 |
-
}
|
446 |
-
|
447 |
-
// add recurring profiles information to the session
|
448 |
-
$profiles = $service->getRecurringPaymentProfiles();
|
449 |
-
if ($profiles) {
|
450 |
-
$ids = array();
|
451 |
-
foreach ($profiles as $profile) {
|
452 |
-
$ids[] = $profile->getId();
|
453 |
-
}
|
454 |
-
$this->_checkoutSession->setLastRecurringProfileIds($ids);
|
455 |
-
// TODO: send recurring profile emails
|
456 |
-
}
|
457 |
-
|
458 |
-
Mage::dispatchEvent(
|
459 |
-
'checkout_submit_all_after',
|
460 |
-
array('order' => $order, 'quote' => $this->getQuote(), 'recurring_profiles' => $profiles)
|
461 |
-
);
|
462 |
-
|
463 |
-
return $this;
|
464 |
-
}
|
465 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/core/Mage/XmlConnect/Model/Corefix/Sales/Quote.php
DELETED
@@ -1,427 +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_XmlConnect
|
23 |
-
* @copyright Copyright (c) 2010 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 |
-
* Override the original Quote model
|
29 |
-
* The represented methods are overridden to fix Core bug:
|
30 |
-
* Order review - no data verifying in "Billing address" and "Shiping address" fields
|
31 |
-
*
|
32 |
-
* Supported events:
|
33 |
-
* sales_quote_load_after
|
34 |
-
* sales_quote_save_before
|
35 |
-
* sales_quote_save_after
|
36 |
-
* sales_quote_delete_before
|
37 |
-
* sales_quote_delete_after
|
38 |
-
*
|
39 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
40 |
-
*/
|
41 |
-
class Mage_XmlConnect_Model_Corefix_Sales_Quote extends Mage_Sales_Model_Quote
|
42 |
-
{
|
43 |
-
/**
|
44 |
-
* Loading quote by identifier
|
45 |
-
* Core fix
|
46 |
-
*
|
47 |
-
* @param int $quoteId
|
48 |
-
* @return Mage_XmlConnect_Model_Corefix_Sales_Quote
|
49 |
-
*/
|
50 |
-
public function loadByIdWithoutStore($quoteId)
|
51 |
-
{
|
52 |
-
$this->_getResource()->loadByIdWithoutStore($this, $quoteId);
|
53 |
-
$this->_afterLoad();
|
54 |
-
return $this;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Assign customer model object data to quote
|
59 |
-
* Core fix
|
60 |
-
*
|
61 |
-
* @param Mage_Customer_Model_Customer $customer
|
62 |
-
* @return Mage_XmlConnect_Model_Corefix_Sales_Quote
|
63 |
-
*/
|
64 |
-
public function assignCustomer(Mage_Customer_Model_Customer $customer)
|
65 |
-
{
|
66 |
-
return $this->assignCustomerWithAddressChange($customer);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Assign customer model to quote with billing and shipping address change
|
71 |
-
* Core fix
|
72 |
-
*
|
73 |
-
* @param Mage_Customer_Model_Customer $customer
|
74 |
-
* @param Mage_Sales_Model_Quote_Address $billingAddress
|
75 |
-
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
76 |
-
* @return Mage_XmlConnect_Model_Corefix_Sales_Quote
|
77 |
-
*/
|
78 |
-
public function assignCustomerWithAddressChange(
|
79 |
-
Mage_Customer_Model_Customer $customer,
|
80 |
-
Mage_Sales_Model_Quote_Address $billingAddress = null,
|
81 |
-
Mage_Sales_Model_Quote_Address $shippingAddress = null
|
82 |
-
)
|
83 |
-
{
|
84 |
-
if ($customer->getId()) {
|
85 |
-
$this->setCustomer($customer);
|
86 |
-
|
87 |
-
if (!is_null($billingAddress)) {
|
88 |
-
$this->setBillingAddress($billingAddress);
|
89 |
-
} else {
|
90 |
-
$defaultBillingAddress = $customer->getDefaultBillingAddress();
|
91 |
-
if ($defaultBillingAddress && $defaultBillingAddress->getId()) {
|
92 |
-
$billingAddress = Mage::getModel('sales/quote_address')
|
93 |
-
->importCustomerAddress($defaultBillingAddress);
|
94 |
-
$this->setBillingAddress($billingAddress);
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
if (is_null($shippingAddress)) {
|
99 |
-
$defaultShippingAddress = $customer->getDefaultShippingAddress();
|
100 |
-
if ($defaultShippingAddress && $defaultShippingAddress->getId()) {
|
101 |
-
$shippingAddress = Mage::getModel('sales/quote_address')
|
102 |
-
->importCustomerAddress($defaultShippingAddress);
|
103 |
-
} else {
|
104 |
-
$shippingAddress = Mage::getModel('sales/quote_address');
|
105 |
-
}
|
106 |
-
}
|
107 |
-
$this->setShippingAddress($shippingAddress);
|
108 |
-
}
|
109 |
-
|
110 |
-
return $this;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Retrieve customer group id
|
115 |
-
* Core fix
|
116 |
-
*
|
117 |
-
* @return int
|
118 |
-
*/
|
119 |
-
public function getCustomerGroupId()
|
120 |
-
{
|
121 |
-
if ($this->getCustomerId()) {
|
122 |
-
return ($this->getData('customer_group_id'))
|
123 |
-
? $this->getData('customer_group_id')
|
124 |
-
: $this->getCustomer()->getGroupId();
|
125 |
-
} else {
|
126 |
-
return Mage_Customer_Model_Group::NOT_LOGGED_IN_ID;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Checking product exist in Quote
|
132 |
-
* Core fix
|
133 |
-
*
|
134 |
-
* @param int $productId
|
135 |
-
* @return bool
|
136 |
-
*/
|
137 |
-
public function hasProductId($productId)
|
138 |
-
{
|
139 |
-
foreach ($this->getAllItems() as $item) {
|
140 |
-
if ($item->getProductId() == $productId) {
|
141 |
-
return true;
|
142 |
-
}
|
143 |
-
}
|
144 |
-
return false;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Remove quote item by item identifier
|
149 |
-
* Core fix
|
150 |
-
*
|
151 |
-
* @param int $itemId
|
152 |
-
* @return Mage_XmlConnect_Model_Corefix_Sales_Quote
|
153 |
-
*/
|
154 |
-
public function removeItem($itemId)
|
155 |
-
{
|
156 |
-
$item = $this->getItemById($itemId);
|
157 |
-
if ($item) {
|
158 |
-
$item->setQuote($this);
|
159 |
-
/**
|
160 |
-
* If we remove item from quote - we can't use multishipping mode
|
161 |
-
*/
|
162 |
-
$this->setIsMultiShipping(false);
|
163 |
-
$item->isDeleted(true);
|
164 |
-
if ($item->getHasChildren()) {
|
165 |
-
foreach ($item->getChildren() as $child) {
|
166 |
-
$child->isDeleted(true);
|
167 |
-
}
|
168 |
-
}
|
169 |
-
Mage::dispatchEvent('sales_quote_remove_item', array('quote_item' => $item));
|
170 |
-
}
|
171 |
-
return $this;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Advanced func to add product to quote - processing mode can be specified there.
|
176 |
-
* Returns error message if product type instance can't prepare product.
|
177 |
-
* Core fix
|
178 |
-
*
|
179 |
-
* @param Mage_Catalog_Model_Product $product
|
180 |
-
* @param null | float | Varien_Object $request
|
181 |
-
* @param null | string $processMode
|
182 |
-
* @throws Mage_Core_Exception
|
183 |
-
* @return Mage_Sales_Model_Quote_Item | string
|
184 |
-
*/
|
185 |
-
public function addProductAdvanced(Mage_Catalog_Model_Product $product, $request = null, $processMode = null)
|
186 |
-
{
|
187 |
-
if ($request === null) {
|
188 |
-
$request = 1;
|
189 |
-
}
|
190 |
-
if (is_numeric($request)) {
|
191 |
-
$request = new Varien_Object(array('qty' => $request));
|
192 |
-
}
|
193 |
-
if (!($request instanceof Varien_Object)) {
|
194 |
-
Mage::throwException(Mage::helper('sales')->__('Invalid request for adding product to quote.'));
|
195 |
-
}
|
196 |
-
|
197 |
-
$cartCandidates = $product->getTypeInstance(true)
|
198 |
-
->prepareForCartAdvanced($request, $product, $processMode);
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Error message
|
202 |
-
*/
|
203 |
-
if (is_string($cartCandidates)) {
|
204 |
-
return $cartCandidates;
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* If prepare process return one object
|
209 |
-
*/
|
210 |
-
if (!is_array($cartCandidates)) {
|
211 |
-
$cartCandidates = array($cartCandidates);
|
212 |
-
}
|
213 |
-
|
214 |
-
$parentItem = null;
|
215 |
-
$errors = array();
|
216 |
-
$items = array();
|
217 |
-
foreach ($cartCandidates as $candidate) {
|
218 |
-
$item = $this->_addCatalogProduct($candidate, $candidate->getCartQty());
|
219 |
-
$items[] = $item;
|
220 |
-
|
221 |
-
/**
|
222 |
-
* As parent item we should always use the item of first added product
|
223 |
-
*/
|
224 |
-
if (!$parentItem) {
|
225 |
-
$parentItem = $item;
|
226 |
-
}
|
227 |
-
if ($parentItem && $candidate->getParentProductId() && !$item->getId()) {
|
228 |
-
$item->setParentItem($parentItem);
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* We specify qty after we know about parent (for stock)
|
233 |
-
*/
|
234 |
-
$item->addQty($candidate->getCartQty());
|
235 |
-
|
236 |
-
// collect errors instead of throwing first one
|
237 |
-
if ($item->getHasError()) {
|
238 |
-
$errors[] = $item->getMessage();
|
239 |
-
}
|
240 |
-
}
|
241 |
-
if (!empty($errors)) {
|
242 |
-
Mage::throwException(implode("\n", $errors));
|
243 |
-
}
|
244 |
-
|
245 |
-
Mage::dispatchEvent('sales_quote_product_add_after', array('items' => $items));
|
246 |
-
|
247 |
-
return $item;
|
248 |
-
}
|
249 |
-
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Add product to quote
|
253 |
-
* return error message if product type instance can't prepare product
|
254 |
-
* Core fix
|
255 |
-
*
|
256 |
-
* @param mixed $product
|
257 |
-
* @param null | float | Varien_Object $request
|
258 |
-
* @return Mage_Sales_Model_Quote_Item | string
|
259 |
-
*/
|
260 |
-
public function addProduct(Mage_Catalog_Model_Product $product, $request = null)
|
261 |
-
{
|
262 |
-
return $this->addProductAdvanced($product, $request, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Adding catalog product object data to quote
|
267 |
-
* Core fix
|
268 |
-
*
|
269 |
-
* @param Mage_Catalog_Model_Product $product
|
270 |
-
* @return Mage_Sales_Model_Quote_Item
|
271 |
-
*/
|
272 |
-
protected function _addCatalogProduct(Mage_Catalog_Model_Product $product, $qty = 1)
|
273 |
-
{
|
274 |
-
$newItem = false;
|
275 |
-
$item = $this->getItemByProduct($product);
|
276 |
-
if (!$item) {
|
277 |
-
$item = Mage::getModel('sales/quote_item');
|
278 |
-
$item->setQuote($this);
|
279 |
-
if (Mage::app()->getStore()->isAdmin()) {
|
280 |
-
$item->setStoreId($this->getStore()->getId());
|
281 |
-
} else {
|
282 |
-
$item->setStoreId(Mage::app()->getStore()->getId());
|
283 |
-
}
|
284 |
-
$newItem = true;
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* We can't modify existing child items
|
289 |
-
*/
|
290 |
-
if ($item->getId() && $product->getParentProductId()) {
|
291 |
-
return $item;
|
292 |
-
}
|
293 |
-
|
294 |
-
$item->setOptions($product->getCustomOptions())
|
295 |
-
->setProduct($product);
|
296 |
-
|
297 |
-
// Add only item that is not in quote already (there can be other new or already saved item
|
298 |
-
if ($newItem) {
|
299 |
-
$this->addItem($item);
|
300 |
-
}
|
301 |
-
|
302 |
-
return $item;
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Updates quote item with new configuration
|
307 |
-
*
|
308 |
-
* $params sets how current item configuration must be taken into account and additional options.
|
309 |
-
* It's passed to Mage_Catalog_Helper_Product->addParamsToBuyRequest() to compose resulting buyRequest.
|
310 |
-
*
|
311 |
-
* Basically it can hold
|
312 |
-
* - 'current_config', Varien_Object or array - current buyRequest that configures product in this item,
|
313 |
-
* used to restore currently attached files
|
314 |
-
* - 'files_prefix': string[a-z0-9_] - prefix that was added at frontend to names of file options (file inputs), so they won't
|
315 |
-
* intersect with other submitted options
|
316 |
-
*
|
317 |
-
* For more options see Mage_Catalog_Helper_Product->addParamsToBuyRequest()
|
318 |
-
*
|
319 |
-
* Core fix
|
320 |
-
*
|
321 |
-
* @param int $itemId
|
322 |
-
* @param Varien_Object $buyRequest
|
323 |
-
* @param null | array | Varien_Object $params
|
324 |
-
* @throws Mage_Core_Exception
|
325 |
-
* @return Mage_Sales_Model_Quote_Item
|
326 |
-
*
|
327 |
-
* @see Mage_Catalog_Helper_Product::addParamsToBuyRequest()
|
328 |
-
*/
|
329 |
-
public function updateItem($itemId, $buyRequest, $params = null)
|
330 |
-
{
|
331 |
-
$item = $this->getItemById($itemId);
|
332 |
-
if (!$item) {
|
333 |
-
Mage::throwException(Mage::helper('sales')->__('Wrong quote item id to update configuration.'));
|
334 |
-
}
|
335 |
-
$productId = $item->getProduct()->getId();
|
336 |
-
|
337 |
-
//We need to create new clear product instance with same $productId
|
338 |
-
//to set new option values from $buyRequest
|
339 |
-
$product = Mage::getModel('catalog/product')
|
340 |
-
->setStoreId($this->getStore()->getId())
|
341 |
-
->load($productId);
|
342 |
-
|
343 |
-
if (!$params) {
|
344 |
-
$params = new Varien_Object();
|
345 |
-
} elseif (is_array($params)) {
|
346 |
-
$params = new Varien_Object($params);
|
347 |
-
}
|
348 |
-
$params->setCurrentConfig($item->getBuyRequest());
|
349 |
-
$buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest($buyRequest, $params);
|
350 |
-
|
351 |
-
$resultItem = $this->addProduct($product, $buyRequest);
|
352 |
-
|
353 |
-
if (is_string($resultItem)) {
|
354 |
-
Mage::throwException($resultItem);
|
355 |
-
}
|
356 |
-
|
357 |
-
if ($resultItem->getParentItem()) {
|
358 |
-
$resultItem = $resultItem->getParentItem();
|
359 |
-
}
|
360 |
-
|
361 |
-
if ($resultItem->getId() != $itemId) {
|
362 |
-
/**
|
363 |
-
* Product configuration didn't stick to original quote item
|
364 |
-
* It either has same configuration as some other quote item's product or completely new configuration
|
365 |
-
*/
|
366 |
-
$this->removeItem($itemId);
|
367 |
-
|
368 |
-
$items = $this->getAllItems();
|
369 |
-
foreach ($items as $item) {
|
370 |
-
if (($item->getProductId() == $productId) && ($item->getId() != $resultItem->getId())) {
|
371 |
-
if ($resultItem->compare($item)) {
|
372 |
-
// Product configuration is same as in other quote item
|
373 |
-
$resultItem->setQty($resultItem->getQty() + $item->getQty());
|
374 |
-
$this->removeItem($item->getId());
|
375 |
-
break;
|
376 |
-
}
|
377 |
-
}
|
378 |
-
}
|
379 |
-
} else {
|
380 |
-
$resultItem->setQty($buyRequest->getQty());
|
381 |
-
}
|
382 |
-
|
383 |
-
return $resultItem;
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Retrieve quote item by product id
|
388 |
-
* Core fix
|
389 |
-
*
|
390 |
-
* @param Mage_Catalog_Model_Product $product
|
391 |
-
* @return Mage_Sales_Model_Quote_Item | false
|
392 |
-
*/
|
393 |
-
public function getItemByProduct($product)
|
394 |
-
{
|
395 |
-
foreach ($this->getAllItems() as $item) {
|
396 |
-
if ($item->representProduct($product)) {
|
397 |
-
return $item;
|
398 |
-
}
|
399 |
-
}
|
400 |
-
return false;
|
401 |
-
}
|
402 |
-
|
403 |
-
/**
|
404 |
-
* Check quote for virtual product only
|
405 |
-
* Core fix
|
406 |
-
*
|
407 |
-
* @return bool
|
408 |
-
*/
|
409 |
-
public function isVirtual()
|
410 |
-
{
|
411 |
-
$isVirtual = true;
|
412 |
-
$countItems = 0;
|
413 |
-
foreach ($this->getItemsCollection() as $_item) {
|
414 |
-
/** @var $_item Mage_Sales_Model_Quote_Item */
|
415 |
-
if ($_item->isDeleted() || $_item->getParentItemId()) {
|
416 |
-
continue;
|
417 |
-
}
|
418 |
-
$countItems ++;
|
419 |
-
if (!$_item->getProduct()->getIsVirtual()) {
|
420 |
-
$isVirtual = false;
|
421 |
-
break;
|
422 |
-
}
|
423 |
-
}
|
424 |
-
return $countItems == 0 ? false : $isVirtual;
|
425 |
-
}
|
426 |
-
|
427 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|