WooCommerce ignoring decimal price - wordpress

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,

Related

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 - Wrong rounded values in Cart

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

Customer segmentation price list does not work as expected in basket and checkout

The problem
We have created a customer segment and linked both a customer and a price list to this customer segment. The linked price list defines a special price of $5 for one of the products. This product has a 'default' price of $10.
When I login to the storefront with a user that belongs to customer segment, I see the correct price of $5 on the PDP. However once this product is added to the basket, it shows the 'default' product price of $10 in the minicart and on the cart page. I would expect to see $5 there as well.
Technical information
The (correct) price on the PDP is retrieved directly from the ProductBO by using the default ISProductPrice module which links to the default ProductPrice.isml.
<ISProductPrice
ProductBO="#ProductBO#"
Currency="#CurrentRequest:Currency#"
ShowInformationalPrice="true"
RichSnippetsEnabled="#RichSnippetsEnabled#"
>
The (wrong) price on the cart page is retrieved from the BasketComputedProductLineItemBO with the following (default ISH) code
<isif condition="#PriceDisplayType EQ 'net'#">
<isprint value="#PLI:SingleBasePriceNet#">
<iselse/>
<isprint value="#PLI:SingleBasePriceGross#">
</isif>
What I've tried so far
Clear cookies/cache to make sure we have a completely new basket
Made sure the Customer Segmentation Service is enabled (default ISH service).
Tried all the different methods to fetch a price from the BasketComputedProductLineItemBO
Added a couple of different products to the price list
Added a couple of different customers to the customer segment
Ran a search index
Tried to reproduce the issue on the ISH demo server
Checked the documentation on customer segmentation from the ISH support page
Tried to add a customer to the price list directly instead of a customer segment. When doing it this way, everything seems to work as expected.
At this point I'm completely stuck. Any help on how to go from here would be greatly appreciated.
Check this
https://support.intershop.com/kb/index.php/Display/IS-22923
If you search on segment on the support for version 7.9 then you get few bugs. Disable the dynamic segment service because it is buggy. See if that work or else i think you really do have a platform bug here.
Also a good idea to upgrade to the lastest minor version.

WooCommerce - Change customer order after it has been placed and paid

Using three plugins:
WooCommerce
Subscriptio
WooEvents
I have created a product which allows for a customer to pay for an event over five instalments.
A customer has placed an order and made their first of the five payments via PayPal and has then contacted me to advise they have booked the wrong event.
The correct event is exactly the same except the dates are a month sooner.
I have added the following snippet to be able to edit 'processing' orders:
add_filter( 'wc_order_is_editable', 'wc_make_processing_orders_editable', 10, 2 );
function wc_make_processing_orders_editable( $is_editable, $order ) {
if ( $order->get_status() == 'processing' ) {
$is_editable = true;
}
return $is_editable;
}
From the order screen within the back-end of WordPress I can see that the the order can be edit by way of removing the product from the order or editing the meta data and cost.
The correct product that should have been ordered has a different product/variation ID.
My question is simply:
Should I remove the incorrectly ordered product from the order and add the correct product (both have the same properties with the exception of the courses dates); or
Should I just change the meta data and increase the stock levels for the incorrectly product back to X and reduce the stock level for the correct product?
Your second option is much better. Change the meta from database if its accessible and then manage the stock accordingly.
I have not yet done this, but according to this exchange ...
How can I add a product to an existing and paid Woocommerce order?
... you can set the order status to "On Hold" and make changes to the order itself. I presume you would then return the status to "Processing".
I would expect that if the application permits those changes, then it would be doing the background meta changes to inventory levels, etc., and spare you the problem of doing so (and the potential errors that may occur when messing with the data tables outside of the application).
Like I said, I haven't done this. But it might be worthwhile doing a little test to make sure it works as it seems to be described in the answer to the other question.
J

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.

Resources