@dropins/storefront-order 1.0.0-beta5 → 1.0.0-beta6

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/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as m,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as pe,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as me}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,c;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((c=e.selectedOptions)==null?void 0:c.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotalExclTax.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=E();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){E().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=`
3
+ import{c as V,r as Y}from"./chunks/requestGuestOrderCancel.js";import{f as R,h as A}from"./chunks/fetch-graphql.js";import{g as j,r as J,s as K,a as W,b as Z}from"./chunks/fetch-graphql.js";import{g as te}from"./chunks/getAttributesForm.js";import{g as oe,a as ae,r as ne}from"./chunks/requestGuestReturn.js";import{g as ue,a as ce}from"./chunks/getGuestOrder.js";import{g as le}from"./chunks/getCustomerOrdersReturn.js";import{a as D}from"./chunks/initialize.js";import{c as de,g as Te,b as Ee,i as me}from"./chunks/initialize.js";import{g as Re}from"./chunks/getStoreConfig.js";import{h as g}from"./chunks/network-error.js";import{events as d}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as O,PRICE_DETAILS_FRAGMENT as h,GIFT_CARD_DETAILS_FRAGMENT as f,ORDER_ITEM_DETAILS_FRAGMENT as x,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as C,ORDER_SUMMARY_FRAGMENT as b,ADDRESS_FRAGMENT as G}from"./fragments.js";import{a as De,c as ge,r as Oe}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const m=(t,r)=>t+r.amount.value,M=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var o,a,n,s,u,c,i,l;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:(o=e.product)==null?void 0:o.canonicalUrl,mainImageUrl:((a=e.product)==null?void 0:a.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((u=e.product)==null?void 0:u.sku)??"",topLevelSku:(c=e.product)==null?void 0:c.sku},prices:{price:{value:e.price.value,currency:e.price.currency,regularPrice:((i=e.regularPrice)==null?void 0:i.value)??e.price.value}},configurableOptions:((l=e.selectedOptions)==null?void 0:l.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}}),prices:{subtotalExcludingTax:{value:r.subtotalExclTax.value,currency:r.subtotalExclTax.currency},subtotalIncludingTax:{value:r.subtotalInclTax.value,currency:r.subtotalInclTax.currency}},discountAmount:r.discounts.reduce(m,0)}),I=t=>{var o,a,n;const r=t.coupons[0],e=(o=t.payments)==null?void 0:o[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((a=t.shipping)==null?void 0:a.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotalExclTax.value,subtotalIncludingTax:t.subtotalInclTax.value,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value,orderId:t.number}]:[],discountAmount:t.discounts.reduce(m,0),taxAmount:t.totalTax.value}},N=t=>{var e,o;const r=(o=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:o.orderV2;return r?D(r):null},T={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},v={PLACE_ORDER:"place-order"};function _(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function E(t,r){const e=_();e.push({[t]:null}),e.push({[t]:r})}function L(t){_().push(e=>{const o=e.getState?e.getState():{};e.push({event:t,eventInfo:{...o}})})}function y(t,r){const e=I(r),o=M(t,r);E(T.ORDER_CONTEXT,{...e}),E(T.SHOPPING_CART_CONTEXT,{...o}),L(v.PLACE_ORDER)}const S=`
4
4
  mutation PLACE_ORDER_MUTATION($cartId: String!) {
5
5
  placeOrder(input: { cart_id: $cartId }) {
6
6
  errors {
@@ -83,11 +83,11 @@ import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as m,h a
83
83
  }
84
84
  }
85
85
  }
86
- ${D}
87
- ${A}
88
- ${g}
89
86
  ${O}
90
87
  ${h}
91
88
  ${f}
89
+ ${x}
92
90
  ${C}
93
- `,$=async t=>{if(!t)throw new Error("No cart ID found");return m(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,pe as config,Te as confirmCancelOrder,Re as confirmGuestReturn,m as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,me as getStoreConfig,de as guestOrderByToken,le as initialize,$ as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders};
91
+ ${b}
92
+ ${G}
93
+ `,H=async t=>{if(!t)throw new Error("No cart ID found");return R(S,{variables:{cartId:t}}).then(r=>{var o;(o=r.errors)!=null&&o.length&&A(r.errors);const e=N(r);return e&&(d.emit("order/placed",e),d.emit("cart/reset",void 0),y(t,e)),e}).catch(g)};export{V as cancelOrder,de as config,De as confirmCancelOrder,ge as confirmGuestReturn,R as fetchGraphQl,te as getAttributesForm,oe as getAttributesList,j as getConfig,ue as getCustomer,le as getCustomerOrdersReturn,ce as getGuestOrder,Te as getOrderDetailsById,Re as getStoreConfig,Ee as guestOrderByToken,me as initialize,H as placeOrder,J as removeFetchGraphQlHeader,Oe as reorderItems,Y as requestGuestOrderCancel,ae as requestGuestReturn,ne as requestReturn,K as setEndpoint,W as setFetchGraphQlHeader,Z as setFetchGraphQlHeaders};
@@ -18,6 +18,7 @@ type ShoppingCartItem = {
18
18
  product: Product;
19
19
  configurableOptions?: Array<ConfigurableOption>;
20
20
  quantity: number;
21
+ discountAmount?: number;
21
22
  };
22
23
  type Price = {
23
24
  value: number;
@@ -28,6 +29,11 @@ type Product = {
28
29
  productId: number;
29
30
  name: string;
30
31
  sku: string;
32
+ /**
33
+ * For simple, downloadable, and virtual products with no configurable options topLevelSku is the same
34
+ * as the product SKU.
35
+ * For grouped, bundled, and configurable products topLevelSku is the parent product SKU of the associated item.
36
+ */
31
37
  topLevelSku?: string | null;
32
38
  specialToDate?: string | null;
33
39
  specialFromDate?: string | null;
@@ -55,15 +61,16 @@ type Product = {
55
61
  mainImageUrl?: string | null;
56
62
  };
57
63
  type ConfigurableOption = {
58
- id?: number;
64
+ id: number;
59
65
  optionLabel: string;
60
- valueId?: number;
66
+ valueId: number;
61
67
  valueLabel: string;
62
68
  };
63
69
  type Payment = {
64
70
  paymentMethodCode: string;
65
71
  paymentMethodName: string;
66
72
  total: number;
73
+ orderId?: string;
67
74
  };
68
75
  type Shipping = {
69
76
  shippingMethod?: string;
@@ -81,6 +88,7 @@ export type ShoppingCartContext = {
81
88
  giftMessageSelected?: boolean;
82
89
  giftWrappingSelected?: boolean;
83
90
  source?: string;
91
+ discountAmount?: number;
84
92
  };
85
93
  export type OrderContext = {
86
94
  appliedCouponCode: string;
@@ -94,6 +102,8 @@ export type OrderContext = {
94
102
  shipping?: Shipping;
95
103
  subtotalExcludingTax: number;
96
104
  subtotalIncludingTax: number;
105
+ discountAmount?: number;
106
+ taxAmount?: number;
97
107
  };
98
108
  export {};
99
109
  //# sourceMappingURL=acdl.d.ts.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-order", "version": "1.0.0-beta5", "@dropins/elsie": "~0.36.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-order", "version": "1.0.0-beta6", "@dropins/elsie": "~0.36.0", "license": "SEE LICENSE IN LICENSE.md"}