<div style="display: none;" id="alsendo-bulk-action-button">
  <button
          type="button"
          data-bs-toggle="tooltip"
          title="{{ text_bulk_send_orders }}"
          id="alsendo-bulk-btn"
          class="btn btn-primary">
    <i class="fa-solid fa-truck"></i>
  </button>
</div>


<script>
  $(function () {
    const targetDiv = $('#button-invoice').parent('div');
    if (targetDiv.length) {
      $('#alsendo-bulk-action-button')
            .css('display', 'inline-block')
            .prependTo(targetDiv);
    }

    $('#alsendo-bulk-btn').on('click', function () {
      const ids = $('input[name="selected[]"]:checked').map(function(){return this.value;}).get().join(',');
      window.location.href = 'index.php?route=extension/alsendo/alsendo_order.showOrderListWithBulkOperation&user_token={{ user_token|e('js') }}&ids=' + encodeURIComponent(ids);
    });
  });
</script>