@dropins/storefront-order 1.2.0 → 1.3.0-beta1
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 +10 -10
- package/chunks/CartSummaryItem.js +1 -1
- package/chunks/fetch-graphql.js +1 -1
- package/lib/acdl.d.ts +2 -0
- package/lib/setReCaptchaToken.d.ts +18 -0
- package/package.json +1 -1
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{c as
|
|
3
|
+
import{c as ce,r as ie}from"./chunks/requestGuestOrderCancel.js";import{s as f,f as m,h as T}from"./chunks/fetch-graphql.js";import{g as de,r as le,a as pe,b as Ee}from"./chunks/fetch-graphql.js";import{g as me}from"./chunks/getAttributesForm.js";import{g as Re,a as Ae,r as he}from"./chunks/requestGuestReturn.js";import{g as Oe,a as Ce}from"./chunks/getGuestOrder.js";import{g as fe}from"./chunks/getCustomerOrdersReturn.js";import{a as M}from"./chunks/initialize.js";import{c as Ne,g as Ge,d as xe,i as ye}from"./chunks/initialize.js";import{g as Fe}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as d}from"@dropins/tools/event-bus.js";import{ADDRESS_FRAGMENT as N,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as G,GIFT_CARD_DETAILS_FRAGMENT as x,ORDER_ITEM_DETAILS_FRAGMENT as y,ORDER_SUMMARY_FRAGMENT as b,PRICE_DETAILS_FRAGMENT as F,PRODUCT_DETAILS_FRAGMENT as P,ORDER_ITEM_FRAGMENT as I,GIFT_WRAPPING_FRAGMENT as L,GIFT_MESSAGE_FRAGMENT as S,APPLIED_GIFT_CARDS_FRAGMENT as v}from"./fragments.js";import{verifyReCaptcha as $}from"@dropins/tools/recaptcha.js";import{c as Ie,a as Le,r as Se}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const A=(t,r)=>t+r.amount.value,w=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,c,i,u,E;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:((c=e.product)==null?void 0:c.sku)??"",topLevelSku:(i=e.product)==null?void 0:i.sku},prices:{price:{value:e.price.value,currency:e.price.currency,regularPrice:((u=e.regularPrice)==null?void 0:u.value)??e.price.value}},configurableOptions:((E=e.selectedOptions)==null?void 0:E.map(_=>({optionLabel:_.label,valueLabel:_.value})))||[]}}),prices:{subtotalExcludingTax:{value:r.subtotalExclTax.value,currency:r.subtotalExclTax.currency},subtotalIncludingTax:{value:r.subtotalInclTax.value,currency:r.subtotalInclTax.currency}},discountAmount:r.discounts.reduce(A,0)}),k=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: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(A,0),taxAmount:t.totalTax.value}},h=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?M(r):null},l={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext",CHANNEL_CONTEXT:"channelContext"},U={PLACE_ORDER:"place-order"};function g(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function p(t,r){const e=g();e.push({[t]:null}),e.push({[t]:r})}function H(t){g().push(e=>{const a=e.getState?e.getState():{};e.push({event:t,eventInfo:{...a}})})}function Q(){return{_id:"https://ns.adobe.com/xdm/channels/web",_type:"https://ns.adobe.com/xdm/channel-types/web"}}function X(){p(l.CHANNEL_CONTEXT,Q())}function O(t,r){const e=k(r),a=w(t,r);p(l.ORDER_CONTEXT,{...e}),p(l.SHOPPING_CART_CONTEXT,{...a}),X(),H(U.PLACE_ORDER)}class q extends Error{constructor(r){super(r),this.name="PlaceOrderError"}}const C=t=>{const r=t.map(e=>e.message).join(" ");throw new q(r)},D=`
|
|
4
4
|
fragment PLACE_ORDER_FRAGMENT on CustomerOrder {
|
|
5
5
|
printed_card_included
|
|
6
6
|
gift_receipt_included
|
|
@@ -71,18 +71,18 @@ import{c as re,r as te}from"./chunks/requestGuestOrderCancel.js";import{f as m,h
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
${G}
|
|
75
|
-
${C}
|
|
76
74
|
${N}
|
|
75
|
+
${G}
|
|
77
76
|
${x}
|
|
78
77
|
${y}
|
|
78
|
+
${b}
|
|
79
79
|
${F}
|
|
80
|
-
${I}
|
|
81
80
|
${P}
|
|
82
|
-
${
|
|
81
|
+
${I}
|
|
82
|
+
${L}
|
|
83
83
|
${S}
|
|
84
84
|
${v}
|
|
85
|
-
`,
|
|
85
|
+
`,B=`
|
|
86
86
|
mutation PLACE_ORDER_MUTATION($cartId: String!) {
|
|
87
87
|
placeOrder(input: { cart_id: $cartId }) {
|
|
88
88
|
errors {
|
|
@@ -95,8 +95,8 @@ import{c as re,r as te}from"./chunks/requestGuestOrderCancel.js";import{f as m,h
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
${
|
|
99
|
-
`,
|
|
98
|
+
${D}
|
|
99
|
+
`,V=async()=>{const t=await $();t&&f("X-ReCaptcha",t)},ae=async t=>{if(!t)throw new Error("No cart ID found");return await V(),m(B,{method:"POST",variables:{cartId:t}}).then(r=>{var a,o,n,s,c;(a=r.errors)!=null&&a.length&&T(r.errors),(s=(n=(o=r.data)==null?void 0:o.placeOrder)==null?void 0:n.errors)!=null&&s.length&&C((c=r.data.placeOrder)==null?void 0:c.errors);const e=h(r);return e&&(d.emit("order/placed",e),d.emit("cart/reset",void 0),O(t,e)),e}).catch(R)},Y=`
|
|
100
100
|
mutation setPaymentMethodAndPlaceOrder($cartId: String!, $paymentMethod: PaymentMethodInput!) {
|
|
101
101
|
setPaymentMethodOnCart(
|
|
102
102
|
input: {
|
|
@@ -122,5 +122,5 @@ import{c as re,r as te}from"./chunks/requestGuestOrderCancel.js";import{f as m,h
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
${
|
|
126
|
-
`,
|
|
125
|
+
${D}
|
|
126
|
+
`,oe=async(t,r)=>{if(!t)throw new Error("No cart ID found");if(!r)throw new Error("No payment method found");return m(Y,{variables:{cartId:t,paymentMethod:r}}).then(e=>{var o,n,s,c,i,u;(o=e.errors)!=null&&o.length&&T(e.errors),(c=(s=(n=e.data)==null?void 0:n.placeOrder)==null?void 0:s.errors)!=null&&c.length&&C((i=e.data.placeOrder)==null?void 0:i.errors);const a=h({data:{placeOrder:(u=e.data)==null?void 0:u.placeOrder}});return a&&(d.emit("order/placed",a),d.emit("cart/reset",void 0),O(t,a)),a}).catch(R)};export{ce as cancelOrder,Ne as config,Ie as confirmCancelOrder,Le as confirmGuestReturn,m as fetchGraphQl,me as getAttributesForm,Re as getAttributesList,de as getConfig,Oe as getCustomer,fe as getCustomerOrdersReturn,Ce as getGuestOrder,Ge as getOrderDetailsById,Fe as getStoreConfig,xe as guestOrderByToken,ye as initialize,ae as placeOrder,le as removeFetchGraphQlHeader,Se as reorderItems,ie as requestGuestOrderCancel,Ae as requestGuestReturn,he as requestReturn,pe as setEndpoint,f as setFetchGraphQlHeader,Ee as setFetchGraphQlHeaders,oe as setPaymentMethodAndPlaceOrder};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as i,jsxs as b,Fragment as
|
|
3
|
+
import{jsx as i,jsxs as b,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{Price as A,Image as B,CartItem as K,Icon as Q,Incrementer as R}from"@dropins/tools/components.js";import{useCallback as F}from"@dropins/tools/preact-hooks.js";import{Slot as H}from"@dropins/tools/lib.js";import{O as G}from"./OrderLoaders.js";import*as w from"@dropins/tools/preact-compat.js";const J=l=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},w.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),w.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),ee=({slots:l,placeholderImage:S="",loading:M,product:e,itemType:Z,taxConfig:$,translations:x,disabledIncrementer:j,onQuantity:P,showConfigurableOptions:E,routeProductDetails:I})=>{var O,D,f,L,V;const{taxExcluded:d,taxIncluded:k}=$,t=F((n,c,s)=>i(A,{amount:n,currency:c,weight:"normal",...s}),[]),T=F(n=>{var o,_;const c=(n==null?void 0:n.productName)??"",s={title:c,src:((_=(o=n==null?void 0:n.product)==null?void 0:o.thumbnail)==null?void 0:_.url)??S,alt:c,width:90,height:120,loading:"lazy"};return i(H,{slotTag:"span",contentTag:"span","data-testid":`cartSummaryItemImage-${n.id}`,name:"CartSummaryItemImage",slot:l==null?void 0:l.CartSummaryItemImage,context:{data:n,defaultImageProps:s},children:i(B,{...s})})},[S,l==null?void 0:l.CartSummaryItemImage]);if(!e)return i(G,{});let u={};const q=Z==="cancelled",W=(D=(O=e==null?void 0:e.product)==null?void 0:O.stockStatus)==null?void 0:D.includes("IN_STOCK"),a=e==null?void 0:e.giftCard,z=e.totalQuantity>1?{quantity:e.totalQuantity}:{},y=e.discounted,{includeAndExcludeTax:r,includeTax:h,excludeTax:m}=e.taxCalculations,g=e==null?void 0:e.totalQuantity,N={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...a!=null&&a.senderName?{[x.sender]:a==null?void 0:a.senderName}:{},...a!=null&&a.senderEmail?{[x.sender]:a==null?void 0:a.senderEmail}:{},...a!=null&&a.senderName?{[x.sender]:a==null?void 0:a.senderName}:{},...a!=null&&a.recipientEmail?{[x.recipient]:a==null?void 0:a.recipientEmail}:{},...a!=null&&a.message?{[x.message]:a==null?void 0:a.message}:{},...e!=null&&e.downloadableLinks?{[`${(f=e==null?void 0:e.downloadableLinks)==null?void 0:f.count} ${x.downloadableCount}`]:(L=e==null?void 0:e.downloadableLinks)==null?void 0:L.result}:{}};if(k&&d){const n=t(r.originalPrice.value,r.originalPrice.currency),c=t(r.baseOriginalPrice.value*g,r.baseOriginalPrice.currency,{variant:e.discounted?"strikethrough":"default",weight:"bold"}),s=t(r.baseDiscountedPrice.value*g,r.baseDiscountedPrice.currency,{sale:!0,weight:"bold"}),o=t(r.baseExcludingTax.value*g,r.baseExcludingTax.currency,{weight:"bold"});u={taxExcluded:!0,taxIncluded:void 0,price:n,total:b(v,{children:[c,e.discounted?s:null]}),totalExcludingTax:o}}else if(!k&&d){const n=t(m.originalPrice.value,m.originalPrice.currency),c=t(m.baseOriginalPrice.value*g,m.baseOriginalPrice.currency,{variant:y?"strikethrough":"default",weight:"bold"}),s=t(m.baseDiscountedPrice.value*g,m.baseDiscountedPrice.currency,{sale:!0,weight:"bold"}),o=t(m.baseExcludingTax.value*g,m.baseExcludingTax.currency,{weight:"bold"});u={taxExcluded:void 0,taxIncluded:void 0,price:n,total:b(v,{children:[c,y?s:null]}),totalExcludingTax:o}}else if(k&&!d){const n=t(h.singleItemPrice.value,h.singleItemPrice.currency),c=t(h.baseOriginalPrice.value*g,h.baseOriginalPrice.currency,{variant:y?"strikethrough":"default",weight:"bold"}),s=t(h.baseDiscountedPrice.value*g,h.baseDiscountedPrice.currency,{sale:!0,weight:"bold"});u={taxExcluded:void 0,taxIncluded:!0,price:n,total:b(v,{children:[c,y?s:null]})}}return i(K,{loading:M,alert:q&&!W?b("span",{children:[i(Q,{source:J}),x.outOfStock]}):i(v,{}),configurations:(E==null?void 0:E(N))??N,title:I?i("a",{"data-testid":"product-name",className:"cart-summary-item__title",href:I(e),children:e==null?void 0:e.productName}):i("div",{"data-testid":"product-name",className:"cart-summary-item__title",children:e==null?void 0:e.productName}),sku:i("div",{children:(V=e==null?void 0:e.product)==null?void 0:V.sku}),...z,image:I?i("a",{href:I(e),children:T(e)}):T(e),...u,footer:b(v,{children:[P&&!j?i(R,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:n=>P==null?void 0:P(Number(n)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0,i(H,{"data-testid":"Footer",name:"Footer",slot:l==null?void 0:l.Footer,context:{item:e}})]})})};export{ee as C,J as S};
|
package/chunks/fetch-graphql.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{FetchGraphQL as s}from"@dropins/tools/fetch-graphql.js";const h=e=>{const r=e.map(a=>a.message).join(" ");throw Error(r)},{setEndpoint:o,setFetchGraphQlHeader:c,removeFetchGraphQlHeader:n,setFetchGraphQlHeaders:p,fetchGraphQl:d,getConfig:g}=new s().getMethods();export{
|
|
3
|
+
import{FetchGraphQL as s}from"@dropins/tools/fetch-graphql.js";const h=e=>{const r=e.map(a=>a.message).join(" ");throw Error(r)},{setEndpoint:o,setFetchGraphQlHeader:c,removeFetchGraphQlHeader:n,setFetchGraphQlHeaders:p,fetchGraphQl:d,getConfig:g}=new s().getMethods();export{o as a,p as b,d as f,g,h,n as r,c as s};
|
package/lib/acdl.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { OrderDataModel } from '../data/models';
|
|
|
6
6
|
export declare const contexts: {
|
|
7
7
|
SHOPPING_CART_CONTEXT: string;
|
|
8
8
|
ORDER_CONTEXT: string;
|
|
9
|
+
CHANNEL_CONTEXT: string;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/events.ts
|
|
@@ -14,5 +15,6 @@ export declare const events: {
|
|
|
14
15
|
PLACE_ORDER: string;
|
|
15
16
|
};
|
|
16
17
|
export declare function getAdobeDataLayer(): any;
|
|
18
|
+
export declare function setChannelContext(): void;
|
|
17
19
|
export declare function publishPlaceOrderEvent(cartId: string, data: OrderDataModel): void;
|
|
18
20
|
//# sourceMappingURL=acdl.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const setReCaptchaToken: () => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=setReCaptchaToken.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-order", "version": "1.
|
|
1
|
+
{"name": "@dropins/storefront-order", "version": "1.3.0-beta1", "@dropins/tools": "~1.2.0", "license": "SEE LICENSE IN LICENSE.md"}
|