Calculating Product Prices (API Terminology Explained #11)

In my last blog post in the series “API Terminology Explained”, I told you about how to map coordinates from Spreadshirt’s SVG user coordinate system to your application’s coordinate system in order to display products in your application correctly. In this blog post, I will tell you more about how to calculate product prices correctly.

Preliminaries

As already explained in the product model, a product is always based on a product type, such as a shirt. A product has one or more text or design configurations that define on which print area Spreadshirt shall print text or designs with a specific print type, such as flock, flex or digital, and for non-digital print types with specific print colors, such as black, red or white.
Product types, print types and print colors have shop specific prices. Designs may have a design commission adjusted by the owner of the design.  Please note that when working in a shop context, e.g. /shops/205909, all prices are returned in the adjusted shop currency.

Calculation

Knowing the basics, the price calculation is quite simple as illustrated below:

  design commission
+ print type price
+ used print color prices (only for non rgb colors - flex, flock, ...)
----------------------------
= design configuration price

  print type price
+ used print color prices (only for non rgb colors - flex, flock, ...)
----------------------------
= text configuration price

  product type price
+ design configuration price
+ text configuration price
...
----------------------------
= product price

The actual product price is the sum of product type price and all configuration prices. The configuration price is the sum of print type price and print color price per used color. For design configurations, the design commission may be added on top of the basic configuration price.

Example

In our example, we want to create a product based on product type 6 with an I heart design and a “leipzig” text printed with print type 14 (flex). We print the design with flex print and the two print colors black (13) and red (20) and the text with print color black (13). The product payload would look as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<product xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://api.spreadshirt.net"
         weight="0.0"
         xlink:href="http://api.spreadshirt.net/api/v1/shops/591997/products/100699801"
         id="100699801">
    <name>Männer T-Shirt klassisch</name>
    <user xlink:href="http://api.spreadshirt.net/api/v1/users/40000" id="40000"/>
    <productType xlink:href="http://api.spreadshirt.net/api/v1/shops/591997/productTypes/6"
                 id="6"/>
    <appearance id="1"/>
    ...
    <configurations>
        <configuration type="design" id="101533180">
            <printArea id="4"/>
            <printType xlink:href="http://api.spreadshirt.net/api/v1/shops/591997/printTypes/14"
                       id="14"/>
            <offset unit="mm">
                <x>54.447</x>
                <y>80.907</y>
            </offset>
            <content dpi="25.4" unit="mm">
                <svg viewBox="0 0 200.025 109.008">
                    <image xlink:href="http://image.spreadshirt.net/image-server/v1/designs/6336245"
                           height="109.008" width="200.025" printColorRGBs="#000000 #D41C3B"
                           printColorIds="13 20" designId="6336245"/>
                </svg>
            </content>
            ...
        </configuration>
        <configuration type="text" id="101533181">
            <printArea id="4"/>
            <printType xlink:href="http://api.spreadshirt.net/api/v1/shops/591997/printTypes/14"
                       id="14"/>
            <offset unit="mm">
                <x>26.178</x>
                <y>211.173</y>
            </offset>
            <content dpi="25.4" unit="mm">
                <svg viewBox="23.633 -0.604 210.072 50.636">
                    <text height="50.636" width="210.072" font-style="normal"
                          font-size="55.337404456041625" font-weight="normal"
                          font-family="CooperBlackLTRegular" fill="#000000"
                          text-anchor="middle" printColorId="13" fontId="45"
                          fontFamilyId="24">
                        <tspan font-style="normal" font-size="55.337404456041625"
                               font-weight="normal" font-family="CooperBlackLTRegular"
                               fill="#000000" lineWidth="256.5638058599638"
                               text-anchor="middle" y="38.79150390625" x="128.2819029299819"
                               printColorId="13" fontId="45" fontFamilyId="24">Leipzig</tspan>
                    </text>
                </svg>
            </content>
            ...
        </configuration>
    </configurations>
    ...
</product>

The price is calculated as follows:

  design m6336245-1           1.00 €
+ print type 14               0.50 €
+ print color 13              2.50 €
+ print color 20              2.50 €
------------------------------------
= design configuration price  6.50 €

+ print type 14               0.50 €
+ print color 13              2.50 €
------------------------------------
= text configuration price    3.00 €

  product type 6             12.90 €
+ design configuration price  6.50 €
+ text configuration price    3.00 €
------------------------------------
= product price              22.40 €

Summary

In this blog post, I told you about how to calculate product prices for Spreadshirt products correctly. You might need this knowledge, in case you want to create new products in your application and need to display the correct product prices during product creation.

Please also have a look at the other articles in the series “API Terminology Explained”:

——————————-
Martin Breest
Platform Evangelist

2 Replies to “Calculating Product Prices (API Terminology Explained #11)”

Comments are closed.