Created
June 3, 2024 11:48
-
-
Save rwsite/b9f4a8ca61ffda5f5d458a3af6c39604 to your computer and use it in GitHub Desktop.
woo2iiko - вывод бонусного баланса для зарегистрированных пользовтаелей
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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