# hostinger/2.1.6/src/js/woo-onboarding.js

Hostinger Tools, version 2.1.6. 58 lines.

- Page: https://pluginprobe.com/plugins/hostinger/2.1.6/code/src/js/woo-onboarding.js
- Raw: https://pluginprobe.com/plugins/hostinger/2.1.6/raw/src/js/woo-onboarding.js
- Modified: 2024-03-15T08:53:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/hostinger/2.1.6/code/src/js/woo-onboarding.js#L10-L20`.

```javascript
(function ($) {

    $( document ).ready(function() {

        /**
         * Button text switcher
         */
        $('body').on('change', 'input[name="chosen_onboarding"]:radio', function(e) {
            let buttonLabel = $(this).data('button-label');
            let imagePath = $(this).data('image-path');

            $('.js-complete-woo-onboarding').html(buttonLabel);
            $('.hostinger-woo-onboarding__column.hostinger-woo-onboarding__column--is-second img').attr('src', imagePath);
        });

        /**
         * Button AJAX
         */
        $('body').on('click', 'a.js-complete-woo-onboarding', function(e) {
            e.preventDefault();

            if($('.hostinger-woo-onboarding').hasClass('hostinger-woo-onboarding--is-loading')) {
                return;
            }

            $('.hostinger-woo-onboarding').addClass('hostinger-woo-onboarding--is-loading');

            let choice = $('input[name="chosen_onboarding"]:checked').val();

            $.ajax( {
                url: ajaxurl,
                method: 'POST',
                beforeSend: function(request) {
                    request.setRequestHeader('Cache-Control', 'no-cache');
                },
                data: {
                    action: 'hostinger_woo_onboarding_choice',
                    nonce: hostingerContainer.nonce,
                    choice: choice
                },
                success: function ( response ) {

                    if( response.data.redirect_url ) {
                        window.location.href = response.data.redirect_url;
                    } else {
                        $('.hostinger-woo-onboarding').removeClass('hostinger-woo-onboarding--is-loading');
                    }

                },
                error: function ( xhr, status, error ) {
                    console.log( 'AJAX request failed: ' + error );
                }
            } );
        });
    });

})(jQuery);

```
