How To Use A Custom Price Suffix For Wholesale Users

How To Use A Custom Price Suffix For Wholesale Users

When setting up tax, some countries require you to show a non-inclusive price for your wholesale customers while still keeping an inclusive price for regular retail customers.
It』s pretty common to set the Price Suffix setting to something like 「Inc. VAT」, 「Inc. GST」 or even 「Inc Tax」, but when you have the wholesale prices showing throughout the store as the non-inclusive price this might need to change for those users only.
We are planning on adding this feature to our WooCommerce Wholesale Prices Premium plugin in the future, but in the meantime, this can be achieved by putting the code snippet below into your functions.php file in your theme.
function fixWholesalePriceSuffix($price_display_suffix) {
global $current_user;

if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) {
$wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance();
if (!empty($wwp_wholesale_roles->getUserWholesaleRole())) {
return ' ex. GST';
}
}

return $price_display_suffix;
}

add_filter('woocommerce_get_price_suffix', 'fixWholesalePriceSuffix', 10, 1);

Simply replace 『 ex. GST』 with the string of your choice and this will only be applied for wholesale users.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注