• Resolved PixelBoy

    (@maitrekou)


    Hello !

    When i use the quantity option in WPForms, i can fix the min and max and the increment is 1 by 1. Is it possible to make (for example) 100 by 100 ?

    Another bonus question : is it possible to put 3 decimals on the unit price (i can do it in functions.php but for the whole website), but only there. I want to keep 2 decimals for the rest of the website and use 3 decimals for this calcul.

    I’m a bit stuck on this problem.

    Thanks in advance !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @maitrekou,

    Thanks for reaching out!

    Currently, WPForms doesn’t offer built-in options to customize the Quantity field increments or apply three decimal places on the unit price within a specific payment field or form. Both of these changes would require custom code.

    For example, if you’re using the Dropdown Items field with the Modern style (screenshot), you can use a PHP snippet like this:

    function wpf_dev_initialize_choices_js( ) {
    ?>

    <script type="text/javascript">
    // Check if Choices.js is not loaded and dynamically load it
    if (typeof Choices === 'undefined') {
    var script = document.createElement('script');
    //script.src = WPFORMS_PLUGIN_URL + 'assets/lib/choices.min.js';
    script.src = 'https://wpforms.local/wp-content/plugins/wpforms/assets/lib/choices.min.js';
    script.onload = function() {
    setupChoices();
    };
    document.head.appendChild(script);
    } else {
    setupChoices();
    }

    // Setup Choices.js for a specific select element
    function setupChoices() {
    var selectElement = document.getElementById('wpforms-85-field_3-quantity');
    // Initialize Choices.js if it has not been applied yet
    if (selectElement && !selectElement.hasAttribute('data-choices') ) {
    var choices = new Choices(selectElement, {
    searchEnabled: false,
    itemSelectText: '',
    shouldSort: false
    });
    // Populate select with options
    choices.setChoices(function() {
    var items = [];
    // Create quantity options, incrementing by 100
    for (var i = 100; i <= 1000; i += 100) {
    items.push({value: i.toString(), label: i.toString(), selected: i === 100});
    }
    return items;
    }, 'value', 'label', true);
    }
    }
    </script>

    <?php
    }

    add_action( 'wpforms_wp_footer_end', 'wpf_dev_initialize_choices_js', 30 );

    Here is a screenshot of the result using this code snippet.

    In case it helps, here’s our tutorial with the most common ways to add custom code like this. For the most beginner-friendly option in that tutorial, I’d recommend using the WPCode plugin.

    However, I apologize as customizations like this are outside of our scope for support. In case you’d like to look into custom development options, we highly recommend posting your customization job here.

    Thanks, and please let me know if you have other questions regarding WPForms Lite.

    Thread Starter PixelBoy

    (@maitrekou)

    Hello,

    I’m using the payment field “Unique item” to have the total at the end. This is not really a big customization because i’m sure that many people are in the same case (other increment that 1 by 1).

    So, I have to do that in another way, sadly with another plugin. Thank you for your response.

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @maitrekou,

    Thank you for sharing the details, and I completely understand how beneficial this feature would be.

    While we don’t currently have the capability to change quantity increments, I’ve made a note of the feature request and we’ll keep it on our radar to be reviewed as we plan out our roadmap for the future.

    We really appreciate your feedback and suggestion!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.