Now that we have gathered all the data we need from the customer, and are able to turn that data into a price using the process pipelines we created in the last step, we can create a yield pipeline.

The duty of the yield pipeline is to transform the collected data into payloadlets of type number, and finally tell Smidyo how to put together a total price from those numbers.

You know the drill, go Yield pipelines > New.

Paste in this code, and replace all references to test-salesdomain to the slug of your own sales domain.

Inputs

If you take a look at the inputs of this pipeline, you can see that they are pretty much the same as the outputs of the form pipeline we created earlier.

This is because we will later pair together the two when we create the offering. 

Quote steps & Order steps

As you can see, we have both quoteSteps and orderSteps in our pipeline. 

Quote steps get executed when we poll our yield pipeline for a price, for an instant price preview, for example.

And once the customer decides to place an order, the order steps get executed.

For now, let's focus on the quote steps!

Step 1

In step 1, using internal source block TABLE_COLUMNS (like we also used in the form pipeline) we fetch the quantity discount breaks. We store column min-quantity in pipeline value min-quantities, and column discount-percentage in discount-percentages

Step 2 

Let's use another internal source block: TABLE_CELLS. It works the same way as TABLE_COLUMNS, but instead of getting the entire column of data, we specify which specific row-name we want in the block's in  parameter.

We fetch the row with the name provided from the pipeline input material-id, and store the data in pipeline values with the same name as the column.

Step 3 

We can use the simple internal source block CONSTANT to get the cutting cost from the constant material-cutting-cost and store it in material-cost.

Step 4

Now let's calculate what we need for the price. The square meter area, and the actual discount percentage.

For this, we use the SUB_PROCESS_PIPELINE block. Provide the slug of the process pipeline we created earlier in the property subProcessPipelineSlug (with the sales domain slug + .pp. ).

Feed the sub process pipeline with the width and the height, and from the pipeline we get the square area, and store it in the pipeline value m2.

{
  "type": "SUB_PROCESS_PIPELINE",
  "subProcessPipelineSlug": "test-salesdomain.pp.calculate-square-area",
  "in": [
    {
      "type": "PIPELINE_VALUE",
      "inFrom": "width-mm",
      "inTo": "width-mm"
    },
    {
      "type": "PIPELINE_VALUE",
      "inFrom": "height-mm",
      "inTo": "height-mm"
    }
  ],
  "out": [
    {
      "outFrom": "m2",
      "outTo": "m2"
    }
  ]
}

Step 5

Same deal here, but we use the get-discount-percentage process pipeline. Now we have the discount-percentage!

{
  "type": "SUB_PROCESS_PIPELINE",
  "subProcessPipelineSlug": "test-salesdomain.pp.get-discount-percentage",
  "in": [
    {
      "type": "PIPELINE_VALUE",
      "inFrom": "discount-percentages",
      "inTo": "discount-percentages"
    },
    {
      "type": "PIPELINE_VALUE",
      "inFrom": "min-quantities",
      "inTo": "min-quantities"
    },
    {
      "type": "PIPELINE_VALUE",
      "inFrom": "quantity",
       "inTo": "quantity"
    }
  ],
  "out": [
    {
      "outFrom": "discount-percentage",
      "outTo": "discount-percentage"
    }
  ]
}

Defining the price sequence

Now we have all the data in the form of payloadlets of type number to put everything together into a price.

Let's take a look at the yield pipeline's quotePriceSequence property.

{
  "type": "ADD",
  "title": "Material",
  "specification": {
    "type": "PIPELINE_VALUE",
    "inFrom": "material-name"
  },
  "name": "m2-price"
},
{
  "type": "MULTIPLY",
  "title": "Usage, m2",
  "name": "m2"
},
{
  "type": "ADD",
  "title": "Cutting cost",
  "name": "cutting-cost"
},
{
  "type": "PERCENTAGE_OFF",
  "title": "Quantity discount",
  "name": "discount-percentage"
},
{
  "type": "MULTIPLY",
  "title": "Quantity",
  "name": "quantity"
}

This should be pretty straight-forward!

  • Start from 0.
  • ADD the payloadlet stored in m2-price.
  • MULTIPLY that with the payloadlet stored in m2.
  • ADD cutting-cost.
  • Detract the percentage stored within discount-percentage, using PERCENTAGE_OFF.
  • MULTIPLY everything by quantity.

And we end up with a total price. Nice!

As you can see, we can also provide a specification property for all steps in the price sequence. All this is is a reference to a pipelne value of type text, so we can provide a descriptive specification for that particular line. In this case, the title of the material (hi-lighted in the image above).

Did this answer your question?