AbleCommerce Forums
	 » 
	AbleCommerce
	 » 
	General Questions
	 » 
	How to Add Shipping Charge to Order Programmatically
	 
	
        
            
            
    | 
	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);
 
 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
	Rank: Advanced Member
 Groups: Developers, Registered, HelpDesk, Authorized UserJoined: 10/5/2018(UTC)
 Posts: 704
 
 Thanks: 6 timesWas thanked: 113 time(s) in 112 post(s)
 
 | 
            
		      
                I think you also need to add the following line: Code:shippingChargeItem.Basket = basket;
 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
        
            
            
    | 
	Rank: Newbie
 Groups: Developers
Joined: 4/30/2019(UTC)
 Posts: 1
 
 |  | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
                           
	AbleCommerce Forums
	 » 
	AbleCommerce
	 » 
	General Questions
	 » 
	How to Add Shipping Charge to Order Programmatically
	 
	
    
        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.
	
	
    
    
        Important Information:
        The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
        
        
More Details
        Close