Home / Archive / MemberPress: Reposition the Invoice Wrapper in the Registration Form
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Reposition the Invoice Wrapper in the Registration Form

This code snippet will move the invoice section (.mepr-transaction-invoice-wrapper) of the registration form and position it directly after or before the submit button. This allows adjustments to the registration form layout for modified user experience or custom design requirements.

The sample code will position the invoice section directly after the submit button.

Note: The snippet will work on the ReadyLaunch™ template. To reposition the invoice wrapper for the Classic registration template, replace the class .mepr-transaction-invoice-wrapper with the .mepr_price class in this line of code:

document.querySelector('.mepr-transaction-invoice-wrapper');

To insert the invoice wrapper before the submit button, replace the "afterend" with the "beforebegin" in the following lines:

submitButton.insertAdjacentElement('afterend', invoiceWrapper);

Code Preview
php
<?php
add_action('wp_head', function() { ?>
    <script>
        document.addEventListener("DOMContentLoaded", function() {
            // Select the invoice wrapper and the submit button
            const invoiceWrapper = document.querySelector('.mepr-transaction-invoice-wrapper');
            const submitButton = document.querySelector('.mp-form-submit');
            // If both elements exist, move the invoice wrapper after the submit button
            if (invoiceWrapper && submitButton) {
                submitButton.insertAdjacentElement('afterend', invoiceWrapper);
            }
        });
    </script>
<?php });

Comments

Add a Comment