Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2007
    Posts
    3
    Plugin Contributions
    0

    help question Code: is customer member of discount group? - restricting view based on membership

    I would like to add the following to my category tree:

    if (customer is member of wholesale)
    {
    select all categories
    } else {

    select all categories except ID=2
    }

    I have the code for the select statements, I just don't know how to determine if the customer is a member of a certain group.

    I realize I will probably have to write a function, but I am brand new to Zen-cart and have no idea which tables & fields I would be looking for.

    If someone can point me in the right direction, I'd appreciate it.

    /Wendy

  2. #2
    Join Date
    Dec 2006
    Posts
    3
    Plugin Contributions
    0

    Default Re: Code: is customer member of discount group

    have a look at the field "customers_group_pricing" in the "customers" table, i think that's what you are looking for in your function

    sylv

  3. #3
    Join Date
    Feb 2007
    Posts
    3
    Plugin Contributions
    0

    Default Re: Code: is customer member of discount group

    Thanks for the tip. I should have posted that I have it mostly figured out.

    I have a wholesale category that I don't want anyone but wholesalers to see.

    So I had to make some hacks that I know will cause problems when we upgrade - if anyone has some ideas for improvement, I'm up for that.

    Changes made:
    includes/modules/pages/login/header_php.php

    I added "customers_group_pricing" to the SQL query
    Code:
      $check_customer_query = "SELECT customers_id, customers_firstname, customers_lastname, customers_password,
                                        customers_email_address, customers_default_address_id,
                                        customers_authorization, customers_group_pricing, customers_referral
                               FROM " . TABLE_CUSTOMERS . "
                               WHERE customers_email_address = :email";
    Then I set a session variable to indicate if they are wholesale members or not
    Code:
    	  // PDD - added info to check for wholesalers
    	$_SESSION['wholesale_member'] = 0;
        if (isset($_SESSION['customer_id']) ) {
    
          $pdd_group_member_of = $check_customer->fields['customers_group_pricing'];
    
          $sql = "select group_id from " . TABLE_GROUP_PRICING . "
                    where group_name = 'Wholesalers'";
          $pdd_group_result = $db->Execute($sql);
          $pdd_group_number = $pdd_group_result->fields['group_id'];
    	  
    	  if ($pdd_group_member_of == $pdd_group_number) {
    	  	$_SESSION['wholesale_member'] = 1;
    	 } // end if member of wholesale group
        } // end if customer logged in
    I included an if statement in my SQL query construction to exclude the wholesale category if they are not wholesalers.
    includes/classes/category_tree.php
    Code:
     if (!(isset($_SESSION['wholesale_member']) && ($_SESSION['wholesale_member'] == 1) )) {
    							 	$categories_query .= " and c.categories_id != 2 ";
    }
    This works great, unless they view ALL or NEW products. I have determined that I really need to modify the product retrieval query and if I excluded products from the wholesale category, then that category shouldn't even show up because there would be 0 products in the query result.

    I made changes to the product query, but I'm getting an SQL error about the syntax being incorrect on the SELECT COUNT part of the query. I tested the query itself and it runs fine. I just think that SELECT COUNT can't support a LEFT JOIN. I'm still investigating this.

    This is my first Zen-cart install and I wish I knew more.

    /Wendy

  4. #4
    Join Date
    Aug 2007
    Location
    Cannon Beach, OR
    Posts
    180
    Plugin Contributions
    0

    Default Re: Code: is customer member of discount group - restricting view based on membership

    Hi Wendy,

    I need to do the exact same thing. Did you solve the "All Products" query? If so, I'd like to see it.

    Also, being new, you may not have become familiar with the template override system. I think these files can all be overridden which will make upgrades easier to accomplish.

    When I get in tomorrow, I will try to execute what you have done on my store using override files.

  5. #5
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Code: is customer member of discount group - restricting view based on membership

    A lot of what you want to achieve can in fact be done within the template override system - except for the products_all and products_new listings. For those two listings, you'll need to modify the sql queries in the relevant includes/modules/pages/products_(new-all)/header_php.php files.

    Rather than modify the category_tree class and have to worry about upgrades, why not duplicate the class file, rename it my_category_tree and rename/modify the two functions within it. (you're going to have to modify it anyway, so with only a little more work you can save a lot of hassle for upgrades in the future - don't forget to pay attention to the cross-references between the two functions).

    Having done that, you simply make an override copy of includes/modules/sideboxes/categories.php to call your new category tree class rather than the regular one.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  6. #6
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Code: is customer member of discount group - restricting view based on membership

    A couple of other things to think about that you may have overlooked:
    1. you also have to filter the category out from searches
    2. you also need to prevent access (by someone simply typing in the direct url to the page) to the product listing page for that category and to individual product info pages for that category if the customer shouldn't have access.

    As an example of how this has been implemented on a working site, visit blackjackbuffers.com and try to view his 'dealer specials' category (cPath is 81) or one of the products within it (product_id 682, named Bulk Discount Buffers.)
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  7. #7
    Join Date
    Aug 2007
    Location
    Cannon Beach, OR
    Posts
    180
    Plugin Contributions
    0

    Default Re: Code: is customer member of discount group? - restricting view based on membershi

    Thank you.

    I think I'd like to get a professional to do these mods for me. Is there a resource somewhere where the pro PHP/ZenCart programmers links can be found?

  8. #8
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Code: is customer member of discount group? - restricting view based on membershi

    You won't find a list of programmers anywhere, but you can post a request in the Commercial Help Wanted forum
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  9. #9
    Join Date
    Aug 2007
    Location
    Cannon Beach, OR
    Posts
    180
    Plugin Contributions
    0

    Default Re: Code: is customer member of discount group? - restricting view based on membershi

    Exellent, thanks.

 

 

Similar Threads

  1. v151 External member discount code implementation
    By spmckee in forum General Questions
    Replies: 7
    Last Post: 14 May 2013, 05:47 PM
  2. Bulk Edit Customers discount-group membership setting
    By townsend2009 in forum Managing Customers and Orders
    Replies: 6
    Last Post: 9 May 2010, 07:35 PM
  3. Buying into a membership group and discount pricing per item.
    By Omen3891 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 33
    Last Post: 7 May 2010, 03:53 PM
  4. Discount for Membership Group
    By Vintage in forum Setting Up Specials and SaleMaker
    Replies: 3
    Last Post: 10 Feb 2010, 12:19 AM
  5. restricting shipping methods based on customer location
    By kreation records in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 28 Jan 2008, 08:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg