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

Commit 2f8b321

Browse files
committed
feat: ability to create cart as customer
1 parent 66f0f63 commit 2f8b321

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Api/Carts.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ public function mine()
1616
return $this->get('/carts/mine');
1717
}
1818

19+
/**
20+
* Returns information for the cart for the authenticated customer. Must have a store code.
21+
*
22+
* @return array
23+
*/
24+
public function create()
25+
{
26+
$this->validateSingleStoreCode();
27+
28+
return $this->post('/carts/mine');
29+
}
30+
1931
/**
2032
* Estimate shipping by address and return list of available shipping methods.
2133
*

tests/Api/CartsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ public function test_can_call_carts_payment_information()
112112
$this->assertTrue($api->ok());
113113
}
114114

115+
public function test_can_call_cart_mine_create()
116+
{
117+
Http::fake([
118+
'*rest/default/V1/carts/mine' => Http::response('foo', 200),
119+
]);
120+
121+
$api = MagentoFacade::setStoreCode('default')->api('carts')->create();
122+
123+
$this->assertTrue($api->ok());
124+
}
125+
115126
public function test_must_pass_a_single_store_code_to_payment_information()
116127
{
117128
$this->expectException('exception');

0 commit comments

Comments
 (0)