WooCommerce.NET icon indicating copy to clipboard operation
WooCommerce.NET copied to clipboard

Sale price does not accepts null

Open rtmrodrigues opened this issue 3 years ago • 4 comments

When updating a Product, if the sale_price has any value and the new value is null, it does not update the sale_price. In debug, I have manualy changed the PROTECTED field "sale_priceValue" to an empty string and the slae_price DID update (to empty).

Is this the normal behavior? How can I solve this issue?

WooCommerceNET v. 0.8.2.0 WooCommerce v. 5.1.0

rtmrodrigues avatar Mar 31 '21 17:03 rtmrodrigues

Try to use UpdateWithNull method

XiaoFaye avatar Apr 05 '21 07:04 XiaoFaye

I have done it, but I beleive that by doing it that way, the number of API calls are multiplicated because sometimes we may want to change several properties with values and other times we may want to change those values to null and other times we may want to change some values with some actual values and other with null...

...unless I´m not understanding how to use UpdateWithNull.

Example: our product has a regular price and a sale price. If I want to update only the sale price and I already have one object with all information I need, then I need to UpdateWithNull, then Get the Product and then Update again.

Is this correct? If not...how should I do it?

rtmrodrigues avatar Apr 05 '21 16:04 rtmrodrigues

If you set the SalePrice == RegularPrice it will clear the sale price.

firestormza avatar Apr 06 '21 20:04 firestormza

OK. Did not knew about it. TY.

rtmrodrigues avatar Apr 12 '21 10:04 rtmrodrigues