VBLED Posted November 10, 2023 Share Posted November 10, 2023 My PS version is 8.0.4, I want to add extra fields show on the backend product quantity page, not for front. There are some modules on the market, but can only add text, images, checkbox, video, but no integer type. Can somebody help? Link to comment Share on other sites More sharing options...
ps8modules Posted November 11, 2023 Share Posted November 11, 2023 (edited) Hi. You can also enter a number in the text field. All you have to do is add javascript, which does not allow you to enter anything other than the range 0..9 For example, you add the actionAdminControllerSetMedia hook in the module and map the javascript. public function hookActionAdminControllerSetMedia($params) { if ($this->context->controller->php_self == 'AdminProducts' && Tools::getValue('id_product')) { $this->context->controller->addJs(_PS_MODULE_DIR_.$this->name.'/views/js/admin/adminProduct.js'); } } and javascript: $(document).ready(function() { /* text field => my_text_field */ $('[name=my_text_field]').keypress(function (e) { var charCode = (e.which) ? e.which : e.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } }); }); Edited November 11, 2023 by ps8moduly.cz (see edit history) Link to comment Share on other sites More sharing options...
VBLED Posted November 11, 2023 Author Share Posted November 11, 2023 Thank you but this is not good idea. Because I want to calculate these fields, so they must be int type. I don't know why all custom field modules are only support text fields, numbers are not support. Link to comment Share on other sites More sharing options...
ps8modules Posted November 11, 2023 Share Posted November 11, 2023 (edited) And why are you stuck on integer? The fact that text fields are also calculated is completely normal. You can use e.g. ((int)$value * (int)$value2) https://www.w3docs.com/snippets/php/simple-php-calculator.html Edited November 11, 2023 by ps8moduly.cz (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted November 11, 2023 Share Posted November 11, 2023 8 hours ago, VBLED said: Thank you but this is not good idea. Because I want to calculate these fields, so they must be int type. I don't know why all custom field modules are only support text fields, numbers are not support. Note that javascript is less tolerant than PHP. In javascript you almost always need to use parseInt or parseFloat if you want to use a field value for calculation. Link to comment Share on other sites More sharing options...
VBLED Posted November 12, 2023 Author Share Posted November 12, 2023 I don't know why prestashop does not support custom field, most online shop system already integrated this and no need other modules. Link to comment Share on other sites More sharing options...
ps8modules Posted November 12, 2023 Share Posted November 12, 2023 (edited) Hi. This is a question directly for the developers of the Prestashop system. We who advise here will not influence it, we are mostly developers of our own modules. https://www.prestashop-project.org/support/ Edited November 12, 2023 by ps8moduly.cz (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now