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

Commit fe37915

Browse files
committed
feat: add endpoint to estimate guest cart shipping methods
1 parent 4ba61af commit fe37915

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ Add/update the specified cart item.
179179
$magento->api('guestCarts')->addItem($cartId, $sku, $quantity);
180180
```
181181

182+
`/V1/guest-carts/{cartId}/estimate-shipping-methods`
183+
184+
Estimate shipping by address and return list of available shipping methods.
185+
```php
186+
$magento->api('guestCarts')->estimateShippingMethods($cartId);
187+
```
188+
182189
<a id="product-attributes"></a>
183190
### Product Attributes (catalogProductAttributeRepositoryV1)
184191

src/Api/GuestCarts.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,16 @@ public function totals($cartId)
6262
{
6363
return $this->get('/guest-carts/'.$cartId.'/totals');
6464
}
65+
66+
/**
67+
* Estimate shipping by address and return list of available shipping methods.
68+
*
69+
* @param string $cartId
70+
* @param array $body
71+
* @return array
72+
*/
73+
public function estimateShippingMethods($cartId, $body = [])
74+
{
75+
return $this->post('/guest-carts/'.$cartId.'/estimate-shipping-methods', $body);
76+
}
6577
}

tests/Api/GuestCartsTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,17 @@ public function test_can_call_guest_carts_totals()
6969

7070
$this->assertTrue($api->ok());
7171
}
72+
73+
public function test_can_call_guest_carts_estimate_shipping_methods()
74+
{
75+
Http::fake([
76+
'*rest/all/V1/guest-carts/foo/estimate-shipping-methods' => Http::response([], 200),
77+
]);
78+
79+
$magento = new Magento();
80+
81+
$api = $magento->api('guestCarts')->estimateShippingMethods('foo');
82+
83+
$this->assertTrue($api->ok());
84+
}
7285
}

0 commit comments

Comments
 (0)