3 lines
12 KiB
JavaScript
3 lines
12 KiB
JavaScript
|
(self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[]).push([[8771],{4113:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Block:()=>y,default:()=>g});var o=r(9196),s=r(4184),n=r.n(s),c=r(5736),a=r(5918),i=r(3775),l=r(3611),d=r(2629),u=r(5271),p=r(4617),_=r(2864),m=r(721);r(1464);const b=({product:t,className:e,style:r})=>{const{id:s,permalink:l,add_to_cart:_,has_options:m,is_purchasable:b,is_in_stock:v}=t,{dispatchStoreEvent:y}=(0,a.n)(),{cartQuantity:g,addingToCart:C,addToCart:E}=(0,i.c)(s),h=Number.isFinite(g)&&g>0,f=!m&&b&&v,w=(0,d.decodeEntities)((null==_?void 0:_.description)||""),S=h?(0,c.sprintf)(/* translators: %s number of products in cart. */
|
||
|
(0,c._n)("%d in cart","%d in cart",g,"woocommerce"),g):(0,d.decodeEntities)((null==_?void 0:_.text)||(0,c.__)("Add to cart","woocommerce")),k=f?"button":"a",T={};return f?T.onClick=async()=>{await E(),y("cart-add-item",{product:t});const{cartRedirectAfterAdd:e}=(0,p.getSetting)("productsSettings");e&&(window.location.href=u.fh)}:(T.href=l,T.rel="nofollow",T.onClick=()=>{y("product-view-link",{product:t})}),(0,o.createElement)(k,{...T,"aria-label":w,disabled:C,className:n()(e,"wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",{loading:C,added:h}),style:r},S)},v=({className:t,style:e})=>(0,o.createElement)("button",{className:n()("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder",t),style:e,disabled:!0}),y=t=>{const{className:e,textAlign:r}=t,s=(0,l.F)(t),{parentClassName:c}=(0,_.useInnerBlockLayoutContext)(),{product:a}=(0,_.useProductDataContext)();return(0,o.createElement)("div",{className:n()(e,"wp-block-button","wc-block-components-product-button",{[`${c}__product-add-to-cart`]:c,[`align-${r}`]:r})},a.id?(0,o.createElement)(b,{product:a,style:s.style,className:s.className}):(0,o.createElement)(v,{style:s.style,className:s.className}))},g=(0,m.withProductDataContext)(y)},3340:(t,e,r)=>{"use strict";r.d(e,{Z:()=>d});var o=r(4617),s=r(5736),n=r(1478),c=r(2646),a=r(5271);const i=t=>{const e={};return void 0!==t.label&&(e.label=t.label),void 0!==t.required&&(e.required=t.required),void 0!==t.hidden&&(e.hidden=t.hidden),void 0===t.label||t.optionalLabel||(e.optionalLabel=(0,s.sprintf)(/* translators: %s Field label. */
|
||
|
(0,s.__)("%s (optional)","woocommerce"),t.label)),t.priority&&((0,n.h)(t.priority)&&(e.index=t.priority),(0,c.H)(t.priority)&&(e.index=parseInt(t.priority,10))),t.hidden&&(e.required=!1),e},l=Object.entries(a.vr).map((([t,e])=>[t,Object.entries(e).map((([t,e])=>[t,i(e)])).reduce(((t,[e,r])=>(t[e]=r,t)),{})])).reduce(((t,[e,r])=>(t[e]=r,t)),{}),d=(t,e,r="")=>{const s=r&&void 0!==l[r]?l[r]:{};return t.map((t=>({key:t,...o.defaultAddressFields[t]||{},...s[t]||{},...e[t]||{}}))).sort(((t,e)=>t.index-e.index))}},6286:(t,e,r)=>{"use strict";r.d(e,{O:()=>u});var o=r(9307),s=r(4801),n=r(9818),c=r(1377),a=r(9456);const i=t=>{const e=null==t?void 0:t.detail;e&&e.preserveCartData||(0,n.dispatch)(s.CART_STORE_KEY).invalidateResolutionForStore()},l=t=>{(null!=t&&t.persisted||"back_forward"===(0,c.f)())&&(0,n.dispatch)(s.CART_STORE_KEY).invalidateResolutionForStore()},d=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},u=()=>{(0,o.useEffect)((()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),(null===(t=window.wcBlocksStoreCartListeners)||void 0===t?void 0:t.count)>0)return void window.wcBlocksStoreCartListeners.count++;var t;document.body.addEventListener("wc-blocks_added_to_cart",i),document.body.addEventListener("wc-blocks_removed_from_cart",i),window.addEventListener("pageshow",l);const e=(0,a.Es)("added_to_cart","wc-blocks_added_to_cart"),r=(0,a.Es)("removed_from_cart","wc-blocks_removed_from_cart");window.wcBlocksStoreCartListeners.count=1,window.wcBlocksStoreCartListeners.remove=()=>{document.body.removeEventListener("wc-blocks_added_to_cart",i),document.body.removeEventListener("wc-blocks_removed_from_cart",i),window.removeEventListener("pageshow",l),e(),r()}})(),d)),[])}},9816:(t,e,r)=>{"use strict";r.d(e,{b:()=>y});var o=r(2991),s=r.n(o),n=r(9307),c=r(4801),a=r(9818),i=r(2629),l=r(3881),d=r(8832),u=r(6286);const p={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},_={...p,email:""},m={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:c.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},b=t=>Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(0,i.decodeEntities)(e)]))),v={cartCoupons:c.EMPTY_CART_COUPONS,cartItems:c.EMPTY_CART_ITEMS,cartFees:c.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:c.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:m,cartIsLoading:!0,cartErrors:c.EMPTY_CART_ERRORS,billingAddress:_,shippingAddress:p,shippingRates:c.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentMethods:c.EMPTY_PAYMENT_METHODS,paymentRequirements:c.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},receiveCartContents:()=>{},extensions:c.EMPTY_EXTENSIONS},y=(t={shouldSelect:!0})=>{const{isEditor:e,previewData:r}=(0,d._)(),o=null==r?void 0:r.previewCart,{shouldSelect:i}=t,m=(0,n.useRef)();(0,u.O)();const y=(0,a.useSelect)(((t,{dispatch:r})=>{if(!i)return v;if(e)return{cartCoupons:o.coupons,cartItems:o.items,crossSellsProducts:o.cross_sells,cartFees:o.fees,cartItemsCount:o.items_count,cartItemsWeight:o.items_weight,cartNeedsPayment:o.needs_payment,cartNeedsShipping:o.needs_shipping,cartItemErrors:c.EMPTY_CART_ITEM_ERRORS,cartTotals:o.totals,cartIsLoading:!1,cartErrors:c.EMPTY_CART_ERRORS,billingData:_,billingAddress:_,shippingAddress:p,extensions:c.EMPTY_EXTENSIONS,shippingRates:o.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:o.has_calculated_shipping,paymentRequirements:o.paymentRequirements,receiveCart:"function"==typeof(null==o?void 0:o.receiveCart)?o.receiveCart:()=>{},receiveCartContents:"function"==typeof(null==o?void 0:o.receiveCartContents)?o.recei
|