We're syncing e-commerce orders (deals) using the ecom bridge and stumbled upon an error in how line item prices are calculated, if the quantity for the line item is more than 1. It seems like the total price is calculated either (not figured out exactly what's happening) like this:
(Produc price * Quantity – Discount) * Quantity
or:
(Product price * Quantity * Quantity) – (Discount * Quantity)
So we end up with a total that is close to what we would get if the quantity would be squared.
Going forward, if an hs_sync_amount value is passed in an Ecommerce Bridge sync message, it will update a line item's amount. Please let me know if your testing reveals different behavior.
At this time, however, these synced amount values are not surfaced in the UI. The team is currently working to identify the best way to avoid presenting misleading information for ecommerce line items.
Going forward, if an hs_sync_amount value is passed in an Ecommerce Bridge sync message, it will update a line item's amount. Please let me know if your testing reveals different behavior.
At this time, however, these synced amount values are not surfaced in the UI. The team is currently working to identify the best way to avoid presenting misleading information for ecommerce line items.
Apologies for the delayed response. I wanted to post an update before heading out for the weekend:
The team has corrected the additional calculation done to line items synced through the Ecommerce Bridge. Now, the amount should properly reflect the product of the price and quantity values you pass. Please let me know if you're still seeing the previous behavior.
We're still trying to get everyone on the same page regarding hs_sync_amount and how it should be another way you can set a line item's amount value without having to sync price and quantity.
I've been able to replicate both of the behaviors you described. They appear related to the same root behavior:
While a line item's amount is calculated correctly on the backend by multiplying price by quantity, there seems to be an additional calculation on the front end which multiplies amount by quantityagain.
Similarly, hs_sync_amount does propagate on the backend, but the front end still multiplies it by quantity, which is 0, so it appears as a null value. If you sync a quantity of 1, then HubSpot ignores the hs_sync_amount value and defers to the associated product's price.
I'll ask the relevant teams to investigate this behavior further. You should be able to set a line item's amount either with price and quantity together, or with hs_sync_amount alone. I appreciate your continued patience.
@Sean_Duane The only viable workaround I found is doing hubspotPrice = priceOfAllItems / quantity as mentioned above, but this is basically a hack and is vulnerable to rounding errors. I think clearly there's a bug in HubSpot regarding how price and quantity are being multiplied.
Also, if I sync directly into hs_sync_amount, and don't sync a price or quantity, the line item shows up in HubSpot with the default price from the Product library, and a quantity of zero, and a total price of zero as well.
@Sean_Duane I am having a similar issue. I am trying to sync Line Items, and the Unit Price and Total price are not being calculated correctly, based on the values I am transmitting.
Here is a sample sync request for a line item with a price of 17.0 and a quantity of 3:
However in my associated HubSpot deal under "Products", this line item is showing a unit price of $51 (that's the $17 x 3), and is then multiplying this number by the quantity AGAIN, for a Total Price of $153 for the line item (when it should just be the $51).
What fields/values should I be syncing, in order to simply get the correct amount for price x quantity for a line item?
I think we've figured out most of what's happening now. A few questions remain though:
Preferably, we'd like to simply sync the line item amount from the ecom store, overruling the calculation that is made (price * quantity) in HubSpot. The reason is that we don't get the single quantity prices from the ecom, but the total line item amount. Hence, in order for us to set the line item price in HubSpot, we'd need to divide that amount by the quantity, which possibly could lead to discrepancies in how the values are rounded.
So the question is if it somehow is possible to set line item amounts manually? Or do we have to set a price for a single quantity and let HubSpot calculate the amount? In our testing it seems like if we set the amount property to a value, it is treated as the price and multiplied with the quantity and put as the line item amount.
Here we've made the following Json call: [{"integratorObjectId":"4607c40d89714f1289d16f775cfc162b_VKBA_1307_1","action":"UPSERT","changeOccurredTimestamp":1540285945198,"propertyNameToValues":{"LitiumDealId":"4607c40d89714f1289d16f775cfc162b","LitiumProductId":"VKBA_1307_1","quantity":1.0,"price":10.0,"discount":0.0000}}]
On a related note, the price of the product that is referenced in this line item is set to $200 in the product library. How is this price used? It seems like it doesn't matter what the price is set to on a product level since it will be given a price on the line item anyway.
@shamash Thanks for the detailed response, it's helpful.
I hear your point about wanting to set amount directly. I'll pass that along and try to come up with a stronger answer about syncing to line items.
To answer your question: It's preferred to set pricequantity and optionally discount, and let hubspot calculate and set the amount from those.
Curious: Do you get the quantity of line items, and the price of all line items? Could you do hubspotPrice = priceOfAllItems / quantity ?
If that still wont work go ahead and sync into hs_sync_amount. This will in turn set amount, and is the preferred way to set amount directly via ecommbridge, thus bypassing the need to set price and quantity
Yes, we can calculate the price for a single quantity, but this is where we might end up with discrepancies, first dividing and then letting HubSpot multiply. How many decimals are handled by HubSpot? This is not critical but can add up to confusing discrepancies on a long term basis.
Also, as I asked in my previous post, it would be great if you could provide an explanation of product price. In what instances would that price be used (other than as a fallback for line item price as it seems to be in the example I provided)? I imagine it's also used if we reference a product in a marketing email for example? Other cases?
Sorry for the late reply, we've been trying to figure out if we're doing something wrong on our end (which probably is the case). So we have the following line item properties:
Price: which we believe refers to the price for a single quantity of the product (which is referred to through the hs_product_id property) Amount: which we believe is calculated in HubSpot by multiplying the value in the Price property with the value in the Quantity property. Is it possible to set this property manually so that it's not calculated? Sync amount: described as "The amount set by Ecommerce sync" which we guess is the property to be used if you want to overrule the calculated Amount property.
Please fill in or elaborate on the correct way to set up line items regarding pricing, quantity, discount, taxes and totals. Thank you!
As I understand it, Line Items have the following properties used in the following way: price - price per line item discount - discount per line item quantity - number of line items amount - (price * quantity) - (discount * quantity)
Do those values line up with what you should be seeing?
If not, can you provide a couple values and the resulting amount you expect to see, and I can try to dig in more tommorow
Edit: Apologies about Sync Amount, you'll see an announcement about that shortly. Basically it's the same as amount, and amount will be discouraged in the future.