Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. <?php
  2. // ====   Change to your coin symbol  =====
  3.  
  4. $symbol ="add your coins symbol";
  5. $redirect = " change to redirect page";
  6.  
  7. // =========================================
  8.  
  9. $current_user = wp_get_current_user();
  10. $user_ID = $current_user->ID;
  11.  
  12. //  available to spend in wallet
  13. $my_balance = apply_filters( 'wallets_api_available_balance', 0, array(
  14.      'symbol' => $symbol,
  15.      'user_id' => $user_ID,
  16.  ) );
  17.  
  18. //  we used floor here as we wanted whole Coins  you can just replace "$my_balance"
  19. echo  'Hello ' . ucfirst($current_user->user_login) . '<br> Your Availabe Balance to transfer is: <br> <strong>' . floor($my_balance). ' ' .$symbol. '</strong><br /><br />';
  20.  
  21. ?>
  22.  
  23. <form class="send2bank" action="#" method="get">
  24.  
  25.      <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"/>
  26.  
  27.     <input type="submit" id="my_submit" name="my_submit" value="submit"/>
  28. </form>
  29.  
  30. <!--Javascript goes here -->
  31. <script type="text/javascript" >
  32.  
  33. jQuery(document).ready(function($) {
  34.  
  35.     $('.send2bank').on('click', '#my_submit', function(e) {
  36.  
  37.         e.preventDefault();
  38.         var form = e.delegateTarget;
  39.         var amount = document.getElementById("amount").value;
  40.         var user = "Central Bank";
  41.         var comment = "Exchanged to Bank"
  42.         var nonce = wp.wallets.viewModels.wallets.nonces()['do_move'];
  43.         var symbol ="<?php echo $symbol; ?>";
  44.  
  45.         if(amount==""){
  46.            
  47.             alert('You Must add an Amount');
  48.  
  49.  
  50.             } else {
  51.                 //  if  user  has added an amount we can continue
  52.                 if (true) {
  53.  
  54.                     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! ");
  55.                     if (r == true) {
  56.  
  57.                     $.ajax({
  58.                         dataType: 'json',
  59.                         cache: false,
  60.                         data: {
  61.                             '__wallets_apiversion' : 3,
  62.                             '__wallets_action' : 'do_move',
  63.                             '__wallets_move_toaccount' : user,
  64.                             '__wallets_move_amount' : amount,
  65.                             '__wallets_move_comment' : comment,
  66.                             '__wallets_symbol' : symbol,
  67.                             '_wpnonce' : nonce
  68.                         },
  69.                         success: function( response ) {
  70.                             $( form ).trigger( 'wallets_do_move', [
  71.                                 response,
  72.                                 symbol,
  73.                                 amount,
  74.                                 user,
  75.                                 comment
  76.                             ] );
  77.                         }   // success
  78.  
  79.                     });    //   ajax call
  80.  
  81.                     } else {
  82.                      //  hits cancel
  83.                      window.location.href = "<?php echo $redirect; ?>";
  84.                   }
  85.  
  86.                 }  
  87.         }  
  88.    })
  89. });
  90. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement