Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit Stripe Link to checkout forms #9753

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/fix-9749-limit-stripe-link-to-checkout-forms
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Small fix for My Account billing address form.


24 changes: 13 additions & 11 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4345,20 +4345,22 @@ public function is_enabled_for_saved_payments( $payment_method_id ) {
* @return array WooCommerce checkout fields.
*/
public function checkout_update_email_field_priority( $fields ) {
$is_link_enabled = in_array(
Link_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
\WC_Payments::get_gateway()->get_payment_method_ids_enabled_at_checkout_filtered_by_fees( null, true ),
true
);
if ( is_checkout() || has_block( 'woocommerce/checkout' ) ) {
$is_link_enabled = in_array(
Link_Payment_Method::PAYMENT_METHOD_STRIPE_ID,
\WC_Payments::get_gateway()->get_payment_method_ids_enabled_at_checkout_filtered_by_fees( null, true ),
true
);

if ( $is_link_enabled && isset( $fields['billing_email'] ) ) {
// Update the field priority.
$fields['billing_email']['priority'] = 1;
if ( $is_link_enabled && isset( $fields['billing_email'] ) ) {
// Update the field priority.
$fields['billing_email']['priority'] = 1;

// Add extra `wcpay-checkout-email-field` class.
$fields['billing_email']['class'][] = 'wcpay-checkout-email-field';
// Add extra `wcpay-checkout-email-field` class.
$fields['billing_email']['class'][] = 'wcpay-checkout-email-field';

add_filter( 'woocommerce_form_field_email', [ $this, 'append_stripelink_button' ], 10, 4 );
add_filter( 'woocommerce_form_field_email', [ $this, 'append_stripelink_button' ], 10, 4 );
}
}

return $fields;
Expand Down
Loading