How to parse all line items of a quote programatically

Hello. I have a custom discounts module that applies to the line items of a quote. To achieve this I have a button in the line item row that says "Apply pricing". All good so far. Now I want to make a button in the HEADER of the line items table that will be "Apply pricing to ALL". When I click this future button I want to go through all the line items present and call the logic of the earlier mentioned "Apply pricing" button. How do I do this from Javascript code? VERY IMPORTANT!!! This button must also function for unsaved, not yet existing, new line items (like you create a quote and before you pressed save). So query-ing it in the database won't work directly.

  • To add button in the HEADER of the line items table: create custom/modules/Quotes/clients/base/views/quote-data-list-header/. Add new button in the php file and the action into js file.

    You can add an event listener at custom/modules/Quotes/clients/base/layouts/quote-data-list-groups/quote-data-list-groups.js, which will be triggered by that new button. This event will walk through all groups it will trigger another custom event on each one.

    You also need to add an event listener at custom/modules/ProductBundles/clients/base/views/quote-data-group-list/quote-data-group-list.js. This one will be triggered by the event listener at Quotes and it will walk through each QLI within.

    For each QLI you will call a method inside custom/modules/ProductBundles/clients/base/views/quote-data-group-list/quote-data-group-list.js.

    This method will apply the prices accordingly.

    Eventually you will need to add some valitions in order to avoid click Save button if such an action is still running.


    André Lopes
    Lampada Global
    Skype: andre.lampada
  • I would like some clarificatioms/details, I have not understud much. I have a custom field type called custom-pricing-button in custom/modules/Products/clients/base/fields that handles in the custom-pricing-button.js

    This button is inserted in the line item layout via a modification in custom/modules/Products/clients/base/views/quote-data-group-list/quote-data-group-list.php $viewdefs['Products']['base']['view']['quote-data-group-list']

    I do not want to trigger custom-pricing-button.js from another place, I want a separate button. So if I create a similar button, let's say custom-pricing-button-all and put it into custom/modules/Quotes/clients/base/views/quote-data-list-header what is the exact javascript code that I can use to loop through each line item, both existing and not yet saved

  • Definitely a button like that in the QLI is the way.

    The changes required are:

    Probably this js controller implements an event listener on clicking some button which trigger some method. This very same method must be invoked by another event listener triggered by custom/modules/ProductBundles/clients/base/views/quote-data-group-list/quote-data-group-list.js on walking through each QLI.

    André Lopes
    Lampada Global
    Skype: andre.lampada