Magento's custom product options can add a fixed price or a percentage to the total cost of a product. With this module you get a third one: a price Per Character. This means the option price is multiplied by the length of the text entered into the input field. This is useful for custom engravable products, where customers need to pay a surcharge per character they want engraved.
The product price is calculated on-the-fly by the JavaScript while the customer enters the text, and once more by the PHP code when the product is added to the cart.
Because the calculation itself hooks into Magento's core JavaScript code, multiple custom options can easily be combined. The module should be compatible with most custom front-end themes without any need for modifications.
- Login to the Magento Admin Panel and create or edit a product.
- Create or edit a custom option with input type Text Field or Text Area.
- Under price, enter the cost of one character, and select Per Character as price type.
- Save the product and try it out on the front-end.
Install the module files using one of the following three methods:
-
Install composer
-
Install magento composer installer
-
Use this command from your Magento installation folder:
composer require bastiaanh/magento-engraving-costs
-
Install modman
-
Use this command from your Magento installation folder:
modman clone https://github.com/bastiaanh/magento-engraving-costs/
You can copy the files from the src/
folder of this repository to the same folders of your installation
Once the files are installed:
- Clear the cache, logout from the admin panel and then login again.
-
Make sure there are no more custom options with price type 'perchar':
UPDATE catalog_product_option_price SET price_type = 'fixed' WHERE price_type = 'perchar';
-
Remove all extension files from your Magento installation.
-
Via composer:
composer remove bastiaanh/magento-engraving-costs
-
Via modman:
modman remove BastiaanH_EngravingCosts
- PHP >= 5.3.0
- Magento CE >= 1.6 and < 2.0
- Magento EE >= 1.11 and < 2.0
If you have any issues with this extension, feel free to open an issue on GitHub.
All contributions are highly appreciated. The best way to contribute code is to open a pull request on GitHub.
The project is licensed under the MIT license.