woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
235 stars 206 forks source link

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

Open roskno opened 4 months ago

roskno commented 4 months ago

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):

aheckler commented 4 months ago

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. :)