Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 5cea061

Browse files
committed
WIP: review changes
1 parent 510747b commit 5cea061

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/Core/Request/Customers/CustomerLoginRequest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function __construct($email, $password, $anonymousCart = null, Context $c
8080
$this->password = $password;
8181
if ($anonymousCart instanceof CartReference) {
8282
$this->anonymousCart = $anonymousCart;
83-
} elseif ($anonymousCart != null) {
84-
$this->anonymousCartId = CartReference::ofId($anonymousCart);
83+
} elseif ($anonymousCart !== null) {
84+
$this->anonymousCart = CartReference::ofId($anonymousCart);
8585
}
8686
}
8787

@@ -129,7 +129,10 @@ public function setPassword($password)
129129
*/
130130
public function getAnonymousCartId()
131131
{
132-
return $this->anonymousCartId;
132+
if ($this->anonymousCart == null) {
133+
return null;
134+
}
135+
return $this->anonymousCart->getId();
133136
}
134137

135138
/**
@@ -139,7 +142,7 @@ public function getAnonymousCartId()
139142
*/
140143
public function setAnonymousCartId($anonymousCartId)
141144
{
142-
$this->anonymousCartId = $anonymousCartId;
145+
$this->anonymousCart = CartReference::ofId($anonymousCartId);
143146

144147
return $this;
145148
}
@@ -209,9 +212,6 @@ public function setAnonymousCart($anonymousCart)
209212
*/
210213
public static function ofEmailAndPassword($email, $password, $anonymousCart = null, Context $context = null)
211214
{
212-
if (!$anonymousCart instanceof CartReference & $anonymousCart != null) {
213-
$anonymousCart = CartReference::ofId($anonymousCart);
214-
}
215215
return new static($email, $password, $anonymousCart, $context);
216216
}
217217

@@ -230,9 +230,6 @@ public static function ofEmailPasswordAndUpdateProductData(
230230
$anonymousCart = null,
231231
Context $context = null
232232
) {
233-
if (!$anonymousCart instanceof CartReference & $anonymousCart != null) {
234-
$anonymousCart = CartReference::ofId($anonymousCart);
235-
}
236233
$request = new static($email, $password, $anonymousCart, $context);
237234
$request->setUpdateProductData($updateProductData);
238235

src/Core/Request/Orders/OrderCreateFromCartRequest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class OrderCreateFromCartRequest extends AbstractApiRequest
4444
* @deprecated use $cart instead
4545
*/
4646
protected $cartId;
47+
/**
48+
* @var CartReference
49+
*/
4750
protected $cart;
4851
protected $version;
4952
protected $orderNumber;
@@ -95,7 +98,10 @@ public function setCart($cart)
9598
*/
9699
public function getCartId()
97100
{
98-
return $this->cartId;
101+
if ($this->cart == null) {
102+
return null;
103+
}
104+
return $this->cart->getId();
99105
}
100106

101107
/**
@@ -105,7 +111,7 @@ public function getCartId()
105111
*/
106112
public function setCartId($cartId)
107113
{
108-
$this->cartId = $cartId;
114+
$this->cart = CartReference::ofId($cartId);
109115

110116
return $this;
111117
}
@@ -264,7 +270,6 @@ public function buildResponse(ResponseInterface $response)
264270
public function httpRequest()
265271
{
266272
$payload = [
267-
static::ID => $this->getCart()->getId(),
268273
static::CART => $this->getCart(),
269274
static::VERSION => $this->getVersion(),
270275
];

tests/unit/Request/Orders/OrderCreateFromCartRequestTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function testHttpRequestObject()
7575
$httpRequest = $request->httpRequest();
7676

7777
$expectedResult = [
78-
'id' => '12345',
78+
"cart" => [
79+
"id" => "12345",
80+
"typeId" => "cart"
81+
],
7982
'version' => 1,
8083
'orderNumber' => '12345678',
8184
'paymentState' => 'paid',

0 commit comments

Comments
 (0)