You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I want to edit a download custom type, price field is formatted and this creates a problem.
For my currency (for display purposes only) I divide amount by 10,
This means that if price is 100, I display 10. But you can guess what happens when you edit a download post. Price that is actually 100 will be formatted to 10, and When I save the page, price will be saved as 10 and displays as 1.
Problem is in metabox.php file,
First there's no filter or anything that I can override the price, And also it shouldn't use edd_format_amount for price, in fact you can see this in their definition :
* Format a numeric value.
*
* Uses the decimal & thousands separator settings, and the number of decimals,
* to format any numeric value.
*
* (Most commonly, this is used to apply site or user preferences to a numeric
* value for output to the page.)
You should use edd_sanitize_amount function that doesn't put any separator in input box.
* Sanitize a numeric value.
*
* Use this function to "unformat" a previously formatted numeric value.
*
* (Most commonly, this is when accepting input from a form field where the
* value is likely to derived from the site or user preferences.)
The text was updated successfully, but these errors were encountered:
@xoex thank you for the report, research, and proposed fix. I've copied the information over to the repository where we are working now and will hope to have an update/fix in a future release.
You may be able to work around it for the time being by returning $formatted early if is_admin() is true and edd_doing_ajax() is not true (both would be needed as ajax calls are considered admin).
Bug Report
Expected behavior
When I want to edit a download custom type, price field is formatted and this creates a problem.
For my currency (for display purposes only) I divide amount by 10,
This means that if price is 100, I display 10. But you can guess what happens when you edit a download post. Price that is actually 100 will be formatted to 10, and When I save the page, price will be saved as 10 and displays as 1.
Problem is in metabox.php file,
First there's no filter or anything that I can override the price, And also it shouldn't use
edd_format_amount
for price, in fact you can see this in their definition :You should use
edd_sanitize_amount
function that doesn't put any separator in input box.The text was updated successfully, but these errors were encountered: