Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Express Checkouts ignoring price modifications during woocommerce_before_calculate_totals #4124

Open
isitgeorge opened this issue Mar 20, 2025 · 3 comments
Labels
component: ECE Issues related to Express Checkout Element priority: medium The issue/PR is medium priority—it affects lots of customers substantially, but not critically.

Comments

@isitgeorge
Copy link

isitgeorge commented Mar 20, 2025

Describe the bug
I'm building functionality where the item price is calculated based on attributes provided by the customer (i.e. height/width inputs on product page). These attributes are intercepted during woocommerce_before_calculate_totals action, where the price is calculated and set on the item.

add_action('woocommerce_before_calculate_totals', function ($cart) {
  if (is_cart()) {
    foreach ($cart->cart_contents as $cartItemKey => $values) {
      $cart_item = $cart->cart_contents[$cartItemKey];    
      $cart_item['data']->set_price(50.00);
    }
  }
}, 10, 1);

In the example above, the item price in checkout is updated to 50.00 and works as expected for normal card payments. However for Express Checkout options the price reverts back to what is configured on the product itself.

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple product in WooCommerce with a price of 10.00
  2. Add the code snippet above
  3. Navigate to the cart, and the display item cost will be 50.00
  4. Navigate to checkout and selected an Express option
  5. The price displayed (within Apple Pay for example) will be 10.00 instead of 50.00

Expected behavior
I expected the item price in Express Checkout options (i.e. Apple Pay) to reflect that of what is displayed in normal checkout

Environment (please complete the following information):

  • WordPress Version: 6.7.2
  • WooCommerce Version: 9.7.1
  • Stripe Plugin Version: 9.3.1
  • Browser [e.g. chrome, safari] and Version: Safari 16.4

Answers I'm looking for:

  • Could modifying the price in the action woocommerce_before_calculate_totals be happening too late?
  • Is there a better action/filter I could be hooking into that the Express Checkouts use or some other work around?
  • How do Express Checkouts fetch the price and why wouldn't it reflect what is displayed in the normal checkout?

Related (stale) issues
#2322
#2304
woocommerce/woocommerce-paypal-payments#1422
woocommerce/woocommerce#29535

@PoeHaH
Copy link

PoeHaH commented Mar 21, 2025

It's so crazy they don't want to implement/fix this. Over the years, I've had to tell around 100 customers to disable the quick buy buttons.

@isitgeorge
Copy link
Author

It's so crazy they don't want to implement/fix this. Over the years, I've had to tell around 100 customers to disable the quick buy buttons.

@PoeHaH Absolutely! It seems like such fundamental functionality to get right.

Don't suppose you know any workarounds?

Cheers

@Mayisha Mayisha added priority: medium The issue/PR is medium priority—it affects lots of customers substantially, but not critically. component: ECE Issues related to Express Checkout Element labels Mar 27, 2025
@kingsleyinfo
Copy link

Reported in ticket ZD-9564860

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component: ECE Issues related to Express Checkout Element priority: medium The issue/PR is medium priority—it affects lots of customers substantially, but not critically.
Projects
None yet
Development

No branches or pull requests

4 participants