Developer forum

Forum » Development » Changing prices to 0 in orders

Changing prices to 0 in orders


Reply
When I try to change values in the orders, it works nice.
Only when I try to set a price to zero (for example set the shippingfee to zero), I get this error:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 7 ("@p5"): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.

The value I'm trying to set is a valid double.

What can I do to set te value to 0 (zero)?

Replies

 
Reply
Hi Martijn,

Can you show use your code? (Always a good idea to post your code when you have code-related issues)

Cheers,

Imar
 
Reply
Hi Imar

This is the last example I tried:

    Dim dNewShippingFee As Double = Convert.ToDecimal(tbVerzendkostenNieuw.Text)
            Dim dNewShippingFeeWithoutVat As Double = (Convert.ToDecimal(tbVerzendkostenNieuw.Text) * (100 - myNewOrder.ShippingFee.VATPercent) / 100)

            Dim myPriceCalculated As New Prices.PriceCalculated(New Prices.PriceRaw(dNewShippingFee, eCommerce.Common.Application.DefaultCurrency))
            myNewOrder.ShippingFee.PriceWithVAT = myPriceCalculated.PriceWithVAT
            myNewOrder.ShippingFee.PriceWithoutVAT = myPriceCalculated.PriceWithoutVAT

            myNewOrder.Save() The order 'myNewOrder' is an new order, based on an excisting order, where values or copied to the new order. When the user fills the textbox 'tbVerzendkostenNieuw' with 0, the code doesn't accept the change
 
Reply
Hi Martijn,

Could this be a data type issue where you assign a Decimal (from Convert.ToDecimal) to a double (dNewShippingFee). Try converting it to a Double instead and turn on Option Explicit.

In C#, the following code seems to work fine for me:

double dNewShippingFee = Convert.ToDouble(0);
PriceCalculated myPriceCalculated = new PriceCalculated(
    new PriceRaw(dNewShippingFee, Dynamicweb.eCommerce.Common.Application.DefaultCurrency));
Order.ShippingFee.PriceWithVAT = myPriceCalculated.PriceWithVAT;
Order.ShippingFee.PriceWithoutVAT = myPriceCalculated.PriceWithoutVAT;
Order.Save();

Hope this helps,

Imar
 
Reply
Hi Imar

It seems that it works for me also, with the right datatype.
Little shameful I didn't see that I was using the wrong datatype.

Many thanks!
Martijn

 

You must be logged in to post in the forum