WooCommerce Apple Pay: Add More Supported Product Types
Apple Pay is now available for WooCommerce via our Stripe add-on. That is pretty sick to tell you the truth. But by default, only some product types are supported, and I’m sure you’d like to add some more right?
So, yes, by default, Apple Pay for WooCommerce supports only variable products and simple products, but let’s say you are using WP Job Manager and you want to propose Apple Pay to pay for a job listing, well we got you covered by introducing a new filter! You can now easily add Apple Pay supports using this code:
<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Add new supported product types to Apple Pay
* This sample adds WP Job Manager supports,
* you can add your own product type in the array.
*
* @return array
*/
function wc_stripe_apple_pay_add_supported_types() {
return array(
'simple',
'variable',
'variation',
'Job_package',
'Job_package_addon'
);
}
add_filter( 'wc_stripe_payment_request_supported_types', 'wc_stripe_apple_pay_add_supported_types' );
/*
* For previous versions of Stripe replace the line above by the line below without the starting "//".
//add_filter( 'wc_stripe_apple_pay_supported_types', 'wc_stripe_apple_pay_add_supported_types' );
EDIT: please note that in the latest version you have to use the following hook: wc\_stripe\_payment\_request\_supported\_types instead of wc\_stripe\_apple\_pay\_supported\_types.
Of course, you can add your own custom product types, it’s not limited to WP Job Manager! Simply add your product types to the array and you’re good to go!