Files
medicalalert-web-reloaded/wp/wp-content/plugins/woocommerce/assets/client/blocks/checkout-blocks/shipping-method-frontend.js
2024-09-05 11:04:01 -04:00

1 line
5.6 KiB
JavaScript

"use strict";(self.webpackChunkwebpackWcBlocksCartCheckoutFrontendJsonp=self.webpackChunkwebpackWcBlocksCartCheckoutFrontendJsonp||[]).push([[9319],{9017:(e,t,o)=>{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}})},3979:(e,t,o)=>{o.r(t),o.d(t,{default:()=>R});var i=o(1609),c=o(851),n=o(1616),r=o(4656),s=o(7143),p=o(7594),a=o(4958),l=o(812),m=o(9292),h=o(7723),d=o(7104),u=o(3705),g=o(1176),k=o(6087),_=o(8531),w=o(5703),v=o(910);const C=({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,h.__)("free","woocommerce")):(0,i.createElement)(r.FormattedMonetaryAmount,{currency:(0,v.getCurrencyFromPriceResponse)(e),value:c});return(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},c!==n||o?(0,k.createInterpolateElement)(0===c&&0===n?"<price />":(0,h.__)("from <price />","woocommerce"),{price:s}):s)};function E(e){return e?{min:e.reduce(((e,t)=>(0,_.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,_.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 x(e){return e?{min:e.reduce(((e,t)=>(0,_.jV)(t.method_id)&&(void 0===e||t.price<e.price)?t:e),void 0),max:e.reduce(((e,t)=>(0,_.jV)(t.method_id)&&(void 0===e||t.price>e.price)?t:e),void 0)}:{min:void 0,max:void 0}}const b=(0,h.__)("Pickup","woocommerce"),f=(0,h.__)("Ship","woocommerce");var T=o(5082),I=o(4845);const S={hidden:!0,message:(0,h.__)("Shipping options are not available","woocommerce")},P=({checked:e,rate:t,showPrice:o,showIcon:n,toggleText:r,multiple:s,onClick:p})=>(0,i.createElement)(I.A,{role:"radio",removeTextWrap:!0,onClick:p,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===n&&(0,i.createElement)(d.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)(C,{multiple:s,minRate:t.min,maxRate:t.max})),y=({checked:e,rate:t,showPrice:o,showIcon:n,toggleText:r,onClick:a,shippingCostRequiresAddress:l=!1})=>{const m=(0,s.useSelect)((e=>e(p.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(_.J_))))),u=l&&(0,T.ND)()&&!m,w=void 0!==t.min&&void 0!==t.max,{setValidationErrors:v,clearValidationError:E}=(0,s.useDispatch)(p.VALIDATION_STORE_KEY);(0,k.useEffect)((()=>{"shipping"!==e||w?E("shipping-rates-error"):v({"shipping-rates-error":S})}),[e,E,w,v]);const x=void 0===t.min||u?(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,h.__)("calculated with an address","woocommerce")):(0,i.createElement)(C,{minRate:t.min,maxRate:t.max});return(0,i.createElement)(I.A,{role:"radio",onClick:a,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)(d.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&&x)},A=({checked:e,onChange:t,showPrice:o,showIcon:c,localPickupText:n,shippingText:r})=>{var s,p;const{shippingRates:l}=(0,a.m)(),m=(0,w.getSetting)("shippingCostRequiresAddress",!1),h=(0,w.getSetting)("localPickupText",n||b);return(0,i.createElement)("div",{id:"shipping-method",className:"components-button-group wc-block-checkout__shipping-method-container",role:"radiogroup"},(0,i.createElement)(y,{checked:e,onClick:()=>{t("shipping")},rate:E(null===(s=l[0])||void 0===s?void 0:s.shipping_rates),showPrice:o,showIcon:c,shippingCostRequiresAddress:m,toggleText:r||f}),(0,i.createElement)(P,{checked:e,onClick:()=>{t("pickup")},rate:x(null===(p=l[0])||void 0===p?void 0:p.shipping_rates),multiple:l.length>1,showPrice:o,showIcon:c,toggleText:h}))},N={...(0,o(9017).A)({defaultTitle:(0,h.__)("Delivery","woocommerce"),defaultDescription:(0,h.__)("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:b},shippingText:{type:"string",default:f},lock:{type:"object",default:{move:!0,remove:!0}}},R=(0,n.withFilteredAttributes)(N)((({title:e,description:t,children:o,className:n,showPrice:h,showIcon:d,shippingText:u,localPickupText:g})=>{const{showFormStepNumbers:k}=(0,m.Oy)(),{checkoutIsProcessing:_,prefersCollection:w}=(0,s.useSelect)((e=>{const t=e(p.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:t.isProcessing(),prefersCollection:t.prefersCollection()}})),{setPrefersCollection:v}=(0,s.useDispatch)(p.CHECKOUT_STORE_KEY),{shippingRates:C,needsShipping:E,hasCalculatedShipping:x,isCollectable:b}=(0,a.m)();return E&&x&&C&&b&&l.F7?(0,i.createElement)(r.FormStep,{id:"shipping-method",disabled:_,className:(0,c.A)("wc-block-checkout__shipping-method",n),title:e,description:t,showStepNumber:k},(0,i.createElement)(A,{checked:w?"pickup":"shipping",onChange:e=>{v("pickup"===e)},showPrice:h,showIcon:d,localPickupText:g,shippingText:u}),o):null}))}}]);