1 line
7.0 KiB
JavaScript
1 line
7.0 KiB
JavaScript
(self.webpackChunkwebpackWcBlocksFrontendJsonp=self.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[9319],{4845:(e,t,o)=>{"use strict";o.d(t,{A:()=>l});var i=o(1609),c=o(8165),n=o(6087),r=o(851),s=o(4040),a=o.n(s),p=(o(2080),o(8730));const l=(0,n.forwardRef)(((e,t)=>{"showSpinner"in e&&a()("showSpinner prop",{version:"8.9.0",alternative:"Render a spinner in the button children instead.",plugin:"WooCommerce"});const{className:o,showSpinner:n=!1,children:s,variant:l="contained",removeTextWrap:m=!1,...d}=e,h=(0,r.A)("wc-block-components-button","wp-element-button",o,l,{"wc-block-components-button--loading":n});if("href"in e)return(0,i.createElement)(c.$,{render:(0,i.createElement)("a",{ref:t,href:e.href},n&&(0,i.createElement)(p.A,null),(0,i.createElement)("span",{className:"wc-block-components-button__text"},s)),className:h,...d});const u=m?e.children:(0,i.createElement)("span",{className:"wc-block-components-button__text"},e.children);return(0,i.createElement)(c.$,{ref:t,className:h,...d},n&&(0,i.createElement)(p.A,null),u)}))},9017:(e,t,o)=>{"use strict";o.d(t,{A:()=>c});var i=o(7723);const c=({defaultTitle:e=(0,i.__)("Step","woocommerce"),defaultDescription:t=(0,i.__)("Step description text.","woocommerce"),defaultShowStepNumber:o=!0})=>({title:{type:"string",default:e},description:{type:"string",default:t},showStepNumber:{type:"boolean",default:o}})},5239:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>P});var i=o(1609),c=o(851),n=o(1616),r=o(4656),s=o(7143),a=o(7594),p=o(4958),l=o(812),m=o(9292),d=o(7723),h=o(7104),u=o(3705),g=o(1176),_=o(6087),k=o(8531),w=o(5703),E=o(8529);const v=({minRate:e,maxRate:t,multiple:o=!1})=>{if(void 0===e||void 0===t)return null;const c=(0,w.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),n=(0,w.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(t.price,10)+parseInt(t.taxes,10):parseInt(t.price,10),s=0===c?(0,i.createElement)("em",null,(0,d.__)("free","woocommerce")):(0,i.createElement)(r.FormattedMonetaryAmount,{currency:(0,E.getCurrencyFromPriceResponse)(e),value:c});return(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},c!==n||o?(0,_.createInterpolateElement)(0===c&&0===n?"<price />":(0,d.__)("from <price />","woocommerce"),{price:s}):s)};function b(e){return e?{min:e.reduce(((e,t)=>(0,k.jV)(t.method_id)?e:void 0===e||parseInt(t.price,10)<parseInt(e.price,10)?t:e),void 0),max:e.reduce(((e,t)=>(0,k.jV)(t.method_id)?e:void 0===e||parseInt(t.price,10)>parseInt(e.price,10)?t:e),void 0)}:{min:void 0,max:void 0}}function f(e){return e?{min:e.reduce(((e,t)=>(0,k.jV)(t.method_id)&&(void 0===e||t.price<e.price)?t:e),void 0),max:e.reduce(((e,t)=>(0,k.jV)(t.method_id)&&(void 0===e||t.price>e.price)?t:e),void 0)}:{min:void 0,max:void 0}}const x=(0,d.__)("Pickup","woocommerce"),C=(0,d.__)("Ship","woocommerce");o(3832);var T=o(4845);const S={hidden:!0,message:(0,d.__)("Shipping options are not available","woocommerce")},I=({checked:e,rate:t,showPrice:o,showIcon:n,toggleText:r,multiple:s,onClick:a})=>(0,i.createElement)(T.A,{role:"radio",removeTextWrap:!0,onClick:a,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===n&&(0,i.createElement)(h.A,{icon:u.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},r),!0===o&&(0,i.createElement)(v,{multiple:s,minRate:t.min,maxRate:t.max})),A=({checked:e,rate:t,showPrice:o,showIcon:n,toggleText:r,onClick:p,shippingCostRequiresAddress:l=!1})=>{const m=(0,s.useSelect)((e=>e(a.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(k.J_))))),u=l&&(()=>{const e=(0,s.select)("wc/store/validation"),t=e.getValidationError("shipping_state"),o=e.getValidationError("shipping_address_1"),i=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),t,o,i,c].some((e=>void 0!==e))})()&&!m,w=void 0!==t.min&&void 0!==t.max,{setValidationErrors:E,clearValidationError:b}=(0,s.useDispatch)(a.VALIDATION_STORE_KEY);(0,_.useEffect)((()=>{"shipping"!==e||w?b("shipping-rates-error"):E({"shipping-rates-error":S})}),[e,b,w,E]);const f=void 0===t.min||u?(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,d.__)("calculated with an address","woocommerce")):(0,i.createElement)(v,{minRate:t.min,maxRate:t.max});return(0,i.createElement)(T.A,{role:"radio",onClick:p,removeTextWrap:!0,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===n&&(0,i.createElement)(h.A,{icon:g.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},r),!0===o&&f)},N=({checked:e,onChange:t,showPrice:o,showIcon:c,localPickupText:n,shippingText:r})=>{var s,a;const{shippingRates:l}=(0,p.m)(),m=(0,w.getSetting)("shippingCostRequiresAddress",!1),d=(0,w.getSetting)("localPickupText",n||x);return(0,i.createElement)("div",{id:"shipping-method",className:"components-button-group wc-block-checkout__shipping-method-container",role:"radiogroup"},(0,i.createElement)(A,{checked:e,onClick:()=>{t("shipping")},rate:b(null===(s=l[0])||void 0===s?void 0:s.shipping_rates),showPrice:o,showIcon:c,shippingCostRequiresAddress:m,toggleText:r||C}),(0,i.createElement)(I,{checked:e,onClick:()=>{t("pickup")},rate:f(null===(a=l[0])||void 0===a?void 0:a.shipping_rates),multiple:l.length>1,showPrice:o,showIcon:c,toggleText:d}))},y={...(0,o(9017).A)({defaultTitle:(0,d.__)("Delivery","woocommerce"),defaultDescription:(0,d.__)("Select how you would like to receive your order.","woocommerce")}),className:{type:"string",default:""},showIcon:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!1},localPickupText:{type:"string",default:x},shippingText:{type:"string",default:C},lock:{type:"object",default:{move:!0,remove:!0}}},P=(0,n.withFilteredAttributes)(y)((({title:e,description:t,children:o,className:n,showPrice:d,showIcon:h,shippingText:u,localPickupText:g})=>{const{showFormStepNumbers:_}=(0,m.Oy)(),{checkoutIsProcessing:k,prefersCollection:w}=(0,s.useSelect)((e=>{const t=e(a.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:t.isProcessing(),prefersCollection:t.prefersCollection()}})),{setPrefersCollection:E}=(0,s.useDispatch)(a.CHECKOUT_STORE_KEY),{shippingRates:v,needsShipping:b,hasCalculatedShipping:f,isCollectable:x}=(0,p.m)();return b&&f&&v&&x&&l.F7?(0,i.createElement)(r.FormStep,{id:"shipping-method",disabled:k,className:(0,c.A)("wc-block-checkout__shipping-method",n),title:e,description:t,showStepNumber:_},(0,i.createElement)(N,{checked:w?"pickup":"shipping",onChange:e=>{E("pickup"===e)},showPrice:d,showIcon:h,localPickupText:g,shippingText:u}),o):null}))},8730:(e,t,o)=>{"use strict";o.d(t,{A:()=>c});var i=o(1609);o(7791);const c=()=>(0,i.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},2080:()=>{},7791:()=>{}}]); |