Wrong calculation when using custom product fields
-
Hi again
I’m still testing you free version before adopting the pro one, but I’m now stuck because I’m experiencing an issue when using product custom input fields. I’m using another plugin to add to cart (and to order) some product input data that a customer must fill in product page [ = Extra Product Options (Product Addons) for WooCommerce ], but i presume the issue is not dependent on that secondary plugin (it simply adds in a fast way some custom input fields I could anyway add in “coding way”).I try to explain the problem.
I have a product having some price x quantity settings (50-> 99, 100->199 and so on) and some text input custom fields the user MUST fill to provide us important product related additional info.
In this situation, the customer can add several times the same product to the cart if he fills the custom fields with different custom fields content. This is ok: same products with different custom fields have to be treated as different cart item and processed separately.But here I have an issue with quantity price calculation in cart, as hereafter detailed.
Let’s say we have a product X having 1 custom field and 2 price ranges, 20€ for qty 0 -> 100 and 10€ for qty 101 -> 200.
The first time I add to the cart 150 pcs of that product, setting it’s custom field to a value ‘A’: the cart correctly displays “Product X – custom field A – 150pcs – 1500€ (=150 x 10€)”
Now I add again the same product to the cart: this time the qty is 20 pcs but the custom field contains a different value ‘B’. The cart correctly displays this second separated item instance as “Product X – custom field B – 20pcs – 400€ (=20 x 20€)” BUT ALSO CHANGES THE PRICE FOR THE FIRST ITEM INSTANCE PREVIOULSY ADDED from the above correct one ( = “Product X – custom field A – 150pcs – 1500€ (=150 x 10€)”) to “Product X – custom field A – 150pcs – 3000€ (=150 x 20€)”Practically when I add a further instance of the same product but having a different custom field, the cart always uses the price detected for the quantity I have set for the last inserted instance recalculating the whole list of the same product instances in the cart (cart items having the same SKU but different custom fields), regardless the quantity each instance really has: in the above case, it uses the 20€ price also for the other item instance having 150 pcs in the cart (instead of the correct 10 € value)
Resuming:
I add twice the same product, but using different custom field values: in that way I get two separate items in cart, having the same sku but different custom field values.In this situation should have these prices in the cart:
1 instance ->> “Product X – custom field A – 150pcs – 1500€ (=150 x 10€)
2 instance ->> “Product X – custom field B – 20pcs – 400€ (=20 x 20€)BUT right now I have these ones:
1 instance ->> “Product X – custom field A – 150pcs – 3000€ (=150 x 20€)
2 instance ->> “Product X – custom field B – 20pcs – 400€ (=20 x 20€)As you can see, your plugin uses the last detected price, matched between qty (20pcs) and price (20€) derived from the last instance, to recalculate all previously inserted instances, also when the price should be different
The question now is: is there a way to avoid this, and get the current calculation when using product custom fields??? I understand this is NOT a WC standard, but many time a custom field is used in product enchantment, so it could be interesting to sove that issue.
I’m sorry, but I have not a live site to show you that live……. I hope you can understand my long explaining and help me addressing to a possible solution.
Waiting for you kindly reply
- The topic ‘Wrong calculation when using custom product fields’ is closed to new replies.