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

Assign a specified customer to a specified shopping cart #62

Merged
merged 3 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ Apply a coupon to a specified cart.
Magento::api('guestCarts')->couponCode($cartId, $couponCode);
```

`/V1/guest-carts/{cartId}`

Assign a specified customer to a specified shopping cart.
```php
Magento::api('guestCarts')->assignCustomer($cartId, $customerId, $storeId);
```

<a id="orders"></a>
### Orders (salesOrderRepositoryV1)

Expand Down
16 changes: 16 additions & 0 deletions src/Api/GuestCarts.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,20 @@ public function removeCoupons($cartId)
{
return $this->delete('/guest-carts/'.$cartId.'/coupons');
}

/**
* Assign a specified customer to a specified shopping cart.
*
* @param string $cartId
* @param int $customerId
* @param int $storeId
* @return array
*/
public function assignCustomer($cartId, $customerId, $storeId)
{
return $this->put('/guest-carts/'.$cartId, [
'customerId' => $customerId,
'storeId' => $storeId,
]);
}
}
11 changes: 11 additions & 0 deletions tests/Api/GuestCartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,15 @@ public function test_can_edit_item()

$this->assertTrue($api->ok());
}

public function test_it_can_assign_customer()
{
Http::fake([
'*rest/all/V1/guest-carts/foo' => Http::response([], 200),
]);

$api = MagentoFacade::api('guestCarts')->assignCustomer('foo', 1, 1);

$this->assertTrue($api->ok());
}
}