Picnic.Resources.Cart (Picnic v0.1.0)

Copy Markdown View Source

The shopping cart.

Mutating calls return the updated cart, as the API does.

In Picnic's model the cart is an order — the payload comes back as "type" => "ORDER" with the same line items a placed order has — which is why every call here returns an order-shaped document.

Summary

Functions

Adds a product. Options: :count (default 1), :as, plus request options.

Empties the cart.

Fetches the current cart. Pass as: :struct to decode into a Picnic.Schema.Cart.

Removes a product. Options: :count (default 1), :as, plus request options.

Types

result()

@type result() :: {:ok, term()} | {:error, Picnic.Error.t()}

Functions

add(client, product_id, opts \\ [])

@spec add(Picnic.Client.t(), String.t(), keyword()) :: result()

Adds a product. Options: :count (default 1), :as, plus request options.

clear(client, opts \\ [])

@spec clear(
  Picnic.Client.t(),
  keyword()
) :: result()

Empties the cart.

get(client, opts \\ [])

@spec get(
  Picnic.Client.t(),
  keyword()
) :: result()

Fetches the current cart. Pass as: :struct to decode into a Picnic.Schema.Cart.

remove(client, product_id, opts \\ [])

@spec remove(Picnic.Client.t(), String.t(), keyword()) :: result()

Removes a product. Options: :count (default 1), :as, plus request options.