Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41
  1. #1
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Category Specific Restriction of Product Price Display (OLD v1 mod)

    The standard Zen Cart installation can be configured in Admin > Configuration > Customer Details asf:

    Customer Shop Status - View Shop and Prices
    Customer must be approved to shop
    0= Not required
    1= Must login to browse
    2= May browse but no prices unless logged in
    3= Showroom Only
    Selecting any of these options assigns conditions 0-3 globally, meaning that every category / product detail page is treated the same way.

    I was faced with restricting only certain categories to option 1 or 2 but leave the bulk of the remaining cats at option 0.

    To achieve this 2 core files had to be copied to my relevant template folder(s) using the override system.

    (I am using ZC version 1.3.9f - but this may work with any 1.3.x install ??)

    These files are:

    1. includes/modules/product_listing.php
    copied to includes/modules/MY_TEMPLATE/product_listing.php

    2. includes/templates/template_default/templates/tpl_product_info_display.php
    copied to includes/templates/MY_TEMPLATE/templates/tpl_product_info_display.php

    Next, these 2 files were edited:

    File product_listing.php

    After line 17 insert: $hide_productprice_cPath = "3_19_45,68,78";

    This specifies categories 68, 78 and category 3 with sub-cat 19 and sub-sub-cat 45 to be restricted that only approved / logged-in customers can see prices.

    Then find

    Code:
            case 'PRODUCT_LIST_PRICE':
            $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
    and edit to read:

    Code:
            case 'PRODUCT_LIST_PRICE':
            if (!$_SESSION['customer_id'] && in_array($cPath,explode(',', $hide_productprice_cPath)) ) {
    	$lc_price = ''; 
    	} else
            $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
    and find

    Code:
            // more info in place of buy now
            $lc_button = '';
            if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
              $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
            } else
    edit to read:

    Code:
            // more info in place of buy now
            $lc_button = '';
            if (!$_SESSION['customer_id'] && in_array($cPath,explode(',', $hide_productprice_cPath)) ) {
              $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
    		  } else
    
            if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
              $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
            } else {
    File tpl_product_info_display.php

    Around lines 14-15 find

    Code:
     //require(DIR_WS_MODULES . '/debug_blocks/product_info_prices.php');
    ?>
    Right after these 2 lines insert new code

    Code:
    <?php
    /**
    * here you can specify product info pages of categories to be accessed by logged in customers only
     */
    $login_required_cPath = "3_19_45,68,78";
    ?>
    
    <?php
    /**
    * if you want product details of certain categories accessed by members only, redirect them to the login page
     */
    if (!$_SESSION['customer_id'] && in_array($cPath,explode(',', $login_required_cPath)) ) {
      $_SESSION['navigation']->set_snapshot();
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); 
      }
    ?>
    That's it.

    Now the whole store works as normal, customers can browse, see prices, add products to the cart and check out. The only categories with are restricted are categories 68, 78 and category 3 with sub-cat 19 and sub-sub-cat 45. These 3 cats will not display prices on listings. If the customer clicks on a short product description within the listing they are prompted to register or log in.

    Make sure you backup, backup, backup before making changes.

    The next step would be to make this configurable from the admin. That, however, is outside my programming skills. If someone has an idea how to do this they are most welcome to post their suggestions / solutions.
    Last edited by frank18; 29 Sep 2010 at 02:06 AM.

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Category Specific Restriction of Product Price Display

    Has anyone tried to implement this? Would like to hear comments / suggestions .... thanks.

  3. #3
    Join Date
    Dec 2007
    Posts
    50
    Plugin Contributions
    0

    Default Re: Category Specific Restriction of Product Price Display

    Hello,
    Thanks, it works! But I have a small question, can it be configured instead of "MORE INFO TEXT" to show: "The price requires authentification"? And wht do I have to change? Thanks, you are a lifesaver!

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Category Specific Restriction of Product Price Display

    You can replace the constant MORE_INFO_TEXT with something like NEED_AUTH_TEXT in the relevant location, and define that in the same file where MORE_INFO_TEXT is defined, like
    PHP Code:
    define('NEED_AUTH_TEXT''The price requires authentification'); 
    This is a nice mod, by the way:)

  5. #5
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Category Specific Restriction of Product Price Display

    Quote Originally Posted by minute View Post
    Hello,
    Thanks, it works! But I have a small question, can it be configured instead of "MORE INFO TEXT" to show: "The price requires authentification"? And wht do I have to change? Thanks, you are a lifesaver!
    Thanks for the feedback minute!

    Just one 'picky' spelling remark :

    please call it authentication ... instead of authentification

    PS: Glenn has beaten me by a whisker to answer your question ... and thanks for your kind comment Glenn.

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Category Specific Restriction of Product Price Display

    Short of making admin configurability, I would take the category setting out of the processing files and put it in the same define file:
    PHP Code:
    define('LOGIN_REQUIRED_CPATH''3_19_45,68,78'); 

  7. #7
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Category Specific Restriction of Product Price Display

    Quote Originally Posted by gjh42 View Post
    Short of making admin configurability, I would take the category setting out of the processing files and put it in the same define file:
    PHP Code:
    define('LOGIN_REQUIRED_CPATH''3_19_45,68,78'); 
    Thanks Glenn, makes sense to me.

  8. #8
    Join Date
    Dec 2007
    Posts
    50
    Plugin Contributions
    0

    Default Re: Category Specific Restriction of Product Price Display

    You can view it working on www.unghiifalse.ro
    I think it is a problem, I don`t know why.
    http://www.unghiifalse.ro/index.php?...=index&cPath=1
    When are only one product in category, the link to show the product, redirects to login page.
    Also here: http://www.unghiifalse.ro/index.php?...=index&cPath=2 the last 3 only have 1 product/cat

  9. #9
    Join Date
    Dec 2007
    Posts
    50
    Plugin Contributions
    0

    Default Re: Category Specific Restriction of Product Price Display

    Another question for you. I guess this trick is made for the:
    Customer Shop Status - View Shop and Prices 0
    Customer Approval Status - Authorization Pending 0
    It is any way that the price of the categories not restricted to be hidden to be published when:
    Customer Approval Status - Authorization Pending 2 ?

    Thanks!

  10. #10
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Category Specific Restriction of Product Price Display

    Quote Originally Posted by minute View Post
    ...When are only one product in category, the link to show the product, redirects to login page.
    Also here: http://www.unghiifalse.ro/index.php?...=index&cPath=2 the last 3 only have 1 product/cat
    That is Zen Cart default behavior. If there is only one product in a given category then the link goes directly to the product info page. One product only does not 'justify' a listing hence the listing will be skipped.

 

 
Page 1 of 5 123 ... LastLast

Similar Threads

  1. v151 Category Specific Access Restriction (CSAR) - [Support Thread]
    By frank18 in forum All Other Contributions/Addons
    Replies: 187
    Last Post: 12 Sep 2021, 09:41 PM
  2. v150 [Not a bug] Category Specific Access Restriction‏
    By raf696 in forum Bug Reports
    Replies: 3
    Last Post: 17 Mar 2012, 03:26 AM
  3. v150 Category Specific Access Restriction‏
    By raf696 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 16 Mar 2012, 10:25 PM
  4. v150 Category Specific Access Restriction
    By raf696 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 13 Mar 2012, 07:36 PM
  5. product-specific shipping restriction
    By word in forum Addon Shipping Modules
    Replies: 1
    Last Post: 3 Dec 2006, 06:11 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR