yireo / Yireo_GoogleTagManager2

Open Software License 3.0
148 stars 76 forks source link

Inconsistent price/value formatting #187

Closed anvanza closed 1 year ago

anvanza commented 1 year ago

Google defines all monetary values as "number" on the documentation. But in the json output this is sometimes a float, integer or a string.

For ex: The value of "view_cart" is generated like: number_format((float)$this->cartModel->getQuote()->getBaseGrandTotal(), 4)

The value of "purchase" is generated like: (float)$order->getGrandTotal()

The value of "add_payment_info" is generated like: $cart->getGrandTotal()

For products and items I've seen: return $this->priceFormatter->format((float)$price);

So Ideally all values should be just floats (and integers as 22.00 will automatically convert to 22). And not something like "value": "5,649.0000", (string with extra comma, from the view_cart)

jissereitsma commented 1 year ago

Good point. I have been receiving PRs all along and underway things got sloppy. The price formatter class was introduced exactly for that purpose, but it was never implemented everywhere properly. This is now fixed in the following commit: https://github.com/yireo/Yireo_GoogleTagManager2/commit/3f4bed991c4fdfe9b37368f451c09eecbc45746c It will be included in the next release.