7 - Creating a calculator from a mathematical formula - HPC
You can use HikaPrice Calculator for creating a calculator using simple mathematical formulas. For more complex formulas and features, you can load a spreadsheet file directly (Pro version).
First of all you need to create your HikaShop Product:
- Click on "Components > HikaShop > Products > New" on the top Joomla! menu
- Insert the name of the Product: HPC will override the HikaShop product features.
- Set a price in "Prices and taxes". Also putting "0" is fine. This is important otherwise, HPC can't attach its features to the product page.
- Save the product by clicking on "Save & Close"
After you've created the HikaShop Product and after you've created your customer input/output fields (See How to create fields) you are now ready to create the calculator.
To create the calculator, go in the "Calculator" tab and click on "Write your formula" and fill in the following information about your new calculator:
- * Name: This value is only needed to remember what the calculator is for, and to find it in the list of calculators later.
- Description: A more detailed description of what the calculator does
- Input Fields: Click this to choose the fields that must be in the calculator. Click on the items that must be moved to the right (Selected fields). To remove items, click on the ones on the right to move them on the left.
- Formula: It's the heart of the calculator because it's where the calculation formula will be placed. In this slot it's possible to place:
- $aws_price_calc_n: Represents the value placed in the field by the visitor. This alias can be seen from the "Field" list.
- $price: It's the starting price for the product, set in HikaShop, in the product's folder.
- a+b: Sum
- a-b: Subtraction
- a*b: Multiplication
- a/b: Division
- a^b: Power
- a!: Factorial
- a%b: Module
- sqrt(a): Square root
- cos(a): Cosine
- sin(a): Sine
- tan(a): Tangent
- sec(a): Secant
- csc(a): Cosecant
- cot(a): Cotangent
- abs(a): Absolute Value
The "Insert Field in the Formula" button can be used to add a field in the formula without typing it in.
- Products: The products that the calculator must be linked to. You can also assign the calculator to whole categories.
- Empty cart: If "Yes" it empties the cart when a product has been added to the cart. It's useful for services.
- Themes: The theme used to see the calculator. The default theme is auto-generated.
Click on "Save" and the calculator will be visible in the pages of the chosen products.