So I have to send products to 95% of my customers and I’ve added this couple of lines of code to create a second item row upon invoice creation to add the line automatically.
The file is application/mouldes/invoices/views/view.php
Search for code:
<?php if (!$items) { ?> $('#new_row').clone().appendTo('#item_table').removeAttr('id').addClass('item').show();
<?php } ?>
Replace with:
<?php if (!$items) { ?> $('#new_row').clone().appendTo('#item_table').removeAttr('id').addClass('item').show();
$('#new_row').clone().appendTo('#item_table').removeAttr('id').addClass('item').show();
const inputsByName = document.getElementsByName('item_name');
if (inputsByName.length > 1) {
const secondInput = inputsByName[2]; // Access the second element
secondInput.value = "Shipment";
}
<?php } ?>
Hope it helps.