ManualPaymentMethods-e5dcf410.js
3 years ago
ManualPaymentMethods-e5dcf410.js.map
3 years ago
_commonjsHelpers-537d719a.js
4 years ago
_commonjsHelpers-537d719a.js.map
3 years ago
add-query-args-17c551b6.js
4 years ago
add-query-args-17c551b6.js.map
3 years ago
address-42b5c61b.js
3 years ago
address-42b5c61b.js.map
3 years ago
animation-registry-58bec802.js
3 years ago
animation-registry-58bec802.js.map
3 years ago
consumer-51f6d265.js
3 years ago
consumer-51f6d265.js.map
3 years ago
countries-0ec7ecdc.js
4 years ago
countries-0ec7ecdc.js.map
3 years ago
fetch-b673a242.js
3 years ago
fetch-b673a242.js.map
3 years ago
form-data-69000afe.js
3 years ago
form-data-69000afe.js.map
3 years ago
functions-77ef3f22.js
4 years ago
functions-77ef3f22.js.map
3 years ago
get-query-arg-53bf21e2.js
4 years ago
get-query-arg-53bf21e2.js.map
3 years ago
getters-52a52d79.js
3 years ago
getters-52a52d79.js.map
3 years ago
getters-6f3470fb.js
3 years ago
getters-6f3470fb.js.map
3 years ago
getters-c8a04b97.js
3 years ago
getters-c8a04b97.js.map
3 years ago
getters-f0455d23.js
3 years ago
getters-f0455d23.js.map
3 years ago
global-6f39d5d2.js
3 years ago
global-6f39d5d2.js.map
3 years ago
index-261b56ec.js
3 years ago
index-261b56ec.js.map
3 years ago
index-2643f18b.js
3 years ago
index-2643f18b.js.map
3 years ago
index-ac77ca60.js
3 years ago
index-ac77ca60.js.map
3 years ago
index-b901844d.js
3 years ago
index-b901844d.js.map
3 years ago
index-cf22257b.js
3 years ago
index-cf22257b.js.map
3 years ago
index.cjs.js
3 years ago
index.cjs.js.map
3 years ago
lazy-bc8baeab.js
4 years ago
lazy-bc8baeab.js.map
3 years ago
library-289cf13f.js
4 years ago
library-289cf13f.js.map
3 years ago
loader.cjs.js
3 years ago
loader.cjs.js.map
3 years ago
media-a7872d6d.js
3 years ago
media-a7872d6d.js.map
3 years ago
mutations-a3ec6490.js
3 years ago
mutations-a3ec6490.js.map
3 years ago
mutations-b8d54585.js
3 years ago
mutations-b8d54585.js.map
3 years ago
page-align-bf197eb4.js
3 years ago
page-align-bf197eb4.js.map
3 years ago
price-d3e21aa4.js
3 years ago
price-d3e21aa4.js.map
3 years ago
pure-5be33f24.js
4 years ago
pure-5be33f24.js.map
3 years ago
sc-address_3.cjs.entry.js
3 years ago
sc-address_3.cjs.entry.js.map
3 years ago
sc-alert.cjs.entry.js
3 years ago
sc-alert.cjs.entry.js.map
3 years ago
sc-avatar.cjs.entry.js
3 years ago
sc-avatar.cjs.entry.js.map
3 years ago
sc-badge-notice.cjs.entry.js
3 years ago
sc-badge-notice.cjs.entry.js.map
3 years ago
sc-block-ui.cjs.entry.js
3 years ago
sc-block-ui.cjs.entry.js.map
3 years ago
sc-breadcrumb.cjs.entry.js
3 years ago
sc-breadcrumb.cjs.entry.js.map
3 years ago
sc-breadcrumbs.cjs.entry.js
3 years ago
sc-breadcrumbs.cjs.entry.js.map
3 years ago
sc-button-group.cjs.entry.js
3 years ago
sc-button-group.cjs.entry.js.map
3 years ago
sc-button_2.cjs.entry.js
3 years ago
sc-button_2.cjs.entry.js.map
3 years ago
sc-cancel-dialog_2.cjs.entry.js
3 years ago
sc-cancel-dialog_2.cjs.entry.js.map
3 years ago
sc-cancel-discount_4.cjs.entry.js
3 years ago
sc-cancel-discount_4.cjs.entry.js.map
3 years ago
sc-card_2.cjs.entry.js
3 years ago
sc-card_2.cjs.entry.js.map
3 years ago
sc-cart-button.cjs.entry.js
3 years ago
sc-cart-button.cjs.entry.js.map
3 years ago
sc-cart-form-submit.cjs.entry.js
3 years ago
sc-cart-form-submit.cjs.entry.js.map
3 years ago
sc-cart-form.cjs.entry.js
3 years ago
sc-cart-form.cjs.entry.js.map
3 years ago
sc-cart-header.cjs.entry.js
3 years ago
sc-cart-header.cjs.entry.js.map
3 years ago
sc-cart-icon.cjs.entry.js
3 years ago
sc-cart-icon.cjs.entry.js.map
3 years ago
sc-cart-loader.cjs.entry.js
3 years ago
sc-cart-loader.cjs.entry.js.map
3 years ago
sc-cart-session-provider_3.cjs.entry.js
3 years ago
sc-cart-session-provider_3.cjs.entry.js.map
3 years ago
sc-cart-submit.cjs.entry.js
3 years ago
sc-cart-submit.cjs.entry.js.map
3 years ago
sc-cart.cjs.entry.js
3 years ago
sc-cart.cjs.entry.js.map
3 years ago
sc-cc-logo_2.cjs.entry.js
3 years ago
sc-cc-logo_2.cjs.entry.js.map
3 years ago
sc-charges-list.cjs.entry.js
3 years ago
sc-charges-list.cjs.entry.js.map
3 years ago
sc-checkbox.cjs.entry.js
3 years ago
sc-checkbox.cjs.entry.js.map
3 years ago
sc-checkout-form-errors.cjs.entry.js
3 years ago
sc-checkout-form-errors.cjs.entry.js.map
3 years ago
sc-checkout-mollie-payment.cjs.entry.js
3 years ago
sc-checkout-mollie-payment.cjs.entry.js.map
3 years ago
sc-checkout-unsaved-changes-warning_7.cjs.entry.js
3 years ago
sc-checkout-unsaved-changes-warning_7.cjs.entry.js.map
3 years ago
sc-checkout.cjs.entry.js
3 years ago
sc-checkout.cjs.entry.js.map
3 years ago
sc-choice-container.cjs.entry.js
3 years ago
sc-choice-container.cjs.entry.js.map
3 years ago
sc-choice.cjs.entry.js
3 years ago
sc-choice.cjs.entry.js.map
3 years ago
sc-choices.cjs.entry.js
3 years ago
sc-choices.cjs.entry.js.map
3 years ago
sc-column_2.cjs.entry.js
3 years ago
sc-column_2.cjs.entry.js.map
3 years ago
sc-compact-address_6.cjs.entry.js
3 years ago
sc-compact-address_6.cjs.entry.js.map
3 years ago
sc-conditional-form.cjs.entry.js
3 years ago
sc-conditional-form.cjs.entry.js.map
3 years ago
sc-consumer.cjs.entry.js
3 years ago
sc-consumer.cjs.entry.js.map
3 years ago
sc-coupon-form.cjs.entry.js
3 years ago
sc-coupon-form.cjs.entry.js.map
3 years ago
sc-custom-order-price-input.cjs.entry.js
3 years ago
sc-custom-order-price-input.cjs.entry.js.map
3 years ago
sc-customer-details.cjs.entry.js
3 years ago
sc-customer-details.cjs.entry.js.map
3 years ago
sc-customer-edit.cjs.entry.js
3 years ago
sc-customer-edit.cjs.entry.js.map
3 years ago
sc-customer-email.cjs.entry.js
3 years ago
sc-customer-email.cjs.entry.js.map
3 years ago
sc-customer-firstname.cjs.entry.js
3 years ago
sc-customer-firstname.cjs.entry.js.map
3 years ago
sc-customer-lastname.cjs.entry.js
3 years ago
sc-customer-lastname.cjs.entry.js.map
3 years ago
sc-customer-name.cjs.entry.js
3 years ago
sc-customer-name.cjs.entry.js.map
3 years ago
sc-customer-phone.cjs.entry.js
3 years ago
sc-customer-phone.cjs.entry.js.map
3 years ago
sc-dashboard-customer-details.cjs.entry.js
3 years ago
sc-dashboard-customer-details.cjs.entry.js.map
3 years ago
sc-dashboard-downloads-list.cjs.entry.js
3 years ago
sc-dashboard-downloads-list.cjs.entry.js.map
3 years ago
sc-dialog.cjs.entry.js
3 years ago
sc-dialog.cjs.entry.js.map
3 years ago
sc-divider.cjs.entry.js
3 years ago
sc-divider.cjs.entry.js.map
3 years ago
sc-donation-choices.cjs.entry.js
3 years ago
sc-donation-choices.cjs.entry.js.map
3 years ago
sc-downloads-list.cjs.entry.js
3 years ago
sc-downloads-list.cjs.entry.js.map
3 years ago
sc-dropdown_4.cjs.entry.js
3 years ago
sc-dropdown_4.cjs.entry.js.map
3 years ago
sc-empty.cjs.entry.js
3 years ago
sc-empty.cjs.entry.js.map
3 years ago
sc-express-payment.cjs.entry.js
3 years ago
sc-express-payment.cjs.entry.js.map
3 years ago
sc-flex.cjs.entry.js
3 years ago
sc-flex.cjs.entry.js.map
3 years ago
sc-form-control_2.cjs.entry.js
3 years ago
sc-form-control_2.cjs.entry.js.map
3 years ago
sc-form-row.cjs.entry.js
3 years ago
sc-form-row.cjs.entry.js.map
3 years ago
sc-form.cjs.entry.js
3 years ago
sc-form.cjs.entry.js.map
3 years ago
sc-format-bytes.cjs.entry.js
3 years ago
sc-format-bytes.cjs.entry.js.map
3 years ago
sc-format-date.cjs.entry.js
3 years ago
sc-format-date.cjs.entry.js.map
3 years ago
sc-format-interval.cjs.entry.js
3 years ago
sc-format-interval.cjs.entry.js.map
3 years ago
sc-format-number.cjs.entry.js
3 years ago
sc-format-number.cjs.entry.js.map
3 years ago
sc-heading_2.cjs.entry.js
3 years ago
sc-heading_2.cjs.entry.js.map
3 years ago
sc-icon.cjs.entry.js
3 years ago
sc-icon.cjs.entry.js.map
3 years ago
sc-image-slider.cjs.entry.js
3 years ago
sc-image-slider.cjs.entry.js.map
3 years ago
sc-invoices-list.cjs.entry.js
3 years ago
sc-invoices-list.cjs.entry.js.map
3 years ago
sc-licenses-list.cjs.entry.js
3 years ago
sc-licenses-list.cjs.entry.js.map
3 years ago
sc-line-item-bump.cjs.entry.js
3 years ago
sc-line-item-bump.cjs.entry.js.map
3 years ago
sc-line-item-total.cjs.entry.js
3 years ago
sc-line-item-total.cjs.entry.js.map
3 years ago
sc-line-item.cjs.entry.js
3 years ago
sc-line-item.cjs.entry.js.map
3 years ago
sc-line-items-provider.cjs.entry.js
3 years ago
sc-line-items-provider.cjs.entry.js.map
3 years ago
sc-line-items.cjs.entry.js
3 years ago
sc-line-items.cjs.entry.js.map
3 years ago
sc-login-form.cjs.entry.js
3 years ago
sc-login-form.cjs.entry.js.map
3 years ago
sc-menu-divider.cjs.entry.js
3 years ago
sc-menu-divider.cjs.entry.js.map
3 years ago
sc-mollie-add-method.cjs.entry.js
3 years ago
sc-mollie-add-method.cjs.entry.js.map
3 years ago
sc-order-confirmation-customer.cjs.entry.js
3 years ago
sc-order-confirmation-customer.cjs.entry.js.map
3 years ago
sc-order-confirmation-details.cjs.entry.js
3 years ago
sc-order-confirmation-details.cjs.entry.js.map
3 years ago
sc-order-confirmation-line-items_2.cjs.entry.js
3 years ago
sc-order-confirmation-line-items_2.cjs.entry.js.map
3 years ago
sc-order-confirmation.cjs.entry.js
3 years ago
sc-order-confirmation.cjs.entry.js.map
3 years ago
sc-order-coupon-form.cjs.entry.js
3 years ago
sc-order-coupon-form.cjs.entry.js.map
3 years ago
sc-order-detail.cjs.entry.js
3 years ago
sc-order-detail.cjs.entry.js.map
3 years ago
sc-order-manual-instructions.cjs.entry.js
3 years ago
sc-order-manual-instructions.cjs.entry.js.map
3 years ago
sc-order-password.cjs.entry.js
3 years ago
sc-order-password.cjs.entry.js.map
3 years ago
sc-order-status-badge.cjs.entry.js
3 years ago
sc-order-status-badge.cjs.entry.js.map
3 years ago
sc-order-submit.cjs.entry.js
3 years ago
sc-order-submit.cjs.entry.js.map
3 years ago
sc-order-summary.cjs.entry.js
3 years ago
sc-order-summary.cjs.entry.js.map
3 years ago
sc-order.cjs.entry.js
3 years ago
sc-order.cjs.entry.js.map
3 years ago
sc-orders-list.cjs.entry.js
3 years ago
sc-orders-list.cjs.entry.js.map
3 years ago
sc-pagination.cjs.entry.js
3 years ago
sc-pagination.cjs.entry.js.map
3 years ago
sc-password-nag.cjs.entry.js
3 years ago
sc-password-nag.cjs.entry.js.map
3 years ago
sc-payment-method-choice_2.cjs.entry.js
3 years ago
sc-payment-method-choice_2.cjs.entry.js.map
3 years ago
sc-payment-methods-list.cjs.entry.js
3 years ago
sc-payment-methods-list.cjs.entry.js.map
3 years ago
sc-payment.cjs.entry.js
3 years ago
sc-payment.cjs.entry.js.map
3 years ago
sc-paypal-add-method.cjs.entry.js
3 years ago
sc-paypal-add-method.cjs.entry.js.map
3 years ago
sc-paypal-buttons_2.cjs.entry.js
3 years ago
sc-paypal-buttons_2.cjs.entry.js.map
3 years ago
sc-phone-input.cjs.entry.js
3 years ago
sc-phone-input.cjs.entry.js.map
3 years ago
sc-premium-tag.cjs.entry.js
3 years ago
sc-premium-tag.cjs.entry.js.map
3 years ago
sc-price-choice-container.cjs.entry.js
3 years ago
sc-price-choice-container.cjs.entry.js.map
3 years ago
sc-price-choice.cjs.entry.js
3 years ago
sc-price-choice.cjs.entry.js.map
3 years ago
sc-price-choices.cjs.entry.js
3 years ago
sc-price-choices.cjs.entry.js.map
3 years ago
sc-price-input.cjs.entry.js
3 years ago
sc-price-input.cjs.entry.js.map
3 years ago
sc-price-range.cjs.entry.js
3 years ago
sc-price-range.cjs.entry.js.map
3 years ago
sc-product-buy-button.cjs.entry.js
3 years ago
sc-product-buy-button.cjs.entry.js.map
3 years ago
sc-product-item-image_3.cjs.entry.js
3 years ago
sc-product-item-image_3.cjs.entry.js.map
3 years ago
sc-product-item-list.cjs.entry.js
3 years ago
sc-product-item-list.cjs.entry.js.map
3 years ago
sc-product-item.cjs.entry.js
3 years ago
sc-product-item.cjs.entry.js.map
3 years ago
sc-product-line-item_2.cjs.entry.js
3 years ago
sc-product-line-item_2.cjs.entry.js.map
3 years ago
sc-product-price-choices.cjs.entry.js
3 years ago
sc-product-price-choices.cjs.entry.js.map
3 years ago
sc-product-price-modal.cjs.entry.js
3 years ago
sc-product-price-modal.cjs.entry.js.map
3 years ago
sc-product-price.cjs.entry.js
3 years ago
sc-product-price.cjs.entry.js.map
3 years ago
sc-product-quantity.cjs.entry.js
3 years ago
sc-product-quantity.cjs.entry.js.map
3 years ago
sc-product-selected-price.cjs.entry.js
3 years ago
sc-product-selected-price.cjs.entry.js.map
3 years ago
sc-product-text.cjs.entry.js
3 years ago
sc-product-text.cjs.entry.js.map
3 years ago
sc-prose.cjs.entry.js
3 years ago
sc-prose.cjs.entry.js.map
3 years ago
sc-provider.cjs.entry.js
3 years ago
sc-provider.cjs.entry.js.map
3 years ago
sc-purchase-downloads-list_2.cjs.entry.js
3 years ago
sc-purchase-downloads-list_2.cjs.entry.js.map
3 years ago
sc-radio-group.cjs.entry.js
3 years ago
sc-radio-group.cjs.entry.js.map
3 years ago
sc-radio.cjs.entry.js
3 years ago
sc-radio.cjs.entry.js.map
3 years ago
sc-rich-text.cjs.entry.js
3 years ago
sc-rich-text.cjs.entry.js.map
3 years ago
sc-skeleton.cjs.entry.js
3 years ago
sc-skeleton.cjs.entry.js.map
3 years ago
sc-stacked-list_2.cjs.entry.js
3 years ago
sc-stacked-list_2.cjs.entry.js.map
3 years ago
sc-stripe-add-method.cjs.entry.js
3 years ago
sc-stripe-add-method.cjs.entry.js.map
3 years ago
sc-stripe-element.cjs.entry.js
3 years ago
sc-stripe-element.cjs.entry.js.map
3 years ago
sc-stripe-payment-element.cjs.entry.js
3 years ago
sc-stripe-payment-element.cjs.entry.js.map
3 years ago
sc-stripe-payment-request.cjs.entry.js
3 years ago
sc-stripe-payment-request.cjs.entry.js.map
3 years ago
sc-subscription-ad-hoc-confirm.cjs.entry.js
3 years ago
sc-subscription-ad-hoc-confirm.cjs.entry.js.map
3 years ago
sc-subscription-details_2.cjs.entry.js
3 years ago
sc-subscription-details_2.cjs.entry.js.map
3 years ago
sc-subscription-payment-method.cjs.entry.js
3 years ago
sc-subscription-payment-method.cjs.entry.js.map
3 years ago
sc-subscription-payment.cjs.entry.js
3 years ago
sc-subscription-payment.cjs.entry.js.map
3 years ago
sc-subscription-switch.cjs.entry.js
3 years ago
sc-subscription-switch.cjs.entry.js.map
3 years ago
sc-subscription.cjs.entry.js
3 years ago
sc-subscription.cjs.entry.js.map
3 years ago
sc-subscriptions-list.cjs.entry.js
3 years ago
sc-subscriptions-list.cjs.entry.js.map
3 years ago
sc-switch.cjs.entry.js
3 years ago
sc-switch.cjs.entry.js.map
3 years ago
sc-tab-group.cjs.entry.js
3 years ago
sc-tab-group.cjs.entry.js.map
3 years ago
sc-tab-panel.cjs.entry.js
3 years ago
sc-tab-panel.cjs.entry.js.map
3 years ago
sc-tab.cjs.entry.js
3 years ago
sc-tab.cjs.entry.js.map
3 years ago
sc-table-head.cjs.entry.js
3 years ago
sc-table-head.cjs.entry.js.map
3 years ago
sc-table_3.cjs.entry.js
3 years ago
sc-table_3.cjs.entry.js.map
3 years ago
sc-tag.cjs.entry.js
3 years ago
sc-tag.cjs.entry.js.map
3 years ago
sc-text.cjs.entry.js
3 years ago
sc-text.cjs.entry.js.map
3 years ago
sc-toggle.cjs.entry.js
3 years ago
sc-toggle.cjs.entry.js.map
3 years ago
sc-toggles.cjs.entry.js
3 years ago
sc-toggles.cjs.entry.js.map
3 years ago
sc-tooltip.cjs.entry.js
3 years ago
sc-tooltip.cjs.entry.js.map
3 years ago
sc-total.cjs.entry.js
3 years ago
sc-total.cjs.entry.js.map
3 years ago
sc-upcoming-invoice.cjs.entry.js
3 years ago
sc-upcoming-invoice.cjs.entry.js.map
3 years ago
sc-upgrade-required.cjs.entry.js
3 years ago
sc-upgrade-required.cjs.entry.js.map
3 years ago
sc-wordpress-password-edit.cjs.entry.js
3 years ago
sc-wordpress-password-edit.cjs.entry.js.map
3 years ago
sc-wordpress-user-edit.cjs.entry.js
3 years ago
sc-wordpress-user-edit.cjs.entry.js.map
3 years ago
sc-wordpress-user.cjs.entry.js
3 years ago
sc-wordpress-user.cjs.entry.js.map
3 years ago
store-79bafee3.js
3 years ago
store-79bafee3.js.map
3 years ago
store-a92c3e74.js
3 years ago
store-a92c3e74.js.map
3 years ago
surecart.cjs.js
3 years ago
surecart.cjs.js.map
3 years ago
tax-39abdb3c.js
3 years ago
tax-39abdb3c.js.map
3 years ago
ui-c6cc5556.js
3 years ago
ui-c6cc5556.js.map
3 years ago
universe-874f42bb.js
3 years ago
universe-874f42bb.js.map
3 years ago
util-872b1a55.js
3 years ago
util-872b1a55.js.map
3 years ago
utils-806dad60.js
3 years ago
utils-806dad60.js.map
3 years ago
watchers-42477f79.js
3 years ago
watchers-42477f79.js.map
3 years ago
watchers-437b71fb.js
3 years ago
watchers-437b71fb.js.map
3 years ago
watchers-503cdd2a.js
3 years ago
watchers-503cdd2a.js.map
3 years ago
watchers-bce289f5.js
3 years ago
watchers-bce289f5.js.map
3 years ago
sc-subscription-switch.cjs.entry.js
207 lines
| 1 | 'use strict'; |
| 2 | |
| 3 | Object.defineProperty(exports, '__esModule', { value: true }); |
| 4 | |
| 5 | const index = require('./index-ac77ca60.js'); |
| 6 | const fetch = require('./fetch-b673a242.js'); |
| 7 | const lazy = require('./lazy-bc8baeab.js'); |
| 8 | const price = require('./price-d3e21aa4.js'); |
| 9 | const addQueryArgs = require('./add-query-args-17c551b6.js'); |
| 10 | |
| 11 | const scSubscriptionSwitchCss = ":host{display:block;position:relative}[hidden]{display:none !important}.subscriptions-switch{display:grid;gap:0.5em}.subscriptions-switch__switcher{background:rgba(0, 0, 0, 0.035);padding:2px;line-height:1;border-radius:var(--sc-border-radius-small)}"; |
| 12 | |
| 13 | const ScSubscriptionSwitch = class { |
| 14 | constructor(hostRef) { |
| 15 | index.registerInstance(this, hostRef); |
| 16 | this.query = undefined; |
| 17 | this.heading = undefined; |
| 18 | this.productGroupId = undefined; |
| 19 | this.productId = undefined; |
| 20 | this.subscription = undefined; |
| 21 | this.filterAbove = 4; |
| 22 | this.selectedPrice = undefined; |
| 23 | this.products = []; |
| 24 | this.prices = undefined; |
| 25 | this.filter = 'month'; |
| 26 | this.hasFilters = undefined; |
| 27 | this.showFilters = undefined; |
| 28 | this.loading = undefined; |
| 29 | this.busy = undefined; |
| 30 | this.error = undefined; |
| 31 | } |
| 32 | componentWillLoad() { |
| 33 | lazy.onFirstVisible(this.el, async () => { |
| 34 | try { |
| 35 | this.loading = true; |
| 36 | await Promise.all([this.getGroup(), this.getProductPrices()]); |
| 37 | } |
| 38 | catch (e) { |
| 39 | console.error(e); |
| 40 | if (e === null || e === void 0 ? void 0 : e.message) { |
| 41 | this.error = e.message; |
| 42 | } |
| 43 | else { |
| 44 | this.error = wp.i18n.__('Something went wrong', 'surecart'); |
| 45 | } |
| 46 | } |
| 47 | finally { |
| 48 | this.loading = false; |
| 49 | } |
| 50 | }); |
| 51 | this.handleSubscriptionChange(); |
| 52 | } |
| 53 | handleProductsChange() { |
| 54 | var _a; |
| 55 | this.prices = this.products |
| 56 | .map(product => { var _a; return (_a = product === null || product === void 0 ? void 0 : product.prices) === null || _a === void 0 ? void 0 : _a.data; }) |
| 57 | .flat() |
| 58 | .filter((v, i, a) => a.findIndex(t => t.id === v.id) === i) // remove duplicates. |
| 59 | .filter(price => !(price === null || price === void 0 ? void 0 : price.archived)); // remove archived |
| 60 | this.showFilters = ((_a = this.prices) === null || _a === void 0 ? void 0 : _a.length) > this.filterAbove; |
| 61 | } |
| 62 | handlePricesChange(val, prev) { |
| 63 | if (!(prev === null || prev === void 0 ? void 0 : prev.length) && (val === null || val === void 0 ? void 0 : val.length)) { |
| 64 | this.selectedPrice = val.find(price => { var _a, _b; return price.id === ((_b = (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.id); }); |
| 65 | } |
| 66 | this.hasFilters = { |
| 67 | ...this.hasFilters, |
| 68 | split: this.prices.some(price => price.recurring_interval === 'month' && (price === null || price === void 0 ? void 0 : price.recurring_period_count) && !(price === null || price === void 0 ? void 0 : price.archived)), |
| 69 | month: this.prices.some(price => price.recurring_interval === 'month' && !(price === null || price === void 0 ? void 0 : price.recurring_period_count) && !(price === null || price === void 0 ? void 0 : price.archived)), |
| 70 | year: this.prices.some(price => price.recurring_interval === 'year' && !(price === null || price === void 0 ? void 0 : price.archived)), |
| 71 | never: this.prices.some(price => (price.recurring_interval === 'never' || !price.recurring_interval) && !(price === null || price === void 0 ? void 0 : price.archived)), |
| 72 | }; |
| 73 | } |
| 74 | handleSubscriptionChange() { |
| 75 | var _a, _b; |
| 76 | this.filter = ((_b = (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.recurring_interval) || 'month'; |
| 77 | } |
| 78 | /** Get all subscriptions */ |
| 79 | async getGroup() { |
| 80 | if (!this.productGroupId) |
| 81 | return; |
| 82 | const products = (await await fetch.apiFetch({ |
| 83 | path: addQueryArgs.addQueryArgs(`surecart/v1/products/`, { |
| 84 | product_group_ids: [this.productGroupId], |
| 85 | expand: ['prices'], |
| 86 | ...this.query, |
| 87 | }), |
| 88 | })); |
| 89 | this.products = [...this.products, ...products]; |
| 90 | } |
| 91 | /** Get the product's prices. */ |
| 92 | async getProductPrices() { |
| 93 | if (!this.productId) |
| 94 | return; |
| 95 | const product = (await await fetch.apiFetch({ |
| 96 | path: addQueryArgs.addQueryArgs(`surecart/v1/products/${this.productId}`, { |
| 97 | expand: ['prices'], |
| 98 | }), |
| 99 | })); |
| 100 | this.products = [...this.products, ...[product]]; |
| 101 | } |
| 102 | async handleSubmit(e) { |
| 103 | var _a; |
| 104 | const { plan } = await e.target.getFormJson(); |
| 105 | const price = this.prices.find(p => p.id === plan); |
| 106 | const currentPlan = (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.price; |
| 107 | if ((price === null || price === void 0 ? void 0 : price.id) === currentPlan.id && !(price === null || price === void 0 ? void 0 : price.ad_hoc)) |
| 108 | return; |
| 109 | // confirm ad_hoc amount. |
| 110 | if (price === null || price === void 0 ? void 0 : price.ad_hoc) { |
| 111 | this.busy = true; |
| 112 | return window.location.assign(addQueryArgs.addQueryArgs(window.location.href, { |
| 113 | action: 'confirm_amount', |
| 114 | price_id: plan, |
| 115 | })); |
| 116 | } |
| 117 | // confirm plan. |
| 118 | this.busy = true; |
| 119 | window.location.assign(addQueryArgs.addQueryArgs(window.location.href, { |
| 120 | action: 'confirm', |
| 121 | price_id: plan, |
| 122 | })); |
| 123 | } |
| 124 | renderSwitcher() { |
| 125 | const hasMultipleFilters = Object.values(this.hasFilters || {}).filter(v => !!v).length > 1; |
| 126 | if (!hasMultipleFilters) |
| 127 | return; |
| 128 | if (!this.showFilters) |
| 129 | return; |
| 130 | return (index.h("sc-flex", { slot: "end", class: "subscriptions-switch__switcher" }, this.hasFilters.month && (index.h("sc-button", { onClick: () => (this.filter = 'month'), size: "small", type: this.filter === 'month' ? 'default' : 'text' }, wp.i18n.__('Monthly', 'surecart'))), this.hasFilters.week && (index.h("sc-button", { onClick: () => (this.filter = 'week'), size: "small", type: this.filter === 'week' ? 'default' : 'text' }, wp.i18n.__('Weekly', 'surecart'))), this.hasFilters.year && (index.h("sc-button", { onClick: () => (this.filter = 'year'), size: "small", type: this.filter === 'year' ? 'default' : 'text' }, wp.i18n.__('Yearly', 'surecart'))), this.hasFilters.never && (index.h("sc-button", { onClick: () => (this.filter = 'never'), size: "small", type: this.filter === 'never' ? 'default' : 'text' }, wp.i18n.__('Lifetime', 'surecart'))), this.hasFilters.split && (index.h("sc-button", { onClick: () => (this.filter = 'split'), size: "small", type: this.filter === 'split' ? 'default' : 'text' }, wp.i18n.__('Payment Plan', 'surecart'))))); |
| 131 | } |
| 132 | renderLoading() { |
| 133 | return (index.h("sc-choice", { name: "loading", disabled: true }, index.h("sc-skeleton", { style: { width: '60px', display: 'inline-block' } }), index.h("sc-skeleton", { style: { width: '80px', display: 'inline-block' }, slot: "price" }), index.h("sc-skeleton", { style: { width: '120px', display: 'inline-block' }, slot: "description" }))); |
| 134 | } |
| 135 | /** Is the price hidden or not */ |
| 136 | isHidden(price) { |
| 137 | // don't hide if no filters. |
| 138 | if (!this.showFilters) |
| 139 | return false; |
| 140 | // hide if the filter does not match the recurring interval. |
| 141 | let hidden = this.filter !== price.recurring_interval; |
| 142 | // if filter is never, show prices with non-recurring interval. |
| 143 | if (this.filter === 'never' && !(price === null || price === void 0 ? void 0 : price.recurring_interval)) { |
| 144 | hidden = false; |
| 145 | } |
| 146 | // if filter is split, show prices with a recurring_period_count. |
| 147 | if (this.filter === 'split' && (price === null || price === void 0 ? void 0 : price.recurring_period_count)) { |
| 148 | hidden = false; |
| 149 | } |
| 150 | return hidden; |
| 151 | } |
| 152 | renderContent() { |
| 153 | if (this.loading) { |
| 154 | return this.renderLoading(); |
| 155 | } |
| 156 | return (index.h("sc-choices", { required: true }, index.h("div", null, (this.prices || []) |
| 157 | .filter(price => !price.archived) |
| 158 | .filter(price => { var _a; return (price === null || price === void 0 ? void 0 : price.currency) === ((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.currency); }) |
| 159 | .map(price$1 => { |
| 160 | var _a, _b; |
| 161 | const currentPlan = ((_b = (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.id) === (price$1 === null || price$1 === void 0 ? void 0 : price$1.id); |
| 162 | const product = this.products.find(product => product.id === (price$1 === null || price$1 === void 0 ? void 0 : price$1.product)); |
| 163 | return (index.h("sc-choice", { key: price$1 === null || price$1 === void 0 ? void 0 : price$1.id, checked: currentPlan, name: "plan", value: price$1 === null || price$1 === void 0 ? void 0 : price$1.id, hidden: this.isHidden(price$1), onScChange: e => { |
| 164 | if (e.detail) { |
| 165 | this.selectedPrice = this.prices.find(p => p.id === (price$1 === null || price$1 === void 0 ? void 0 : price$1.id)); |
| 166 | } |
| 167 | } }, index.h("div", null, index.h("strong", null, (price$1 === null || price$1 === void 0 ? void 0 : price$1.name) || (product === null || product === void 0 ? void 0 : product.name))), index.h("div", { slot: "description" }, (price$1 === null || price$1 === void 0 ? void 0 : price$1.ad_hoc) ? (`${wp.i18n.__('Custom amount', 'surecart')} ${price.intervalString(price$1)}`) : (index.h(index.Fragment, null, index.h("sc-format-number", { type: "currency", currency: (price$1 === null || price$1 === void 0 ? void 0 : price$1.currency) || 'usd', value: price$1 === null || price$1 === void 0 ? void 0 : price$1.amount }), " ", price.intervalString(price$1, { showOnce: true })))), currentPlan && (index.h("sc-tag", { type: "warning", slot: "price" }, wp.i18n.__('Current Plan', 'surecart'))))); |
| 168 | })))); |
| 169 | } |
| 170 | buttonText() { |
| 171 | var _a, _b, _c, _d; |
| 172 | if ((_a = this.selectedPrice) === null || _a === void 0 ? void 0 : _a.ad_hoc) { |
| 173 | if (((_b = this.selectedPrice) === null || _b === void 0 ? void 0 : _b.id) === ((_d = (_c = this.subscription) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.id)) { |
| 174 | return wp.i18n.__('Update Amount', 'surecart'); |
| 175 | } |
| 176 | else { |
| 177 | return wp.i18n.__('Choose Amount', 'surecart'); |
| 178 | } |
| 179 | } |
| 180 | return wp.i18n.__('Next', 'surecart'); |
| 181 | } |
| 182 | render() { |
| 183 | var _a, _b, _c, _d, _e, _f, _g, _h; |
| 184 | // we are not loading and we don't have enough prices to switch. |
| 185 | if (!this.loading && ((_a = this.prices) === null || _a === void 0 ? void 0 : _a.length) < 2) { |
| 186 | if (!((_c = (_b = this.prices) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.ad_hoc)) { |
| 187 | return null; |
| 188 | } |
| 189 | } |
| 190 | // subscription is a payment plan. |
| 191 | if ((_d = this.subscription) === null || _d === void 0 ? void 0 : _d.finite) { |
| 192 | return (index.h("sc-alert", { type: "info", open: true }, wp.i18n.__('To make changes to your payment plan, please contact us.', 'surecart'))); |
| 193 | } |
| 194 | return (index.h("sc-dashboard-module", { heading: this.heading || wp.i18n.__('Update Plan', 'surecart'), class: "subscription-switch", error: this.error }, index.h("span", { slot: "end" }, this.renderSwitcher()), index.h("sc-form", { class: "subscriptions-switch", onScFormSubmit: e => this.handleSubmit(e) }, this.renderContent(), index.h("sc-button", { type: "primary", full: true, submit: true, loading: this.loading || this.busy, disabled: ((_f = (_e = this.subscription) === null || _e === void 0 ? void 0 : _e.price) === null || _f === void 0 ? void 0 : _f.id) === ((_g = this.selectedPrice) === null || _g === void 0 ? void 0 : _g.id) && !((_h = this.selectedPrice) === null || _h === void 0 ? void 0 : _h.ad_hoc) }, this.buttonText(), " ", index.h("sc-icon", { name: "arrow-right", slot: "suffix" })), this.busy && index.h("sc-block-ui", { style: { zIndex: '9' } })))); |
| 195 | } |
| 196 | get el() { return index.getElement(this); } |
| 197 | static get watchers() { return { |
| 198 | "products": ["handleProductsChange"], |
| 199 | "prices": ["handlePricesChange"], |
| 200 | "subscription": ["handleSubscriptionChange"] |
| 201 | }; } |
| 202 | }; |
| 203 | ScSubscriptionSwitch.style = scSubscriptionSwitchCss; |
| 204 | |
| 205 | exports.sc_subscription_switch = ScSubscriptionSwitch; |
| 206 | |
| 207 | //# sourceMappingURL=sc-subscription-switch.cjs.entry.js.map |