Best way to update line item shipments through code?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Best way to update line item shipments through code?

Post by AbleMods » Wed Nov 21, 2007 1:28 pm

I need to mark specific line items of an order as "shipped" through my programming code. Certain products I sell will be processed and generated electronically, so no physical shipment will occur.

I'd like to write my processing routine so that it can scan for what hasn't been processed, do the work, then mark the item as processed/shipped.

I see how I can grab the orders from ac_Orders. I can grab the line items from ac_OrderItems and tie to the product template responses in ac_OrderItemInputs using the OrderItemID and OrderId values.

Any suggestions on this or a direction you could point me towards?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Post by sohaib » Thu Nov 22, 2007 12:15 am

Hello,

First I would suggest that for items that are not shippable you simply set them as not shippable in Product edit screen. This should solve your problem. You do not have to mark them shipped manually or with a script.

If you still want to have these items remain shippable and mark their status shipped using a script then you can do something like this

First note that you do not mark order items as shipped ... you mark the shipments as shipped.
Load the Orders that you want to process... For this purpose check the methods in OrderDataSource. You can load all orders or you can load selected orders based on some criteria.

for each order loop the shipments for each order ... then it is upto you to decide which shipments you want to set as shipped. After making the change just call shipment.Save() method.

Thanks,
Sohaib

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Post by AbleMods » Thu Nov 22, 2007 8:13 am

Already have the nonshippable items marked as such, so I'm ok there.

My situation is unique in that some line items on an order will be physical product that require shipment, while others will be electronically processed and delivered via email attachment.

So I need to figure out an effective way to mark the electronically-processed line items as "done" once I've processed them, without marking the entire order as complete. Conversely, this gives me the ability to filter for the unprocessed ones so I know which ones still need to be handled.

Almost sounds like I should make them "shippable" and just ship them as they are electronically processed.

Thoughts?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply