mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
15 lines
571 B
Text
15 lines
571 B
Text
add_action( 'woocommerce_before_cart', 'wc_show_banner_if_user_spent_more_than_99' );
|
|
|
|
function wc_show_banner_if_user_spent_more_than_99() {
|
|
|
|
$current_user = wp_get_current_user();
|
|
|
|
// if logged out, exit
|
|
if ( 0 == $current_user->ID ) return;
|
|
|
|
// if spent more than 99, display banner
|
|
if ( wc_get_customer_total_spent( $current_user->ID ) > 99 ) {
|
|
echo '<div class="woocommerce-info">Well done - you have unlocked your Valued Customer discount! Use coupon code <i><b>JRP7EWKD2</b></i> and get 5% off all products.</div>';
|
|
}
|
|
|
|
}
|