Developer forum

Forum » Ecommerce - Standard features » Extend a SalesDiscountProvider

Extend a SalesDiscountProvider

Diogo Lino
Reply
Hello,

I'm trying to create a new SalesDiscountProvider to validate voucher codes from diferent tables from a database in C#.
I'm using version 19.1.0.5 ans Cart v1, for now i cannot change that.
I've tried to use the two functions "CreateProductOrderline" and "CreateAmountOrderline" as I saw in an example, but it says it cannot access internal method...

    [AddInName("One use Voucher discount")]
    [AddInDescription("If the user introduces a valid voucher number a discount will be triggered.")]
    public class OneUseVoucherDiscount : SalesDiscountProvider, IDropDownOptions
    {
        #region Parameters
        [AddInParameter("OrderField"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.DropDownParameterEditor), "")]
        public string OrderFieldParameter { get; set; }
        
        [AddInParameter("VoucherTable"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.DropDownParameterEditor), "")]
        public string VoucherTableParameter { get; set; }
        #endregion

        public override void ProcessOrder(Order order)
        {
            if (order.OrderFields.Contains(OrderFieldParameter))
            {
                string voucherCode = order.OrderFieldValues.GetOrderFieldValue(OrderFieldParameter).Value.ToString();
                
                //TODO seeks if exists on a database table
                
                bool isVoucherValid = true; //TODO let's assume it was found

                if (isVoucherValid)
                {
                    if (DiscountValue.Type == DiscountTypes.Products)
                    {
                        foreach (Products.Product product in DiscountValue.ProductCollection)
                        {
                            OrderLine line = CreateProductOrderline(order, product);


I also want to subscribe an order complete event as shown at http://developer.dynamicweb-cms.com/documentation/for-developers/ecommerce/extensibility/notifications/cart-v2.aspx but it does not recognize the "Dynamicweb.Notifications.eCommerce.Cart.CheckoutDoneOrderIsCompleteArgs" notification. How can i catch the order complete?

Thanks,
Diogo Lino


Replies

 
Diogo Lino
Reply
I've moved this question to the Development area, and is already answered.
Sorry for the mistake. This can be closed or deleted.

Diogo Lino

 

You must be logged in to post in the forum