← Back
Editing: product-price.js
(globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[]).push([[2388],{98226:(e,r,c)=>{"use strict";c.d(r,{A:()=>p});var t=c(27723),a=c(14656),o=c(4921),s=c(70910),n=c(86087),i=(c(8501),c(10790));const l=({currency:e,maxPrice:r,minPrice:c,priceClassName:n,priceStyle:l={}})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,t.sprintf)(/* translators: %1$s min price, %2$s max price */ /* translators: %1$s min price, %2$s max price */ (0,t.__)("Price between %1$s and %2$s","woocommerce"),(0,s.formatPrice)(c),(0,s.formatPrice)(r))}),(0,i.jsxs)("span",{"aria-hidden":!0,children:[(0,i.jsx)(a.FormattedMonetaryAmount,{className:(0,o.A)("wc-block-components-product-price__value",n),currency:e,value:c,style:l})," — ",(0,i.jsx)(a.FormattedMonetaryAmount,{className:(0,o.A)("wc-block-components-product-price__value",n),currency:e,value:r,style:l})]})]}),m=({currency:e,regularPriceClassName:r,regularPriceStyle:c,regularPrice:s,priceClassName:n,priceStyle:l,price:m})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,t.__)("Previous price:","woocommerce")}),(0,i.jsx)("del",{className:(0,o.A)("wc-block-components-product-price__regular",r),style:c,translate:"no",children:(0,i.jsx)(a.FormattedMonetaryAmount,{currency:e,value:s})}),(0,i.jsx)("span",{className:"screen-reader-text",children:(0,t.__)("Discounted price:","woocommerce")}),(0,i.jsx)("ins",{className:(0,o.A)("wc-block-components-product-price__value","is-discounted",n),style:l,translate:"no",children:(0,i.jsx)(a.FormattedMonetaryAmount,{currency:e,value:m})})]}),p=({align:e,className:r,currency:c,format:t="<price/>",maxPrice:s,minPrice:p,price:u,priceClassName:d,priceStyle:g,regularPrice:y,regularPriceClassName:_,regularPriceStyle:x,style:N})=>{const f=(0,o.A)(r,"price","wc-block-components-product-price",{[`wc-block-components-product-price--align-${e}`]:e});t.includes("<price/>")||(t="<price/>",console.error("Price formats need to include the `<price/>` tag."));const h=void 0!==y&&void 0!==u&&u<y;let b=(0,i.jsx)("span",{className:(0,o.A)("wc-block-components-product-price__value",d)});return h?b=(0,i.jsx)(m,{currency:c,price:u,priceClassName:d,priceStyle:g,regularPrice:y,regularPriceClassName:_,regularPriceStyle:x}):void 0!==p&&void 0!==s?b=(0,i.jsx)(l,{currency:c,maxPrice:s,minPrice:p,priceClassName:d,priceStyle:g}):(u||0===u)&&(b=(0,i.jsx)(a.FormattedMonetaryAmount,{className:(0,o.A)("wc-block-components-product-price__value",d),currency:c,value:u,style:g})),(0,i.jsx)("span",{className:f,style:N,children:(0,n.createInterpolateElement)(t,{price:b})})}},2374:(e,r,c)=>{"use strict";c.d(r,{p:()=>n});var t=c(4921),a=c(73993),o=c(25028),s=c(63512);const n=e=>{const r=(e=>{const r=(0,a.isObject)(e)?e:{style:{}};let c=r.style;return(0,a.isString)(c)&&(c=JSON.parse(c)||{}),(0,a.isObject)(c)||(c={}),{...r,style:c}})(e),c=(0,s.BK)(r),n=(0,s.aR)(r),i=(0,s.fo)(r),l=(0,o.x)(r);return{className:(0,t.A)(l.className,c.className,n.className,i.className),style:{...l.style,...c.style,...n.style,...i.style}}}},25028:(e,r,c)=>{"use strict";c.d(r,{x:()=>a});var t=c(73993);const a=e=>{const r=(0,t.isObject)(e.style.typography)?e.style.typography:{},c=(0,t.isString)(r.fontFamily)?r.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:c,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:r.fontSize,fontStyle:r.fontStyle,fontWeight:r.fontWeight,letterSpacing:r.letterSpacing,lineHeight:r.lineHeight,textDecoration:r.textDecoration,textTransform:r.textTransform}}}},63512:(e,r,c)=>{"use strict";c.d(r,{BK:()=>l,aR:()=>m,fo:()=>p});var t=c(4921),a=c(67356),o=c(49786),s=c(73993);function n(e={}){const r={};return(0,o.getCSSRules)(e,{selector:""}).forEach(e=>{r[e.key]=e.value}),r}function i(e,r){return e&&r?`has-${(0,a.c)(r)}-${e}`:""}function l(e){const{backgroundColor:r,textColor:c,gradient:a,style:o}=e,l=i("background-color",r),m=i("color",c),p=function(e){if(e)return`has-${e}-gradient-background`}(a),u=p||o?.color?.gradient;return{className:(0,t.A)(m,p,{[l]:!u&&!!l,"has-text-color":c||o?.color?.text,"has-background":r||o?.color?.background||a||o?.color?.gradient,"has-link-color":(0,s.isObject)(o?.elements?.link)?o?.elements?.link?.color:void 0}),style:n({color:o?.color||{}})}}function m(e){const r=e.style?.border||{};return{className:function(e){const{borderColor:r,style:c}=e,a=r?i("border-color",r):"";return(0,t.A)({"has-border-color":!!r||!!c?.border?.color,[a]:!!a})}(e),style:n({border:r})}}function p(e){return{className:void 0,style:n({spacing:e.style?.spacing||{}})}}},87746:(e,r,c)=>{"use strict";c.r(r),c.d(r,{Block:()=>u,convertAdminPriceToStoreApiFormat:()=>p,default:()=>d});var t=c(4921),a=c(98226),o=c(70910),s=c(62796),n=c(2374),i=c(41616),l=c(15703),m=c(10790);const p=(e,r,c="0")=>{const t=10**r.minorUnit;return Math.round(Number.parseFloat(e??c)*t).toString()},u=e=>{const{className:r,textAlign:c,isDescendentOfSingleProductTemplate:i,isAdmin:u,product:d,isExperimentalWcRestApiV4Enabled:g}=e,{parentName:y,parentClassName:_}=(0,s.useInnerBlockLayoutContext)(),{product:x}=(0,s.useProductDataContext)(g?{isAdmin:u,product:d}:void 0),N="woocommerce/all-products"===y,f="woocommerce/add-to-cart-with-options-grouped-product-item"===y,h=(0,n.p)(e),{margin:b,marginTop:v,marginRight:P,marginBottom:k,marginLeft:A,...j}=h.style,S={margin:b,marginTop:v,marginRight:P,marginBottom:k,marginLeft:A},C=i&&!f||!x,w=(0,t.A)("wp-block-woocommerce-product-price",r),F=(0,t.A)(h.className,{[`${_}__product-price`]:_});if(!x?.id&&!i){const e=(0,m.jsx)(a.A,{align:c,className:F,style:j});return N?(0,m.jsx)("div",{className:w,style:u?void 0:S,children:e}):e}let $=x?.prices??{};const R=C?(0,o.getCurrencyFromPriceResponse)():(0,o.getCurrencyFromPriceResponse)($);g&&($={price:p(x?.price,R),...x?.sale_price?{sale_price:p(x?.sale_price,R)}:{},...x?.regular_price?{regular_price:p(x?.regular_price,R)}:{},currency_minor_unit:l.SITE_CURRENCY.minorUnit,price_range:x?.max_price&&x?.min_price?{min_amount:p(x.min_price,R),max_amount:p(x.max_price,R)}:null});const T="5000",B=$.price!==$.regular_price,M=(0,t.A)({[`${_}__product-price__value`]:_,[`${_}__product-price__value--on-sale`]:B}),D=(0,m.jsx)(a.A,{align:c,className:F,style:j,priceClassName:M,currency:R,price:C?T:$.price,minPrice:$?.price_range?.min_amount,maxPrice:$?.price_range?.max_amount,regularPrice:C?T:$.regular_price,regularPriceClassName:(0,t.A)({[`${_}__product-price__regular`]:_})});return N?(0,m.jsx)("div",{className:w,style:u?void 0:S,children:D}):D},d=e=>e.isDescendentOfSingleProductTemplate?(0,m.jsx)(u,{...e}):(0,i.withProductDataContext)(u)(e)},8501:()=>{}}]);
Save File
Cancel