woocommerce/woocommerce-gateway-stripe

Products with custom product types will be added with price 0 to the cart when using the Apple Pay button

Opened this issue · 1 comments

Describe the bug
The WC_Stripe_Payment_Request::ajax_add_to_cart() function won't allow custom product-type products to be added to the cart. It will return 0 as the price to the Apple Pay modal (It seems to work properly with Google Pay).

The Google and Apple Pay buttons appear on the custom product page because we used the 'wc_stripe_payment_request_supported_types' filter to add our types.

Product types allowed:
variable
variable-subscription
simple
variation
subscription
subscription_variation

Any additional type won't work.

To Reproduce
Steps to reproduce the behaviour:

  1. Apple Pay must be enabled in the plugin and configured in Stripe.
  2. Go to a custom-type product page on the front end using a Mac (Safari required) or an iPhone with Apple Pay enabled.
  3. Click on the Apple Pay button.
  4. The modal pops up with the correct price set, but it connects to the add_to_cart function and replaces the price by 0

Expected behaviour
It should check and set the correct price for all product types. Maybe two filters could be added, one for parent products and the other for simple products.

Screenshots
The Apple Pay button
image
The modal with the correct price
image
The modal after refreshing the price using the ajac_add_to_cart function
image

Environment (please complete the following information):

  • WordPress Version: 6.5.4
  • WooCommerce Version: 8.9.3
  • Stripe Plugin Version: 8.3.1
  • Browser: Safari 17.5

My guess is that just adding a custom product type to wc_stripe_payment_request_supported_types isn't enough. There's likely other work that needs to be done to make it work with Apple Pay, but I'll let our devs provide a more detailed answer. :)