Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Line totals are occasionally missing from PPC Simulate Cart requests (3524) #2493

Open
jimjasson opened this issue Aug 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jimjasson
Copy link

jimjasson commented Aug 7, 2024

Describe the Bug

When PayPal is active on a store and Smart Buttons are enabled for the Single Product page and the Cart, then two AJAX requests run when viewing the single product page of a Simple Product:

Markup on 2024-08-07 at 13:58:04

If someone hooks into the woocommerce_cart_shipping_packages hook and inspect the cart items there, they would notice that in one of the requests the line totals are set and in another request they are not set, causing an inconsistency:

1/2 requests (missing line totals):

Markup on 2024-08-07 at 14:01:29

2/2 requests:

Markup on 2024-08-07 at 14:01:45

To Reproduce

  1. Enable only WooCommerce and PayPal Payments.
  2. Enable Smart buttons for the Single Product page and the Cart.
  3. Install this snippet:
add_filter( 'woocommerce_cart_shipping_packages', 'test_paypal_add_to_cart' );

function test_paypal_add_to_cart( $packages ) {
	
	$cart = WC()->cart->cart_contents;
	
 	foreach( $cart as $cart_item ) {
 		$logger = wc_get_logger();
		
 		$logger->log( 'info', $cart_item , array( 'source' => 'test_paypal_simple' ) );
 	}
	return $packages;
}
  1. Create a Simple Product.
  2. Open an incognito window.
  3. View the Simple Product.
  4. View the logs and check that the line totals are missing from some requests.

Expected Behavior

When woocommerce_cart_shipping_packages all calculations must have been completed and cart items should consistently have all line totals.

Actual Behavior

In some requests, the line totals are missing from the cart items.

Environment

Clean WordPress install with only WooCommerce and PayPal Payments active.

@InpsydeNiklas InpsydeNiklas changed the title Line totals are occasionally missing from PPC Simulate Cart requests Line totals are occasionally missing from PPC Simulate Cart requests (3524) Aug 12, 2024
@InpsydeNiklas InpsydeNiklas added the bug Something isn't working label Aug 13, 2024
@jimjasson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants