Upgrade Safe Line_Items.php for AOS_Products_Quotes

No dice there either by changing the “display_lines” to something else. Here’s the httpd error. This did however push me to the final upgrade safe solution.

PHP Warning: call_user_func() expects parameter 1 to be a valid callback, function ‘custom_display_lines’ not found or invalid function name

This error set off a light bulb and FINALLY figured this out, and wow this was unnecessarily complicated. There is probably an easier way to do this, but this works… Here is the upgrade safe way to override the line items panel in the AOS_Invoice module. Thank you everyone for pushing me in the right direction…

Step 1:
Copy
/modules/AOS_Products_Quotes/Line_Items.php to
custom/modules/AOS_Products_Quotes/Line_Items.php

Step 2:
Create file called ´_override_vardefs.php in custom/Extension/modules/AOS_Invoices/Ext/Vardefs/`

Step 3:
Populate _override_vardefs.php with the following code

    <?php

          $dictionary['AOS_Invoices']['fields']['line_items']['function'] = array(
                        'name' => 'custom_display_lines',
                        'returns' => 'html',
                        'include' => 'custom/modules/AOS_Products_Quotes/Line_Items.php');
      ?>

Step 4:

Edit these 3 function names in your custom Line_Items.php

display_lines = custom_display_lines
stripDecimalPointsAndTrailingZeroes = custom_stripDecimalPointsAndTrailingZeroes
get_discount_string = custom_get_discount_string
display_shipping_vat = custom_display_shipping_vat

Step 5:
Find and replace all uses of the functions from step 4 in your custom Line_Items.php to their “custom_” counterpart.

Step 6:
QRR and let go a big sigh of relief.

Hopefully they just add this to Studio like quotes in a future update.

4 Likes