Wrong value for productPriceWithTaxes and SKU feautre
-
Hi there,
Thanks for the much needed backend implementation.
However I have one issue to report and one ‘feature request’.
I’ve been running the plugin alongside the client GA and the ecommerce tracking is much more accurate but in GA the transaction details show that the prices are being sent the wrong way.
It has to be unit prices, not subtotals since GA multiplies the given price with the quantity.
Also most of the time the WP id for the product is not very helpful if one tries to create reports so I added the functionality to have the SKU as an id:
Here’s the part of class_nsc_gabt_collect_data_order.php:97 I modified so the prices are correct and the SKU is used if it exists:
$product = new WC_Product($orderItem->get_product_id()); $productPriceWithTaxes = $orderItem->get_subtotal() + $orderItem->get_subtotal_tax(); $productPriceWithTaxes = $productPriceWithTaxes / $orderItem->get_quantity(); $productPriceWithTaxes = $this->format_number($productPriceWithTaxes); $sku = product->get_sku(); $ga_order_items[$productIndex]["id"] = (!empty($sku)) ? $sku : $orderItem->get_product_id(); $ga_order_items[$productIndex]["name"] = $orderItem->get_name(); $ga_order_items[$productIndex]["qty"] = $orderItem->get_quantity(); $ga_order_items[$productIndex]["productPriceWithTaxes"] = $productPriceWithTaxes; $ga_order_items[$productIndex]["variation_id"] = $orderItem->get_variation_id(); $ga_order_items[$productIndex]["categories"] = strip_tags(wc_get_product_category_list($orderItem->get_product_id())); $ga_order_items[$productIndex]["tags"] = strip_tags(wc_get_product_tag_list($orderItem->get_product_id())); $productIndex = $productIndex + 1;
Please consider updating the plugin.
Thanks,
ákos
- The topic ‘Wrong value for productPriceWithTaxes and SKU feautre’ is closed to new replies.