Skip to content

Commit 16dc76d

Browse files
committed
Merge pull request #108 from magento-south/BUGS
[South + B2B + MPI] Bugfixes
2 parents 1326cf1 + db06aa2 commit 16dc76d

File tree

9 files changed

+51
-591
lines changed

9 files changed

+51
-591
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ define(
1414
var address = null;
1515
if (quote.shippingAddress() && billingAddress.getCacheKey() == quote.shippingAddress().getCacheKey()) {
1616
address = $.extend({}, billingAddress);
17-
address.save_in_address_book = false;
17+
address.saveInAddressBook = false;
18+
if (quote.shippingAddress().saveInAddressBook || quote.shippingAddress().save_in_address_book) {
19+
address.saveInAddressBook = true;
20+
quote.shippingAddress().saveInAddressBook = false;
21+
}
1822
} else {
1923
address = billingAddress;
2024
}

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor/default.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
define(
77
[
88
'ko',
9+
'jquery',
910
'Magento_Checkout/js/model/quote',
1011
'Magento_Checkout/js/model/resource-url-manager',
1112
'mage/storage',
@@ -16,6 +17,7 @@ define(
1617
],
1718
function (
1819
ko,
20+
$,
1921
quote,
2022
resourceUrlManager,
2123
storage,
@@ -27,7 +29,12 @@ define(
2729
'use strict';
2830
return {
2931
saveShippingInformation: function() {
30-
var billingAddress = quote.billingAddress() || quote.shippingAddress();
32+
var billingAddress = quote.billingAddress();
33+
if (!billingAddress) {
34+
billingAddress = $.extend({}, quote.shippingAddress());
35+
quote.billingAddress(billingAddress);
36+
quote.shippingAddress().sameAsBilling = 1;
37+
}
3138
var payload = {
3239
addressInformation: {
3340
shipping_address: quote.shippingAddress(),

app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public function showCustomerInfo()
146146
[
147147
'customer' => $this->getTable('customer_entity')
148148
],
149-
'main_table.customer_id = customer.entity_id'
149+
'main_table.customer_id = customer.entity_id',
150+
['firstname', 'lastname']
150151
);
151152
return $this;
152153
}

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 22 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Customer\Api\Data\CustomerInterface as CustomerDataObject;
99
use Magento\Customer\Model\AccountManagement;
1010
use Magento\Paypal\Model\Config as PaypalConfig;
11-
use Magento\Paypal\Model\Express\Checkout\Quote as PaypalQuote;
1211
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
1312
use Magento\Quote\Model\Quote\Address;
1413
use Magento\Framework\DataObject;
@@ -254,11 +253,6 @@ class Checkout
254253
*/
255254
protected $orderSender;
256255

257-
/**
258-
* @var PaypalQuote
259-
*/
260-
protected $paypalQuote;
261-
262256
/**
263257
* @var \Magento\Quote\Api\CartRepositoryInterface
264258
*/
@@ -296,7 +290,6 @@ class Checkout
296290
* @param \Magento\Framework\Message\ManagerInterface $messageManager
297291
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
298292
* @param AccountManagement $accountManagement
299-
* @param PaypalQuote $paypalQuote
300293
* @param OrderSender $orderSender
301294
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
302295
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
@@ -326,7 +319,6 @@ public function __construct(
326319
\Magento\Framework\Message\ManagerInterface $messageManager,
327320
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
328321
AccountManagement $accountManagement,
329-
PaypalQuote $paypalQuote,
330322
OrderSender $orderSender,
331323
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
332324
\Magento\Quote\Model\Quote\TotalsCollector $totalsCollector,
@@ -353,7 +345,6 @@ public function __construct(
353345
$this->_messageManager = $messageManager;
354346
$this->orderSender = $orderSender;
355347
$this->_accountManagement = $accountManagement;
356-
$this->paypalQuote = $paypalQuote;
357348
$this->quoteRepository = $quoteRepository;
358349
$this->totalsCollector = $totalsCollector;
359350
$this->_customerSession = isset($params['session'])
@@ -620,7 +611,7 @@ public function returnFromPaypal($token)
620611
->callGetExpressCheckoutDetails();
621612
$quote = $this->_quote;
622613

623-
$this->_ignoreAddressValidation();
614+
$this->ignoreAddressValidation();
624615

625616
// import shipping address
626617
$exportedShippingAddress = $this->_api->getExportedShippingAddress();
@@ -708,7 +699,7 @@ public function prepareOrderReview($token = null)
708699
$this->_quote->setMayEditShippingMethod(
709700
'' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
710701
);
711-
$this->_ignoreAddressValidation();
702+
$this->ignoreAddressValidation();
712703
$this->_quote->collectTotals();
713704
$this->quoteRepository->save($this->_quote);
714705
}
@@ -763,7 +754,7 @@ public function updateShippingMethod($methodCode)
763754
$shippingAddress = $this->_quote->getShippingAddress();
764755
if (!$this->_quote->getIsVirtual() && $shippingAddress) {
765756
if ($methodCode != $shippingAddress->getShippingMethod()) {
766-
$this->_ignoreAddressValidation();
757+
$this->ignoreAddressValidation();
767758
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
768759
$this->_quote->collectTotals();
769760
$this->quoteRepository->save($this->_quote);
@@ -786,31 +777,14 @@ public function place($token, $shippingMethodCode = null)
786777
$this->updateShippingMethod($shippingMethodCode);
787778
}
788779

789-
$isNewCustomer = false;
790-
switch ($this->getCheckoutMethod()) {
791-
case \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST:
792-
$this->_prepareGuestQuote();
793-
break;
794-
case \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER:
795-
$this->_prepareNewCustomerQuote();
796-
$isNewCustomer = true;
797-
break;
798-
default:
799-
$this->_prepareCustomerQuote();
800-
break;
780+
if ($this->getCheckoutMethod() == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) {
781+
$this->prepareGuestQuote();
801782
}
802783

803-
$this->_ignoreAddressValidation();
784+
$this->ignoreAddressValidation();
804785
$this->_quote->collectTotals();
805786
$order = $this->quoteManagement->submit($this->_quote);
806787

807-
if ($isNewCustomer) {
808-
try {
809-
$this->_involveNewCustomer();
810-
} catch (\Exception $e) {
811-
$this->_logger->critical($e);
812-
}
813-
}
814788
if (!$order) {
815789
return;
816790
}
@@ -843,7 +817,7 @@ public function place($token, $shippingMethodCode = null)
843817
*
844818
* @return void
845819
*/
846-
private function _ignoreAddressValidation()
820+
private function ignoreAddressValidation()
847821
{
848822
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
849823
if (!$this->_quote->getIsVirtual()) {
@@ -1109,62 +1083,6 @@ protected function _matchShippingMethodCode(Address $address, $selectedCode)
11091083
return '';
11101084
}
11111085

1112-
/**
1113-
* Prepare quote for guest checkout order submit
1114-
*
1115-
* @return $this
1116-
*/
1117-
protected function _prepareGuestQuote()
1118-
{
1119-
$quote = $this->_quote;
1120-
$quote->setCustomerId(null)
1121-
->setCustomerEmail($quote->getBillingAddress()->getEmail())
1122-
->setCustomerIsGuest(true)
1123-
->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID);
1124-
return $this;
1125-
}
1126-
1127-
/**
1128-
* Prepare quote for customer registration and customer order submit
1129-
* and restore magento customer data from quote
1130-
*
1131-
* @return void
1132-
*/
1133-
protected function _prepareNewCustomerQuote()
1134-
{
1135-
$this->paypalQuote->prepareQuoteForNewCustomer($this->_quote);
1136-
}
1137-
1138-
/**
1139-
* Prepare quote for customer order submit
1140-
*
1141-
* @return void
1142-
*/
1143-
protected function _prepareCustomerQuote()
1144-
{
1145-
$this->paypalQuote->prepareRegisteredCustomerQuote($this->_quote, $this->_customerSession->getCustomerId());
1146-
}
1147-
1148-
/**
1149-
* Involve new customer to system
1150-
*
1151-
* @return $this
1152-
*/
1153-
protected function _involveNewCustomer()
1154-
{
1155-
$customer = $this->_quote->getCustomer();
1156-
$confirmationStatus = $this->_accountManagement->getConfirmationStatus($customer->getId());
1157-
if ($confirmationStatus === AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED) {
1158-
$this->_messageManager->addSuccess(
1159-
__('Thank you for registering with Main Website Store.')
1160-
);
1161-
} else {
1162-
$this->getCustomerSession()->regenerateId();
1163-
$this->getCustomerSession()->loginById($customer->getId());
1164-
}
1165-
return $this;
1166-
}
1167-
11681086
/**
11691087
* Create payment redirect url
11701088
* @param bool|null $button
@@ -1218,4 +1136,19 @@ private function setShippingOptions(PaypalCart $cart, Address $address = null)
12181136
}
12191137
}
12201138
}
1139+
1140+
/**
1141+
* Prepare quote for guest checkout order submit
1142+
*
1143+
* @return $this
1144+
*/
1145+
protected function prepareGuestQuote()
1146+
{
1147+
$quote = $this->_quote;
1148+
$quote->setCustomerId(null)
1149+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
1150+
->setCustomerIsGuest(true)
1151+
->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID);
1152+
return $this;
1153+
}
12211154
}

0 commit comments

Comments
 (0)