04-01-04 06:42 PM
Commerce Server 2002
Retail Site (ASP)
Windows 2000 Server
Someone can help me? I created a custom component that
calculates the shipping. I registred it using the
tool "PipeReg.exe", selecting shipping stage.
When I select the shipping in the site, the error is
raised:
Commerce.MtsTxPipeline (0x80004005)
Component Execution failed for component[0x3] hr:
0x80004005 ProgID: Commerce.ShippingDiscountAdjust.1
Dictionary error: Value for key '_cy_shipping_total' in
dictionary 'Order Dict' missing (expected a variant of
type 6) (orderform=default)
Code of Component:
' Execute() -- This function gets called when the
pipeline runs
' Return 1 for Success, 2 for shopper warnings, 3 for error
Private Function IPipelineComponent_Execute(ByVal
pdispOrder As Object, ByVal pdispContext As Object, ByVal
lFlags As Long) As Long
IPipelineComponent_Execute = 1
On Error GoTo ErrorHandler
' Initialize the orderform and context dictionaries as
CDictionary's
Dim Context As CDictionary, Orderform As CDictionary
Set Context = pdispContext
Set Orderform = pdispOrder
' Shipping components commonly look at the Addresses
datastruct, and Orderform.Items, and MessageManager
Dim Items As CSimpleList, Addresses As CDictionary,
MessageManager As Object
Set Items = Orderform.Value("Items")
Set Addresses = Orderform.Value("Addresses")
Set MessageManager = Context.Value("MessageManager")
Dim AddressShipping As Dictionary
Set AddressShipping = New Dictionary
' Shipping components iterate over a list of shipments
to process
Dim Shipment As CDictionary, ShipmentsToProcess As
CSimpleList
Set ShipmentsToProcess = Context.Value
("shipments_to_process")
For Each Shipment In ShipmentsToProcess
Dim ShipmentItemTotal As Currency, Item As
CDictionary, ItemPrice As Currency, ItemIndex As Variant
Dim dWeigth As Double, priceTotal As Currency,
weigthTotal As Double
Dim dictProd As CDictionary
Set dictProd = New CDictionary
' Each Shipment dictionary contains a simplelist
of orderform ItemIndexes
ShipmentItemTotal = 0
For Each ItemIndex In Shipment.Value("ItemIndexes")
' Get the indexed item from the orderform.items
Set Item = Items(ItemIndex)
' Get any item info needed to calculate
shipment price
ItemPrice = Item.[_cy_oadjust_adjustedprice]
If IsNull(Item.Value("peso")) Then
dWeigth = 1
Else
If Item.Value("peso") < 1 Then
dWeigth = 1
Else
dWeigth = Item.Value("peso")
End If
End If
weigthTotal = weigthTotal + dWeigth
priceTotal = priceTotal + ItemPrice
Next
' You could also look at the addresss info...
' Each shipment dictionary contains a
shipping_address_id, that refers to the address dict for
the shipment
Dim ShippingAddressId As String
ShippingAddressId = Shipment.Value
("shipping_address_id")
Dim Address As CDictionary, PostalCode As
String, RegionCode As String
Dim bCapital As Boolean, iAddressItem As
Variant
bCapital = False
Set Address = Addresses.Value
(ShippingAddressId)
PostalCode = Address.Value("postal_code")
RegionCode = Address.Value("region_code")
' Compute the shipping total for the shipment
Dim ShipmentShippingPrice As Currency
ShipmentShippingPrice = CCur(getValorFrete
(PostalCode, RegionCode, priceTotal, weigthTotal, Context
("TransactionConfigConnectionString")))
Shipment.[_cy_shipping_total] = RoundCurrency
(Orderform, ShipmentShippingPrice)
Next
ErrorHandler:
IPipelineComponent_Execute = 2
End Function
[ Post a follow-up to this message ]
|