Problem with adding a custom handling charge

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
zxcjason
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Jul 29, 2009 3:56 pm

Problem with adding a custom handling charge

Post by zxcjason » Fri Jul 09, 2010 9:53 pm

I'm trying to add an additional custom handling charge during the checkout process. I tried adding a simple piece of code that adds a basket item in the RecalculateBasket function in the one page checkout code, but it's not being added to the database, any idea what I might have done wrong?

This is the piece of code that adds the handling charge to the basket:

BasketItem brokerageItem = new BasketItem();
brokerageItem.Name = "Customs Brokerage Fee";
brokerageItem.Price = AlwaysConvert.ToDecimal(1.23);
brokerageItem.OrderItemTypeId = 2;
brokerageItem.Weight = 0;
brokerageItem.Quantity = 1;
brokerageItem.BasketId = basket.BasketId;
brokerageItem.BasketShipmentId = shipment.BasketShipmentId;
brokerageItem.ProductId = 0;
brokerageItem.Save();

basket.Items.Add(brokerageItem);
basket.Save();

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Problem with adding a custom handling charge

Post by mazhar » Sat Jul 10, 2010 5:46 am

Give a try to these code lines

Code: Select all

BasketItem brokerageItem = new BasketItem();
        brokerageItem.Name = "Customs Brokerage Fee";
        brokerageItem.Price = AlwaysConvert.ToDecimal(1.23);
        brokerageItem.OrderItemType = OrderItemType.Credit;
        brokerageItem.Quantity = 1;
        Token.Instance.User.Basket.Items.Add(brokerageItem);
        Token.Instance.User.Basket.SaveChildren();

zxcjason
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Jul 29, 2009 3:56 pm

Re: Problem with adding a custom handling charge

Post by zxcjason » Mon Jul 12, 2010 1:19 am

Thanks. That works!

Post Reply