Dynamic product prices

The price of a product may be defined at the moment that it is added to the cart. This functionality is useful when the application logic is responsible for calculating the product price.


            BasketIf b = new Basket();
            b.setQuantity(1);
            b.setProductId(selectedProd.getId());
            b.setFinalPriceExTax(new BigDecimal("22.22"));
            kkAppEng.getBasketMgr().addToBasket(b, /* refresh */true);


In order to define your own price, you must set the FinalPriceExTax attribute of the Basket object as shown above. Normally this isn't set and the price is retrieved from the Product. The above example is taken from one of the storefront application action classes which is communicating with the KonaKart client engine. The concept is the same when communicating directly with the server engine.

In order to allow this functionality, the "Allow to use Basket Price" configuration variable must be set. This can be done through the Admin App under Configuration >> Security and Auditing. Note that if the Web Services interface is publicly available, a programmer has the possibility of writing a utility to add a product to the cart with any price. Therefore we advise using this functionality only when the Web Services interface isn't available over the web (the normal case).