← Back
Editing: settings-payments-cheque.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6620],{60431:(e,t,s)=>{s.d(t,{W:()=>n});var o=s(56427),i=s(39793);const n=({size:e="medium"})=>(0,i.jsx)("div",{className:`woocommerce-field-placeholder woocommerce-field-placeholder--${e}`,children:(0,i.jsx)(o.Placeholder,{})})},224:(e,t,s)=>{s.d(t,{w:()=>a});var o=s(56427),i=s(51609),n=s(39793);const a=({children:e})=>(0,n.jsx)(n.Fragment,{children:e});a.Layout=({children:e})=>((0,i.useEffect)(()=>{const e=document.getElementById("wpbody");e&&e.querySelector(".settings-layout")&&e.classList.add("has-settings-layout")},[]),(0,n.jsx)("div",{className:"settings-layout",children:e})),a.Section=({title:e,description:t,children:s,id:o})=>(0,n.jsxs)("div",{className:"settings-section",id:o,children:[(0,n.jsxs)("div",{className:"settings-section__details",children:[(0,n.jsx)("h2",{children:e}),(0,n.jsx)("p",{children:t})]}),(0,n.jsx)("div",{className:"settings-section__controls",children:s})]}),a.Actions=({children:e})=>(0,n.jsx)(o.Card,{className:"settings-card__wrapper ",children:(0,n.jsx)(o.CardBody,{className:"form__actions",children:e})}),a.Form=({children:e,onSubmit:t})=>(0,n.jsx)("form",{onSubmit:t,className:"settings-form",children:e})},56592:(e,t,s)=>{s.d(t,{C0:()=>n,lV:()=>l,mF:()=>a});var o=s(56427),i=s(39793);const n=({data:e,field:t,onChange:s})=>(0,i.jsx)(o.CheckboxControl,{label:t.label,help:t.description,checked:Boolean(t.getValue({item:e})),onChange:e=>s({[t.id]:e})}),a=({data:e,field:t,onChange:s})=>(0,i.jsx)(o.TextControl,{label:t.label,help:t.description,placeholder:t.placeholder,value:String(t.getValue({item:e})??""),onChange:e=>s({[t.id]:e})}),l=({data:e,field:t,onChange:s})=>(0,i.jsx)(o.TextareaControl,{label:t.label,help:t.description,value:String(t.getValue({item:e})??""),onChange:e=>s({[t.id]:e})})},31346:(e,t,s)=>{s.r(t),s.d(t,{SettingsPaymentsCheque:()=>_,default:()=>p});var o=s(56427),i=s(27723),n=s(47143),a=s(40314),l=s(86087),r=s(35453),c=s(224),d=s(60431),m=s(56592),h=s(72002),u=s(39793);const _=()=>{const{createSuccessNotice:e,createErrorNotice:t}=(0,n.useDispatch)("core/notices"),{chequeSettings:s,isLoading:_}=(0,n.useSelect)(e=>({chequeSettings:e(a.paymentGatewaysStore).getPaymentGateway("cheque"),isLoading:!e(a.paymentGatewaysStore).hasFinishedResolution("getPaymentGateway",["cheque"])}),[]),{updatePaymentGateway:p,invalidateResolutionForStoreSelector:g}=(0,n.useDispatch)(a.paymentGatewaysStore),{invalidateResolution:b,invalidateResolutionForStoreSelector:y}=(0,n.useDispatch)(a.paymentSettingsStore),[w,f]=(0,l.useState)({}),[v,x]=(0,l.useState)(!1),[j,S]=(0,l.useState)(!1);(0,l.useEffect)(()=>{s&&f({enabled:s.enabled,title:s.settings.title.value,description:s.description,instructions:s.settings.instructions.value,...(0,h.Z3)(s)})},[s]);const C=(0,l.useMemo)(()=>[{id:"enabled",label:(0,i.__)("Enable check payments","woocommerce"),Edit:m.C0},{id:"title",label:(0,i.__)("Title","woocommerce"),description:(0,i.__)("Payment method name that the customer will see during checkout.","woocommerce"),placeholder:(0,i.__)("Check payments","woocommerce"),Edit:m.mF},{id:"description",label:(0,i.__)("Description","woocommerce"),description:(0,i.__)("Payment method description that the customer will see during checkout.","woocommerce"),Edit:m.lV},{id:"instructions",label:(0,i.__)("Instructions","woocommerce"),description:(0,i.__)("Instructions that will be added to the thank you page and emails.","woocommerce"),Edit:m.lV},...(0,h.es)(s,(0,i.__)("check payments","woocommerce"))],[s]);return(0,u.jsx)(c.w,{children:(0,u.jsx)(c.w.Layout,{children:(0,u.jsxs)(c.w.Form,{onSubmit:o=>{o.preventDefault(),(()=>{if(!s)return;x(!0);const o={title:String(w.title),instructions:String(w.instructions),...(0,h.YV)(w)};p("cheque",{enabled:Boolean(w.enabled),description:String(w.description),settings:o}).then(()=>{S(!1),g("getPaymentGateway"),e((0,i.__)("Settings updated successfully","woocommerce"))}).catch(()=>{t((0,i.__)("Failed to update settings","woocommerce"))}).finally(()=>{x(!1),b("getPaymentProviders",[]),y("getOfflinePaymentGateways")})})()},children:[(0,u.jsx)(c.w.Section,{title:(0,i.__)("Enable and customise","woocommerce"),description:(0,i.__)("Choose how you want to present check payments to your customers during checkout.","woocommerce"),children:_?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(d.W,{size:"small"}),(0,u.jsx)(d.W,{size:"medium"}),(0,u.jsx)(d.W,{size:"large"}),(0,u.jsx)(d.W,{size:"large"}),(0,u.jsx)(d.W,{size:"medium"}),(0,u.jsx)(d.W,{size:"small"})]}):(0,u.jsx)(r.A,{data:w,fields:C,form:{layout:{type:"regular"},fields:["enabled","title","description","instructions","enable_for_methods","enable_for_virtual"]},onChange:e=>{f(t=>({...t,...e})),S(!0)}})}),(0,u.jsx)(c.w.Actions,{children:(0,u.jsx)(o.Button,{variant:"primary",type:"submit",isBusy:v,disabled:v||!j,children:(0,i.__)("Save changes","woocommerce")})})]})})})},p=_},72002:(e,t,s)=>{s.d(t,{es:()=>d,YV:()=>c,Z3:()=>r});var o=s(98846),i=s(27723);function n(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}var a=s(56592),l=s(39793);const r=e=>({enable_for_methods:Array.isArray(e.settings.enable_for_methods?.value)?e.settings.enable_for_methods.value:[],enable_for_virtual:"yes"===e.settings.enable_for_virtual?.value}),c=e=>({enable_for_methods:Array.isArray(e.enable_for_methods)?e.enable_for_methods:[],enable_for_virtual:e.enable_for_virtual?"yes":"no"}),d=(e,t)=>{const s=e?.settings.enable_for_methods?.options?(r=e.settings.enable_for_methods.options,Object.entries(r).map(([e,t])=>({label:n(e),value:e,children:Object.entries(t).map(([e,t])=>({value:e,label:n(t)}))}))):[];var r;const c=(0,i.__)("Select shipping methods for which this payment method is enabled.","woocommerce");return[{id:"enable_for_methods",label:(0,i.__)("Enable for shipping methods","woocommerce"),description:c,Edit:({data:e,field:t,onChange:i})=>{const n=t.getValue({item:e});return(0,l.jsx)(o.TreeSelectControl,{label:t.label,help:c,options:s,value:Array.isArray(n)?n:[],onChange:e=>i({[t.id]:e}),selectAllLabel:!1})}},{id:"enable_for_virtual",label:(0,i.__)("Accept for virtual orders","woocommerce"),description:(0,i.sprintf)((0,i.__)("Accept %s if the order is virtual","woocommerce"),t),Edit:a.C0}]}}}]);
Save File
Cancel