Skip to content

Decimal points being ignored for add_to_cart WooCommerce items #10972

@jamesozzie

Description

@jamesozzie

Bug Description

As reported by one user in the support forums, when we're recording add_to_cart events within Site Kit for WooCommerce products (via Enhanced Conversion Tracking), decimal points are being ignored. For example, a price of 1.99 is being passed with a price of 199.

I have been able to reproduce this on a couple of test sites, testing via dev tools and tagassistant.google.com.

Image

Image

We are using a get_formatted_price function without our codebase, which could be reviewed.

The user mentioned this occurs variable type products, although I can reproduce the behavior on single set priced items also. See the recording below. There is a standard priced item, costing 543,210.99. This appears without decimal points, as 54321099.

The recording below demonstrates the price ignoring the decimal points on a tastewp site (variable price product).
https://github.com/user-attachments/assets/7ccd7c26-830c-4b2d-9a34-a9c4a3e57a1f

The recording below demonstrates the price ignoring the decimal points on sample test site. (set price product).

5d2c5cc7-f586-4d9e-9b0e-9b71f9c2dc7d.webm

Steps to reproduce

  1. Set up a site with Site Kit active, and Enhanced Conversion Tracking enabled
  2. Set up WooCommerce and add a product with a price
  3. Visit your site and add the product to your cart, triggering the add_to_cart event
  4. Check the price that's passed

Additional Context

  • Site Kit 1.154.0 was the first report
  • This may not be specifically a Site Kit issue. It could be WP Core, Woo or something else
  • There are other examples, screenshots and recordings present on the related WordPress support forum topic

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions