This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

atba

  • ****
  • 193 posts
insert the balance
« on: January 30, 2022, 08:39:30 AM »
Hello. Help insert the balance in the required place in the code...

<?php echo $credit_msg; ?>

Here she is in index.php:

function osp_user_sidebar () {
 if(osc_current_web_theme() == 'veronika' || osc_current_web_theme() == 'stela' || osc_current_web_theme() == 'starter' || @USER_MENU_ICONS == 1 ) {
 echo '<li class="opt_osp_payment"><a href="' . osc_route_url('osp-item') . '" >' . __('Wallet', 'osclass_pay') . '</a></li>';
 }
 else {
 echo '<li class="opt_osp_payment"><a href="' . osc_route_url('osp-item') . '" >' . __('Promotions', 'osclass_pay') . '</a></li>';
 }
}

It turned out everywhere, in this case I tried everything, but the browser eventually comments on part of the code and the balance is not displayed.
« Last Edit: January 30, 2022, 08:43:01 AM by atba »
osclass.by

*

MB Themes

Re: insert the balance
« Reply #1 on: January 31, 2022, 04:00:30 PM »
@atba
what is behind variable $credit_msg ?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

atba

  • ****
  • 193 posts
Re: insert the balance
« Reply #2 on: February 01, 2022, 12:20:51 PM »
$user_id = osc_logged_user_id();
      $currency = osp_currency();
      $symbol = osp_currency_symbol();
      $packs = osp_get_user_packs($user_id);
      $wallet = osp_get_wallet();
      $style = (osp_param('pack_style') == 1 ? 'gallery' : 'list');
      $group = ModelOSP::newInstance()->getGroup(osp_get_user_group());

      @$user = User::newInstance()->findByPrimaryKey($user_id);

  if($currency == 'BTC') {
    $amount = isset($wallet['formatted_amount']) ? $wallet['formatted_amount'] : 0;
    $formatted_amount = osp_format_btc($amount);
    $credit_msg = sprintf(__('Buy Credit pack to save time with checkout. Your current credit is %s', 'osclass_pay'), '<strong>' . $formatted_amount . '</strong >');
  } else {
    $amount = isset($wallet['i_amount']) ? $wallet['i_amount'] : 0;
    if($amount != 0) {
      $formatted_amount = osp_format_price(osp_price_divide($amount)/1000000);
      $credit_msg = sprintf(__('%s', 'osclass_pay'), '<strong style="margin:0 0 0 10px;clear: none;display:inline-block;font-size:14px;text-decoration:none;font-family:Open Sans,Arial,Helvetica,Verdana,sans-serif!important;font-weight: 500!important;">' . $formatted_amount . '</strong>');
    } else {
     $credit_msg = __('<strong style="margin:0 0 0 10px;clear: none;display:inline-block;font-size:14px;text-decoration:none;font-family: Open Sans,Arial,Helvetica,Verdana,sans-serif!important;font-weight: 500!important;">0.00 р. </strong>', 'osclass_pay');
    }
  }


    function osp_user_sidebar() {
      if(osc_current_web_theme() == 'veronika' || osc_current_web_theme() == 'stela' || osc_current_web_theme() == 'starter' || @USER_MENU_ICONS == 1 ) {
   echo '<li class="opt_osp_payment"><a href="https://test-site-test.com/payment/pack" ><i class="fas fa-wallet"></i> ' . __('<p style="color:#fff;">Wallet</p>', 'osclass_pay') . ' <strong style="font-family: Open Sans,Arial,Helvetica,Verdana,sans-serif!important;font-weight: 500!important;">     
   

      <?php echo $credit_msg; ?>
   
   
   </strong></a></li>';
   
    }
   else {
    echo '<li class="opt_osp_payment"><a href="' . osc_route_url('osp-item') . '" >' . __('Promotions', 'osclass_pay') . '</a></li>';
  }
}
osclass.by

*

MB Themes

Re: insert the balance
« Reply #3 on: February 01, 2022, 03:36:30 PM »
Sorry I am lost.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

atba

  • ****
  • 193 posts
Re: insert the balance
« Reply #4 on: February 01, 2022, 05:31:00 PM »
@atba
what is behind variable $credit_msg ?

Maybe I didn't understand your question?
« Last Edit: February 01, 2022, 05:37:17 PM by atba »
osclass.by

*

MB Themes

Re: insert the balance
« Reply #5 on: February 02, 2022, 09:11:17 AM »
@atba
Not sure what you want to achieve, seems you already have all needed codes.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

atba

  • ****
  • 193 posts
Re: insert the balance
« Reply #6 on: February 02, 2022, 01:14:09 PM »
Yes, I understand) It works everywhere I put it, except index.php (Osclass Pay). The balance is not displayed and is automatically commented by the browser. What if <?php echo $credit_msg; ?> i take out the quotes, it works, but of course it is not displayed in the right place.
osclass.by

*

MB Themes

Re: insert the balance
« Reply #7 on: February 02, 2022, 03:20:18 PM »
@atba
This should do it:
Code: [Select]
<?php echo osp_get_wallet(osc_logged_user_id()); ?>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by frosticek on February 03, 2022, 10:52:52 AM
*

atba

  • ****
  • 193 posts
Re: insert the balance
« Reply #8 on: February 03, 2022, 10:29:53 AM »
That solved the problem.

Code: [Select]
<?php 
  
if(osc_is_web_user_logged_in()) {
    
$wallet osp_get_wallet(osc_logged_user_id());
    
$credit osp_format_price($wallet['formatted_amount']);

    echo 
$credit;
  }
?>


Thanks for the help
« Last Edit: February 03, 2022, 10:52:46 AM by MB Themes »
osclass.by

*

MB Themes

Re: insert the balance
« Reply #9 on: February 03, 2022, 10:52:36 AM »
Cool :)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots