The plugin Custom size allows your customers to easily adjust the price of your products, based on the size they require, which can be by dimension, surface, or volume.
Installation
- Browse in the menu Extensions > Entension Manager, and install the plugin
- Browse in the Extensions > Plug-in Manager, and enable the plugin named VM - Custom - iStraxx customsize
Create a custom field prototype
Create a custom field
- Browse to Components > VirtueMart
- Select the menu Products > Custom Fields
- Click on the button New
- Select for the field Custom Field Type: Plug-ins
- Enter a Title
- Select for the field Cart Input the value Yes
- For the field Select a plug-in, select VM - Custom - iStraxx customsize
- Fill in the default values
- Width of input field
- Unit
- Offset for calculation
- Dimension or a surface ?
- Minimum value for length
- Maximum value for length
- Number of decimal values for length
- Minimum value for width
- Maximum value for width
- Number of decimal values for width
- Click on Save
Note: In the customfield prototype the default values are set. You can override settings by changing values for product details as explained in steps below.
Attach the Custom field to your product
- Select the menu Products > Products
- Click on the product you would like to add the custom field
- Select the tab Custom Fields
- In the Custom Field Type area, select the custom field you created
- Click on Save
Note: In product details customfield you can set different values then default to fit your certain product configuration.
How to use the different variants
The plugin provides different strategies.
- Product price + calculated price by input and customs price.
- Product price + calculated price by input and product variant price
- Unit price using product price
- Unit price using product variant price
Use the product price makes only sense, if you have a cart variant with own prices. If you choose this the variant prices are not just added to the product, they are used for the calculation with the input. With this option you can easily reflect different materials for example.
Use offset as default unit size is meant for a price system working with unit prices. The offset reflects the unit size. For example, you want that your customers enter the value in cm, select as unit mm. But you want as unit price per meter, than use as offset 100 (=1 meter).
The offset for calculation is most time the minimum size. It defines at which value the input value is calculated.
For example you sell a rope, the first 10 meters are already in the product price, the minimum is 1. But the customer must only pay for more than 10 meters. Then use offset 10.
The last field with the value 5 is the additional amount to pay (netto).
Template overriding
You can customize the plugin output displayed in the product view, and/or in the cart view.
Store your files in yourtemplate/html/com_virtuemart/vmcustom/customsize. More explanations here how-to-overwrite-plugins.html
Options overview
Basic settings
Custom price: set price per unit - only required if price per unit differ from vm product price
Width of input field: specifies the width of an input element at fe > product details view
Unit: Set used unit e.g. cm, m or inch, display on fe > product details view and cart view
Use offset as unit size: The usual value is enabled. So for values below the offset the price is decreased. For example you sell boards, the price 5/m. If the option is enabled, an entered value of 0.5 creates a price of 2.5
Use the product variant price: Activate this to use the variant price of the product. Be aware this works only if you have different customfield variants of your product.
Dimension, surface, or volume: Select number of dimension input used for calculation. Dimension for length only, Surface for length and height, Volume for three dimension.
Settings for each dimension
Fieldname Dimension: By default use VMCUSTOM_ISTRAXX_CUSTOMSIZE_A, to use the language delivered in language pack. If you desire to use custom text add placeholders for value and unit according to: LoremIpsum %1$s %2$s
Minimum value for length: Input field restriction, let empty or 0 for no restriction. If restriction is present and user input does not meet restricted area a popup displays hinting the user to the limits. Additionally the input value is corrected automatically to meet the limits.
Additional feature: use semicolon to create selection e.g. 100;200;300 results in a dropdown select field instead the userinput field in fe product details view.
Maximum value for length: Same according to minimum value
Number of decimal values for length: Set precision for rounding of user input. The used value depends on maximum precision which can be ordered by shopper
e.g. 3 for 1.234 or 5 for 1.23456 as userinput, 0 or empty for no decimals.
Offset for length: set offset for calculation purpose. e.g. product price 100€, customfield price empty, the product price includes 1m, set value 1 as offset. 1 meter is now included in product base price. If you would use 0 as offset userinput 1 would cost 200€ in this example.
You can also see the offset as the default value, which should be already entered, when entering the product. When we sell for example a rope, the price for 0 meter rope is 0. But of course we want to advertise our product, so the normal case is to display the price per meter. VirtueMart expects a price for the product. The common way is to use for example 1 meter. In this example the offset would be 1.
Advanced settings
Time to wait for checking the values in seconds: delay time in miliseconds after userinput. Good values differ based on expected input. If you have simple input with no digits values around 1000 are good, for more digits to insert use higher delay value, e.g. 2000
Calculation Divisor: use this option only for specific cases e.g. your user input is cm but calculation and price is based on m. use 100 for this case. It is also possible to use this option for inch/feet calculation or similar. If using this option the offset for each dimension has to be adjusted according this setting, e.g. if previous offset was 1.0 and you change calculation divisor to 100 your new offset for the dimension has to be 100 (for each dimension). Also check your total offset.
Quantity Steps: use this option if there are minimum steps of user input that cannot be handled by precision, you sell chains at 2.5m steps, so 5 and 7.5 is allowed input but 6 is not, instead the plugin automatically rounds up to the next step resulting in the suggestion of 7.5 instead of 6.
Optionally this option can be used to calculate with fractions e.g. 1 1/2 is allowed input if set.
Enable for ceil() else round(): on some machines we have encountered rounding issues when using fractions. In case you experience rounding issues this option enabled might solve the problem.
Weight/unit: optionally set custom weight per unit, product settings for weight unit are used.
Dimension ration: optionally set dimension ratio e.g. for photo format or posters, insert values with colons example 1:2
FAQ
Question rounding: My input value in frontend is always rounded: e.g. 1.25 will display as 1. How do I set round precision?
Answer: In product details > customfield > in the field "Number of decimal values" set your precision, 1.23 requires option value 2, 1.234 requires option value 3. If zero or no value is set the input is rounded with no decimals.
Question cart display lenght and unit: In cart view I see neither value nor unit of user input. For our need we have changed the Fieldname of Dimension. Our fieldname is present but no value nor unit - how to solve?
Answer: By default Fieldname Dimension contains a string VMCUSTOM_ISTRAXX_CUSTOMSIZE_A. When you browse the language file you will find this content for the language key: Length %1$s %2$s
In most cases it is solved by adding %1$s %2$s to your dimension string e.g.: LoremIpsum %1$s %2$s
Examples
Lets sell a rope with 5 euro per meter (net). We want that the product appears with a product price of 5 euro. We do not sell less than a half meter and in 10 cm steps. We just add the product price of 5 euro, leave the customfield price empty.
In our example here we have a tax of 10%. The unit price is by default with vat (gross). Our prices range from 2.50 - 500.00 euro. This is of course the simpelst case.
Now we want to offer a better quality of the rope and just provide it as variant. There is now an important rule of VirtueMart in the game. The order of customfields is very important. The ordering in the product edit view defines which customfield is handled first. So when we want to change the price per unit of the rope, we must put the customfields changing the price above. It can be also usefull to change the price after the calculation of the customsize. The plugin just takes the "sum of all modifications done so far". The simple setup just uses the String customfield and additionally we activate the "Use the product variant price".
The results of this configuration (version 1.2.0)
Note: The system worked different in versions before 1.26.x and need an empty product price (or very tiny one like 0.00001). Variant prices were also entered as endprice, in our example 5.00 and 5.20. This system has some disadvantages, unintuitiv, js needs to set the price for any reload and so on. So the new system uses the variant price which is added to the product price (as normal variants do).
We can add now more fancy things like a dropdown for entering in cm. For that we just enter "cm" in "Alternative Unit" below the topic "Advanced". The system needs to know the calculation factor. We use here a divisor which is just the inverse of the factor. So in our case it is 100 (100 cm for 1 m). Or we could quantity steps instead, for example 1/4, to allow only steps of 0.25. The system recognises fractions.
More dimensional examples are analogue. 2 dimensional examples have an additional area offset (or default).
customsize QUANTITY (not part of the standard customsize)
The quantity customsize plugin provides different prices and/or discounts for different inputs. We use the example from above and just add this to our table.
This means the price per meter is 5 euro from 0.5-9.9 meters. And 5 euro for at least 10 and 5 euro for at least 50 meters. But as you can see in the second line, we give a discount of 5% when you buy at least 10 meters. The results look like this.
The table becomes really interesting, when it is used for 2 dimensional wares like a textils. Here the price changes to 6 euro the m² when the length is at least 50 meters. When the width is at least 50 and also the length, we give a discount of 20%.
Some examle results:
General intro