mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-07 01:54:05 +00:00
35 lines
10 KiB
JavaScript
35 lines
10 KiB
JavaScript
(()=>{"use strict";var e={20:(e,r,s)=>{var t=s(609),n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function a(e,r,s){var t,i={},a=null,p=null;for(t in void 0!==s&&(a=""+s),void 0!==r.key&&(a=""+r.key),void 0!==r.ref&&(p=r.ref),r)o.call(r,t)&&!l.hasOwnProperty(t)&&(i[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===i[t]&&(i[t]=r[t]);return{$$typeof:n,type:e,key:a,ref:p,props:i,_owner:c.current}}r.Fragment=i,r.jsx=a,r.jsxs=a},609:e=>{e.exports=window.React},848:(e,r,s)=>{e.exports=s(20)}},r={};const s=window.wp.plugins,t=window.wc.blocksCheckout,n=window.wp.i18n,i=window.wc.priceFormat,o=window.wc.wcSettings;function c(e){return{day:(0,n._nx)("day","days",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),week:(0,n._nx)("week","weeks",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),month:(0,n._nx)("month","months",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions"),year:(0,n._nx)("year","years",e,"Used in recurring totals section in Cart. 2+ will need plural, 1 will need singular.","woocommerce-subscriptions")}}function l({billing_interval:e,billing_period:r},s,t){const i=c(e)[r];return s=s.trim(),1===e?`${t} ${s} ${i}`:(0,n.sprintf)(
|
|
/*
|
|
* translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
|
|
* %3$d is the length, %4$s is week, month, year
|
|
*/
|
|
/*
|
|
* translators: %1$s is the price of the product. %2$s is the separator used e.g "every" or "/",
|
|
* %3$d is the length, %4$s is week, month, year
|
|
*/
|
|
(0,n.__)("%1$s %2$s %3$d %4$s","woocommerce-subscriptions"),t,s,e,i)}function a({subscriptionLength:e,billingInterval:r}){return e===r}var p=function s(t){var n=r[t];if(void 0!==n)return n.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,s),i.exports}(848);const u=(0,o.getSetting)("displayCartPricesIncludingTax",!1),m=({currency:e,values:r})=>{const{total_discount:s,total_discount_tax:i}=r,o=parseInt(s,10);if(!o)return null;const c=parseInt(i,10),l=u?o+c:o;return(0,p.jsx)(t.TotalsItem,{className:"wc-block-components-totals-discount",currency:e,label:(0,n.__)("Discount","woocommerce-subscriptions"),value:-1*l})},_=({values:e,currency:r,selectedRate:s,needsShipping:i,calculatedShipping:c})=>{if(!i||!c)return null;const l=u?parseInt(e.total_shipping,10)+parseInt(e.total_shipping_tax,10):parseInt(e.total_shipping,10),a=0===l&&(0,o.isWcVersion)("9.0",">=")?(0,p.jsx)("strong",{children:(0,n.__)("Free","woocommerce-subscriptions")}):l;return(0,p.jsx)(t.TotalsItem,{value:a,label:(0,n.__)("Shipping","woocommerce-subscriptions"),currency:r,description:!!s&&(0,n.sprintf)(
|
|
// translators: %s selected shipping rate (ex: flat rate)
|
|
// translators: %s selected shipping rate (ex: flat rate)
|
|
(0,n.__)("via %s","woocommerce-subscriptions"),s)})},g=({nextPaymentDate:e,subscriptionLength:r,billingPeriod:s,billingInterval:t})=>{const i=function({subscriptionLength:e,billingPeriod:r}){const s=c(e);return(0,n.sprintf)("For %1$d %2$s",e,s[r],"woocommerce-subscriptions")}({subscriptionLength:r,billingPeriod:s}),o=a({subscriptionLength:r,billingInterval:t})?(0,n.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
|
|
(0,n.__)("Due: %1$s","woocommerce-subscriptions"),e):(0,n.sprintf)(/* Translators: %1$s is a date. */ /* Translators: %1$s is a date. */
|
|
(0,n.__)("Starting: %1$s","woocommerce-subscriptions"),e);return(0,p.jsxs)("span",{children:[!!e&&o," ",!!r&&r>=t&&(0,p.jsx)("span",{className:"wcs-recurring-totals__subscription-length",children:i})]})},d=({currency:e,billingInterval:r,billingPeriod:s,nextPaymentDate:i,subscriptionLength:o,totals:c})=>{const l=a({billingInterval:r,subscriptionLength:o})?(0,n.__)("Total","woocommerce-subscriptions"):function({billingInterval:e,billingPeriod:r}){switch(e){case 1:if("day"===r)return(0,n.__)("Daily recurring total","woocommerce-subscriptions");if("week"===r)return(0,n.__)("Weekly recurring total","woocommerce-subscriptions");if("month"===r)return(0,n.__)("Monthly recurring total","woocommerce-subscriptions");if("year"===r)return(0,n.__)("Yearly recurring total","woocommerce-subscriptions");break;case 2:return(0,n.sprintf)(/* translators: %1$s is week, month, year */ /* translators: %1$s is week, month, year */
|
|
(0,n.__)("Recurring total every 2nd %1$s","woocommerce-subscriptions"),r);case 3:return(0,n.sprintf)(/* Translators: %1$s is week, month, year */ /* Translators: %1$s is week, month, year */
|
|
(0,n.__)("Recurring total every 3rd %1$s","woocommerce-subscriptions"),r);default:return(0,n.sprintf)(/* Translators: %1$d is number of weeks, months, days, years. %2$s is week, month, year */ /* Translators: %1$d is number of weeks, months, days, years. %2$s is week, month, year */
|
|
(0,n.__)("Recurring total every %1$dth %2$s","woocommerce-subscriptions"),e,r)}}({billingInterval:r,billingPeriod:s});return(0,p.jsx)(t.TotalsItem,{className:"wcs-recurring-totals-panel__title",currency:e,label:l,value:c,description:(0,p.jsx)(g,{nextPaymentDate:i,subscriptionLength:o,billingInterval:r,billingPeriod:s})})},b=({subscription:e,needsShipping:r,calculatedShipping:s})=>{const{totals:o,billing_interval:c,billing_period:l,next_payment_date:a,subscription_length:g,shipping_rates:b}=e;if(!a)return null;const w=b?.[0]?.shipping_rates?.find((({selected:e})=>e))?.name,h=(0,i.getCurrencyFromPriceResponse)(o);return(0,p.jsxs)("div",{className:"wcs-recurring-totals-panel",children:[(0,p.jsx)(d,{billingInterval:c,billingPeriod:l,nextPaymentDate:a,subscriptionLength:g,totals:parseInt(o.total_price,10),currency:h}),(0,p.jsxs)(t.Panel,{className:"wcs-recurring-totals-panel__details",initialOpen:!1,title:(0,n.__)("Details","woocommerce-subscriptions"),children:[(0,p.jsxs)(t.TotalsWrapper,{children:[(0,p.jsx)(t.Subtotal,{currency:h,values:o}),(0,p.jsx)(m,{currency:h,values:o})]}),(0,p.jsx)(t.TotalsWrapper,{className:"wc-block-components-totals-shipping",children:(0,p.jsx)(_,{currency:h,needsShipping:r,calculatedShipping:s,values:o,selectedRate:w})}),!u&&(0,p.jsx)(t.TotalsWrapper,{children:(0,p.jsx)(t.TotalsTaxes,{currency:h,values:o})}),(0,p.jsx)(t.TotalsWrapper,{children:(0,p.jsx)(t.TotalsItem,{className:"wcs-recurring-totals-panel__details-total",currency:h,label:(0,n.__)("Total","woocommerce-subscriptions"),value:parseInt(o.total_price,10)})})]})]})},w=({extensions:e,cart:r})=>{const{subscriptions:s}=e,{cartNeedsShipping:t,cartHasCalculatedShipping:n}=r;return s&&0!==s.length?s.map((({key:e,...r})=>(0,p.jsx)(b,{subscription:r,needsShipping:t,calculatedShipping:n},e))):null},h=window.wp.element,x=({extensions:e,collapsible:r,collapse:s,showItems:t,noResultsMessage:n,renderOption:i,components:o,context:c})=>{const{subscriptions:l=[]}=e,{ShippingRatesControlPackage:a}=o,u=(0,h.useMemo)((()=>Object.values(l).map((e=>e.shipping_rates)).filter(Boolean).flat()),[l]),m=(0,h.useMemo)((()=>u.length>1||s),[u.length,s]),_=(0,h.useMemo)((()=>u.length>1||t),[u.length,t]);return u.map((({package_id:e,...s})=>(0,p.jsx)(a,{packageId:e,packageData:s,collapsible:r,collapse:m,showItems:_,noResultsMessage:n,renderOption:i,highlightChecked:"woocommerce/checkout"===c},e)))};(0,s.registerPlugin)("woocommerce-subscriptions",{render:()=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(t.ExperimentalOrderShippingPackages,{children:(0,p.jsx)(x,{})}),(0,p.jsx)(t.ExperimentalOrderMeta,{children:(0,p.jsx)(w,{})})]}),scope:"woocommerce-checkout"}),(0,t.registerCheckoutFilters)("woocommerce-subscriptions",{totalLabel:(e,{subscriptions:r})=>r?.length>0?(0,n.__)("Total due today","woocommerce-subscriptions"):e,subtotalPriceFormat:(e,{subscriptions:r})=>{if(r?.billing_period&&r?.billing_interval){const{billing_interval:s,subscription_length:t}=r;return a({subscriptionLength:t,billingInterval:s})?l(r,1===t?
|
|
// translators: the word used to describe billing frequency, e.g. "for" 1 day or "for" 1 month.
|
|
// translators: the word used to describe billing frequency, e.g. "for" 1 day or "for" 1 month.
|
|
(0,n.__)("for 1","woocommerce-subscriptions"):
|
|
// translators: the word used to describe billing frequency, e.g. "for" 6 days or "for" 2 weeks.
|
|
// translators: the word used to describe billing frequency, e.g. "for" 6 days or "for" 2 weeks.
|
|
(0,n.__)("for","woocommerce-subscriptions"),e):l(r,
|
|
// translators: the word used to describe billing frequency, e.g. "every" 6 days or "every" 2 weeks.
|
|
// translators: the word used to describe billing frequency, e.g. "every" 6 days or "every" 2 weeks.
|
|
(0,n.__)("every","woocommerce-subscriptions"),e)}return e},saleBadgePriceFormat:(e,{subscriptions:r})=>r?.billing_period&&r?.billing_interval?l(r,"/",e):e,itemName:(e,{subscriptions:r})=>r?.is_resubscribe?(0,n.sprintf)(
|
|
// translators: %s Product name.
|
|
// translators: %s Product name.
|
|
(0,n.__)("%s (resubscription)","woocommerce-subscriptions"),e):r?.switch_type?(0,n.sprintf)(
|
|
// translators: %1$s Product name, %2$s Switch type (upgraded, downgraded, or crossgraded).
|
|
// translators: %1$s Product name, %2$s Switch type (upgraded, downgraded, or crossgraded).
|
|
(0,n.__)("%1$s (%2$s)","woocommerce-subscriptions"),e,function(e){switch(e){case"upgraded":return(0,n.__)("Upgrade","woocommerce-subscriptions");case"downgraded":return(0,n.__)("Downgrade","woocommerce-subscriptions");case"crossgraded":return(0,n.__)("Crossgrade","woocommerce-subscriptions");default:return""}}(r.switch_type)):e,cartItemPrice:(e,{subscriptions:r},{context:s})=>r?.sign_up_fees?"cart"===s?(0,n.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
|
|
(0,n.__)("Due today %s","woocommerce-subscriptions"),e):(0,n.sprintf)(/* translators: %s is the subscription price to pay immediately (ie: $10). */ /* translators: %s is the subscription price to pay immediately (ie: $10). */
|
|
(0,n.__)("%s due today","woocommerce-subscriptions"),e):e,placeOrderButtonLabel:e=>{const r=(0,o.getSetting)("subscriptions_data");return r?.place_order_override?r?.place_order_override:e}})})(); |