Creating User Interfaces
Library WebUI Home

Overview

Startup & Operation Capturing & Displaying data Styling with CSS Sale lifecycle

Examples

Hello World / minimal Online Selling Page

Overrideables

User Message User Prompt Device

In Depth

EventSource realtime feed The Fieldpine Object UI Dispatch Data Fields Global Namespace Scripts

WebView2

Barcode Handling

Lifecycle of a sale

Once you have created your page and can successfully login you will want to expand the selling screen. This page quickly explains the lifecycle of a sale, so that you can understand the internal process which will make changing the flow easier to understand. For more examples see Primitives Cheat Sheet

The general lifecycle of a sale is

  1. Create a new sale
  2. Add items to the sale
  3. Edit items if needed
  4. Pay for the sale
  5. Finish and close the sale

Create a Sale

The basic command is 'sale id new', but if you skip this step and simply start adding items to a sale then a sale will be automatically created

FieldpinePrimitive(":sale id new")

Save the Sale id in case you want it later? The following modifies the create command and uses a callback function to extract the Sale id. This can be done in other ways and at any time as you are sent the complete sale every time.

FieldpinePrimitive(":sale id new", function(fromFieldpine) {
    SalePhyskey = fromFieldpine.PrimitiveRun[0].Sale[0].Physkey;
})

Set the customer associated with this sale.

FieldpinePrimitive(":sale set customer 1234")

You can generally set the customer at any stage in the sale lifecycle, except if can be blocked by business rules, so is generally a better idea to set the customer early.

The Fieldpine engine will go back and reprice the sale when you change the customer, but some things are not possible to retroactively apply. Consider a business rule that says customer 1234 must provide an order number when purchasing lumber. If you first sell some lumber, then order number will not be prompted. If you now set the customer as 1234 then that business rule has already been processed and will not be reprocessed. There are many other examples as well. This restriction is not common though and tends to be more rules/process driven retail environments.

Add Items to Sale

FieldpinePrimitive(":sale add pid 10")

Edit Items on Sale

FieldpinePrimitive(":sale alter line qty 2")
FieldpinePrimitive(":Sale alter line serial ABC123")    // See comments about field encoding

Pay the Sale

FieldpinePrimitive(":sale pay cash")

Finish and Close the Sale

Autoclosed?