Rounding Approx Price and Approx Amount
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from sammie on November 7, 2020, 09:05Hi,
I am currently testing out your free plugin on a staging site for 1 extra currency and will most probably be purchasing your premium plugin for the extra currencies we will need on the live site.
By the way - I've tested out a few currency plugins and yours seems to be (by far) the most useful and complete solution - bravo! :)
I have tested using the plugin to add approx prices based on Geo IP, but show AUD always as the main price. I have managed to get this working using your tips and snippets (yay!).
Now I need to round the approx prices to the nearest 5c or 5p so that the prices look appealing on the front end for the customer. I tried some of your rounding snippets, however these round the main price, not the approx. prices.
I'd love to get a solution to rounding the approx. price and the approx. amounts. I would really appreciate your help on this.
Thanks,
Sammie
Hi,
I am currently testing out your free plugin on a staging site for 1 extra currency and will most probably be purchasing your premium plugin for the extra currencies we will need on the live site.
By the way - I've tested out a few currency plugins and yours seems to be (by far) the most useful and complete solution - bravo! :)
I have tested using the plugin to add approx prices based on Geo IP, but show AUD always as the main price. I have managed to get this working using your tips and snippets (yay!).
Now I need to round the approx prices to the nearest 5c or 5p so that the prices look appealing on the front end for the customer. I tried some of your rounding snippets, however these round the main price, not the approx. prices.
I'd love to get a solution to rounding the approx. price and the approx. amounts. I would really appreciate your help on this.
Thanks,
Sammie
Quote from sammie on November 8, 2020, 07:15I meant to say in my previous post. I did see this in the forum: https://pluginus.net/support/topic/rounding-aproximate-price-value-and-shipping-rates/
But I need to know what code to place in that file. Do I simply add the below code in place of some code in one of the plugin files?
global $WOOCS; if($WOOCS->current_currency=="RUB") { add_filter('woocs_raw_woocommerce_price', function($price) { if (($price <= 10)) { $price = round($price / 10, 0) * 10; return $price; } else { $price = ceil($price/10) * 10; return $price; } });}What do I replace with this code please? Or is there a hook snippet that I can place in my snippets plugin or functions.php?
Sorry, it would be great if you can be specific about what I need to do to achieve this.
Many thanks,
Sam
I meant to say in my previous post. I did see this in the forum: https://pluginus.net/support/topic/rounding-aproximate-price-value-and-shipping-rates/
But I need to know what code to place in that file. Do I simply add the below code in place of some code in one of the plugin files?
global $WOOCS;
if($WOOCS->current_currency=="RUB") {
add_filter('woocs_raw_woocommerce_price', function($price) {
if (($price <= 10))
{
$price = round($price / 10, 0) * 10;
return $price;
} else
{
$price = ceil($price/10) * 10;
return $price;
}
});}What do I replace with this code please? Or is there a hook snippet that I can place in my snippets plugin or functions.php?
Sorry, it would be great if you can be specific about what I need to do to achieve this.
Many thanks,
Sam
Quote from Pablo Borysenco on November 9, 2020, 11:38Hello Sam
Add this code to functions.php:
add_filter('woocs_raw_woocommerce_price', function($price) { $price = round($price * 2, 1) / 2; return $price; });
Hello Sam
Add this code to functions.php:
add_filter('woocs_raw_woocommerce_price', function($price) {
$price = round($price * 2, 1) / 2;
return $price;
});Quote from sammie on November 9, 2020, 14:19Thanks for your reply, Pablo. I really appreciate it.
Unfortunately, the code you gave me just seems to round the main price. I do not need it to round the main price because I have set WOOCS to only show AUD as the main prices.
I only want to round the approx price and approx amount numbers.
Like here: https://share.getcloudapp.com/llu2pgpy
See how they're ugly numbers with random cents. I would like to round those to 5c. So that the example says "Approx. US$313.60" (or US$313.55, I don't really mind if it rounds up or down).
Is this possible?
Sorry if I wasn't clear enough before.
I appreciate your help.
thanks :)
Sam
Thanks for your reply, Pablo. I really appreciate it.
Unfortunately, the code you gave me just seems to round the main price. I do not need it to round the main price because I have set WOOCS to only show AUD as the main prices.
I only want to round the approx price and approx amount numbers.
Like here: https://share.getcloudapp.com/llu2pgpy
See how they're ugly numbers with random cents. I would like to round those to 5c. So that the example says"Approx. US$313.60" (or US$313.55, I don't really mind if it rounds up or down).
Is this possible?
Sorry if I wasn't clear enough before.
I appreciate your help.
thanks :)
Sam
Quote from Pablo Borysenco on November 10, 2020, 11:52Hello Sam
Try this code
add_filter('woocs_raw_woocommerce_price', function($price) { global $WOOCS; if($WOOCS->current_currency=="USD") { $price = round($price * 2, 1) / 2; } return $price; });
Hello Sam
Try this code
add_filter('woocs_raw_woocommerce_price', function($price) {
global $WOOCS;
if($WOOCS->current_currency=="USD") {
$price = round($price * 2, 1) / 2;
}
return $price;
});Quote from sammie on November 10, 2020, 15:06Thank you again Pablo.
I used your code - thank you.
This seems to be working on the cart and checkout pages, so we are making progress. :)
However, it is not working on the archive or product pages (I think this is Approx. Price). So it seems to be working on Approx. Amount, but not on Approx. Price.
Individual Product Page: https://share.getcloudapp.com/NQu10B1R (rounding not working)
Checkout page: https://share.getcloudapp.com/X6ud1X0j (rounding is working as expected)
Your help is very much appreciated.
I've purchased the premium plugin and added my purchase code.
Thanks again :)
Sam
Thank you again Pablo.
I used your code - thank you.
This seems to be working on the cart and checkout pages, so we are making progress. :)
However, it is not working on the archive or product pages (I think this is Approx. Price). So it seems to be working on Approx. Amount, but not on Approx. Price.
Individual Product Page: https://share.getcloudapp.com/NQu10B1R (rounding not working)
Checkout page: https://share.getcloudapp.com/X6ud1X0j (rounding is working as expected)
Your help is very much appreciated.
I've purchased the premium plugin and added my purchase code.
Thanks again :)
Sam
Quote from Pablo Borysenco on November 11, 2020, 15:49Hello
Ok! Try in file - \wp-content\plugins\woocommerce-currency-switcher\classes\woocs_after_33.php
Add code - https://c2n.me/49MCe6n.png
$value = round($value * 2, 1) / 2;
Add code - https://c2n.me/49MCiJr.png
$min_value = round($min_value * 2, 1) / 2;
$max_value = round($max_value * 2, 1) / 2;
Hello
Ok! Try in file - \wp-content\plugins\woocommerce-currency-switcher\classes\woocs_after_33.php
Add code - https://c2n.me/49MCe6n.png
$value = round($value * 2, 1) / 2;
Add code - https://c2n.me/49MCiJr.png
$min_value = round($min_value * 2, 1) / 2;
$max_value = round($max_value * 2, 1) / 2;
Quote from sammie on November 12, 2020, 14:12Thanks again Pablo.
That works directly into the file inside the plugin - we are really making progress now!
I was hoping to override by adding the edited file to my child theme, but when I added the file as below, it didn't work.
themes/[my-child-theme]/woocommerce-currency-switcher/classes/woocs_after_33.phpIt only worked when I edited the file in:
plugins/woocommerce-currency-switcher/classes/woocs_after_33.phpI thought that was correct structure for overriding plugin files. Is it possible to do it in my child theme?
Thanks again for your help :)
Sam
Thanks again Pablo.
That works directly into the file inside the plugin - we are really making progress now!
I was hoping to override by adding the edited file to my child theme, but when I added the file as below, it didn't work.
themes/[my-child-theme]/woocommerce-currency-switcher/classes/woocs_after_33.php
It only worked when I edited the file in:
plugins/woocommerce-currency-switcher/classes/woocs_after_33.php
I thought that was correct structure for overriding plugin files. Is it possible to do it in my child theme?
Thanks again for your help :)
Sam
Quote from Pablo Borysenco on November 13, 2020, 12:25Hello Sam
Is it possible to do it in my child theme? - Unfortunately no. Only in the plugin code
Hello Sam
Is it possible to do it in my child theme? - Unfortunately no. Only in the plugin code
Quote from sammie on November 14, 2020, 08:38Thanks Pablo,
I appreciate your help. It seems that the code is actually still not working on the archive pages, or individual product pages (I thought it was before because when I checked a few, the ones I checked were x.05, but perhaps it was just a coincidence).
It DOES work on Checkout and Cart using the "woocs_raw_woocommerce_price" filter, but I believe the approx prices are changed based on the code in the file. This does NOT appear to be working where I edited the plugin code as instructed above inside woocs_after_33.php
As you can see here: https://share.getcloudapp.com/12urwg08
You can ignore the AU$, the odd numbers are due to no tax applied outside of Australia. But the Euro is still showing odd cents and not what it is meant to be.
Is there somewhere else in the plugin I would need to add the rounding code to make this work for Approx. Prices?
I even flushed wordpress cache and litespeed cache on the server.
Again, I appreciate you help.
Thanks,
Sam
Thanks Pablo,
I appreciate your help. It seems that the code is actually still not working on the archive pages, or individual product pages (I thought it was before because when I checked a few, the ones I checked were x.05, but perhaps it was just a coincidence).
It DOES work on Checkout and Cart using the"woocs_raw_woocommerce_price" filter, but I believe the approx prices are changed based on the code in the file. This does NOT appear to be working where I edited the plugin code as instructed above inside woocs_after_33.php
As you can see here: https://share.getcloudapp.com/12urwg08
You can ignore the AU$, the odd numbers are due to no tax applied outside of Australia. But the Euro is still showing odd cents and not what it is meant to be.
Is there somewhere else in the plugin I would need to add the rounding code to make this work for Approx. Prices?
I even flushed wordpress cache and litespeed cache on the server.
Again, I appreciate you help.
Thanks,
Sam
Quote from Pablo Borysenco on November 16, 2020, 13:33Hello Sam
I did test on my site - it works correctly
Please double check the code
Hello Sam
I did test on my site - it works correctly
Please double check the code
Quote from sammie on November 16, 2020, 14:47Thank you Pablo. It seems to have resolved itself now. Must have been a caching issue.
I appreciate your help.
Thanks again,
Sam :)
Thank you Pablo. It seems to have resolved itself now. Must have been a caching issue.
I appreciate your help.
Thanks again,
Sam :)
Quote from Pablo Borysenco on November 17, 2020, 11:49Hello Sam
Welcome;)
Hello Sam
Welcome;)