How do I update an Order with custom values

×

BirdDog eCommerce allows you to easily make changes to an Order, just before it is written to Macola using the UpdateOrder routine. This routine hands in an Order object of type IOrder.

Set User Defined Field 1 to Custom Value

Using the following syntax you can set User Defined Field 1 on the Order to the value of a Drop Down List you passed on the page.

Create the following Drop Down List on the CheckOut.Aspx page:

    <asp:DropDownList runat="server" ID="MyCustomDropDownList">

        <asp:ListItem Value="Value1" Text="Display Text 1" Selected="true"></asp:ListItem>

        <asp:ListItem Value="Value2" Text="Display Text 2"></asp:ListItem>

        <asp:ListItem Value="Value3" Text="Display Text 3"></asp:ListItem>

    </asp:DropDownList>

This Drop Down List will show 3 values (Display Text 1-3) with Display Text 1 being selected by default.

Set Delivery Date with Date Picker

The add the following date control:

<BDW:DatePicker runat="server" ID="dpDeliveryDate"></BDW:DatePicker>

(FYI: Be aware the current iteration of this BDW:DatePicker has some styling issues on the Ecommerce side that will need to be addressed on-page.)

The Routine

Create the following routine after the <script runat="server"> tag at the top of the page:

    Protected Overrides Sub BeforePageLoad()

        MyBase.BeforePageLoad()
        If Not IsPostBack Then
            'This makes the initial value today's date
            dpDeliveryDate.Value = Now.Date
        End If

    End Sub

    Protected Overrides Sub UpdateOrder(ByVal Order As BirdDogSoftware.Interfaces.IOrder)

        With Order

            .User_Field_1 = MyCustomDropDownList.Text

           'Set the order's default shipping date to the value the user chose

            .Shipping_Date = dpDeliveryDate.Value

            'Set a custom field named DueDate to the value the user chose
            .Fields("DueDate").ValueDate = dpDeliveryDate.Value

        End With

    End Sub

This routine will write 'Display Text 1' into User Defined Field 1 on the Order.  If you instead wrote:

    .User_Field_1 = MyCustomDropDownList.Value

The routine would write 'Value1' into User Defined Field 1.