Developer forum

Forum » Development » FeeProvider / PaymentFeeProvider

FeeProvider / PaymentFeeProvider


Reply

Hi

 

I want to add a fixed amount to the shipping fee depending on a value in a custom field on the product.

 

I'm pretty much into how to look into the product custom fields, and i have a FeeProvider running OK.

 

But how to ADD instead of REPLACING the Fee, i cannot figure out.

 

What i need is to retrieve the calculated Fee and then add f.ex 35,- to that amount.

 

How do i get the calculated Fee within a feeProvider ?

Alternatively - how and where can i set/override the PaymentFee

 

Sample code please ;o)

/Lars


Replies

 
Reply

The return value of the FeeProvider should be Order.ShippingFee.Price + (double)YourCustomFee.

 

If you want the extra fee to appear in the order, you may want to add it as an order line with a negative price to the OrderLines collection

 
Reply

Is that value available at that time ?

Isn't that calculated AFTER the Custom FeeProvider.

 

I tried this, but the server fell over when i came to Accept Basket:

 

Public

Class LHFeeProviderInherits Dynamicweb.eCommerce.Orders.FeeProviderPublic Overloads Overrides Function FindFee(ByVal Order As Dynamicweb.eCommerce.Orders.Order) As Dynamicweb.eCommerce.Prices.PriceRawDim ReturnFee As Dynamicweb.eCommerce.Prices.PriceRaw = Nothing

 

 

ReturnFee =

 

 

End

Dim MyFee As Double = 11.5RDim DWFee As Double = Order.ShippingFee.PriceNew Dynamicweb.eCommerce.Prices.PriceRaw(MyFee, Dynamicweb.eCommerce.Common.Application.DefaultCurrency)Return ReturnFeeEnd Function Class

 

The only thing i added from a working version was this line:

Dim DWFee As Double = Order.ShippingFee.Price

 

Adding a line to the order could be done, but then you have the hazzle of pulling it off again if the order suddenly meets the condition of NOT requiring this handlingfee.

 

Any suggestions ?

Can i control the PaymentFee instead ?

eg setting that to a value of my choice depending on certain conditions..

 

 

 

 

 
Reply

Honestly, I'm not sure of the order of which they are executed. If you're not able to retrieve the standard fee at that point, please try the following:

 

Dim

Fee As New Dynamicweb.eCommerce.Orders.Shipping([ShippingID])Dim StandardFee As Double = Fee.PriceOverMaxWeight;

 

And then use StandardFee for your calculations.

 

 

You must be logged in to post in the forum