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.
- 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
- 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).
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
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 dropdown select fielld 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.
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 3000 are good, for more digits to insert use higher delay value, e.g. 8000
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
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