Skip to content

Commit

Permalink
Fix js problem
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuesken committed Dec 20, 2024
1 parent 0131911 commit af08ad5
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ document.addEventListener( 'DOMContentLoaded', () => {
};

const checkSubscriptionPeriodsInterval = (period, period_interval, linkBtn) => {
if ( ! linkBtn) {
return;
}
if (
( period === 'year' && parseInt( period_interval ) > 1 ) ||
( period === 'month' && parseInt( period_interval ) > 12 ) ||
Expand All @@ -88,15 +91,15 @@ document.addEventListener( 'DOMContentLoaded', () => {

const setupProducts = () => {
jQuery( '.wc_input_subscription_period' ).on( 'change', (e) => {
const linkBtn = e.target.parentElement.parentElement.parentElement.querySelector('input[name="_ppcp_enable_subscription_product"]');
const linkBtn = e.target.parentElement.parentElement.parentElement.parentElement.querySelector('input[name="_ppcp_enable_subscription_product"]');
const period_interval = e.target.parentElement.querySelector('select.wc_input_subscription_period_interval')?.value;
const period = e.target.value;

checkSubscriptionPeriodsInterval(period, period_interval, linkBtn);
});

jQuery( '.wc_input_subscription_period_interval' ).on( 'change', (e) => {
const linkBtn = e.target.parentElement.parentElement.parentElement.querySelector('input[name="_ppcp_enable_subscription_product"]');
const linkBtn = e.target.parentElement.parentElement.parentElement.parentElement.querySelector('input[name="_ppcp_enable_subscription_product"]');
const period_interval = e.target.value;
const period = e.target.parentElement.querySelector('select.wc_input_subscription_period')?.value;

Expand Down

0 comments on commit af08ad5

Please sign in to comment.