mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-10 08:26:55 +08:00
Hide non updatable form fields if subscription product connected to PayPal
This commit is contained in:
parent
8c407546a3
commit
09c7537e48
3 changed files with 15 additions and 9 deletions
|
@ -91,6 +91,9 @@ class SingleProductBootstap {
|
||||||
}
|
}
|
||||||
|
|
||||||
priceAmountIsZero() {
|
priceAmountIsZero() {
|
||||||
|
if(subscriptionHasPlan()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const price = this.priceAmount();
|
const price = this.priceAmount();
|
||||||
return !price || price === 0;
|
return !price || price === 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,15 @@ document.addEventListener(
|
||||||
const subscriptionPeriod = document.querySelector('#_subscription_period');
|
const subscriptionPeriod = document.querySelector('#_subscription_period');
|
||||||
subscriptionPeriod.setAttribute('disabled', 'disabled');
|
subscriptionPeriod.setAttribute('disabled', 'disabled');
|
||||||
|
|
||||||
const subscriptionLength = document.querySelector('#_subscription_length');
|
const subscriptionLength = document.querySelector('._subscription_length_field');
|
||||||
subscriptionLength.setAttribute('disabled', 'disabled');
|
subscriptionLength.style.display = 'none';
|
||||||
|
|
||||||
const subscriptionTrialLength = document.querySelector('#_subscription_trial_length');
|
const subscriptionTrial = document.querySelector('._subscription_trial_length_field');
|
||||||
subscriptionTrialLength.setAttribute('disabled', 'disabled');
|
subscriptionTrial.style.display = 'none';
|
||||||
|
|
||||||
const subscriptionTrialPeriod = document.querySelector('#_subscription_trial_period');
|
|
||||||
subscriptionTrialPeriod.setAttribute('disabled', 'disabled');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const unlinkBtn = document.getElementById('ppcp_unlink_sub_plan');
|
const unlinkBtn = document.getElementById('ppcp_unlink_sub_plan');
|
||||||
unlinkBtn.addEventListener('click', (event)=>{
|
unlinkBtn?.addEventListener('click', (event)=>{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
unlinkBtn.disabled = true;
|
unlinkBtn.disabled = true;
|
||||||
const spinner = document.getElementById('spinner-unlink-plan');
|
const spinner = document.getElementById('spinner-unlink-plan');
|
||||||
|
@ -59,6 +56,9 @@ document.addEventListener(
|
||||||
const planUnlinked = document.getElementById('pcpp-plan-unlinked');
|
const planUnlinked = document.getElementById('pcpp-plan-unlinked');
|
||||||
planUnlinked.style.display = 'block';
|
planUnlinked.style.display = 'block';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
location.reload();
|
||||||
|
}, 1000)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,7 +56,10 @@ trait FreeTrialHandlerTrait {
|
||||||
|
|
||||||
$product = wc_get_product();
|
$product = wc_get_product();
|
||||||
|
|
||||||
if ( ! $product || ! WC_Subscriptions_Product::is_subscription( $product ) ) {
|
if (
|
||||||
|
! $product || ! WC_Subscriptions_Product::is_subscription( $product )
|
||||||
|
|| $product->get_meta( '_ppcp_enable_subscription_product' ) === 'yes'
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue