Woocommerce not diplaying correct price with "Math Formula" - wordpress

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?

Related

Calculation based on the price of the selected product in Woocommerce

How can I perform the instant update of the calculation according to the variable product price?
For a simple product, I can calculate the product price according to my own calculation algorithm with php, but if the product has variation, it will probably have to be calculated instantly according to the price of the selected product with javascript. How should I go about this?
If the commission rate is not empty, the calculation below gives the result I want for the simple product.
if(!empty($commission)){$result = $product->get_price()/ ((100-$commission)/100);}

WooCommerce Sort-by SKU - Get numeric order correct

I have a website running WooCommerce and on the Product Category page we have the option "Sort by SKU in Ascending order". The products have SKUs in the format of 4 Alpha and 2 Numeric, e.g. BLHS-20.
The issue we have is when the list of products in the Product Category page is sorted the SKUs aren't in true numeric order.
Example:
BLHS-1
BLHS-10
BLHS-11
BLHS-2
What code would we need to get the SKUs to sort as follows?
BLHS-1
BLHS-2
BLHS-10
BLHS-11
Thanks for any help given.
Ok, we have a workaround. Because the SKU field is a text field the simple fix is to find the largest numeric part of the SKU and for all smaller numbers add leading zeros.
Example:
BLHS-01
BLHS-02
BLHS-10
BLHS-11
This sorts correctly.

How can I add weight units to my quantity in woocommerce?

I would like to add a weight quantity input field on product pages that allow customer to change the item weight by clicking on a plus or minus buttons. For example, you want to buy 1.25kg of tomatoes. For that, you can just click the plus icon until it reaches 1.25kg or you can type 1.25 kg. Here is an example of what I am looking for (this one does not have the ability to insert your quantity though).
Currently, I have used the plugins WPC Product Quantity and WooCommerce Price Per Unit PRO, but the problem is that it does not show the "kg" unit after the quantity number. You can have a look at that over here
Is there a plugin or a custom code that I can insert to fix this issue?
Note: I have products, which use units "kg" and "tk". So the code/plugin should be able to fix this issue on a product basis. "tk" just means "piece" in Estonian.
You may try to change the quantity box from integer datatype to float/double datatype, So the customer can place float number like 0.25 or 0.5,
you can use settype($var,"double"); in your code.
if the kg is not showing you also can use concatenate to add "kg" to your return value.
you return your value with concatenate by adding this to the end of your return value:
. " kg"

Two different prices for the one product on the checkout page (bug)

The correct price for the product is €38 and VAT is included to the price #23%
In the products page the price 30.89 plus 23% = 30.894*1.23 = 37.99962
But when I add a product and go tho the cart, the total price and the cart prices are out by a cent
the cart is €38 but the check out is €38.01
I tried every combination possible to get both prices correct and I can get €37.99 and €40.01 but I can't get €40 in both carts.
I'm not sure how they could be different I thought they would be going by the same calculation but obviously not.
It looks like a rounding issue. Try increasing the number of decimals in WooCommerce > Settings > General

WooCommerce: Date as attribute term

I'm relatively new to using WooCommerce so all advice would be great.
I've got a number of inclass training course products I'm trying to sell. Each have multiple date offerings.
Is there a way I can set the attribute term to a date value or do I have to manually add every possible date?
Is there another way to solve this problem, I am just ignorant off?
Thank you!
When you add the products and while entering the product data in general tab you will see two fields REGULAR PRICE & SALE PRICE beside the SALE PRICE text box you will see the schedule click on it you will find the DATE fields from Date to Date variations in price you can set it from there. Here I set an Image
Here you will Find the date fields to set

Resources