Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nrlsyhmina/13bc18bd765c9224cdac1db7a4be1ddc to your computer and use it in GitHub Desktop.
Save nrlsyhmina/13bc18bd765c9224cdac1db7a4be1ddc to your computer and use it in GitHub Desktop.
WooCommerce - Add text after cart table for selected roles
/*@ Display text at cart page based on selected roles*/
add_action('woocommerce_before_cart_collaterals', 'tf_cart_page_custom_text');
function tf_cart_page_custom_text() {
if (current_user_can('subscriber')) {
$message = '<div class="cart-custom-message">';
$message.= '<h2>GET FREE SHIPPING</h2>';
$message.=
'<p align="justify">Use freeshipping code to get Free Shipping</p>';
$message.= '</div>';
echo $message;
} else if (current_user_can('customer')) {
$message = '<div class="cart-custom-message">';
$message.= '<h2>FREE SHIPPING</h2>';
$message.=
'<p align="justify">Apply freeshipping code to get Free Shipping</p>';
$message.= '</div>';
echo $message;
} else {
$message = '<div class="cart-custom-message">';
$message.= '<h2>JOIN MEMBERSHIP</h2>';
$message.= '<p align="justify">Join Member to Get Discount Voucher</p>';
$message.= '</div>';
echo $message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment