Skip to content

Commit e680fbb

Browse files
author
Tang, Yu(ytang1)
committed
Merge pull request #101 from magento-fearless-kiwis/FearlessKiwis-develop-no-refactoring
[FearlessKiwis] Bug fixes
2 parents 5744ef3 + 25bc818 commit e680fbb

File tree

45 files changed

+1186
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1186
-360
lines changed

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ protected function populateAuthorizeRequest(InfoInterface $payment, $token)
409409
if ($token) {
410410
$transactionParams['paymentMethodToken'] = $token;
411411
$transactionParams['customerId'] = $customerId;
412+
$transactionParams['billing'] = $this->toBraintreeAddress($billing);
413+
$transactionParams['shipping'] = $this->toBraintreeAddress($shipping);
412414
} elseif ($this->getInfoInstance()->getAdditionalInformation('payment_method_nonce')) {
413415
$transactionParams['paymentMethodNonce'] =
414416
$this->getInfoInstance()->getAdditionalInformation('payment_method_nonce');

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,6 @@ public function authorizeDataProvider()
13611361
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
13621362
'paymentMethodToken' => self::CC_TOKEN,
13631363
'customerId' => self::CUSTOMER_ID,
1364-
'billing' => null,
1365-
'shipping' => null,
13661364
'deviceData' => 'fraud_detection_data',
13671365
],
13681366
'braintree_response' => [
@@ -1429,8 +1427,6 @@ public function authorizeDataProvider()
14291427
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
14301428
'paymentMethodNonce' => self::PAYMENT_METHOD_NONCE,
14311429
'customerId' => self::CUSTOMER_ID,
1432-
'billing' => null,
1433-
'shipping' => null,
14341430
'deviceData' => 'fraud_detection_data',
14351431
'options' => [
14361432
'three_d_secure' => [
@@ -1502,8 +1498,6 @@ public function authorizeDataProvider()
15021498
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
15031499
'paymentMethodToken' => self::CC_TOKEN,
15041500
'customerId' => self::CUSTOMER_ID,
1505-
'billing' => null,
1506-
'shipping' => null,
15071501
'deviceData' => 'fraud_detection_data',
15081502
],
15091503
'braintree_response' => [

app/code/Magento/Bundle/Pricing/Adjustment/BundleCalculatorInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ interface BundleCalculatorInterface extends CalculatorInterface
1717
/**
1818
* @param float|string $amount
1919
* @param Product $saleableItem
20-
* @param null|bool $exclude
20+
* @param null|bool|string|array $exclude
2121
* @return \Magento\Framework\Pricing\Amount\AmountInterface
2222
*/
2323
public function getMaxAmount($amount, Product $saleableItem, $exclude = null);
2424

2525
/**
2626
* @param float|string $amount
2727
* @param Product $saleableItem
28-
* @param null|bool $exclude
28+
* @param null|bool|string|array $exclude
2929
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3030
*/
3131
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null);
3232

3333
/**
3434
* @param float|string $amount
3535
* @param Product $saleableItem
36-
* @param null|bool $exclude
36+
* @param null|bool|string|array $exclude
3737
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3838
*/
3939
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null);
@@ -42,7 +42,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
4242
* Option amount calculation for saleable item
4343
*
4444
* @param Product $saleableItem
45-
* @param null|string $exclude
45+
* @param null|bool|string|array $exclude
4646
* @param bool $searchMin
4747
* @param \Magento\Framework\Pricing\Amount\AmountInterface|null $bundleProductAmount
4848
* @return \Magento\Framework\Pricing\Amount\AmountInterface
@@ -60,7 +60,7 @@ public function getOptionsAmount(
6060
* @param float $basePriceValue
6161
* @param Product $bundleProduct
6262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
63-
* @param null|string $exclude code of adjustment that has to be excluded
63+
* @param null|bool|string|array $exclude code of adjustment that has to be excluded
6464
* @return \Magento\Framework\Pricing\Amount\AmountInterface
6565
*/
6666
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null);

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct(
7777
*
7878
* @param float|string $amount
7979
* @param SaleableInterface $saleableItem
80-
* @param null|string $exclude
80+
* @param null|bool|string|array $exclude
8181
* @param null|array $context
8282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
8383
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -92,7 +92,7 @@ public function getAmount($amount, SaleableInterface $saleableItem, $exclude = n
9292
*
9393
* @param float $amount
9494
* @param Product $saleableItem
95-
* @param null|string $exclude
95+
* @param null|bool|string|array $exclude
9696
* @return \Magento\Framework\Pricing\Amount\AmountInterface
9797
*/
9898
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -105,7 +105,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
105105
*
106106
* @param float $amount
107107
* @param Product $saleableItem
108-
* @param null|string $exclude
108+
* @param null|bool|string|array $exclude
109109
* @return \Magento\Framework\Pricing\Amount\AmountInterface
110110
*/
111111
public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
@@ -118,7 +118,7 @@ public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
118118
*
119119
* @param float $amount
120120
* @param Product $saleableItem
121-
* @param null|string $exclude
121+
* @param null|bool|string|array $exclude
122122
* @return \Magento\Framework\Pricing\Amount\AmountInterface
123123
*/
124124
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -130,7 +130,7 @@ public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = n
130130
* Option amount calculation for bundle product
131131
*
132132
* @param Product $saleableItem
133-
* @param null|string $exclude
133+
* @param null|bool|string|array $exclude
134134
* @param bool $searchMin
135135
* @param float $baseAmount
136136
* @param bool $useRegularPrice
@@ -260,7 +260,7 @@ protected function getBundleOptions(Product $saleableItem)
260260
* @param float $basePriceValue
261261
* @param Product $bundleProduct
262262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
263-
* @param null|string $exclude
263+
* @param null|bool|string|array $exclude
264264
* @return \Magento\Framework\Pricing\Amount\AmountInterface
265265
*/
266266
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null)
@@ -278,7 +278,7 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
278278
* @param float $basePriceValue
279279
* @param Product $bundleProduct
280280
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
281-
* @param null|string $exclude
281+
* @param null|bool|string|arrayy $exclude
282282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
283283
*/
284284
protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude)
@@ -297,7 +297,7 @@ protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $
297297
* @param float $basePriceValue
298298
* @param Product $bundleProduct
299299
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
300-
* @param null|string $exclude
300+
* @param null|bool|string|array $exclude
301301
* @return \Magento\Framework\Pricing\Amount\AmountInterface
302302
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
303303
*/
@@ -340,9 +340,18 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct,
340340
}
341341
}
342342
}
343-
if ($exclude && isset($adjustments[$exclude])) {
344-
$fullAmount -= $adjustments[$exclude];
345-
unset($adjustments[$exclude]);
343+
if (is_array($exclude) == false) {
344+
if ($exclude && isset($adjustments[$exclude])) {
345+
$fullAmount -= $adjustments[$exclude];
346+
unset($adjustments[$exclude]);
347+
}
348+
} else {
349+
foreach ($exclude as $oneExclusion) {
350+
if ($oneExclusion && isset($adjustments[$oneExclusion])) {
351+
$fullAmount -= $adjustments[$oneExclusion];
352+
unset($adjustments[$oneExclusion]);
353+
}
354+
}
346355
}
347356
return $this->amountFactory->create($fullAmount, $adjustments);
348357
}

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BundleSelectionPrice extends AbstractPrice
6868
* @param ManagerInterface $eventManager
6969
* @param DiscountCalculator $discountCalculator
7070
* @param bool $useRegularPrice
71-
* @param string $excludeAdjustment
71+
* @param array $excludeAdjustment
7272
*/
7373
public function __construct(
7474
Product $saleableItem,

app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CustomOptionPrice extends AbstractPrice implements CustomOptionPriceInterf
4141
* @param float $quantity
4242
* @param CalculatorInterface $calculator
4343
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
44-
* @param string $excludeAdjustment
44+
* @param array $excludeAdjustment
4545
*/
4646
public function __construct(
4747
SaleableInterface $saleableItem,
@@ -113,7 +113,7 @@ public function getValue()
113113

114114
/**
115115
* @param float $amount
116-
* @param null|bool|string $exclude
116+
* @param null|bool|string|array $exclude
117117
* @param null|array $context
118118
* @return AmountInterface|bool|float
119119
*/

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ public function getConfig()
278278
);
279279
$output['postCodes'] = $this->postCodesConfig->getPostCodes();
280280
$output['imageData'] = $this->imageProvider->getImages($quoteId);
281-
$output['defaultCountryId'] = $this->directoryHelper->getDefaultCountry();
282281
$output['totalsData'] = $this->getTotalsData();
283282
$output['shippingPolicy'] = [
284283
'isEnabled' => $this->scopeConfig->isSetFlag(

app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ define([], function() {
1414
return {
1515
email: addressData.email,
1616
countryId: (addressData.country_id) ? addressData.country_id : window.checkoutConfig.defaultCountryId,
17-
regionId: (addressData.region) ? addressData.region.region_id : null,
17+
regionId: (addressData.region && addressData.region.region_id)
18+
? addressData.region.region_id
19+
: window.checkoutConfig.defaultRegionId,
1820
regionCode: (addressData.region) ? addressData.region.region_code : null,
1921
region: (addressData.region) ? addressData.region.region : null,
2022
customerId: addressData.customer_id,
2123
street: addressData.street,
2224
company: addressData.company,
2325
telephone: addressData.telephone,
2426
fax: addressData.fax,
25-
postcode: addressData.postcode,
27+
postcode: addressData.postcode ? addressData.postcode : window.checkoutConfig.defaultPostcode,
2628
city: addressData.city,
2729
firstname: addressData.firstname,
2830
lastname: addressData.lastname,

app/code/Magento/Quote/Model/Quote/Address/Total/Subtotal.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected function _initItem($address, $item)
104104
}
105105
}
106106

107+
$quoteItem->setConvertedPrice(null);
107108
$originalPrice = $product->getPrice();
108109
if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
109110
$finalPrice = $quoteItem->getParentItem()->getProduct()->getPriceModel()->getChildFinalPrice(
@@ -170,6 +171,7 @@ protected function _removeItem($address, $item)
170171
* @param \Magento\Quote\Model\Quote $quote
171172
* @param Address\Total $total
172173
* @return array
174+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
173175
*/
174176
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
175177
{

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Sales\Api\Data\OrderInterfaceFactory as OrderFactory;
2121
use Magento\Sales\Api\OrderManagementInterface as OrderManagement;
2222
use Magento\Store\Model\StoreManagerInterface;
23+
use Magento\Quote\Model\Quote\Address;
2324

2425
/**
2526
* Class QuoteManagement
@@ -94,6 +95,11 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
9495
*/
9596
protected $customerModelFactory;
9697

98+
/**
99+
* @var \Magento\Quote\Model\Quote\AddressFactory
100+
*/
101+
protected $quoteAddressFactory;
102+
97103
/**
98104
* @var \Magento\Framework\Api\DataObjectHelper
99105
*/
@@ -138,6 +144,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
138144
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
139145
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
140146
* @param \Magento\Customer\Model\CustomerFactory $customerModelFactory
147+
* @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
141148
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
142149
* @param StoreManagerInterface $storeManager
143150
* @param \Magento\Checkout\Model\Session $checkoutSession
@@ -160,6 +167,7 @@ public function __construct(
160167
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
161168
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
162169
\Magento\Customer\Model\CustomerFactory $customerModelFactory,
170+
\Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
163171
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
164172
StoreManagerInterface $storeManager,
165173
\Magento\Checkout\Model\Session $checkoutSession,
@@ -180,6 +188,7 @@ public function __construct(
180188
$this->quoteRepository = $quoteRepository;
181189
$this->customerRepository = $customerRepository;
182190
$this->customerModelFactory = $customerModelFactory;
191+
$this->quoteAddressFactory = $quoteAddressFactory;
183192
$this->dataObjectHelper = $dataObjectHelper;
184193
$this->storeManager = $storeManager;
185194
$this->checkoutSession = $checkoutSession;
@@ -196,6 +205,9 @@ public function createEmptyCart()
196205
$storeId = $this->storeManager->getStore()->getStoreId();
197206
$quote = $this->createAnonymousCart($storeId);
198207

208+
$quote->setBillingAddress($this->quoteAddressFactory->create());
209+
$quote->setShippingAddress($this->quoteAddressFactory->create());
210+
199211
try {
200212
$this->quoteRepository->save($quote);
201213
} catch (\Exception $e) {

0 commit comments

Comments
 (0)