(function () { // get form element and cart from mpa booking details section wp.hooks.addAction('mpa_booking_details_section_init', 'mpainvoices', function ($element, $cart) { new mpaInvoices($element, $cart); }); class mpaInvoices { /** * @param {Object} $element * * @since 1.0 */ constructor($element, $cart) { this.$element = $element this.$cart = $cart; this.updateInvoiceLink($element, $cart); } updateInvoiceLink($element, $cart) { this.$invoices = $element.find('.booking-invoice'); let link = this.$invoices.find('.invoice-link'); let currentHref = link.attr('href'); let newHref = currentHref + '&mpa_booking_id=' + $cart.paymentDetails.booking_id; link.attr('href', newHref); } } })();