1 line
No EOL
4 KiB
JavaScript
1 line
No EOL
4 KiB
JavaScript
"use strict";(self.webpackChunkwebpackWcBlocksStylingJsonp=self.webpackChunkwebpackWcBlocksStylingJsonp||[]).push([[9319],{84025:(e,i,t)=>{t.r(i),t.d(i,{default:()=>R});var o=t(51609),c=t(70851),s=t(41616),n=t(14656),p=t(47143),r=t(47594),l=t(14958),a=t(40812),h=t(99292),d=t(27723),g=t(7104),m=t(63705),u=t(11176),k=t(86087),_=t(18531),w=t(15703),E=t(78165),C=t(56713),b=t(18144),T=t(89854);t(93832);const v={hidden:!0,message:(0,d.__)("Shipping options are not available","woocommerce")},x=({checked:e,rate:i,showPrice:t,showIcon:s,toggleText:n,multiple:p,onClick:r})=>(0,o.createElement)(E.$,{render:(0,o.createElement)("div",null),role:"radio",onClick:r,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===s&&(0,o.createElement)(g.A,{icon:m.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},n),!0===t&&(0,o.createElement)(C.e,{multiple:p,minRate:i.min,maxRate:i.max})),S=({checked:e,rate:i,showPrice:t,showIcon:s,toggleText:n,onClick:l,shippingCostRequiresAddress:a=!1})=>{const h=(0,p.useSelect)((e=>e(r.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(_.J_))))),m=a&&(()=>{const e=(0,p.select)("wc/store/validation"),i=e.getValidationError("shipping_state"),t=e.getValidationError("shipping_address_1"),o=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),i,t,o,c].some((e=>void 0!==e))})()&&!h,w=void 0!==i.min&&void 0!==i.max,{setValidationErrors:b,clearValidationError:T}=(0,p.useDispatch)(r.VALIDATION_STORE_KEY);(0,k.useEffect)((()=>{"shipping"!==e||w?T("shipping-rates-error"):b({"shipping-rates-error":v})}),[e,T,w,b]);const x=void 0===i.min||m?(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,d.__)("calculated with an address","woocommerce")):(0,o.createElement)(C.e,{minRate:i.min,maxRate:i.max});return(0,o.createElement)(E.$,{render:(0,o.createElement)("div",null),role:"radio",onClick:l,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===s&&(0,o.createElement)(g.A,{icon:u.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},n),!0===t&&x)},A=({checked:e,onChange:i,showPrice:t,showIcon:c,localPickupText:s,shippingText:n})=>{var p,r;const{shippingRates:a}=(0,l.m)(),h=(0,w.getSetting)("shippingCostRequiresAddress",!1),d=(0,w.getSetting)("localPickupText",s||T.A);return(0,o.createElement)("div",{id:"shipping-method",className:"components-button-group wc-block-checkout__shipping-method-container",role:"radiogroup"},(0,o.createElement)(S,{checked:e,onClick:()=>{i("shipping")},rate:(0,b.L)(null===(p=a[0])||void 0===p?void 0:p.shipping_rates),showPrice:t,showIcon:c,shippingCostRequiresAddress:h,toggleText:n||T.x}),(0,o.createElement)(x,{checked:e,onClick:()=>{i("pickup")},rate:(0,b._)(null===(r=a[0])||void 0===r?void 0:r.shipping_rates),multiple:a.length>1,showPrice:t,showIcon:c,toggleText:d}))};var P=t(3530);const R=(0,s.withFilteredAttributes)(P.A)((({title:e,description:i,children:t,className:s,showPrice:d,showIcon:g,shippingText:m,localPickupText:u})=>{const{showFormStepNumbers:k}=(0,h.Oy)(),{checkoutIsProcessing:_,prefersCollection:w}=(0,p.useSelect)((e=>{const i=e(r.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:i.isProcessing(),prefersCollection:i.prefersCollection()}})),{setPrefersCollection:E}=(0,p.useDispatch)(r.CHECKOUT_STORE_KEY),{shippingRates:C,needsShipping:b,hasCalculatedShipping:T,isCollectable:v}=(0,l.m)();return b&&T&&C&&v&&a.F7?(0,o.createElement)(n.FormStep,{id:"shipping-method",disabled:_,className:(0,c.A)("wc-block-checkout__shipping-method",s),title:e,description:i,showStepNumber:k},(0,o.createElement)(A,{checked:w?"pickup":"shipping",onChange:e=>{E("pickup"===e)},showPrice:d,showIcon:g,localPickupText:u,shippingText:m}),t):null}))}}]); |