Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
test
/
wp-content
/
plugins
/
woocommerce
/
assets
/
client
/
blocks
/
checkout-blocks
:
shipping-method-frontend.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
"use strict";(self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[]).push([[7413],{1070:(e,t,i)=>{i.d(t,{Z:()=>c});var o=i(5736);const c=({defaultTitle:e=(0,o.__)("Step","woocommerce"),defaultDescription:t=(0,o.__)("Step description text.","woocommerce"),defaultShowStepNumber:i=!0})=>({title:{type:"string",default:e},description:{type:"string",default:t},showStepNumber:{type:"boolean",default:i}})},7477:(e,t,i)=>{i.r(t),i.d(t,{default:()=>V});var o=i(9196),c=i(3849),n=i.n(c),s=i(721),r=i(711),p=i(9818),a=i(4801),l=i(3251),h=i(8752),d=i(5736),m=i(8220),u=i(8174),g=i(2911),_=i(1998),k=i(31),w=i(9307),E=i(7865),v=i(4617),b=i(4293);const f=({minRate:e,maxRate:t,multiple:i=!1})=>{if(void 0===e||void 0===t)return null;const c=(0,v.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),n=(0,v.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(t.price,10)+parseInt(t.taxes,10):parseInt(t.price,10),s=0===c?(0,o.createElement)("em",null,(0,d.__)("free","woocommerce")):(0,o.createElement)(r.FormattedMonetaryAmount,{currency:(0,b.getCurrencyFromPriceResponse)(e),value:c});return(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},c!==n||i?(0,w.createInterpolateElement)(0===c&&0===n?"<price />":(0,d.__)("from <price />","woocommerce"),{price:s}):s)};function x(e){return e?{min:e.reduce(((e,t)=>(0,E.Ep)(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,E.Ep)(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 I(e){return e?{min:e.reduce(((e,t)=>(0,E.Ep)(t.method_id)&&(void 0===e||t.price<e.price)?t:e),void 0),max:e.reduce(((e,t)=>(0,E.Ep)(t.method_id)&&(void 0===e||t.price>e.price)?t:e),void 0)}:{min:void 0,max:void 0}}const S=(0,d.__)("Local Pickup","woocommerce"),T=(0,d.__)("Shipping","woocommerce");i(6483);const C={hidden:!0,message:(0,d.__)("Shipping options are not available","woocommerce")},P=({checked:e,rate:t,showPrice:i,showIcon:c,toggleText:s,multiple:r})=>(0,o.createElement)(m.Z,{value:"pickup",className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===c&&(0,o.createElement)(g.Z,{icon:_.Z,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},s),!0===i&&(0,o.createElement)(f,{multiple:r,minRate:t.min,maxRate:t.max})),y=({checked:e,rate:t,showPrice:i,showIcon:c,toggleText:s,shippingCostRequiresAddress:r=!1})=>{const l=(0,p.useSelect)((e=>e(a.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(E.J3))))),h=r&&(()=>{const e=(0,p.select)("wc/store/validation"),t=e.getValidationError("shipping_state"),i=e.getValidationError("shipping_address_1"),o=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),t,i,o,c].some((e=>void 0!==e))})()&&!l,u=void 0!==t.min&&void 0!==t.max,{setValidationErrors:_,clearValidationError:v}=(0,p.useDispatch)(a.VALIDATION_STORE_KEY);(0,w.useEffect)((()=>{"shipping"!==e||u?v("shipping-rates-error"):_({"shipping-rates-error":C})}),[e,v,u,_]);const b=void 0===t.min||h?(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,d.__)("calculated with an address","woocommerce")):(0,o.createElement)(f,{minRate:t.min,maxRate:t.max});return(0,o.createElement)(m.Z,{value:"shipping",className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===c&&(0,o.createElement)(g.Z,{icon:k.Z,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},s),!0===i&&b)},R=({checked:e,onChange:t,showPrice:i,showIcon:c,localPickupText:n,shippingText:s})=>{var r,p;const{shippingRates:a}=(0,l.V)(),h=(0,v.getSetting)("shippingCostRequiresAddress",!1);return(0,o.createElement)(u.Z,{id:"shipping-method",className:"wc-block-checkout__shipping-method-container",label:"options",onChange:t,checked:e},(0,o.createElement)(y,{checked:e,rate:x(null===(r=a[0])||void 0===r?void 0:r.shipping_rates),showPrice:i,showIcon:c,shippingCostRequiresAddress:h,toggleText:s||T}),(0,o.createElement)(P,{checked:e,rate:I(null===(p=a[0])||void 0===p?void 0:p.shipping_rates),multiple:a.length>1,showPrice:i,showIcon:c,toggleText:n||S}))},N={...(0,i(1070).Z)({defaultTitle:(0,d.__)("Shipping method","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:!0},localPickupText:{type:"string",default:S},shippingText:{type:"string",default:T},lock:{type:"object",default:{move:!0,remove:!0}}},V=(0,s.withFilteredAttributes)(N)((({title:e,description:t,showStepNumber:i,children:c,className:s,showPrice:d,showIcon:m,shippingText:u,localPickupText:g})=>{const{checkoutIsProcessing:_,prefersCollection:k}=(0,p.useSelect)((e=>{const t=e(a.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:t.isProcessing(),prefersCollection:t.prefersCollection()}})),{setPrefersCollection:w}=(0,p.useDispatch)(a.CHECKOUT_STORE_KEY),{shippingRates:E,needsShipping:v,hasCalculatedShipping:b,isCollectable:f}=(0,l.V)();return v&&b&&E&&f&&h.oC?(0,o.createElement)(r.FormStep,{id:"shipping-method",disabled:_,className:n()("wc-block-checkout__shipping-method",s),title:e,description:t,showStepNumber:i},(0,o.createElement)(R,{checked:k?"pickup":"shipping",onChange:e=>{w("pickup"===e)},showPrice:d,showIcon:m,localPickupText:g,shippingText:u}),c):null}))}}]);