mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #1835 from woocommerce/PCP-2217-hide-apple-pay-google-pay-for-subscription-type-products
Hide Apple Pay & Google Pay for subscription type products (2217)
This commit is contained in:
commit
4fb9e50a91
10 changed files with 65 additions and 1 deletions
|
@ -42,6 +42,10 @@ class ApplepayButton {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.contextHandler.validateContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.log('Init', this.context);
|
||||
this.initEventHandlers();
|
||||
this.isInitialized = true;
|
||||
|
@ -263,7 +267,7 @@ class ApplepayButton {
|
|||
switch (this.context) {
|
||||
case 'product':
|
||||
// Refresh product data that makes the price change.
|
||||
this.productQuantity = document.querySelector('input.qty').value;
|
||||
this.productQuantity = document.querySelector('input.qty')?.value;
|
||||
this.products = this.contextHandler.products();
|
||||
this.log('Products updated', this.products);
|
||||
break;
|
||||
|
|
|
@ -9,6 +9,13 @@ class BaseHandler {
|
|||
this.ppcpConfig = ppcpConfig;
|
||||
}
|
||||
|
||||
validateContext() {
|
||||
if ( this.ppcpConfig?.locations_with_subscription_product?.cart ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
shippingAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,13 @@ import CheckoutActionHandler
|
|||
|
||||
class PayNowHandler extends BaseHandler {
|
||||
|
||||
validateContext() {
|
||||
if ( this.ppcpConfig?.locations_with_subscription_product?.payorder ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
shippingAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@ import BaseHandler from "./BaseHandler";
|
|||
|
||||
class SingleProductHandler extends BaseHandler {
|
||||
|
||||
validateContext() {
|
||||
if ( this.ppcpConfig?.locations_with_subscription_product?.product ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
transactionInfo() {
|
||||
const errorHandler = new ErrorHandler(
|
||||
this.ppcpConfig.labels.error.generic,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue