Table of Contents

Class FeeProvider

Namespace
Dynamicweb.Ecommerce.Orders
Assembly
Dynamicweb.Ecommerce.dll
The FeeProvider allows you to manipulate the shipping fee of an order in eCommerce using class inherited from Dynamicweb.eCommerce.Orders.FeeProvider.
public class FeeProvider
Inheritance
FeeProvider
Inherited Members

Examples

The following example demonstrates how to grant free shipping to customers who posts multiple orders within 24 hours. If the web shop can ship the items from the first and second order together, there is no need for the customer to be double-charged for shipping and handling. In cases where no previous orders have been submitted, the FeeProvider simply returns null which then will cause Dynamicweb eCommerce to ignore the FeeProvider when it sorts out the shipping fee.
using Dynamicweb.Data;
using System;

namespace Dynamicweb.Ecommerce.Examples.Orders
{
    /// <summary>
    /// The following example demonstrates how to grant free shipping to customers 
    /// who posts multiple orders within 24 hours.If the web shop can ship the items
    /// from the first and second order together, there is no need for the customer to be double-charged for shipping and handling.
    /// In cases where no previous orders have been submitted, the FeeProvider
    /// simply returns null which then will cause Dynamicweb eCommerce to ignore
    /// the FeeProvider when it sorts out the shipping fee.
    /// </summary>
    class FeeProviderSample : Dynamicweb.Ecommerce.Orders.FeeProvider
    {
        public override Dynamicweb.Ecommerce.Prices.PriceRaw FindFee(Dynamicweb.Ecommerce.Orders.Order order)
        {
            Dynamicweb.Ecommerce.Prices.PriceRaw returnFee = null;

            if (!string.IsNullOrEmpty(order.CustomerEmail))
            {
                using (var reader = Database.CreateDataReader(CommandBuilder.Create("SELECT TOP 1 * FROM EcomOrders WHERE OrderCustomerEmail = {0} AND OrderDate >= {1} AND OrderComplete = {2}", order.CustomerEmail, DateTime.Now.AddDays(-1), true)))
                {
                    if (reader.Read())
                    {
                        returnFee = new Dynamicweb.Ecommerce.Prices.PriceRaw(0d, order.Currency);
                    }
                }
            }

            return returnFee;
        }
    }
}

Methods

FindFee(Order)

Finds the fee for the order that should replace standard ones.
public virtual PriceRaw FindFee(Order order)

Parameters

order Order
The order.

Returns

PriceRaw
Returns shipping fee for the specified order
To top