Skip to content

Instantly share code, notes, and snippets.

@braddalton
Created July 15, 2024 04:18
Show Gist options
  • Save braddalton/45e6e8d2f4232077039ffe4915886090 to your computer and use it in GitHub Desktop.
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/
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