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

Commit e4536a4

Browse files
authored
Merge pull request #62 from grayloon/assign-cart
Assign a specified customer to a specified shopping cart
2 parents 4a2af15 + fd6e77e commit e4536a4

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ Apply a coupon to a specified cart.
253253
Magento::api('guestCarts')->couponCode($cartId, $couponCode);
254254
```
255255

256+
`/V1/guest-carts/{cartId}`
257+
258+
Assign a specified customer to a specified shopping cart.
259+
```php
260+
Magento::api('guestCarts')->assignCustomer($cartId, $customerId, $storeId);
261+
```
262+
256263
<a id="orders"></a>
257264
### Orders (salesOrderRepositoryV1)
258265

src/Api/GuestCarts.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,20 @@ public function removeCoupons($cartId)
168168
{
169169
return $this->delete('/guest-carts/'.$cartId.'/coupons');
170170
}
171+
172+
/**
173+
* Assign a specified customer to a specified shopping cart.
174+
*
175+
* @param string $cartId
176+
* @param int $customerId
177+
* @param int $storeId
178+
* @return array
179+
*/
180+
public function assignCustomer($cartId, $customerId, $storeId)
181+
{
182+
return $this->put('/guest-carts/'.$cartId, [
183+
'customerId' => $customerId,
184+
'storeId' => $storeId,
185+
]);
186+
}
171187
}

tests/Api/GuestCartsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,15 @@ public function test_can_edit_item()
156156

157157
$this->assertTrue($api->ok());
158158
}
159+
160+
public function test_it_can_assign_customer()
161+
{
162+
Http::fake([
163+
'*rest/all/V1/guest-carts/foo' => Http::response([], 200),
164+
]);
165+
166+
$api = MagentoFacade::api('guestCarts')->assignCustomer('foo', 1, 1);
167+
168+
$this->assertTrue($api->ok());
169+
}
159170
}

0 commit comments

Comments
 (0)