Customer roles and prices
-
Hello there,
I am building a webstore for a client using WooCommerce, and I have the following problem(s). What I want to do is display different prices for each product for different customers.
Using this tutorial, I managed to add two new roles to my role list and during registration, the user must specify if he/she is a “private” or “retailer” customer.
https://octalforty.com/articles/assigning-role-on-wordpress-registration-profile-page/
Now to the big question. Currently, I am using variable products for the products in the webstore. I have two attributes for each product, “private” and “retailer”, which has different prices, and “private” is always the standard choice. Using some simple CSS and PHP I hide certain sections if the user is logged in or not.
If logged in, the user can select between the “private” and “retailer” attribute prices. If not logged in, only the “add to cart” button is displayed. However, using my two new roles that I added I only want to display the “private” attribute price for logged in “private” users (and not logged in users/guests), and vice versa for “retailers”.
Is this possible to do? If so, how? This is and example of how I’m thinking;
<?php if (current_user_can('private') { // display the price for "private" users and guests in the select box } else if (current_user_can('retailer') { // display the price for "retailer" users in the select box } ?>
- The topic ‘Customer roles and prices’ is closed to new replies.