magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Custom options save wrong price values after editing

Open AirmanAJK opened this issue 10 years ago • 14 comments

Magento CE 2.1.0 using USD as currency.

When product custom options are saved with prices > $999, revisiting the product page will display the "Price" field for custom options using commas to separate thousands (ie 1,500.00 or 1,000.00).

When saving prices with these default values, the first comma is used as the decimal point. Saving 1,000.00 in a custom options field will store 1.00 in the database.

Steps to reproduce

  1. Create a product and add a custom option price greater than or equal to 1000
  2. Save the product and go to its edit page again.
  3. The new value of the custom option price will 1,000.0
  4. Without changing this value, save the product.
  5. The new value for the custom option price will be 1.00

Expected result

Magento should handle custom option prices on product edit pages as it does for regular product prices.

AirmanAJK avatar Aug 25 '16 15:08 AirmanAJK

Hi @AirmanAJK , thanks for reporting this issue. We've created internal ticket MAGETWO-57639.

Best, Anton.

antboiko avatar Aug 25 '16 15:08 antboiko

Can confirm this issue also exists using $AUD as currency also. Also not sure if it's related but even if choosing percentage as the option, the value still displays as currency.

donky6 avatar Sep 20 '16 02:09 donky6

This issue also exits with đ - Vietnam dong..

ntkp avatar Sep 26 '16 08:09 ntkp

Confirmed still an issue in CE 2.1.3

WaterSlide avatar Jan 20 '17 18:01 WaterSlide

For USD price formatting in the administration back end, there is really no need for a comma in the price (which seems to improperly attribute a decimal to your value on product save). My temporary fix is to just stop reporting prices with the comma with:

\vendor\magento\module-catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions.php

protected function formatPrice($value)
    {
        if (!is_numeric($value)) {
            return null;
        }

        $store = $this->storeManager->getStore();
        $currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
        $value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
        // Remove comma from value:
        $value = str_replace(",","",$value);
        return $value;
    }

I've yet to learn how to override in a much more proper way and for this I apologize.

WaterSlide avatar Jan 21 '17 18:01 WaterSlide

Hi WaterSlide. To address the right way to fix this, normally you would want to create an "after" plugin in your own extension to just update the value after the function is called, but since this formatPrice() function is protected, you either need to apply the plugin to another function in the call stack, or extend the class and force you inherited version to be injected using the di.xml configuration. The latter is a bit more invasive as it replaces the entire class with yours, which is why a plugin is typically preferred for these kinds of small changes.

AirmanAJK avatar Jan 21 '17 19:01 AirmanAJK

I'm using current version 2.1.3 but has this problem wrong price for all those products which have customize options in all currencies other than base currency for example attached product has price 43,065 PKR but show in millions screenhunter_85 jan 13 08 46_810

mthsialkot avatar Jan 23 '17 05:01 mthsialkot

This Bug is still open since month. And I can confirm that it still exists in 2.1.5. When will you remedy that problem.

senders avatar Apr 03 '17 15:04 senders

This patch seems to work fine in magento 2.1.5:

https://github.com/magento/magento2/commit/496c24d58a0624a865c78b5da63f138bd279ea01

But why it isn't still integrated in one of the latest magento versions 2.1.3, 2.1.4 or 2.1.5. ???

senders avatar Apr 03 '17 16:04 senders

Still its not working in 2.1.5. Totally wrong prices when currency switching. its fine in default currency.

titechnologies avatar May 03 '17 06:05 titechnologies

Internal ticket for ver. 2.1 - MAGETWO-58571. The issue has been already fixed and will be available in one of the nearest releases.

veloraven avatar Jun 20 '17 06:06 veloraven

@AirmanAJK, thank you for your report. The issue is already fixed in 2.2.0

magento-engcom-team avatar Sep 20 '17 22:09 magento-engcom-team

i have same issue like that. when i have update product price rs50000 and save, after some time it show the value like rs50 in backend and frontend in magento 2 version 2.1.8. kindly resolved it asap.price change automatically.fully frustrated guys help me.

nawabamit avatar Jan 03 '18 18:01 nawabamit

I have also same issue . When i have update product price 1.000,00 which is converted into 1 Kindly update mY version is 2.1.7

gopal2k6 avatar Jan 16 '19 17:01 gopal2k6