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

Notification

Icon
Error

jorgem
#1 Posted : Tuesday, October 17, 2006 4:36:15 PM(UTC)
jorgem

Rank: Member

Joined: 10/17/2006(UTC)
Posts: 66

I have defined several products with custom property types, like "Color" and "InternalProductCode".

In the checkout.aspx, I am looping through the line items in the basket with code like:

Code:

Dim lineItem as BVSoftware.Bvc5.Core.Orders.LineItem
For Each lineItem in Basket.Items

'*** Here, I would like to access the custom property types of the lineItem



How can I get to the values of the custom property types from the line Item? I have looked at the lineItem.AssociatedProduct and everything else I can think of in the debugger. But can't find the right property. Any times?
Andy Miller
#2 Posted : Tuesday, October 17, 2006 5:07:21 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
Does this help?


Code:

ProductType pt = ProductType.FindByBvin(lineitem.AssociatedProduct.ProductTypeId);
List<ProductProperty> props = ProductType.FindPropertiesForType(pt.Bvin);

foreach (ProductProperty property in props)
{
string value = InternalProduct.GetPropertyValue(lineitem.AssociatedProduct.Bvin, property.Bvin);
}

Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
jorgem
#3 Posted : Tuesday, October 17, 2006 5:47:53 PM(UTC)
jorgem

Rank: Member

Joined: 10/17/2006(UTC)
Posts: 66

Nice. Seems like that would be a handy collection to hang off the LineItem object.

There is one problem, though. If the value is a dropdown list item, it looks like I get a BVIN style number, like "1212313-123123-123123-12312312313". How do I look up the string value for that?

Just for posterity, here is the code in VB:

Code:

Dim pt As ProductType = ProductType.FindByBvin(lineItem.AssociatedProduct.ProductTypeId)
Dim props As System.Collections.Generic.List(Of ProductProperty) = ProductType.FindPropertiesForType(pt.Bvin)
Dim pp As ProductProperty
For Each pp In props
Dim value As String = InternalProduct.GetPropertyValue(lineItem.AssociatedProduct.Bvin, pp.Bvin)
Next


Thanks.
jorgem
#4 Posted : Thursday, October 19, 2006 12:46:33 PM(UTC)
jorgem

Rank: Member

Joined: 10/17/2006(UTC)
Posts: 66

Here is the answer to the second part of the question:

If the product type has a list of choices, then Internal.GetPropertyValue(...) will return the bvin of a ProductPropertyChoice object. The ProductPropertyChoice collection must then be searched. The following function handles the details:

Code:

''' <summary>
''' Lookup the value of a line item's product type by key.
''' </summary>
''' <param name="lineItem"></param>
''' <param name="key"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetProductTypeValue(ByRef lineItem As LineItem, ByVal key As String) As String

Dim pt As ProductType = ProductType.FindByBvin(lineItem.AssociatedProduct.ProductTypeId)
Dim props As System.Collections.Generic.List(Of ProductProperty) = ProductType.FindPropertiesForType(pt.Bvin)
Dim pp As ProductProperty
For Each pp In props
If pp.DisplayName = key Then
Dim ppc As System.Collections.Generic.List(Of ProductPropertyChoice) = ProductPropertyChoice.FindByPropertyID(pp.Bvin)
If ppc.Count = 0 Then
Return InternalProduct.GetPropertyValue(lineItem.AssociatedProduct.Bvin, pp.Bvin)
Else
'*** For items with choices, the property value contains the BVIN of the choice...
Dim bvin As String
bvin = InternalProduct.GetPropertyValue(lineItem.AssociatedProduct.Bvin, pp.Bvin)
For Each choice As ProductPropertyChoice In ppc
If choice.Bvin = bvin Then
Return choice.ChoiceName
End If
Next
Return ""
End If
End If
Next

'*** Not found.
Return ""

End Function

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