'Woocommerce not diplaying correct price with "Math Formula"

I'm using WooCommerce and also I'm using "Global Extra Product Options". I'm trying to calculate a custom price based on two "date field".

In the second field I set as price the result of the following formula:

abs((({this.value}-{date1.value})/1000000)*{product_price})

I can't use datediff() so I had to be creative on how to get the number of days between two day (hence the /1000000).

Using this formula on the product page the price is display correctly (eg. for two days it would display € 2Price). When I go to the my cart the final price is deducted by a value equal to the previously calculated price for field2. (eg. the final price would be: € FinalPrice - € 2Price)

I'm messing around with the options but I can't find a solution, am I doing something wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source