Merge pull request #374 from woocommerce/PCP-425-save-your-credit-card-shouldnt-b

Do not display save credit card if subscription in the cart
This commit is contained in:
Emili Castells 2021-11-22 11:24:39 +01:00 committed by GitHub
commit 016d72683a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 26 deletions

View file

@ -3,16 +3,19 @@
= 1.6.2 - TBD =
* Fix - Order of WooCommerce checkout actions causing incompatibility with AvaTax address validation #335
* Fix - Can't checkout to certain countries with optional postcode #330
* FIx - Prevent subscription from being purchased when saving payment fails #308
* FIx - Guest users must checkout twice for subscriptions, no smart buttons loaded #342
* FIx - Failed PayPal API request causing strange error #347
* FIx - PayPal payments page empty after switching packages #350
* FIx - Could Not Validate Nonce Error #239
* FIx - Refund via PayPal dashboard does not set the WooCommerce order to "Refunded" #241
* FIx - Uncaught TypeError: round() #344
* FIx - Broken multi-level (nested) associative array values after getting submitted from checkout page #307
* FIx - Transaction id missing in some cases #328
* FIx - Payment not possible in pay for order form because of terms checkbox missing #294
* Fix - Prevent subscription from being purchased when saving payment fails #308
* Fix - Guest users must checkout twice for subscriptions, no smart buttons loaded #342
* Fix - Failed PayPal API request causing strange error #347
* Fix - PayPal payments page empty after switching packages #350
* Fix - Could Not Validate Nonce Error #239
* Fix - Refund via PayPal dashboard does not set the WooCommerce order to "Refunded" #241
* Fix - Uncaught TypeError: round() #344
* Fix - Broken multi-level (nested) associative array values after getting submitted from checkout page #307
* Fix - Transaction id missing in some cases #328
* Fix - Payment not possible in pay for order form because of terms checkbox missing #294
* Fix - "Save your Credit Card" shouldn't be optional when paying for a subscription #368
* Fix - When paying for a subscription and vaulting fails, cart is cleared #367
* Fix - Fatal error when activating PayPal Checkout plugin #363
= 1.6.1 - 2021-10-12 =
* Fix - Handle authorization capture failures #312

View file

@ -199,14 +199,18 @@ class SmartButton implements SmartButtonInterface {
11
);
$subscription_helper = $this->subscription_helper;
add_filter(
'woocommerce_credit_card_form_fields',
function ( $default_fields, $id ) {
function ( array $default_fields, $id ) use ( $subscription_helper ) : array {
if ( is_user_logged_in() && $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) && CreditCardGateway::ID === $id ) {
$default_fields['card-vault'] = sprintf(
'<p class="form-row form-row-wide"><label for="vault"><input class="ppcp-credit-card-vault" type="checkbox" id="ppcp-credit-card-vault" name="vault">%s</label></p>',
esc_html__( 'Save your Credit Card', 'woocommerce-paypal-payments' )
);
if ( ! $subscription_helper->cart_contains_subscription() ) {
$default_fields['card-vault'] = sprintf(
'<p class="form-row form-row-wide"><label for="vault"><input class="ppcp-credit-card-vault" type="checkbox" id="ppcp-credit-card-vault" name="vault">%s</label></p>',
esc_html__( 'Save your Credit Card', 'woocommerce-paypal-payments' )
);
}
$tokens = $this->payment_token_repository->all_for_user_id( get_current_user_id() );
if ( $tokens && $this->payment_token_repository->tokens_contains_card( $tokens ) ) {

View file

@ -47,7 +47,7 @@ class SubscriptionHelper {
if ( ! isset( $item['data'] ) || ! is_a( $item['data'], \WC_Product::class ) ) {
continue;
}
if ( $item['data']->is_type( 'subscription' ) ) {
if ( $item['data']->is_type( 'subscription' ) || $item['data']->is_type( 'subscription_variation' ) ) {
return true;
}
}

View file

@ -84,16 +84,19 @@ Follow the steps below to connect the plugin to your PayPal account:
= 1.6.2 =
* Fix - Order of WooCommerce checkout actions causing incompatibility with AvaTax address validation #335
* Fix - Can't checkout to certain countries with optional postcode #330
* FIx - Prevent subscription from being purchased when saving payment fails #308
* FIx - Guest users must checkout twice for subscriptions, no smart buttons loaded #342
* FIx - Failed PayPal API request causing strange error #347
* FIx - PayPal payments page empty after switching packages #350
* FIx - Could Not Validate Nonce Error #239
* FIx - Refund via PayPal dashboard does not set the WooCommerce order to "Refunded" #241
* FIx - Uncaught TypeError: round() #344
* FIx - Broken multi-level (nested) associative array values after getting submitted from checkout page #307
* FIx - Transaction id missing in some cases #328
* FIx - Payment not possible in pay for order form because of terms checkbox missing #294
* Fix - Prevent subscription from being purchased when saving payment fails #308
* Fix - Guest users must checkout twice for subscriptions, no smart buttons loaded #342
* Fix - Failed PayPal API request causing strange error #347
* Fix - PayPal payments page empty after switching packages #350
* Fix - Could Not Validate Nonce Error #239
* Fix - Refund via PayPal dashboard does not set the WooCommerce order to "Refunded" #241
* Fix - Uncaught TypeError: round() #344
* Fix - Broken multi-level (nested) associative array values after getting submitted from checkout page #307
* Fix - Transaction id missing in some cases #328
* Fix - Payment not possible in pay for order form because of terms checkbox missing #294
* Fix - "Save your Credit Card" shouldn't be optional when paying for a subscription #368
* Fix - When paying for a subscription and vaulting fails, cart is cleared #367
* Fix - Fatal error when activating PayPal Checkout plugin #363
= 1.6.1 =
* Fix - Handle authorization capture failures #312