Skip to content

Commit

Permalink
Update tutorial.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-traciporter authored Nov 6, 2023
1 parent b73e01e commit 22c766e
Showing 1 changed file with 99 additions and 98 deletions.
197 changes: 99 additions & 98 deletions docs/api-docs/headless/tutorial.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ This article assumes you are familiar with the following:

### Prerequisites

* A store-level API account with the following permissions.
- **Carts:** `Modify`
- **Checkout:** `Modify`
- **Orders:** `Modify`
- **Products:** `Read Only`
* A store-level or app-level API account with the following permissions.

| UI Name | Permission | Parameter |
|----------|------------|-------------------------------|
| Carts | modify | `store_cart` |
| Checkouts| modify | `store_checkouts` |
| Orders | modify | `store_v2_orders_read_only` |
| Products | read-only | `store_v2_products_read_only` |

For more information, see [OAuth Scopes](/docs/start/authentication/api-accounts#oauth-scopes).

Expand All @@ -29,12 +32,12 @@ To generate the cart ID, send a request to the [create a cart](/docs/rest-manage

<Tabs items={['Request', 'Response']}>
<Tab>
```http filename="Example request: Create a cart" showLineNumbers copy
POST https://api.bigcommerce.com/stores/{{store_hash}}/v3/carts
Accept: application/json
Content-Type: application/json
X-Auth-Token: {{ACCESS_TOKEN}}
{
```json filename="Example request: Create a cart" showLineNumbers copy
POST https://api.bigcommerce.com/stores/{{store_hash}}/v3/carts
Accept: application/json
Content-Type: application/json
X-Auth-Token: {{ACCESS_TOKEN}}
{
"customer_id": 0,
"line_items": [
{
Expand All @@ -49,57 +52,57 @@ To generate the cart ID, send a request to the [create a cart](/docs/rest-manage
"code": "USD"
},
"locale": "en-US"
}
```
}
```
</Tab>
<Tab>
```json filename="Example response: Create a cart" showLineNumbers copy
{
"data": {
"id": "3cae6525-d0e8-4252-afec-0890fbb710c5",
"customer_id": 0,
"channel_id": 1,
"email": "",
"currency": {
"code": "USD"
```http filename="Example response: Create a cart" showLineNumbers copy
{
"data": {
"id": "3cae6525-d0e8-4252-afec-0890fbb710c5",
"customer_id": 0,
"channel_id": 1,
"email": "",
"currency": {
"code": "USD"
},
"tax_included": false,
"base_amount": 30,
"discount_amount": 4.5,
"cart_amount": 25.5,
"coupons": [],
"line_items": {
"physical_items": [
{
"id": "ca9ef0d1-1da9-48e5-a505-7051eb575432",
"parent_id": null,
"variant_id": 118,
"product_id": 120,
"sku": "SM-13",
"name": "mug",
"url": "https://arabic-store.mybigcommerce.com/bigcommerce-coffee-mug/",
"quantity": 2,
"taxable": true,
"image_url": "https://cdn11.bigcommerce.com/r-4b20dad619e29ebf3490f7f35369a8220637ce48/themes/ClassicNext/images/ProductDefault.gif",
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"original_price": 15,
"list_price": 15,
"sale_price": 13.86,
"extended_list_price": 30,
"extended_sale_price": 27.72,
"is_require_shipping": true,
"is_mutable": true
}
],
"digital_items": [],
"gift_certificates": [],
"custom_items": []
"tax_included": false,
"base_amount": 30,
"discount_amount": 4.5,
"cart_amount": 25.5,
"coupons": [],
"line_items": {
"physical_items": [
{
"id": "ca9ef0d1-1da9-48e5-a505-7051eb575432",
"parent_id": null,
"variant_id": 118,
"product_id": 120,
"sku": "SM-13",
"name": "mug",
"url": "https://arabic-store.mybigcommerce.com/bigcommerce-coffee-mug/",
"quantity": 2,
"taxable": true,
"image_url": "https://cdn11.bigcommerce.com/r-4b20dad619e29ebf3490f7f35369a8220637ce48/themes/ClassicNext/images/ProductDefault.gif",
"coupons": [],
"discount_amount": 0,
"coupon_amount": 0,
"original_price": 15,
"list_price": 15,
"sale_price": 13.86,
"extended_list_price": 30,
"extended_sale_price": 27.72,
"is_require_shipping": true,
"is_mutable": true
}
],
"digital_items": [],
"gift_certificates": [],
"custom_items": []
},
"created_time": "2023-09-28T20:30:33+00:00",
"updated_time": "2023-09-28T20:30:33+00:00",
"locale": "en-US"
"created_time": "2023-09-28T20:30:33+00:00",
"updated_time": "2023-09-28T20:30:33+00:00",
"locale": "en-US"
},
"meta": {}
}
Expand All @@ -109,7 +112,7 @@ To generate the cart ID, send a request to the [create a cart](/docs/rest-manage

### Step 2: Generate the redirect URLs

To generate the redirect URLs, send a POST request to the [create cart redirect URL](https://developer.bigcommerce.com/docs/rest-management/carts/redirects#create-cart-redirect-url) endpoint. You must use the cart ID generated in [step 1](#creating-a-cart) above. The response will contain the `cart_url` and the `checkout_url`. Use these URLs to redirect customers to the BigCommerce-hosted cart or checkout pages.
To generate the redirect URLs, send a POST request to the [create cart redirect URL](/docs/rest-management/carts/redirects#create-cart-redirect-url) endpoint. You must use the cart ID generated in [step 1](#creating-a-cart) above. The response will contain the `cart_url` and the `checkout_url`. Use these URLs to redirect customers to the BigCommerce-hosted cart or checkout pages.

<Tabs items={['Request', 'Response']}>
<Tab>
Expand All @@ -122,13 +125,13 @@ X-Auth-Token: {{ACCESS_TOKEN}}
```
</Tab>
<Tab>
```json filename="Example response: Create cart redirect URLs" showLineNumbers copy
{
```http filename="Example response: Create cart redirect URLs" showLineNumbers copy
{
"data": {
"cart_url": "https://test-store.mybigcommerce.com/cart.php?action=load&id=3cae6525-d0e8-4252-afec-0890fbb710c5&token=888dbf8bc89d5bc925ed40d39996387574f8deceaf759c64c101679d1f164f4f",
"checkout_url": "https://test-store.mybigcommerce.com/cart.php?action=loadInCheckout&id=3cae6525-d0e8-4252-afec-0890fbb710c5&token=888dbf8bc89d5bc925ed40d39996387574f8deceaf759c64c101679d1f164f4f",
"embedded_checkout_url": "https://test-store.mybigcommerce.com/cart.php?embedded=1&action=loadInCheckout&id=3cae6525-d0e8-4252-afec-0890fbb710c5&token=888dbf8bc89d5bc925ed40d39996387574f8deceaf759c64c101679d1f164f4f"
},
},
"meta": {}
}
```
Expand All @@ -137,11 +140,11 @@ X-Auth-Token: {{ACCESS_TOKEN}}

## Creating a checkout

In this section, we will add a billing address to your checkout. You must have a `checkoutID`. The `checkoutID` is the same as the `cart_id` you generated in [step 1](#creating-a-cart) of creating a cart. To add a billing address, send a POST request to the [Add Checkout Billing Address](https://developer.bigcommerce.com/docs/rest-management/checkouts/checkout-billing-address#add-checkout-billing-address) endpoint.
In this section, we will add a billing address to your checkout. You must have a `checkoutID`. The `checkoutID` is the same as the `cart_id` you generated in [step 1](#creating-a-cart) of creating a cart. To add a billing address, send a POST request to the [Add Checkout Billing Address](/docs/rest-management/checkouts/checkout-billing-address#add-checkout-billing-address) endpoint.

<Tabs items={['Request', 'Response']}>
<Tab>
```json filename="Example request: Add Checkout Billing Address" showLineNumbers copy
```http filename="Example request: Add Checkout Billing Address" showLineNumbers copy
POST https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkoutId}/billing-address
Accept: application/json
Content-Type: application/json
Expand All @@ -161,9 +164,9 @@ X-Auth-Token: {{ACCESS_TOKEN}}
"phone": "555-555-5555"
}
```
</Tab>
</Tab>
<Tab>
```json filename="Example response: Add Checkout Billing Address" showLineNumbers copy
```http filename="Example response: Add Checkout Billing Address" showLineNumbers copy
{
"data": {
"id": "3cae6525-d0e8-4252-afec-0890fbb710c5",
Expand Down Expand Up @@ -298,7 +301,7 @@ X-Auth-Token: {{ACCESS_TOKEN}}
```
</Tab>
<Tab>
```json filename="Example response: Add Consignment to checkout" showLineNumbers copy
```http filename="Example response: Add Consignment to checkout" showLineNumbers copy
{
"data": {
"id": "3cae6525-d0e8-4252-afec-0890fbb710c5",
Expand Down Expand Up @@ -469,38 +472,36 @@ X-Auth-Token: {{ACCESS_TOKEN}}
</Tabs>
The response will contain an array of `available_shipping_options`. In the next step, you will use one of the available shipping options to update the consignment.

```json filename="available shipping options" showLineNumbers copy
```http filename="available shipping options" showLineNumbers copy
"available_shipping_options": [
{
"id": "6ded13392879983ee32a3563f5fa6a7b",
"type": "shipping_pickupinstore",
"description": "Pickup In Store",
"image_url": "",
"cost": 0,
"transit_time": "",
"additional_description": ""
},
{
"id": "26fb2db4ad77b0f039328d22d2869617",
"type": "shipping_flatrate",
"description": "Flat Rate",
"image_url": "",
"cost": 5,
"transit_time": "",
"additional_description": ""
},
{
"id": "508540c73074d5ffa2cc3dced0adc552",
"type": "shipping_byweight",
"description": "Ship by Weight",
"image_url": "",
"cost": 8,
"transit_time": "",
"additional_description": ""
}
]
}
],
{
"id": "6ded13392879983ee32a3563f5fa6a7b",
"type": "shipping_pickupinstore",
"description": "Pickup In Store",
"image_url": "",
"cost": 0,
"transit_time": "",
"additional_description": ""
},
{
"id": "26fb2db4ad77b0f039328d22d2869617",
"type": "shipping_flatrate",
"description": "Flat Rate",
"image_url": "",
"cost": 5,
"transit_time": "",
"additional_description": ""
},
{
"id": "508540c73074d5ffa2cc3dced0adc552",
"type": "shipping_byweight",
"description": "Ship by Weight",
"image_url": "",
"cost": 8,
"transit_time": "",
"additional_description": ""
}
]
```

### Step 2: Update the consignment
Expand Down

0 comments on commit 22c766e

Please sign in to comment.