Skip to content

Commit

Permalink
Merge pull request #67 from chec/bugfix/remove-backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ authored Sep 1, 2020
2 parents 0f3f1bf + 8d2349c commit ba60498
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 73 deletions.
41 changes: 26 additions & 15 deletions docs/01_Products.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
---
title: Products
description: ''
description: 'The Products and Categories endpoints in Commerce.js.'
position: 1
category: Products
---

This section of the documentation goes through the core [products](#list-products) resource and [categories](#categories) which can be associated with products. Anytime we indicate **product catalog**, we are referring to entities that you would work with when developing your product listing or product details pages.\
\
[Products](/docs/api/?shell#products) in **Chec** are one of the core resources with all the data properties to out your frontend. A product is something you sell eg. physical items, services or digital goods and downloads. Requests to the products endpoint will return the full product data object with properties such as the name, description, price, variants of the product and more. With this verbose returned data, you are able to build a truly unique front-facing layer for your customers and users.
This section of the documentation goes through the core [products](#list-products) resource and
[categories](#categories) which can be associated with products. Anytime we indicate **product catalog**, we are
referring to entities that you would work with when developing your product listing or product details pages.

[Products](/docs/api/?shell#products) in **Chec** are one of the core resources with all the data properties to out your
frontend. A product is something you sell eg. physical items, services or digital goods and downloads. Requests to the
products endpoint will return the full product data object with properties such as the name, description, price,
variants of the product and more. With this verbose returned data, you are able to build a truly unique front-facing
layer for your customers and users.

---

## List products

One of the first things you will want to do when using Commerce.js is list your products in order to make a product catalog page. The `list()` method uses `GET v1/products` to return a list of product details for the current merchant. You may filter this by the optional query parameters listed in the [API](/docs/api/?shell#list-all-products).\
\
One of the first things you will want to do when using Commerce.js is list your products in order to make a product
catalog page. The `list()` method uses `GET v1/products` to return a list of product details for the current merchant.
You may filter this by the optional query parameters listed in the [API](/docs/api/?shell#list-all-products).

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -42,14 +50,15 @@ curl -X GET \
<p>Refer to the full response for listing products <a href="/docs/api/?shell#products">here</a>.</p>
</div>

Once you've got your product data you can populate your product listing view. The response here will include everything you need to build this view, such as metadata, assets, variants and options, conditionals, and prices.
Once you've got your product data you can populate your product listing view. The response here will include everything
you need to build this view, such as metadata, assets, variants and options, conditionals, and prices.

---

## Retrieve product

The `retrieve()` method uses `GET v1/products/{product_id}` to retrieve a specific product from the merchant account.\
\
The `retrieve()` method uses `GET v1/products/{product_id}` to retrieve a specific product from the merchant account.

Example request using Commerce.js:

```js
Expand All @@ -76,12 +85,13 @@ curl -X GET \

# Categories

The categories resource helps to organize products into groups using the `GET v1/categories` API endpoint. Categories can be associated to products and also accessed from the products object.
The categories resource helps to organize products into groups using the `GET v1/categories` API endpoint. Categories
can be associated to products and also accessed from the products object.

## List categories

The `list()` method uses `GET v1/categories` to return a list of all the merchant's product categories.\
\
The `list()` method uses `GET v1/categories` to return a list of all the merchant's product categories.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -113,8 +123,8 @@ $ curl -X GET \

## Retrieve category

The `retrieve()` method at the `GET v1/categories` API endpoint gets a specific category by permalink or ID.\
\
The `retrieve()` method at the `GET v1/categories` API endpoint gets a specific category by permalink or ID.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -149,7 +159,8 @@ curl -X GET \

## Products and Categories SDK reference

Refer to the full list of all the available products and categories methods [here](/docs/sdk/full-sdk-reference#products).
Refer to the full list of all the available products and categories methods
[here](/docs/sdk/full-sdk-reference#products).

---

Expand Down
45 changes: 27 additions & 18 deletions docs/02_Cart.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
---
title: Cart
description: ''
description: 'The Cart endpoint in Commerce.js.'
position: 2
category: Cart
---

The **Cart** resource can hold product data, product variants, quantity, price, and other meta data to be used to [generate a checkout token](/docs/sdk/checkout#generate-token) and [capture an order](/docs/sdk/checkout#capture-order). This feature comes equipped with multiple intuitive endpoints to help develop a seamless shopping cart experience.
The **Cart** resource can hold product data, product variants, quantity, price, and other meta data to be used to
[generate a checkout token](/docs/sdk/checkout#generate-token) and [capture an order](/docs/sdk/checkout#capture-order).
This feature comes equipped with multiple intuitive endpoints to help develop a seamless shopping cart experience.

---

## Retrieve cart

In order to start adding products to your cart, you'll need to first create a cart. When you first call the method `retrieve()` using `GET v1/carts`, it will automatically create a cart for you if a cart does not exist yet or a current cart will be retrieved if the `cart_id` is passed in as an argument. Commerce.js tracks the current cart ID using a cookie.\
\
In order to start adding products to your cart, you'll need to first create a cart. When you first call the method
`retrieve()` using `GET v1/carts`, it will automatically create a cart for you if a cart does not exist yet or a current
cart will be retrieved if the `cart_id` is passed in as an argument. Commerce.js tracks the current cart ID using a
cookie.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -49,8 +54,8 @@ curl -X GET \

## Refresh cart

The `refresh()` method uses `GET v1/carts` to create a new cart and update the stored cart ID in Commerce.js.\
\
The `refresh()` method uses `GET v1/carts` to create a new cart and update the stored cart ID in Commerce.js.

Example request using Commerce.js:

```js
Expand All @@ -74,8 +79,9 @@ commerce.cart.refresh().then((cart) => console.log(cart));

## Add to cart

The `add()` method uses `POST v1/carts/{cart_id}` to add a product to cart. You will need the ID of the product you want to add e.g. `prod_05389st98t49h`.\
\
The `add()` method uses `POST v1/carts/{cart_id}` to add a product to cart. You will need the ID of the product you want
to add e.g. `prod_05389st98t49h`.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -114,8 +120,9 @@ curl -X POST \

## Update cart

The `update()` method uses `PUT v1/carts/{cart_id}/items/{line_item_id}` to update the quantity or variant for the line item ID in the cart.\
\
The `update()` method uses `PUT v1/carts/{cart_id}/items/{line_item_id}` to update the quantity or variant for the line
item ID in the cart.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -149,8 +156,8 @@ curl -X PUT \

## Get cart contents

The `contents()` method uses `GET v1/carts/{cart_id}/items` to return the contents and items of the cart.\
\
The `contents()` method uses `GET v1/carts/{cart_id}/items` to return the contents and items of the cart.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -182,8 +189,9 @@ curl -X GET \

## Remove from cart

The `remove()` method uses `DELETE v1/carts/{cart_id}/items/{line_item_id}` to remove a specific line item from the cart.\
\
The `remove()` method uses `DELETE v1/carts/{cart_id}/items/{line_item_id}` to remove a specific line item from the
cart.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -215,8 +223,8 @@ curl -X DELETE \

## Delete cart

The `delete()` method uses `DELETE v1/carts/{cart_id}` to delete a cart entirely.\
\
The `delete()` method uses `DELETE v1/carts/{cart_id}` to delete a cart entirely.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -248,8 +256,9 @@ curl -X DELETE \

## Empty cart

The `empty()` method uses `DELETE v1/carts/{cart_id}/items` to clear the contents of the current cart. This is different from the `.refresh()` method in that it empties the current cart but not create a new cart.\
\
The `empty()` method uses `DELETE v1/carts/{cart_id}/items` to clear the contents of the current cart. This is different
from the `.refresh()` method in that it empties the current cart but not create a new cart.

Example request using Commerce.js:

```js
Expand Down
57 changes: 30 additions & 27 deletions docs/03_Checkout.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: "Checkout"
title: Checkout
description: 'The Checkout endpoint in Commerce.js.'
position: 3
category: Checkout
---

The checkout resource is used to navigate your customers through the transaction and shipping stage of a purchasing
Expand All @@ -15,8 +18,8 @@ resource.

The `generateToken()` method uses `GET v1/checkouts/{id}` to generate a [checkout
token](/docs/sdk/concepts#checkout-tokens) which can be used to initiate the process of capturing an order from a cart.
`generateTokenFrom()` gets a new checkout token from a specific identifier type. See below for the example request.\
\
`generateTokenFrom()` gets a new checkout token from a specific identifier type. See below for the example request.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -56,8 +59,8 @@ checkout page.

The `capture()` method uses `POST v1/checkouts/{checkout_token_id}` to capture an order and payment by providing the
checkout token and necessary data for the order to be completed. The resolved promise returns an order object which can
be used for receipt.\
\
be used for receipt.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -115,8 +118,8 @@ commerce.checkout.capture({
In response to a successful checkout capture, you'll get all the information for the order you need to show a
confirmation page to your customer, including the `id` (the order ID), the `customer_reference` (customer's order
reference), and much more. Note that you may want to store the response in local state since fetching the data again
would require a secret key.\
\
would require a secret key.

Key-value multi-dimensional arrays/objects/hashes are used to immediately associate values with their parent(s) ID when
submitting data. For example with line items, the key would be the `line_item_id` and the related values would be nested
under that key.
Expand All @@ -139,8 +142,8 @@ under that key.
## Get existing token

The `getToken()` method uses `GET v1/checkouts/tokens/{checkout_token_id}` to return an existing checkout token by it's
ID. The output from this request will be the same as that of `.generateToken()`.\
\
ID. The output from this request will be the same as that of `.generateToken()`.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -174,8 +177,8 @@ check discount etc) will return the live object.
## Get the live object

The live object is a living object which udpates to show the live tax rates, prices, and totals for a checkout token.
The `getLive()` method uses `GET v1/checkouts/{checkout_token_id}/live` to return the current checkout live object.\
\
The `getLive()` method uses `GET v1/checkouts/{checkout_token_id}/live` to return the current checkout live object.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -203,8 +206,8 @@ Commerce.checkout.getLive('chkt_L5z3kmQpdpkGlA').then((response) => console.log(
If you have enabled "Pay What You Want" pricing, your customers are able to choose the amount they pay. The
`checkPayWhatYouWant()` method uses `GET v1/checkouts/{checkout_token_id}/check/pay_what_you_want` to validate and saves
the desired "Pay What You Want" amount for the provided checkout token, if enabled. If the amount is too low, an invalid
response will be returned with the minimum amount required.\
\
response will be returned with the minimum amount required.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -232,8 +235,8 @@ commerce.checkout.checkPayWhatYouWant('chkt_L5z3kmQpdpkGlA', {
## Check discount code

The `checkDiscount()` method uses `GET v1/checkouts/{checkout_token_id}/check/pay_what_you_want` to validate a discount
code for the provided checkout token, and applies it to the order if it is valid.\
\
code for the provided checkout token, and applies it to the order if it is valid.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -261,8 +264,8 @@ commerce.checkout.checkPayWhatYouWant('chkt_L5z3kmQpdpkGlA', {
## Check shipping method

The `checkShippingOption()` method uses `GET v1/checkouts/{checkout_token_id}/check/shipping` to validate a shipping
method for the provided checkout token, and applies it to the order.\
\
method for the provided checkout token, and applies it to the order.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -294,8 +297,8 @@ commerce.checkout.checkShippingOption('chkt_L5z3kmQpdpkGlA', {

The `setTaxZone()` method uses `GET v1/checkouts/{checkout_token_id}/helper/set_tax_zone` to set the tax zone for the
provided checkout token's order, either automatically from a provided IP address, or by the geographic data provided in
the request arguments.\
\
the request arguments.

Example request using Commerce.js:

```js
Expand Down Expand Up @@ -334,8 +337,8 @@ The **Services** endpoint are additional checkout helpers service methods.

The `localeListCountries()` method uses `GET v1/services/locale/countries`to return a list of all countries registered
in the platform. See [List available shipping countries](#list-available-shipping-countries) for an equivalent list of
countries that can be shipped to your account.\
\
countries that can be shipped to your account.

Example request using Commerce.js:

```js
Expand All @@ -362,8 +365,8 @@ commerce.services.localeListCountries().then((response) => console.log(response)
The `localeListSubdivisions()` method uses `GET v1/services/locale/{country_code}/subdivisions` to return a list of all
subdivisions (states, provinces, or regions) for that country, given a valid country code is provided. See [List
available shipping subdivisions for country](#list-available-shipping-subdivisions)" for an equivalent list of
subdivisions that can be shipped to for your account.\
\
subdivisions that can be shipped to for your account.

Example request using Commerce.js:

```js
Expand All @@ -388,8 +391,8 @@ commerce.services.localeListSubdivisions('US').then((response) => console.log(re
## List available shipping countries

The `localeListShippingCountries()` method at `GET v1/services/locale/{country_code}/subdivisions` returns only the
countries which can be shipped to the current checkout.\
\
countries which can be shipped to the current checkout.

Example request using Commerce.js:

```js
Expand All @@ -411,8 +414,8 @@ Commerce.services.localeListShippingCountries('chkt_L5z3kmQpdpkGlA').then((respo

The `localeListShippingSubdivisions()` method at `GET
v1/services/locale/{checkout_token_id}/countries/{country_code}/subdivisions` returns only the subdivisions (states,
provinces, or regions) in a country which can be shipped to for the current checkout.\
\
provinces, or regions) in a country which can be shipped to for the current checkout.

Example request using Commerce.js:

```js
Expand Down
Loading

0 comments on commit ba60498

Please sign in to comment.