Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ==== Change to your coin symbol =====
- $symbol ="add your coins symbol";
- $redirect = " change to redirect page";
- // =========================================
- $current_user = wp_get_current_user();
- $user_ID = $current_user->ID;
- // available to spend in wallet
- $my_balance = apply_filters( 'wallets_api_available_balance', 0, array(
- 'symbol' => $symbol,
- 'user_id' => $user_ID,
- ) );
- // we used floor here as we wanted whole Coins you can just replace "$my_balance"
- echo 'Hello ' . ucfirst($current_user->user_login) . '<br> Your Availabe Balance to transfer is: <br> <strong>' . floor($my_balance). ' ' .$symbol. '</strong><br /><br />';
- ?>
- <form class="send2bank" action="#" method="get">
- <input id="amount" name="amount" type="text" class="field text medium" value="" min="1" maxlength="255" tabindex="1" onkeypress="return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57" ondrop="return false;" onpaste="return false;" autocomplete="off"/>
- <input type="submit" id="my_submit" name="my_submit" value="submit"/>
- </form>
- <!--Javascript goes here -->
- <script type="text/javascript" >
- jQuery(document).ready(function($) {
- $('.send2bank').on('click', '#my_submit', function(e) {
- e.preventDefault();
- var form = e.delegateTarget;
- var amount = document.getElementById("amount").value;
- var user = "Central Bank";
- var comment = "Exchanged to Bank"
- var nonce = wp.wallets.viewModels.wallets.nonces()['do_move'];
- var symbol ="<?php echo $symbol; ?>";
- if(amount==""){
- alert('You Must add an Amount');
- } else {
- // if user has added an amount we can continue
- if (true) {
- var r = confirm("this is the amount: " + amount + "\n Are your sure you want to make this Transfer?\n You won't be able to revert this! ");
- if (r == true) {
- $.ajax({
- dataType: 'json',
- cache: false,
- data: {
- '__wallets_apiversion' : 3,
- '__wallets_action' : 'do_move',
- '__wallets_move_toaccount' : user,
- '__wallets_move_amount' : amount,
- '__wallets_move_comment' : comment,
- '__wallets_symbol' : symbol,
- '_wpnonce' : nonce
- },
- success: function( response ) {
- $( form ).trigger( 'wallets_do_move', [
- response,
- symbol,
- amount,
- user,
- comment
- ] );
- } // success
- }); // ajax call
- } else {
- // hits cancel
- window.location.href = "<?php echo $redirect; ?>";
- }
- }
- }
- })
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement