Skip to content

Instantly share code, notes, and snippets.

@rwsite
Created June 3, 2024 11:48
Show Gist options
  • Save rwsite/b9f4a8ca61ffda5f5d458a3af6c39604 to your computer and use it in GitHub Desktop.
Save rwsite/b9f4a8ca61ffda5f5d458a3af6c39604 to your computer and use it in GitHub Desktop.
woo2iiko - вывод бонусного баланса для зарегистрированных пользовтаелей
function true_logged_in_user_content( $atts, $content = null ) {
if(!class_exists('\iiko\bonuses\Bonuses')){
return 'Ошибка вывода баланса. woo2iiko не подключен';
}
$bonuses = \iiko\bonuses\Bonuses::getInstance();
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) {
$balance = $bonuses->get_user_balances();
return 'Ваш бонусный баланс: ' . ($balance ?: '0');
}
ob_start(); ?>
<div class="alert alert-danger"><strong>Зарегистрируйтесь</strong>, что бы получить бонусы!</div>
<?php
return ob_get_clean();
}
add_shortcode( 'reg_alert', 'true_logged_in_user_content' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment