Skip to content

Commit

Permalink
Fixed auto setting addresses when retrieving a cart fixes #1476
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed May 28, 2020
1 parent 16947ec commit 0982926
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed
- Fixed a bug where “Purchase Total” and “Purchase Quantity” discount conditions weren’t being applied correctly. ([#1389](https://github.com/craftcms/commerce/issues/1389))
- Fixed a bug where transaction information could show as undefined. ([#1467](https://github.com/craftcms/commerce/issues/1467))
- Fixed a bug where addresses weren’t being set when retrieving a cart. ([#1476](https://github.com/craftcms/commerce/issues/1476))

## 3.1.5 - 2020-05-27

Expand Down
6 changes: 4 additions & 2 deletions src/services/Carts.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ class Carts extends Component
*/
public function getCart($forceSave = false): Order
{
$customerId = Plugin::getInstance()->getCustomers()->getCustomerId();

// If there is no cart set for this request, and we can't get a cart from session, create one.
if (null === $this->_cart && !$this->_cart = $this->_getCart()) {
$this->forgetCart(); // TODO: Probably remove this so we don't get a new cart number on every request?
$this->_cart = new Order();
$this->_cart = new Order(['customerId' => $customerId]);
$this->_cart->number = $this->getSessionCartNumber();
}

Expand All @@ -80,7 +82,7 @@ public function getCart($forceSave = false): Order
$this->_cart->orderLanguage = Craft::$app->language;
$this->_cart->currency = Plugin::getInstance()->getPaymentCurrencies()->getPrimaryPaymentCurrencyIso();
$this->_cart->paymentCurrency = $this->_getCartPaymentCurrencyIso();
$this->_cart->customerId = Plugin::getInstance()->getCustomers()->getCustomerId();
$this->_cart->customerId = $customerId;
$this->_cart->origin = Order::ORIGIN_WEB;

$changedIp = $originalIp != $this->_cart->lastIp;
Expand Down

0 comments on commit 0982926

Please sign in to comment.