Software to help you build a better store
SEARCH
August 12, 2007

How to Create a BVC5 Shipping Provider

BV Commerce 5 (BVC5) supports several kinds of extensions using a provider pattern. One of those is the ShippingProvider extension. A ShippingProvider can provide shipping cost estimates (called shipping rates), or a tracking URL, or both. This article includes a sample ShippingProvider that only provides a tracking URL.

The Code

    1 Imports BVSoftware.Bvc5.Core.Orders
    2 Imports BVSoftware.Bvc5.Core.Shipping
    3 Imports System.Collections.ObjectModel
    4 
    5 Public Class TrackingOnly
    6     Inherits ShippingProvider
    7 
    8     Public Overrides ReadOnly Property Name() As String
    9         Get
   10             Return "Tracking Only"
   11         End Get
   12     End Property
   13 
   14     Public Overrides ReadOnly Property ProviderId() As String
   15         Get
   16             Return "F0FA8EC8-1186-4669-A04F-C47196192730"
   17         End Get
   18     End Property
   19 
   20     Public Overrides ReadOnly Property SupportsTracking() As Boolean
   21         Get
   22             Return True
   23         End Get
   24     End Property
   25 
   26     Public Overrides Function GetTrackingUrl( _
   27         ByVal trackingCode As String) As String
   28 
   29         Return String.Format("http://www.carrier.com/track?id={0}", trackingCode)
   30     End Function
   31 
   32     Protected Overloads Overrides Function GetRates( _
   33         ByVal o As Order, _
   34         ByVal m As ShippingMethod) As Collection(Of ShippingRate)
   35 
   36         Return New Collection(Of ShippingRate)
   37     End Function
   38 
   39     Protected Overloads Overrides Function GetRates( _
   40         ByVal g As Collection(Of ShippingGroup), ByVal m As ShippingMethod) _
   41         As Collection(Of ShippingRate)
   42 
   43         Return New Collection(Of ShippingRate)
   44     End Function
   45 
   46     Public Overrides Function GetSelectedShippingNames( _
   47         ByVal method As ShippingMethod) As Collection(Of String)
   48 
   49         Return New Collection(Of String)
   50     End Function
   51 
   52     Public Overrides ReadOnly Property RequiresCity( _
   53         ByVal shippingMethodId As String) As Boolean
   54 
   55         Get
   56             Return False
   57         End Get
   58     End Property
   59 
   60     Public Overrides ReadOnly Property RequiresPostalCode( _
   61         ByVal shippingMethodId As String) As Boolean
   62 
   63         Get
   64             Return False
   65         End Get
   66     End Property
   67 
   68     Public Overrides ReadOnly Property RequiresState( _
   69         ByVal shippingMethodId As String) As Boolean
   70 
   71         Get
   72             Return False
   73         End Get
   74     End Property
   75 End Class

Notes

Lines 8-12: Return the name you want to appear in every list of shipping providers. For example "UPS", "US Postal Service", or "Yellow Freight".

Lines 14-18: Return a unique id for this ShippingProvider. The id must be unique among all ShippingProviders in your site. It can be a GUID as in this example, but it is up to you.

Lines 20-24: Return True to indicate that this ShippingProvider will provide a tracking URL.

Lines 26-30: Return the tracking URL. The trackingCode parameter is the code that the merchant enters in the Tracking Code field on the BV Admin > Orders > Order Shipping page.

Lines 32-74: This ShippingProvider does not provide shipping rates so all of the functions related to shipping rates return False or empty lists.

To Install this ShippingProvider

  1. Create a file in the App_Code directory of your site called TrackingOnly.vb and type the code shown above into the file (or copy TrackingOnly.vb from the attached zip file to the App_Code directory of your site).
  2. Add the line shown below to the LoadCustomShippingProviders method in App_Code/TaskLoader.Custom.vb:

    result.Add(New TrackingOnly())

To Use this ShippingProvider

Navigate to the BV Admin > Orders > Order Shipping page.

  1. Select "Tracking Only" from the list of ShippingProviders.
  2. Enter a tracking code and click on the Ship Items button.

This site looks much better in a browser that supports current web standards, but it is accessible to any browser. Download one now This link is to a third party web site which will open in a new window

Some parts of this site will not work effectively on this older browser.
Please consider updating your browser This link is to a third party web site which will open in a new window

SSL