@konfiqo/storefront-react 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -142,6 +142,13 @@ interface UseCartResult extends CartSnapshot {
142
142
  setAddress(input: AddressInput): Promise<Cart>;
143
143
  /** Selects a shipping option. */
144
144
  setShippingOption(optionId: string): Promise<Cart>;
145
+ /**
146
+ * Enters a coupon code (one per cart). Rejects with `coupon_invalid`
147
+ * (`details.reason` `unknown` or `used_up`) and keeps the cart as it was.
148
+ */
149
+ applyCode(code: string): Promise<Cart>;
150
+ /** Removes the cart's coupon code. */
151
+ removeCode(): Promise<Cart>;
145
152
  /** The shipping options of the cart (`{ items: [] }` without a cart). */
146
153
  shippingOptions(options?: RequestOptions): Promise<ShippingOptionList>;
147
154
  /** Reads the cart again (a cart whose payment failed comes back `open`). */
package/dist/index.d.ts CHANGED
@@ -142,6 +142,13 @@ interface UseCartResult extends CartSnapshot {
142
142
  setAddress(input: AddressInput): Promise<Cart>;
143
143
  /** Selects a shipping option. */
144
144
  setShippingOption(optionId: string): Promise<Cart>;
145
+ /**
146
+ * Enters a coupon code (one per cart). Rejects with `coupon_invalid`
147
+ * (`details.reason` `unknown` or `used_up`) and keeps the cart as it was.
148
+ */
149
+ applyCode(code: string): Promise<Cart>;
150
+ /** Removes the cart's coupon code. */
151
+ removeCode(): Promise<Cart>;
145
152
  /** The shipping options of the cart (`{ items: [] }` without a cart). */
146
153
  shippingOptions(options?: RequestOptions): Promise<ShippingOptionList>;
147
154
  /** Reads the cart again (a cart whose payment failed comes back `open`). */
package/dist/index.js CHANGED
@@ -239,6 +239,8 @@ var CartStore = class {
239
239
  setCustomer = (input) => this.write((id) => this.client.carts.setCustomer(id, input));
240
240
  setAddress = (input) => this.write((id) => this.client.carts.setAddress(id, input));
241
241
  setShippingOption = (optionId) => this.write((id) => this.client.carts.setShippingOption(id, optionId));
242
+ applyCode = (code) => this.write((id) => this.client.carts.applyCode(id, code));
243
+ removeCode = () => this.write((id) => this.client.carts.removeCode(id));
242
244
  /** The shipping options of the cart (empty when there is no cart yet). */
243
245
  shippingOptions = async (options) => {
244
246
  const id = this.currentId();
@@ -603,6 +605,8 @@ function useCart() {
603
605
  setCustomer: store.setCustomer,
604
606
  setAddress: store.setAddress,
605
607
  setShippingOption: store.setShippingOption,
608
+ applyCode: store.applyCode,
609
+ removeCode: store.removeCode,
606
610
  shippingOptions: store.shippingOptions,
607
611
  refresh: store.refresh,
608
612
  reset: store.reset