• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

danscan
#1 Posted : Thursday, May 18, 2017 10:13:21 PM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I am reading the result of the Orders_Order_FindByCriteria
I am looking at the order items and I am trying to determine where the order item options are now listed. In an old version this was in SelectionData.

My end goal is to list the order options as OptionName and Selected value. So where can I get find that? (KitSelections?)

Thank you for the help
Aaron
#2 Posted : Friday, May 19, 2017 8:33:50 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
The Modifiers and Inputs properties of the LineItem contain the options for regular products. If the product is a kit you would look at the KitSelections property.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
 1 user thanked Aaron for this useful post.
danscan
#3 Posted : Friday, May 19, 2017 9:50:30 AM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I looked up the post here:
http://www.bvcommerce.co...eItems-in-an-Order.aspx


Orders_LineItem_FindByOrderId does this return a collection of line items for an order?

I figured the pseudo code would be like this:
Get the collection of orders by calling Orders_order_findbycriteria
For each order call Orders_LineItem_FindByOrderId
With this full order my code could save it.

Are these the relevant calls I have to make get the pending orders for the day?


Aaron
#4 Posted : Friday, May 19, 2017 11:05:17 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: danscan Go to Quoted Post
Orders_LineItem_FindByOrderId does this return a collection of line items for an order?

Yes

Alternately you could call Orders_Order_FindByBvin which will load the entire Order object and it's children. So, if you need anything other than line items you could use this call to save additional API calls.

Originally Posted by: danscan Go to Quoted Post
I figured the pseudo code would be like this:
Get the collection of orders by calling Orders_order_findbycriteria
For each order call Orders_LineItem_FindByOrderId
With this full order my code could save it.

Are these the relevant calls I have to make get the pending orders for the day?

This should work. What are you trying to save/update? The reason I ask is that if you call Orders_Order_Update to perform an update it will only update the main Order object, not it's children (e.g. line items).

Edited by user Friday, May 19, 2017 11:05:53 AM(UTC)  | Reason: Not specified

Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
danscan
#5 Posted : Friday, May 19, 2017 2:21:42 PM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I assume that I will need to update line items that were shipped or not based on quantity on hand discrepancies.
Your cart has the ability to update partial shipments for line items. For example someone orders 4 shirts but only 3 are actually available.
If so is there an end point to handle this type of Update?

Aaron
#6 Posted : Friday, May 19, 2017 3:50:26 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
It depends how tight you want the integration to be. The LineItem record has a QuantityShipped property. However, if you want to include a tracking number, show partial shipments, etc you will need to create shipping packages for the order. Below is a heavily commented C# code sample written against the API. This should give you a better understanding of what needs to happen:

Code:

private static bool ShipOrder(ref WebServices3.AuthenticationToken token, string orderId)
{
    bool result = false;

    if (!token.TokenRejected)
    {
        WebServices3.WebServices3SoapClient ws = new WebServices3.WebServices3SoapClient();

        // look up order -- alternately you could use FindByCriteria to look it up by the order number (or look up a group of orders)
        WebServices3.Order o = ws.Orders_Order_FindByBvin(ref token, orderId);

        // create new package to be shipped -- note that this code assumes that ALL items in the order will ship in a single package
        WebServices3.Package pkg = new WebServices3.Package();
        pkg.Bvin = Guid.NewGuid().ToString();
        pkg.OrderId = o.Bvin;
        pkg.ShipDate = DateTime.Now;
        pkg.Length = 5;
        pkg.Width = 5;
        pkg.Height = 5;
        pkg.SizeUnits = WebServices3.LengthType.Inches;
        pkg.Weight = 10;
        pkg.WeightUnits = WebServices3.WeightType.Pounds; // -or- WebServices3.WeightType.Kilograms
        pkg.TrackingNumber = "12345"; // your tracking number
        pkg.ShippingProviderId = o.ShippingProviderId;

        // NOTE: there are many more optional fields that you can set for the Package object

        // get the shipping service code -- this field can be an empty string
        if (!String.IsNullOrEmpty(o.ShippingProviderServiceCode))
            pkg.ShippingProviderServiceCode = o.ShippingProviderServiceCode;
        else
        {
            WebServices3.ListItem[] items = ws.Shipping_ShippingProvider_ListServiceCodes(ref token, o.ShippingProviderId);
            if (items != null)
            {
                foreach (WebServices3.ListItem item in items)
                {
                    // if no code is provided, you can hardcode defaults, possibly using a switch statement that looks for a specific default method for each shipping provider. A list of providers and the corresponding shipping methods available is provided below. This part is optional.

                    if (item.Text == "shipping method/service name") // change this value to use whichever shipping method you desire; a list of the configured shipping methods for each
                        pkg.ShippingProviderServiceCode = item.Value;
                }
            }
        }

        // create our PackageItem array to hold the items being shipped in this package
        WebServices3.PackageItem[] packageItems = null;

        // add items to package
        foreach (WebServices3.LineItem li in o.Items)
        {
            // exclude non-shipping items - if we can't find the associated product, assume that it's a shipping product
            WebServices3.Product p = li.AssociatedProduct;
            if (p == null)
            {
                p = ws.Catalog_InternalProduct_FindBySku(ref token, li.ProductId);
            }

            if (p == null || !p.NonShipping)
            {
                if (packageItems == null)
                    packageItems = new WebServices3.PackageItem[1];
                else
                    Array.Resize(ref packageItems, packageItems.Length + 1);

                // quantity of each item that will be shipped in the package
                decimal qty = (li.Quantity - li.QuantityShipped);

                // create PackageItem
                WebServices3.PackageItem pi = new WebServices3.PackageItem();
                pi.LineItemBvin = li.Bvin;
                pi.ProductBvin = li.ProductId;
                pi.Quantity = qty;

                // add PackageItem to PackageItem array
                packageItems[packageItems.Length - 1] = pi;

                // add item weight to package weight
                decimal unitWeight = 1.0m; // 1 lb.
                pkg.Weight += unitWeight * qty;
            }
        }

        // add all package items (PackageItem array) to the package
        pkg.Items = packageItems;

        // if the package is empty, do not add it and do not ship it
        if (pkg.Items.Length > 0)
        {
            if (ws.Shipping_Package_Insert(ref token, pkg))
                if (ws.Shipping_Package_Ship(ref token, pkg))
                {
                    result = true;
                    o.ShippingStatus = WebServices3.OrderShippingStatus.FullyShipped;
                    ws.Orders_Order_Update(ref token, o);
                }
        }
    }

    

    return result;
}
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
danscan
#7 Posted : Tuesday, May 23, 2017 10:40:48 PM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I think there might be an issue with the demo store API
I have been calling Orders_Order_FindByCriteria but I have not been getting any lineitems.

I created two orders (11pm est) in the demo site.
When I call the Orders_Order_FindByCriteria I see the two orders but there are no line items.
When I call the Orders_LineItem_FindByOrderId no line items are returned either.
I also moved the order from pending to ready to be shipped but that did not fix the issue.

Thanks for the help.
Aaron
#8 Posted : Wednesday, May 24, 2017 9:50:38 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: danscan Go to Quoted Post
When I call the Orders_Order_FindByCriteria I see the two orders but there are no line items.

Only the Orders_Order_FindByBvin call will return all of the child objects of the Order object, such as line items. So, you can either make this call to get all child objects or call Orders_LineItem_FindByOrderId to just get the line items.

Originally Posted by: danscan Go to Quoted Post
When I call the Orders_LineItem_FindByOrderId no line items are returned either.

Can you post your request XML?
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
danscan
#9 Posted : Wednesday, May 24, 2017 10:19:33 AM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I might be able to later today or tonight.
To check this out sooner I did the following steps:
Placed two orders in the demo store. (demoadmin)
In my service
1. Made a login request
2. Used the authtoken to make a Orders_Order_FindByCriteria request
3. Recieved the two orders
4. Loop through the two orders to get the LineItems
5. I called the Orders_LineItem_FindByOrderId passing my authtoken and the order id of 1001 or 1002.
No exception is returned just empty lineitem array.

Since the store resets it might be easier to just place an order and try it when you get a chance.
Note:
I am attempting to get orders so they can be sent to an order management system. Do you think that using the Orders_Order_findByBvin would be better anyway? I need the particulars of an order that are needed to ship the correct item. I am early enough in the development process to switch if need be.
Aaron
#10 Posted : Wednesday, May 24, 2017 10:55:10 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
The order number is not the order ID. You should be passing the Bvin value of the order, which is the database ID value.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
 1 user thanked Aaron for this useful post.
danscan
#11 Posted : Friday, May 26, 2017 1:22:07 PM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I pulled the order with the Order_Order_FindbyBvin.
It has almost all the information needed but one piece of information is still needed.
The line item modifier values.
At first glance I think I have to make another call to get the value of the modifier by calling
Catalog_ProductModifier_FindByBvin and then looking at the results to find the value of the selected option.


Is there a better way to get all of the values for an order in one call? I am ok with making a call to get the list of orders and then looping through to get the detailed order information.

I am updating a script that used to go directly to the database and would get the LineItem.SelectionData.SelectedOption value. this is the last piece holding me up for this portion of the code.
danscan
#12 Posted : Monday, May 29, 2017 10:48:01 PM(UTC)
danscan

Rank: Member

Joined: 5/17/2017(UTC)
Posts: 11
Location: New Jersey

Thanks: 4 times
I have another question on the Order update webservice.
Does the service update only the provided fields or does it try to update all fields even items that were not provided?
Should I grab the original order from the system update that object and send that object for updating?
Aaron
#13 Posted : Tuesday, May 30, 2017 2:31:32 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: danscan Go to Quoted Post
I pulled the order with the Order_Order_FindbyBvin.
It has almost all the information needed but one piece of information is still needed.
The line item modifier values.

At first glance I think I have to make another call to get the value of the modifier by calling
Catalog_ProductModifier_FindByBvin and then looking at the results to find the value of the selected option.

Yes, basically. There is a Modifiers property of the LineItem object (the Items property of the Order object) which contains an array of LineItemModifier objects that apply to the LineItem. It has a ModifierValue property which will be the ID/Bvin value of the ProductModifierOption. So, if you need more than the ID value, like the text of the selection, then you will need to do a subsequent call to get the ProductModifier object using Catalog_ProductModifier_FindByBvin. It has a ModifierOptions property which is an array of the ProductModifierOption objects. You'll just need to match the Bvin value of the ProductModifierOption that you got from your LineItemModifier.ModifierValue property.

Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Aaron
#14 Posted : Tuesday, May 30, 2017 2:36:07 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: danscan Go to Quoted Post
Does the service update only the provided fields or does it try to update all fields even items that were not provided?

Internally the update will be on the entire parent object. So, if you only change one field of an Order object it will update all fields of that parent record. If you don't provide the other fields that may generate an error. If it doesn't, the existing values for the Order would be used for the other fields (i.e. they would not be cleared).

Originally Posted by: danscan Go to Quoted Post
Should I grab the original order from the system update that object and send that object for updating?

Yes
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
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.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012