image CryptoWiz Manual and
Documentation

Pre-init hook

If you want to do something to the button links before they’re turned into buttons, you just need to add a function element to the wpuni_mciwidget_preinit_callbacks array as follows:

<script type="text/javascript">

   

    /////////////////////////////////////////////////////////

    // Hook sample for CryptoWiz Controller pre-init event //

    /////////////////////////////////////////////////////////

   

    // Let's assume that these variables already exist in the DOM...

    var order_id   = 121564;

    var user_id    = 467897984561;

    var user_name  = 'John Doe';

    var user_email = 'johndoe@nowhere.com';

   

    // We'll also asume that the URL already contains some placeholders to replace with, E.G.:

    // https://blockchainfinancial.com/crypto_wiz/buttonizer/public_key/button_id

    //     ?entry_id={entry_id}

    //     &entry_data1={user_id}

    //     &entry_data3={user_name}

    //     &entry_data2={user_email}

   

    // First, we check if the callbacks array is undefined.

    // If so, we’ll init it.

    if ( typeof wpuni_mciwidget_preinit_callbacks === 'undefined' )

        wpuni_mciwidget_preinit_callbacks = [];

   

    // Here’s our hook:

    wpuni_mciwidget_preinit_callbacks[wpuni_mciwidget_preinit_callbacks.length] = function() {

        console.log('Running my custom CryptoWiz pre-init now!');

       

        // Let’s load all button links in an array

        var $all_links = jQuery(wpuni_mcwidget._buttonizer_selector);

       

        // Now let’s do something with them!

        $all_links.each(function() {

            var $link = $(this);

            var href  = $link.attr('href');

            

            console.log( 'Link URL before modification: %s', href );

            href = href.replace('{entry_id}',   encodeURI(order_id));

            href = href.replace('{user_id}',    encodeURI(user_id));

            href = href.replace('{user_name}',  encodeURI(user_name));

            href = href.replace('{user_email}', encodeURI(user_email));

            console.log( 'Link URL after modification: %s', href );

        });

    };

   

</script>

© 2018 Blockchain Financial image