The code in this download folder enables the storeowner to discount WooCommerce products based on the wholesale user role.
- This code defines a function called add_wholesale_user_role using the add_role function. It creates a new user role named “wholesale” with the display name “Wholesale Customer.”
- This code defines a function that modifies the displayed price for wholesale users.
- It checks if the user is logged in and has the “wholesale” role using
current_user_can( 'wholesale' ).
- If the conditions are met, it calculates a discounted price based on a specified percentage discount.
- The original price is displayed
crossed outwith the discounted price shown beside it.
There’s only 1 step :
Copy and paste the code to the end of your child themes functions file or custom/functionality plugin.