Support » Plugin: WooCommerce » Show a different store/products/prices for each logged in user?

  • Hey guys, I have a client who is a custom printer (business cards, mugs, hats, etc.) and they want the ability to display different prices for each of these clients. Also, can I limit which products get shown to clients?

    To give you an example, Company ABC orders mugs at $1 each and Company XYZ orders the exact same mugs for $2 each. Also, Company QRS never orders mugs so there is no reason to display them as options.

    So can I limit which products are shown to which clients, AND can I set specific pricing for each client? (FYI, they manually create each client so they are entering specific details about each and it is not open to the public.)

    Kind of off topic but when a client does login to the system (their profile), does it show their previous orders and give them the ability to hit “reorder” ?

    I am trying to wrap my head around having, basically, a different store for each client.

    Thanks guys!

Viewing 15 replies - 1 through 15 (of 19 total)
  • So the more I think about this the closer I am getting…. could I add custom taxonomies to wooCommerce? I am thinking that if I added a CLIENT taxonomy then gave each client a tax, I could call to the page any client taxonomy that matched the username…. Thoughts?

    Ok I think I should be able to add a Client Attribute with a specific price, the next question is can I call a list of products that have a specific attribute? For example, give me all products that have the Client Attribute that equals “Client ABC” ? Is this possible?

    Could I also call a list of categories that have products with this attribute?

    attributes are taxonomies, so you’d just modify the loop query with a taxonomy query (and you can include multiple taxonomies within the query)

    bheadrick, so something like this…

    $clientposts = new WP_Query(array( 'clients' => 'companyABC' ) );
      while ($clientposts->have_posts()) : $clientposts->the_post();
      $clientvalue = $clientposts->ID;

    I will give it a try!


    Ok so no luck with the following:

    global $current_user;
    $company = $current_user->billing_company;
    query_posts(array('post_type' => 'product', 'product_tag' => '$company'));
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    <?php the_title(); ?>
    <?php endwhile; endif; wp_reset_query(); ?>

    To reiterate what I need, since each of my clients will have different pricing on our products, I only want to display Products that have a Variation Attribute that matches my client’s Billing Company. For example, display all products with a variation that equals Company ABC.

    I think we are almost there!

    remove the quotes around $company
    also, I don’t think you’d want to use product_tag for your company selector. I’d make it an attribute that’s not visible on the product page
    also , keep in mind that the taxonomy name for attributes is going to have a ‘pa_’ prefix, so an attribute named “clients” would be “pa_clients”

    Ok so since I was using product_tag instead of the taxonomy, I changed the code to this, but still no luck.

    global $current_user;
    // get logged in user's information
    // get logged in user billing company and convert it to lowercase
    $billing_company = strtolower($current_user->billing_company);
    // replace spaces in the billing company with hyphens
    $company = str_replace( " ", "-", $billing_company);
    // setup argument
    $args = array(
       'post_type' => 'product',  // first, call all products (wooproducts)
       'tax_query' => array(   // next, run a tax query on the Attributes...
    	'taxonomy' => 'pa_client',  // ... on all Client Attributes
    	'field' => 'slug',  // with a slug of...
    	'terms' => $company  // the user's billing company
    $query = new WP_Query( $args );
    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();

    This code is on a custom template assigned to the my-account page so when the user first logs in, they are taken to this page and on the left side they only see a list of items that have their company name as a Variation.

    I am so close! 🙂 Thanks again for the help bheadrick!


    Ok so I got it to work! The Client logs in, and in the left column of their My Account page, they see only Products that have an Attribute that matches their Company Name. Thank you for the guidance bheadrick!

    Now, can I HIDE the Client Attribute so they cannot choose the other Variations, which are other client’s pricing? I assume that is done on the single product page…


    you could use the woocommerce_attribute filter or you could just edit the product-attributes.php template to say if($attribute[‘name’]!=’pa_clients’):…. endif;

    bheadrick, how would I show content based on Variation? So the Attribute is Client, and the Term for this Attribute is Company ABC, Company XYZ, etc. If I only want to show the Company ABC Variation for a logged in user whose Billing Company is equal to Company ABC, can I block all other Variations (like Company XYZ) ?

    I am thinking I need to edit the variation.php file within this section:

    <td class="value"><select id="<?php echo esc_attr( sanitize_title($name) ); ?>" name="attribute_<?php echo sanitize_title($name); ?>">
    <option value=""><?php echo __('Choose an option', 'woocommerce') ?>&hellip;</option>
    if ( is_array( $options ) ) {
    if ( empty( $_POST ) )
    $selected_value = ( isset( $selected_attributes[ sanitize_title( $name ) ] ) ) ? $selected_attributes[ sanitize_title( $name ) ] : '';
    $selected_value = isset( $_POST[ 'attribute_' . sanitize_title( $name ) ] ) ? $_POST[ 'attribute_' . sanitize_title( $name ) ] : '';
    // Get terms if this is a taxonomy - ordered
    if ( taxonomy_exists( sanitize_title( $name ) ) ) {
    $terms = get_terms( sanitize_title($name), array('menu_order' => 'ASC') );
    foreach ( $terms as $term ) {
    if ( ! in_array( $term->slug, $options ) ) continue;
    echo '<option value="' . $term->slug . '" ' . selected( $selected_value, $term->slug, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>';
    } else {
    foreach ( $options as $option )
    echo '<option value="' . $option . '" ' . selected( $selected_value, $option, false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $option ) . '</option>';
    </select> <?php
    if ( sizeof($attributes) == $loop )
    echo '<a class="reset_variations" href="#reset">'.__('Clear selection', 'woocommerce').'</a>';


    doing this with variations is a bit difficult unless you write some jquery to automatically make the selection for you. The variation select boxes aren’t used in the way you’d expect normal select fields to work. Basically, if javascript were turned off, you couldn’t buy a variable item.

    Another option, there’s an “update_price” function on the wc_product class, though I have yet to use it successfully, you could make your “client” a meta field instead of an attribute (which is something you can modify in bulk, unlike attributes).

    You could, then do a filter so the price displayed is the price the logged in customer gets, and if they’re not logged in, you could display a custom message.

    I feel like it is so close with the variations.php file but it looks like I will just have to create separate products for each Client, then filter the display based on Attribute = Client ABC. I was hoping I could edit the variations.php file above to display the option specifically for the logged in customer, but it’s over my head 🙂

    Thanks for all the help.

    Hey bangbangmobile, wondering if you got this all sorted out? I’m creating a site that needs the exact same functionality. Any help you can give would be much appreciated!

    I’m also working on something similar. The target customers will be part of teams and will only be able to see the general items + their team gear. The other teams gear will be hidden.

    I’ve been able to add a custom team category to the registration using S2member plugin. I’ve also coded some functions to prevent anyone who is not logged in or not on a team from viewing another teams page.

    The final two things I need to do is figure out how to separate the store so that Team A can’t browse Team B’s gear or end up finding it using the Search function.

    I’ll most likely be using WooCommerce plugin.

    Bang & Sara, have you guys reached a final solution?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Show a different store/products/prices for each logged in user?’ is closed to new replies.