logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
dandersonMLT  
#1 Posted : Sunday, May 9, 2021 4:43:09 PM(UTC)
dandersonMLT

Rank: Newbie

Groups: Developers
Joined: 4/30/2019(UTC)
Posts: 1

We want to add some special logic to add a shipping or handling charge for certain dates where the charge price is based on weight.

What is the best way to add a shipping or handling charge to a basket programmatically?

I'm thinking of adding a basket item and just setting the type to Shipping or Handling, then setting price and weight to 0, but didn't know if this is the correct way or what fields must be set if creating a basket item using simply new BasketItem().

This is what I am thinking but please let me know if this is the best method or if there are additional properties that must be populated.

Quote:

BasketItem shippingChargeItem = new BasketItem();
shippingChargeItem.Name = "CustomShippingCharge";
shippingChargeItem.OrderItemType = OrderItemType.Shipping;
shippingChargeItem.Price = CalculateShippingCharge(basket, dateToCalculate);
shippingChargeItem.Weight = 0;
shippingChargeItem.Quantity = 1;
basket.Items.Add(shippingChargeItem);

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyar  
#2 Posted : Monday, May 10, 2021 4:07:03 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
I think you also need to add the following line:
Code:
shippingChargeItem.Basket = basket;

dandersonMLT  
#3 Posted : Monday, May 10, 2021 12:02:48 PM(UTC)
dandersonMLT

Rank: Newbie

Groups: Developers
Joined: 4/30/2019(UTC)
Posts: 1

Thank you!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.