Having trouble with "shippable" on items in kits

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
Thistle3408
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Apr 19, 2010 4:52 pm

Having trouble with "shippable" on items in kits

Post by Thistle3408 » Mon May 10, 2010 1:04 pm

We're trying to post orders (and all the pertinent information about them) to a 3rd party shipping firm using an XML interface.

I only want to include items that are A) shippable and B) assigned to be shipped from a specific warehouse.
We have the current code in a .cs module special for this interface.

Here's my first problem. If you look at the code below, with the "&& item.Shippable != Shippable.No" condition in the if statement I do not get the items in kits and because of the "&& item.Product.KitStatus != KitStatus.Master" I won't get the kit master product either (which is the intention). If I remove the "&& item.Shippable != Shippable.No" then all the items in the kit get properly listed in the XML (I left out the details of the XML.Append as they are not the problem and just make the code longer and harder to read). Why would it include the items in the kit when there is no test for "shippable" and not include them when the test for "shippable" is in the if statement? Maybe I am going blind!

Code: Select all

 foreach (OrderItem item in _Order.Items)
        {
            //order items
            if (item.OrderItemType == OrderItemType.Product && item.Product != null
                 && item.Product.KitStatus != KitStatus.Master && item.Shippable != Shippable.No)
            {
               // xml append commands to insert the items and quantities 
         
            }
        }

        //end order items
My second question is how to find the "warehouse" to which each item is assigned. I'd love to extend that conditional statement to also not include items that are shipped from a different warehouse. So, let's call it "warehouse 1" and then if an item is shippable AND ships from warehouse 1 how do I do that test?

BTW, let me answer at least one of the obvious questions.
It seems that the items in the kit are not included regardless of the master product (the kit) is "shippable' or not or if the component items are marked as "shippable" or not.
If I have a product (not a kit) that is not shippable, the if shown in the code segment above really does exclude it from the xml.

Inputs are appreciated.

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

Re: Having trouble with "shippable" on items in kits

Post by mazhar » Tue May 11, 2010 7:47 am

For shippable you can try

Code: Select all

if(item.Product.Shippable == Shippable.Yes)
and for warehouse you can try

Code: Select all

if(item.Product.WarehouseId == warehouseId)

Thistle3408
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Apr 19, 2010 4:52 pm

Re: Having trouble with "shippable" on items in kits

Post by Thistle3408 » Tue May 11, 2010 9:22 am

Great. That works. I knew I was missing something trivial...reason is likely that I am going blind reading code all day.

Thanks.

Post Reply