Discount percentage and price rounding

  • Posts: 71
  • Thank you received: 0
9 years 2 months ago #214057

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.1

Hi,

For certain customer groups we've set a discount of 25%. The discounted price however should be rounded to the nearest .05 eg. when the discounted price is 6.53, it should show 6.55 or with 6.52 it should show 6.50. How can this be achieved?

Thanks.
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214062

Hi,

Did you configure a rounding increment of 0.05 in the settings page of your currency that you can edit via the menu System>Currencies ?
If not, then it's normal that it round the prices by 0.01 increments as that's the default rounding increment of the system.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 2 months ago #214088

Hi Nicolas,

As you can see from the screenshots below, the increment is set to 0.05, but the discounted prices are still shown with a 0.01 rounding...

Thanks,
Michel

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214110

Hi,

Ok, I see the issue.
Can you try to change the code:

function addDiscount(&$price, &$discount, $discount_before_tax, $zone_id, $product_tax_id) {
		$config = hikashop_config();
		if($config->get('floating_tax_prices', 0)) {
			$price->price_value = $price->price_value_with_tax;
		}

		$price->price_value_without_discount = $price->price_value;

		if($discount_before_tax) {
			if(bccomp($discount->discount_flat_amount,0,5) !== 0) {
				$price->price_value = $price->price_value -floatval($discount->discount_flat_amount);
			} else {
				$price->price_value = (($price->price_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value)) {
					$price->price_orig_value_without_discount = $price->price_orig_value;
					$price->price_orig_value = (($price->price_orig_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}
			$price->price_value_without_discount_with_tax = $this->getTaxedPrice($price->price_value_without_discount, $zone_id, $product_tax_id);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value_with_tax = $this->getTaxedPrice($price->price_value, $zone_id, $product_tax_id);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value)) {
				$price->price_orig_value_with_tax = $this->getTaxedPrice($price->price_orig_value, $zone_id, $product_tax_id);
				$price->taxes_orig = $this->taxRates;
			}
		} else {
			$price->price_value_without_discount_with_tax = $price->price_value_with_tax;
			if(bccomp($discount->discount_flat_amount, 0, 5) !== 0) {
				$price->price_value_with_tax = $price->price_value_with_tax - floatval($discount->discount_flat_amount);
			} else {
				$price->price_value_with_tax = (($price->price_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value_with_tax)) {
					$price->price_orig_value_without_discount_with_tax = $price->price_orig_value_with_tax;
					$price->price_orig_value_with_tax = (($price->price_orig_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}

			$price->price_value_without_discount = $this->getUntaxedPrice($price->price_value_without_discount_with_tax, $zone_id, $product_tax_id);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value = $this->getUntaxedPrice($price->price_value_with_tax,$zone_id,$product_tax_id);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value_with_tax)) {
				$price->price_orig_value = $this->getUntaxedPrice($price->price_orig_value_with_tax, $zone_id, $product_tax_id);
				$price->taxes_orig = $this->taxRates;
			}
		}
	}
to:
function addDiscount(&$price, &$discount, $discount_before_tax, $zone_id, $product_tax_id) {
		$config = hikashop_config();
		if($config->get('floating_tax_prices', 0)) {
			$price->price_value = $price->price_value_with_tax;
		}

		$price->price_value_without_discount = $price->price_value;

		$round = $this->getRounding(@$price->price_currency_id,true);

		if($discount_before_tax) {
			if(bccomp($discount->discount_flat_amount,0,5) !== 0) {
				$price->price_value = $price->price_value -floatval($discount->discount_flat_amount);
			} else {
				$price->price_value = (($price->price_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value)) {
					$price->price_orig_value_without_discount = $price->price_orig_value;
					$price->price_orig_value = (($price->price_orig_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}
			$price->price_value_without_discount_with_tax = $this->getTaxedPrice($price->price_value_without_discount, $zone_id, $product_tax_id, $round);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value_with_tax = $this->getTaxedPrice($price->price_value, $zone_id, $product_tax_id, $round);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value)) {
				$price->price_orig_value_with_tax = $this->getTaxedPrice($price->price_orig_value, $zone_id, $product_tax_id, $round);
				$price->taxes_orig = $this->taxRates;
			}
		} else {
			$price->price_value_without_discount_with_tax = $price->price_value_with_tax;
			if(bccomp($discount->discount_flat_amount, 0, 5) !== 0) {
				$price->price_value_with_tax = $price->price_value_with_tax - floatval($discount->discount_flat_amount);
			} else {
				$price->price_value_with_tax = (($price->price_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value_with_tax)) {
					$price->price_orig_value_without_discount_with_tax = $price->price_orig_value_with_tax;
					$price->price_orig_value_with_tax = (($price->price_orig_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}

			$price->price_value_without_discount = $this->getUntaxedPrice($price->price_value_without_discount_with_tax, $zone_id, $product_tax_id, $round);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value = $this->getUntaxedPrice($price->price_value_with_tax,$zone_id,$product_tax_id, $round);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value_with_tax)) {
				$price->price_orig_value = $this->getUntaxedPrice($price->price_orig_value_with_tax, $zone_id, $product_tax_id, $round);
				$price->taxes_orig = $this->taxRates;
			}
		}
	}
in the file administrator/components/com_hikashop/classes/currency.php and see if that helps ?

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 2 months ago #214207

Hi Nicolas,

Thanks for the reply!
Unfortunately it doesn't work. See result in Screenshot.

Thanks,
Michel

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214258

Hi,

It seems to be working way better than before though on your screenshot.
I see however on my end that the price with tax isn't rounded as it should.
With that code however, it works fine on my end:

function addDiscount(&$price, &$discount, $discount_before_tax, $zone_id, $product_tax_id) {
		$config = hikashop_config();
		if($config->get('floating_tax_prices', 0)) {
			$price->price_value = $price->price_value_with_tax;
		}

		$price->price_value_without_discount = $price->price_value;

		$round = $this->getRounding(@$price->price_currency_id,true);

		if($discount_before_tax) {
			if(bccomp($discount->discount_flat_amount,0,5) !== 0) {
				$price->price_value = $price->price_value -floatval($discount->discount_flat_amount);
			} else {
				$price->price_value = (($price->price_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value)) {
					$price->price_orig_value_without_discount = $price->price_orig_value;
					$price->price_orig_value = (($price->price_orig_value * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}
			$price->price_value_without_discount_with_tax = $this->getTaxedPrice($price->price_value_without_discount, $zone_id, $product_tax_id, $round);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value_with_tax = $this->getTaxedPrice($price->price_value, $zone_id, $product_tax_id, $round);
			$price->price_value = $this->round($price->price_value, $round);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value)) {
				$price->price_orig_value_with_tax = $this->getTaxedPrice($price->price_orig_value, $zone_id, $product_tax_id, $round);
				$price->taxes_orig = $this->taxRates;
			}
		} else {
			$price->price_value_without_discount_with_tax = $price->price_value_with_tax;
			if(bccomp($discount->discount_flat_amount, 0, 5) !== 0) {
				$price->price_value_with_tax = $price->price_value_with_tax - floatval($discount->discount_flat_amount);
			} else {
				$price->price_value_with_tax = (($price->price_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				if(isset($price->price_orig_value_with_tax)) {
					$price->price_orig_value_without_discount_with_tax = $price->price_orig_value_with_tax;
					$price->price_orig_value_with_tax = (($price->price_orig_value_with_tax * (100.0 - floatval($discount->discount_percent_amount))) / 100.0);
				}
			}

			$price->price_value_without_discount = $this->getUntaxedPrice($price->price_value_without_discount_with_tax, $zone_id, $product_tax_id, $round);
			$price->taxes_without_discount = $this->taxRates;
			$price->price_value = $this->getUntaxedPrice($price->price_value_with_tax,$zone_id,$product_tax_id, $round);
			$price->price_value_with_tax = $this->round($price->price_value_with_tax, $round);
			$price->taxes = $this->taxRates;
			if(isset($price->price_orig_value_with_tax)) {
				$price->price_orig_value = $this->getUntaxedPrice($price->price_orig_value_with_tax, $zone_id, $product_tax_id, $round);
				$price->taxes_orig = $this->taxRates;
			}
		}
	}
So please try it.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 2 months ago #214380

Hi Nicolas,

With the code before no discount was deducted.
With the new code you sent, it's the same as before (see screenshot), the prices are not rounded to nearest 0.05.

Thanks,
Michel

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214384

I'm not able to reproduce the problem on my end.
Please provide:
- a link to the page with the issue
- a backend access to check your settings
- a FTP access to your website so that we can look and modify the code
www.hikashop.com/support/contact-us.html

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 2 months ago #214456

I've sent you the info via pm.

Please Log in or Create an account to join the conversation.

  • Posts: 62
  • Thank you received: 1
9 years 2 months ago #214460

Hi
I had the same problem.
Maybe this will help:
www.hikashop.com/forum/checkout/876704-round-price.html
Regards

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214537

Hi,

I'm not able to access your backend. There is a htaccess authentication before the login screen and you didn't provide the credentials for that. Could you provide them too ?

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 1 month ago #215544

Any news on this? I have sent you the credential per pm a week ago....

Thanks,
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 1 month ago #215552

Hi,

As Nicolas wrote one week ago ; we do not have any credentials for the Htaccess authentication for your backend.
You sent us a login and password for Joomla but that does not work for the first authentication part.
So please provide us that information and please use the "contact us" form, specially if you want us to be able to read your message.. Private message are inefficient for the support.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 1 month ago #215610

Hi,

As I have written, I sent the credentials by pm, not being aware that it should have been sent through the contact form.
I have now sent them using the contact form.

Thanks,
Michel

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 1 month ago #216066

Hi,

Sorry for the delay.
I was able to check your settings and indeed, the code modification I gave is correct and you correctly put it in place.
The issue is that you had turned off the "round prices during calculations" setting of the HikaShop configuration, and thus prices weren't rounded during the discount calculations anymore.
I've turned it on and the results are correct now on your website as far as I can see.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
9 years 1 month ago #216292

Hi,

Great. Thanks! Could you tell me where this setting is? I can't find it....
How is it when I install an update of Hikashop? Will this modification be included or should I apply the changes again, after updating?

Michel

Last edit: 9 years 1 month ago by bmichu.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 1 month ago #216305

Hi,

For the setting see : www.hikashop.com/support/support/documen...nfig.html#main_taxes

Otherwise, the fix that Nicolas gave you will be include in the next release.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
4 years 3 months ago #323154

Hi,

I am using latest version of hikashop and selected the option Round off with calcultion on hikashop configuration page.

My product price is 25,90 € and after applied the discount of 25% the amount will be 19.43 € and want to round of this value to 19.40 or 19.45 € .

Could you please tell me the way to get this value without changing the original price of the product and discount percentage.

Thanks,
Regards,
Vijay

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 3 months ago #323213

Hi,

The rounding option in the Hikashop configuration is to have the prices rounded during calculations or not based on the rounding configured in the settings of the currency. So for example if you have a product costing 10.01 and you have a tax of 10% on top of that, it means the tax is 1.001 so it is rounded to 1. But suppose you have 10 elements of that product in the cart.
In that case, the total tax will either be 10 or 10.01 based on how that setting is configured.
So this setting has no influence on what you're trying to do.
By default the euro currency is configured with a rounding increment of 1 cent, so what you want to do, it's to edit the euro currency via the menu System>Currencies and change the rounding increment from 0.01 to 0.05. That way, it will round prices with 5 cents steps instead of 1 cent steps.

The following user(s) said Thank You: lowcostwebagency

Please Log in or Create an account to join the conversation.

Time to create page: 0.115 seconds
Powered by Kunena Forum