Created
July 15, 2024 04:18
-
-
Save braddalton/45e6e8d2f4232077039ffe4915886090 to your computer and use it in GitHub Desktop.
Enable Google Pay and Apple Pay for event product type https://wpsites.net/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function enable_google_apple_pay_for_event_tickets($available_gateways) { | |
if (is_admin()) return $available_gateways; | |
global $product; | |
if (!$product) return $available_gateways; | |
// Check if the product is an event ticket | |
$is_event_ticket = has_term('event', 'product_cat', $product->get_id()); | |
if ($is_event_ticket) { | |
if (isset($available_gateways['stripe'])) { | |
$available_gateways['stripe']->supports[] = 'apple_pay'; | |
$available_gateways['stripe']->supports[] = 'google_pay'; | |
} | |
} | |
return $available_gateways; | |
} | |
add_filter('woocommerce_available_payment_gateways', 'enable_google_apple_pay_for_event_tickets'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment