Woocommerce - Wrong rounded values in Cart - woocommerce

I have a problem with the round function (woocommerce) for the value in the cart.
Problem is that the value 8.4903€ is rounded to 8.50€. It should be 8.49€
Take a look a the captures:
In capture 1 I set the woocommerce to show 4 decimals in the prices so that we can see the real values.
In capture 2 I set the woocommerce to show 2 decimals. Here you will see that the rounded values are wrong.
How can I trace this issue? I already deactivate all plugins (except woocommerce, of course), so that I can be sure this issue is not caused by other plugin.
I already opened (week ago) an issue for this in the plugin author page, but nothing yet. So, I guess if we can sort this out with a function in the function.php file of my child theme.
I know how to use the php round() functions but I need help to target ALL woocommerce values in the cart.
---------------capture 1--
---------------capture 2--
---------------capture 3--

Fixed!. I just enabled 'Round tax at subtotal level, instead of rounding per line' and the issue is gone. Thank you #MujeebuRahman!
https://s.nimbusweb.me/share/2533555/4x99afoss5d7vtfny98w

Round tax at subtotal level, instead of rounding per line

Related

WooCommerce ignoring decimal price

I have a WooCommerce 7.0.0 shop for which I'm programmatically creating products.
The price of these products is calculated according to various user input values.
I've done it before on other sites without problem, but I'm currently facing an issue : when the calculated price is a float, on the review order table, the price is not displayed correctly, and I'm getting a notice : A non well formed numeric value encountered in class-wc-cart.php on line 2151
Eg. if the price is 5.24€, I get 5.00€ on the product detail, subtotal, and total of the cart.
However, the price is displayed correctly as 5.24€ in the back-office.
Also, it is stored correctly in database.
Here's 2 methods I've tried to save the price before getting to checkout :
// Method 1
$product->set_price($total);
$product->set_regular_price($total);
$product->save();
// Method 2
add_post_meta($pID, '_regular_price', $total);
add_post_meta($pID, '_price', $total);
I tried various casting and rounding methods before saving (flotval, number_format, sprintf('%.2F') ) to no avail.
I also tried both , and . separators on the WooCommerce settings.
I'm running out of ideas, I must have missed something obvious but as it is, I can't put my finger on it.
Maybe something has changed on the newer versions of WooCommerce ? The last version I've used where I created products in the same way without issue, was 6.3.1.
Any help is welcome :)
Thanks,

WooCommerce (4.8.0) WordPress (5.6) not saving the SKU value for Variable Product

I am afraid its a new issue.
Update the SKU value on main variable product is not shown, after successful update message.
While, update of each SKU value variation of this product succeeds.
I am using WooCommerce (4.8.0) WordPress (5.6)
Turned off all plugins, but Woocommerce - did not help.
Replaced theme to default 2020 - did not help.
Debug is ON and clean on all tests & No JS issues reported.
Any idea what might be the issue? or how to debug it?
Does your variation have a ton of variations? If so it's possible that not all fields are saved due to too many form fields being submitted at once.
Also see: https://docs.woocommerce.com/document/problems-with-large-amounts-of-data-not-saving-variations-rates-etc/#php-539-and-max_input_vars
You can edit your php.ini to allow more form-fields:
max_input_vars = 2000

WooCommerce - WooSquare Plus plugin - plus product variations must be an array

WooSquare plugin failed to synchronize products between WooCommerce and Square.
I had a look at the contents of the xxxx_woo_square_integration_logs table in the WordPress database. One of the log entries said - "variations must be an array". I had a brief look at the program that I thought was performing the synchronization, WooToSquareSynchronizer.php and it had a statement:
$product_variations = unserialize($productDetails['_product_attributes'][0]);
Despite variations having another meaning in WooCommerce, the code appears to suggest what we are talking about here is product attributes. I guessed that the code expects at least one attribute for each product. I added a single global attribute and then set that on each of my products. My products were then successfully synchronized. Note that this failure only occurred when creating products, not when updating products. Looking at the WooSquare plus documentation, product variations looked to managed with attributes but in my case, I was not using product variations.
P.S. Could someone with 1500 reputation please add "WooSquare plus" as a tag?
References:
https://apiexperts.io/documentation/woosquare-plus/ (NOT TO BE CONFUSED WITH WooSquare Pro!).
https://apiexperts.io/fast-support/
This is probably the free version - https://wordpress.org/support/plugin/woosquare/reviews/ - https://apiexperts.io/documentation/woosquare/

WooCommerce Variable Products - Can't choose products with '0' as an attribute - Error 'please choose all product options'

I've been developing an e-commerce store for a client using WooCommerce and I've come across a very strange issue. All of my products are variable products and I have set them up like this:
Variation 1 - Weight (0,0.5,1.0,1.5,2.0...5.0 in Kgs)
Variation 2 - Units (0,1,2,3,4,5...10)
Variation 3 - Cut Type (Ground, Slices, Whole etc)
I set the variations in such a way that a customer has to choose either Variation 1 or Variation 2 (weight or in units) and Variation 3. If they choose to purchase a product by Weight (Weight is great than '0') the only choice in 'Units' is 0 and vice versa. This worked for me for a day or two and stopped working, I keep getting an error 'please select product options'..
I then changed the '0' value to 'Zero' and the combination works, has anyone come across this problem before?
I tried to switch to the default theme of WP and shut off all plugins except WooCommerce but nothing works.
Any ideas?
Link to a product page - http://www.best-foods-for-fat-burning.com/wordpress/?product=%D7%90%D7%A1%D7%90%D7%93%D7%95
Thanks,
Ofer
This is a bug. I've tested it on several different installation. Using the latest versions of Woocommerce 2.0.20 and WordPress 3.8.1. The best thing to do is add additional info like 0-Kgs to your attribute slug and that solves the problem until woothemes fixes this bug.

Making the +/- Plus and Minus quantity button go up in increments of 12 in WooCommerce

I have been trying to solve what I thought might be an easy fix but I can't seem to find any information anywhere.
My problem is this:
I am setting up a wholesale store using WooCommerce with the min/max quantity and wholesale store plugins. I want to show a simple product with its single unit price (no problem) but as all products in the store are wholesale they can only be sold in (multiples) cartons of 6 or 12.
The min/max plugin allows me to set a minimum order quantity (say 12 items) but when I click on the -/+ Minus and Plus quantity selector to add another carton (another 12 items) it only adds one number (single item) at a time... E.g. 13, 14, 15, 16 and so on.
So my question is... "Is it possible to modify the 'quantity.php' file so the order quantities only go up in increments of 12?" (E.g. 12, 24, 36, 48, etc.)
I know I could simply set up and show the single carton cost as a simple product or do variables but my client wants to show a per unit price.
Thanks in advance for any feedback you may have.
There's no need to change core, nor even to use WooCommerce's template override. As Rashid points out, there is a filter in place for modifying this value. We just need to use it. Put this in a site-specific plugin.
add_filter( 'woocommerce_quantity_input_step', 'kia_quantity_input_step', 10, 2 );
function kia_quantity_input_step( $step, $product ){
return 6; // the will be the new step value
}
I'm sure you've moved on by now, but for posterity's sake this plug in might do what you are looking for:
http://www.woothemes.com/products/minmax-quantities/
I wanted similar functionality for my cart section which I achieved like this.
In the woocommerce template file forlders navigate to cart->cart.php file then search for something like this
apply_filters( 'woocommerce_quantity_input_step', '1', $_product );
Then change '1' to '12'. I believe it should be similar if you want to change on single product page.
This is quite hard to do without any hackery. If you don't mind changing a core file (which you will have to do again each time you update WooCommerce), you can do the following:
open wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.js
go to line 34 "$qty.val(currentVal + 1);" and change '1' into '12'.
do the same for the minus function on line 52
note that this affects ALL products!

Resources