Falsehoods programmers believe about online shopping…


Selling stuff is a pretty old human activity, and merchants had found ways to distinguish themselves from their competition way before Archimedes had shouted Heúrēka. Trade is a complicated business, and online shopping has not made that simpler, quite the contrary. So when programmers build system to support online shopping they tend to stumble on their own erroneous, assumptions.

This post is similar to the one I made about geographic assumptions, but about online shopping, again this list is not exhaustive, and some of the falsehoods are disputable.

A product has a price
Products sold on auction site do not yet have a price. The moment the price is known is actually the moment the item will not be on sale anymore.

Except for auctioned items, products have one price
Products do not have one price, they have many prices: with or without taxes, then there is the sale price, the regular price, the list price, the manufacturer approved price, the mandatory publisher price.
Products have one final total price
The total price paid typically depends on a lot of variables: time of the transaction, location of the buyer, shipping methods, memberships, sometimes even the profiling of the buyer.
A product has a strictly positive price
Many phones are sold for “free”, there is typically a subscription behind it. Some online shops also add samplers and documentation as free items to their inventory.
A price is a number
Without a currency, a price is meaningless on the internet.
A price is a floating pointer number and a currency
Using floating points for price is incorrect: no currency is defined for transaction below two decimal points, 3.1415 is a valid floating point number value, but USD 3.1415 is not a valid price for a transaction. Some currencies like the Japanese yen don’t accept any decimal position at all (the fraction of the yen, the sen, was removed from circulation in 1953). More generally floating point representation has rounding and approximation behaviour which are bad for monetary values which need to be exact.
Currencies need to be rounded to some decimal position
The Swiss franc needs to be rounded to five centimes.
Currencies symbols uniquely identify a currency.
The peso and dollar sign $ is used my many countries: USA, Cananda, Australia, Brunei, Namibia. The ¥ sign is used both the Japanese Yen and the Chinese Yuan.
Currencies have a unicode symbol
The Swiss franc does not, and until 2010, neither did the India rupee.
Currencies have zero or one unicode symbol
The dollar and peso symbol appears three times in unicode: 0x24 ($), 0xFF04 ($), 0xFE69 (﹩)
Currencies have zero or one unicode symbol after normalisation
The Japanese yen can be represented by the following symbols: ¥, 円, 圓.
Currencies can be described by a single three letter code
The ISO 4216 code for the Russian ruble is RUB, the three letter code руб is widely used, so is CA$ for the Canadian dollar.
Each stock keeping unit translates to a product
Some bulky items have to be kept in the warehouse as two or more boxes, hence two stock keeping units, but can only sold together as one product.
Each product has an picture
Many generic, or bulky items are sold online without pictures: pocket books in Japan, but also packs of screws etc.
You can put all products in database
Increasingly products can be customised, a shop that sells T-shirts with custom text as an infinite number of products, which won’t fit in a database. Even if you consider some good whose dimensions can be customised, the combinatorial growth of possibilities will quickly go beyond the capacity of a database.
There is a common keying system for products
GTINs are the closest thing, but many smaller manufacturer do not participate in the system, some items have multiple keys. The system also does not support custom goods.
There is a common system for annotating web-pages with products
There are multiple micro-data and micro-format variants.
In stock means the item is in the warehouse
Many online sellers do not have any actual warehouse, they ship directly from their suppliers (Drop shipping)

Flattr this!

6 thoughts on “Falsehoods programmers believe about online shopping…

  1. – One more falsehood, in your own text: “no currency is defined for transaction below two decimal points” : that is/will probably be necessary with bitcoins. A bitcoin is more than 300 €: even 0.01 BC is too much to pay for my daily baguette. I wonder if there are more common currencies with this problem.
    And I’ve seen unit prices with 5 or 6 decimals, because the amounts were huge (how many barrels of oil per month through a pipeline?). Of course the final invoice was rounded.

    – You can add another one : “You can convert from one unit to another one with a fixed number”. I was naive enough to think this until I had to compute the number of phones to put in boxes on a pallet, or the number of bottles (with different sizes) in a crate, all of this depending of course of the precise product. My last problem of the kind involved converting linear meters of drywall to kg or m3…

  2. You are right, but this brings another point which is there are two prices, unit-price (which might be a smaller fraction) and transaction price. Note that with smaller fractions, using floating point is even more dangerous, as the rounding effects become more prevalent…

  3. Regarding the code for Russian ruble: in 2013 a symbol looking like a “P” with a horizontal bar was officially adopted by the Russian Central bank (and it was sometimes used even before its official recognition: http://www.artlebedev.ru/kovodstvo/sections/159/ ). AFAIK, it has not yet found its way to Unicode, and often the three-letter rub. or руб. is still used – and for the new symbol, you have to do dirty tricks in HTML and CSS (http://www.artlebedev.ru/tools/technogrette/html/rouble/ ).

  4. > Products have one final total price

    Other cases where this is not true:
    If the product is sold in various countries it might have multiple prices because of different taxes or just because the people selling it fell like the Europeans can afford a higher price than the Americans.

    Maybe another point to add:

    > Products have a physical representation (that has to be shipped to a physical address)

    Not true for software or song downloads etc.

  5. About Swiss Francs and 5 Rappen: this is not totally true.
    – the smallest coin in general is 5rp and the 1 & 2rp aren’t coined anymore, but they’re still valid (but I think can be rejected in shops).
    – you can have items tagged as *.99, usually it’s then rounded after the total. One shop used to do this and also give out 1rp coins ~20 years ago, not sure about today.
    – bank accounts also can have weird amounts like “564.83+”, signifying that it was rounded down and can be rounded up next time.
    – there’s also the question when to round: each step, sometimes, only at the end. Also VAT at 8%. Which one is rounded, with or without?

  6. “Using floating points for price is incorrect: no currency is defined for transaction below two decimal points”

    Uh. This isn’t true. Bitcoin has 8 decimal digits of precision. Worse, unlike dollars, where using a 32-bit fixed point might be (relatively) unlikely to cause a disaster (2^31 cents is a ridiculous amount of money, about 21 million dollars), fixed points to represent Satoshi (10^-8 BTC) could plausibly be the price of a singular item, as that’s only 21 bitcoins, which is as of this writing worth a̶b̶s̶o̶l̶u̶t̶e̶l̶y̶ ̶n̶o̶t̶h̶i̶n̶g̶ $22000 USD.

    A bitcoin-specific falsehood might be “I’ll never have to deal with any amount more than the supply cap of ~21 MegaBTC, or a 2.1 quadrillion Satoshi.

    Whilst it’s clearly impossible to have that many bitcoins, things like the total transaction value for a year could, and probably do, easily exceed this hard cap.

Leave a Reply