A few users have asked whether it is possible to just remove the regular retail price from their products, but still, have wholesale customers see the wholesale price.
The result in doing this is that the Add To Cart button is hidden.
Unfortunately, this is behaviour that is built deep into WooCommerce itself. A product MUST have a regular price set in order for the Add To Cart button to show on the product page.
The wholesale price field is an add-on field we add to the products in order to capture the wholesale price data.
Filling in the wholesale price field doesn』t automatically override the regular price, rather it replaces the price on the front end during the price display process and this isn』t connected to the behaviour of the Add To Cart button itself.
Still need to hide your product from retail customers?
So what is the solution if you need to hide the product from retail customers but still allow your wholesale customers to purchase it?
This is where WooCommerce Wholesale Prices Premium comes in with its product visibility restrictions.
Using the product visibility restrictions guide you can adjust your products so that they are effectively wholesale-only products.
Once done, this means you can safely fill in the regular price field (with whatever data you like) and the Add To Cart button will show, but retail customers will not be able to see the product at all.
Author 诗语
How To Allow Shop Managers To Edit Users & Wholesale Users In WooCommerce
On WooCommerce version 3.4.6, they released a security fix that prevents shop managers to edit other users except for users with customer roles.
This means from this version onwards, Shop Managers will not be able to edit Users with the wholesale user roles generated from our WooCommerce Wholesale Prices and Prices Premium plugin by default.
If you want to just let your Shop Managers edit those users, you will need to do two things:
Allow them to edit users
Allow them to edit users with the roles that you say they can
Allow Shop Managers To Edit Users (Customer Role Users Only)
The first part you just need to adjust the capabilities of the Shop Manager role:
/* Lets Shop Managers be able to edit users again */
function wws_add_shop_manager_user_editing_capability() {
$shop_manager = get_role( 'shop_manager' );
$shop_manager->add_cap( 'edit_users' );
$shop_manager->add_cap( 'edit_user' );
}
add_action( 'admin_init', 'wws_add_shop_manager_user_editing_capability');
Note that the above snippet will not let Shop Managers promote/demote a user, meaning they can』t change the User Role of a customer. Read on for how to do that.
Add The Ability To Edit Users With Wholesale Roles
Next, you need to say which user roles the Shop Managers are allowed to edit. If you don』t do the following, it will mean they can only edit users with Customer role.
/* Lets Shop Managers edit users with these user roles */
function wws_allow_shop_manager_role_edit_capabilities( $roles ) {
$roles[] = 'wholesale_customer'; // insert the wholesale role here, copy+paste this line for additional user roles
return $roles;
}
add_filter( 'woocommerce_shop_manager_editable_roles', 'wws_allow_shop_manager_role_edit_capabilities' );
If you want to allow your Shop Managers to also be able to promote/demote users from Customer to Wholesale Roles, you will need to explicitly give them that capability. You can do so by editing the top snippet to add the following line:
$shop_manager->add_cap( 'promote_users' );
Please use this snippet to allow shop managers to edit users with the default wholesale_customer roles. If you have additional wholesale roles, you can include them in roles in the snippet, just copy and paste the line and adjust to use the proper role slug.
The Full Code Snippet (Includes Everything Above)
/* Lets Shop Managers have the capability of editing and promoting users */
function wws_add_shop_manager_user_editing_capability() {
$shop_manager = get_role( 'shop_manager' );
$shop_manager->add_cap( 'edit_users' );
$shop_manager->add_cap( 'edit_user' );
$shop_manager->add_cap( 'promote_users' );
}
add_action( 'admin_init', 'wws_add_shop_manager_user_editing_capability');
/* Lets Shop Managers edit users with these user roles */
function wws_allow_shop_manager_role_edit_capabilities( $roles ) {
$roles[] = 'wholesale_customer'; // insert the wholesale role here, copy+paste this line for additional user roles
return $roles;
}
add_filter( 'woocommerce_shop_manager_editable_roles', 'wws_allow_shop_manager_role_edit_capabilities' );
These snippets should be placed in your theme/child theme』s functions.php or in a drop-in or custom plugin.
NOTE: Keep in mind the above snippets change the way security operates for the Shop Manager role in your store. So please careful and ensure you understand what capabilities you are opening up.
Javascript Event Triggers for Before and After Loading of the Wholesale Order Form
In our WooCommerce Wholesale Order Form version 1.13, we introduced new Javascript event triggers for before and after loading of the Wholesale Order Form.
These new event triggers are useful for shops that have custom Javascript functionalities. With this new feature, they can easily customize their Wholesale Order Form.
List of Triggers:
trigger: before_load_product_listing
element: #wwof_product_listing_container
parameters: [ paged , search , catFilter , $shortcodeAtts , first_load ]
trigger: after_load_product_listing
element: #wwof_product_listing_container
parameters: [ paged , search , catFilter , $shortcodeAtts , first_load ]
trigger: found_variation
element: #wwof_product_listing_table tbody tr
parameter: [ new_variation ] (this contains data of new selected variation)
trigger: added_to_cart
element: body
parameters: [ fragments, cart_hash, $button ] (this uses the same parameters as the one in WC. see https://github.com/woocommerce/woocommerce/blob/master/assets/js/frontend/add-to-cart.js#L63)
Example Usage
You can use the javascript event triggers like so:
jQuery( '#wwof_product_listing_container' ).on(
'before_load_product_listing',
function(e, paged, search , catFilter , atts , first ) {
console.log( paged );
console.log( search );
console.log( catFilter );
console.log( atts );
console.log( first );
}
);
Replace the console logs with whatever you want your code to do when this event happens.
Having an issue?
If you are still running into problems with the new event triggers, feel free to reach out to our friendly support team for advice.
Create A Wholesale Test User
One of the first steps you need to do after installing WooCommerce Wholesale Prices is to create a test user.
WooCommerce Wholesale Prices creates a new user role called Wholesale Customer. It』s a carbon copy of the Customer user role created by WooCommerce and is used to identify to the system which users should have access to see wholesale pricing.
To create a test user simply:
Login to your WordPress backend
Goto Users->Add New
Fill in your new user details, I recommend naming it 「Wholesale Test User」 for easy identification
Make sure you select the 「Wholesale Customer」 user role
This test user will be used to check the function of the wholesale side of your WooCommerce store from a user』s perspective.
Can』t I just use my admin user?
Although we don』t restrict administrator users in any way (eg. product visibility restrictions in WooCommerce Wholesale Prices Premium don』t affect admins), it』s still not quite enough to just use your admin user for wholesale testing as admins will only see retail pricing on the front end.
By logging in as your wholesale test user you are checking the site』s function exactly as a real wholesale customer would use it which is the most reliable way to test.
Can I log in as both admin and my wholesale test user at the same time?
Yes, the beauty of modern web browsers like Chrome, Safari or Firefox is they have a mode called Incognito/Private Browsing mode.
Click on the File menu
Click New Incognito/Private Browsing Window
This will open a fresh new session of your browser which doesn』t know anything about you being logged into your site as your admin.
Navigate to your login page and log in as your new wholesale test user.
Now you can easily switch between making changes as your admin user and testing those changes in real time with your wholesale test user.
Alternatively, you can also skip using Incognito/Private Browsing mode and just open up the site in two different web browsers (eg. use Chrome for admin and Firefox for testing) and this will also keep the sessions separate.
What if I need more than one wholesale level?
WooCommerce Wholesale Prices Premium allows you to create additional levels of wholesale user roles so you can easily segregate your customers.
If you have created multiple wholesale customer roles you have two options for testing:
Create multiple test users with different user roles and test with each separately
Simply change the user role on your wholesale test user when you need to check the behaviour of a different user role. Sometimes it will be better if you close down your whole Incognito/Private Browsing window to refresh the session, but in most cases for simple checks this isn』t even necessary.
How To Change 「Wholesale Price」 Text In Free Version
In the free version of the WooCommerce Wholesale Prices plugin (download here) we have packed the code full of useful filters and actions that you can use to extend functionality.
One common thing people want to do is change the bit of text that shows before the price on your wholesale prices. This defaults to 「Wholesale Price:」
To do this we prefer you don』t edit the plugin code directly as this tweak will be removed next time you update the plugin. Instead, we have a filter for it, just place the code in your functions.php file:
add_filter('wwp_filter_wholesale_price_title_text', 'override_wholesale_text', 10, 1);
function override_wholesale_text($wholesaletext) {
return 'Trade Price:';
}
Of course, all of this and more is easily tweakable in the WooCommerce Wholesale Prices Premium add-on plugin. You can check our KB article here to do this in our Premium version.
Registration Issues when using Internet Explorer
Our Wholesale Registration Page uses AJAX and JavaScript to save the user』s data on your registration form. However, there are some users who still use Internet Explorer and they might have some issues.
Internet Explorer is an old browser that doesn』t support JavaScript functions and AJAX very well and its extremely insecure. Microsoft has already phased out Internet Explorer and recommends switching to their modern browser called Microsoft Edge instead.
We suggest you actively recommend to your customers to use more modern browsers such as Google Chrome, Mozilla Firefox, Microsoft Edge and etc.
For external reference about Microsoft』s move on retiring the Internet Explorer, you can visit the following links:
https://www.theverge.com/2015/3/17/8230631/microsoft-is-killing-off-the-internet-explorer-brand
https://www.theverge.com/2019/2/8/18216767/microsoft-internet-explorer-warning-compatibility-solution
Configure Your Wholesale Price On Products
Once you have installed WooCommerce Wholesale Prices and any of the other premium plugins in the Bundle you require for your site, the first step you need to get going is to decide how you want to set up your wholesale prices and visibility settings.
Setting Wholesale Prices with WooCommerce Wholesale Prices
In the free Prices plugin, you have one option for setting your wholesale prices which is to add the wholesale price to each individual product.
If you navigate to your Product edit screen for a product, you might have noticed that your edit screen has a new field called Wholesale Prices.
This field is responsible for capturing the price you want to sell this product to your wholesale customers.
Simply fill in this pricing field at the price you want to sell your product at to wholesale customers and this will reflect on the front-end for those wholesale customers only. You can test this with your wholesale test user.
More advanced pricing capabilities
There are more advanced pricing options available in the WooCommerce Wholesale Prices Premium plugin.
These include:
Global % discount – for really broad wholesale pricing based on a simple % across all your products
Category based % discounts – acts in a similar way to the global setting only per category
Tiered pricing based on quantity – uses the quantity in the cart to determine further % beyond the standard wholesale price.
We have a great Advanced Pricing Control guide which gives you a detailed rundown of all the pricing capabilities of WooCommerce Wholesale Prices and the Prices Premium add-on as well.
My download links have expired, can I download the plugin again?
The download links found in your invoice email will only last for a certain time before they expire.
Once expired you will not be able to use these links to download the plugin/s again.
Instead, you can access the latest version of your plugins at any time by logging into your account.
You』ll find a link to the My Account page in the footer of our site.
Once logged in you will see a section containing all of the available downloads for your account along with the details of your past orders:
These links will always point towards the latest version of the product.
If you have any troubles accessing your account, try resetting your password, and if that fails please contact support.
Force HTTPS Secure Protocol On Wholesale Login
If you』ve followed our WooCommerce SSL guide you will know about the benefits of having your site on secure protocol.
But what happens if you only run part of your WooCommerce website on secure protocol?
Wholesale Customers that login via the WooCommerce Wholesale Lead Capture plugin』s login page will also likely need to login via this protocol to ensure they are browsing the website in this secure version of your site.
In this case, it might be best to ensure that anyone that logs in is redirected to the https:// version of your site to avoid issues during checkout.
You can try the following code to force the secure protocol on login redirection:
function wwlcWholesaleLeadLoginRedirect( $redirect_to, $request, $user ) {
if ( parse_url( $redirect_to, PHP_URL_SCHEME ) == 'http' ) {
$redirect_to = str_replace( 'http://', 'https://', $redirect_to );
}
return $redirect_to;
}
add_filter( 'login_redirect' , 'wwlcWholesaleLeadLoginRedirect' , 10 , 3 );
Add this code to your functions.php file in your theme and it will redirect any non-secure login to the secure version of your website and people can browse and checkout happily.
How to fix the admin-side product listing loading slow when Wholesale Prices Premium is active
If you experience a slow loading on your product listing (Products > All Products) when our Wholesale Prices Premium is active, there are two possibilities:
You are loading too many products on your admin product listing; OR
You might have a lot of variable products in your product list
To fix the former, goto the Products->All Products view, then click Screen Options on the top right and adjust the products shown to 20.
For the latter, please keep in mind that Wholesale Prices Premium provides multiple wholesale pricing options for your products, and if you have a lot of variations, it takes time for the plugin to check, calculate and display the wholesale price on the product listing page.
If this is the case, we suggest enabling the Hide wholesale price on admin product listing on WooCommerce > Settings > Wholesale Prices > Price. This will disable the wholesale price calculation in your product listing page, which will result in much faster loading time.