@@ -608,7 +608,7 @@ public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $q
608
608
}
609
609
610
610
$ product = $ this ->_objectManager ->create (
611
- ' Magento\Catalog\Model\Product '
611
+ \ Magento \Catalog \Model \Product::class
612
612
)->setStoreId (
613
613
$ this ->getSession ()->getStoreId ()
614
614
)->load (
@@ -662,7 +662,7 @@ public function getCustomerWishlist($cacheReload = false)
662
662
663
663
$ customerId = (int )$ this ->getSession ()->getCustomerId ();
664
664
if ($ customerId ) {
665
- $ this ->_wishlist = $ this ->_objectManager ->create (' Magento\Wishlist\Model\Wishlist ' );
665
+ $ this ->_wishlist = $ this ->_objectManager ->create (\ Magento \Wishlist \Model \Wishlist::class );
666
666
$ this ->_wishlist ->loadByCustomerId ($ customerId , true );
667
667
$ this ->_wishlist ->setStore (
668
668
$ this ->getSession ()->getStore ()
@@ -716,7 +716,9 @@ public function getCustomerCompareList()
716
716
}
717
717
$ customerId = (int )$ this ->getSession ()->getCustomerId ();
718
718
if ($ customerId ) {
719
- $ this ->_compareList = $ this ->_objectManager ->create ('Magento\Catalog\Model\Product\Compare\ListCompare ' );
719
+ $ this ->_compareList = $ this ->_objectManager ->create (
720
+ \Magento \Catalog \Model \Product \Compare \ListCompare::class
721
+ );
720
722
} else {
721
723
$ this ->_compareList = false ;
722
724
}
@@ -762,7 +764,7 @@ public function moveQuoteItem($item, $moveTo, $qty)
762
764
$ info ->setOptions ($ this ->_prepareOptionsForRequest ($ item ))->setQty ($ qty );
763
765
764
766
$ product = $ this ->_objectManager ->create (
765
- ' Magento\Catalog\Model\Product '
767
+ \ Magento \Catalog \Model \Product::class
766
768
)->setStoreId (
767
769
$ this ->getQuote ()->getStoreId ()
768
770
)->load (
@@ -784,7 +786,7 @@ public function moveQuoteItem($item, $moveTo, $qty)
784
786
if ($ cart && is_null ($ item ->getOptionByCode ('additional_options ' ))) {
785
787
//options and info buy request
786
788
$ product = $ this ->_objectManager ->create (
787
- ' Magento\Catalog\Model\Product '
789
+ \ Magento \Catalog \Model \Product::class
788
790
)->setStoreId (
789
791
$ this ->getQuote ()->getStoreId ()
790
792
)->load (
@@ -819,13 +821,17 @@ public function moveQuoteItem($item, $moveTo, $qty)
819
821
$ wishlist = null ;
820
822
if (!isset ($ moveTo [1 ])) {
821
823
$ wishlist = $ this ->_objectManager ->create (
822
- ' Magento\Wishlist\Model\Wishlist '
824
+ \ Magento \Wishlist \Model \Wishlist::class
823
825
)->loadByCustomerId (
824
826
$ this ->getSession ()->getCustomerId (),
825
827
true
826
828
);
827
829
} else {
828
- $ wishlist = $ this ->_objectManager ->create ('Magento\Wishlist\Model\Wishlist ' )->load ($ moveTo [1 ]);
830
+ $ wishlist = $ this ->_objectManager ->create (
831
+ \Magento \Wishlist \Model \Wishlist::class
832
+ )
833
+ ->load ($ moveTo [1 ]);
834
+
829
835
if (!$ wishlist ->getId () || $ wishlist ->getCustomerId () != $ this ->getSession ()->getCustomerId ()
830
836
) {
831
837
$ wishlist = null ;
@@ -885,7 +891,7 @@ public function applySidebarData($data)
885
891
if (isset ($ data ['add_order_item ' ])) {
886
892
foreach ($ data ['add_order_item ' ] as $ orderItemId => $ value ) {
887
893
/* @var $orderItem \Magento\Sales\Model\Order\Item */
888
- $ orderItem = $ this ->_objectManager ->create (' Magento\Sales\Model\Order\Item ' )->load ($ orderItemId );
894
+ $ orderItem = $ this ->_objectManager ->create (\ Magento \Sales \Model \Order \Item::class )->load ($ orderItemId );
889
895
$ item = $ this ->initFromOrderItem ($ orderItem );
890
896
if (is_string ($ item )) {
891
897
throw new \Magento \Framework \Exception \LocalizedException (__ ($ item ));
@@ -904,7 +910,7 @@ public function applySidebarData($data)
904
910
if (isset ($ data ['add_wishlist_item ' ])) {
905
911
foreach ($ data ['add_wishlist_item ' ] as $ itemId => $ qty ) {
906
912
$ item = $ this ->_objectManager ->create (
907
- ' Magento\Wishlist\Model\Item '
913
+ \ Magento \Wishlist \Model \Item::class
908
914
)->loadWithOptions (
909
915
$ itemId ,
910
916
'info_buyRequest '
@@ -957,12 +963,15 @@ public function removeItem($itemId, $from)
957
963
case 'wishlist ' :
958
964
$ wishlist = $ this ->getCustomerWishlist ();
959
965
if ($ wishlist ) {
960
- $ item = $ this ->_objectManager ->create (' Magento\Wishlist\Model\Item ' )->load ($ itemId );
966
+ $ item = $ this ->_objectManager ->create (\ Magento \Wishlist \Model \Item::class )->load ($ itemId );
961
967
$ item ->delete ();
962
968
}
963
969
break ;
964
970
case 'compared ' :
965
- $ this ->_objectManager ->create ('Magento\Catalog\Model\Product\Compare\Item ' )->load ($ itemId )->delete ();
971
+ $ this ->_objectManager ->create (
972
+ \Magento \Catalog \Model \Product \Compare \Item::class
973
+ )
974
+ ->load ($ itemId )->delete ();
966
975
break ;
967
976
}
968
977
@@ -1003,7 +1012,7 @@ public function addProduct($product, $config = 1)
1003
1012
if (!$ product instanceof \Magento \Catalog \Model \Product) {
1004
1013
$ productId = $ product ;
1005
1014
$ product = $ this ->_objectManager ->create (
1006
- ' Magento\Catalog\Model\Product '
1015
+ \ Magento \Catalog \Model \Product::class
1007
1016
)->setStore (
1008
1017
$ this ->getSession ()->getStore ()
1009
1018
)->setStoreId (
@@ -1103,7 +1112,7 @@ public function updateQuoteItems($items)
1103
1112
protected function _parseOptions (\Magento \Quote \Model \Quote \Item $ item , $ additionalOptions )
1104
1113
{
1105
1114
$ productOptions = $ this ->_objectManager ->get (
1106
- ' Magento\Catalog\Model\Product\Option\Type\DefaultType '
1115
+ \ Magento \Catalog \Model \Product \Option \Type \DefaultType::class
1107
1116
)->setProduct (
1108
1117
$ item ->getProduct ()
1109
1118
)->getProductOptions ();
@@ -1115,11 +1124,15 @@ protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additio
1115
1124
if (strlen (trim ($ _additionalOption ))) {
1116
1125
try {
1117
1126
if (strpos ($ _additionalOption , ': ' ) === false ) {
1118
- throw new \Magento \Framework \Exception \LocalizedException (__ ('There is an error in one of the option rows. ' ));
1127
+ throw new \Magento \Framework \Exception \LocalizedException (
1128
+ __ ('There is an error in one of the option rows. ' )
1129
+ );
1119
1130
}
1120
1131
list ($ label , $ value ) = explode (': ' , $ _additionalOption , 2 );
1121
1132
} catch (\Exception $ e ) {
1122
- throw new \Magento \Framework \Exception \LocalizedException (__ ('There is an error in one of the option rows. ' ));
1133
+ throw new \Magento \Framework \Exception \LocalizedException (
1134
+ __ ('There is an error in one of the option rows. ' )
1135
+ );
1123
1136
}
1124
1137
$ label = trim ($ label );
1125
1138
$ value = trim ($ value );
@@ -1132,7 +1145,7 @@ protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additio
1132
1145
$ option = $ item ->getProduct ()->getOptionById ($ optionId );
1133
1146
1134
1147
$ group = $ this ->_objectManager ->get (
1135
- ' Magento\Catalog\Model\Product\Option '
1148
+ \ Magento \Catalog \Model \Product \Option::class
1136
1149
)->groupFactory (
1137
1150
$ option ->getType ()
1138
1151
)->setOption (
@@ -1231,7 +1244,7 @@ protected function _prepareOptionsForRequest($item)
1231
1244
$ optionValue = $ item ->getOptionByCode ('option_ ' . $ optionId )->getValue ();
1232
1245
1233
1246
$ group = $ this ->_objectManager ->get (
1234
- ' Magento\Catalog\Model\Product\Option '
1247
+ \ Magento \Catalog \Model \Product \Option::class
1235
1248
)->groupFactory (
1236
1249
$ option ->getType ()
1237
1250
)->setOption (
@@ -1255,7 +1268,7 @@ protected function _prepareOptionsForRequest($item)
1255
1268
*/
1256
1269
protected function _parseCustomPrice ($ price )
1257
1270
{
1258
- $ price = $ this ->_objectManager ->get (' Magento\Framework\Locale\FormatInterface ' )->getNumber ($ price );
1271
+ $ price = $ this ->_objectManager ->get (\ Magento \Framework \Locale \FormatInterface::class )->getNumber ($ price );
1259
1272
$ price = $ price > 0 ? $ price : 0 ;
1260
1273
1261
1274
return $ price ;
@@ -1360,7 +1373,7 @@ public function setShippingAddress($address)
1360
1373
{
1361
1374
if (is_array ($ address )) {
1362
1375
$ shippingAddress = $ this ->_objectManager ->create (
1363
- ' Magento\Quote\Model\Quote\Address '
1376
+ \ Magento \Quote \Model \Quote \Address::class
1364
1377
)->setData (
1365
1378
$ address
1366
1379
)->setAddressType (
@@ -1428,7 +1441,7 @@ public function setBillingAddress($address)
1428
1441
{
1429
1442
if (is_array ($ address )) {
1430
1443
$ billingAddress = $ this ->_objectManager ->create (
1431
- ' Magento\Quote\Model\Quote\Address '
1444
+ \ Magento \Quote \Model \Quote \Address::class
1432
1445
)->setData (
1433
1446
$ address
1434
1447
)->setAddressType (
@@ -1543,6 +1556,11 @@ public function setPaymentData($data)
1543
1556
public function applyCoupon ($ code )
1544
1557
{
1545
1558
$ code = trim ((string )$ code );
1559
+ $ this ->getQuote ()->getShippingAddress ()->setCollectShippingRates (true );
1560
+
1561
+ if (empty ($ code )) {
1562
+ $ this ->getQuote ()->getShippingAddress ()->setFreeShipping (null );
1563
+ }
1546
1564
$ this ->getQuote ()->setCouponCode ($ code );
1547
1565
$ this ->setRecollect (true );
1548
1566
@@ -1568,7 +1586,7 @@ public function setAccountData($accountData)
1568
1586
$ this ->dataObjectHelper ->populateWithArray (
1569
1587
$ customer ,
1570
1588
$ data ,
1571
- ' \Magento\Customer\Api\Data\CustomerInterface '
1589
+ \Magento \Customer \Api \Data \CustomerInterface::class
1572
1590
);
1573
1591
$ this ->getQuote ()->updateCustomerData ($ customer );
1574
1592
$ data = [];
@@ -1690,7 +1708,7 @@ protected function _validateCustomerData(\Magento\Customer\Api\Data\CustomerInte
1690
1708
$ this ->dataObjectHelper ->populateWithArray (
1691
1709
$ customer ,
1692
1710
$ data ,
1693
- ' \Magento\Customer\Api\Data\CustomerInterface '
1711
+ \Magento \Customer \Api \Data \CustomerInterface::class
1694
1712
);
1695
1713
return $ customer ;
1696
1714
}
0 commit comments