Forums / All Other Contributions/Addons / Category Specific Restriction of Product Price Display (OLD v1 mod)

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

Locked

Views: 10,910

Results 1 to 20 of 41
This thread is locked. New replies are disabled.
29 Sep 2010, 1:03 AM
#1
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

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

and edit to read:

        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

        // 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:

        // 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

 //require(DIR_WS_MODULES . '/debug_blocks/product_info_prices.php');
?>

Right after these 2 lines insert new 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:huh:. If someone has an idea how to do this they are most welcome to post their suggestions / solutions.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

1 Oct 2010, 10:05 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

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

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 9:45 AM
#3
minute avatar

minute

New Zenner

Join Date:
Dec 2007
Posts:
50
Plugin Contributions:
0

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

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!

3 Nov 2010, 10:02 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

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

define('NEED_AUTH_TEXT', 'The price requires authentification');

This is a nice mod, by the way:)

3 Nov 2010, 10:09 AM
#5
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

minute:

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 :D :

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.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 10:10 AM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

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
define('LOGIN_REQUIRED_CPATH', '3_19_45,68,78');

3 Nov 2010, 10:19 AM
#7
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

gjh42:

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
define('LOGIN_REQUIRED_CPATH', '3_19_45,68,78');


Thanks Glenn, makes sense to me.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 10:24 AM
#8
minute avatar

minute

New Zenner

Join Date:
Dec 2007
Posts:
50
Plugin Contributions:
0

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

You can view it working on https://www.unghiifalse.ro
I think it is a problem, I don`t know why.
http://www.unghiifalse.ro/index.php?main_page=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?main_page=index&cPath=2 the last 3 only have 1 product/cat

3 Nov 2010, 12:33 PM
#9
minute avatar

minute

New Zenner

Join Date:
Dec 2007
Posts:
50
Plugin Contributions:
0

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

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!

3 Nov 2010, 12:36 PM
#10
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

minute:

...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?main_page=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.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 12:47 PM
#11
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

minute:

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

That is correct - it was the whole idea of my exercise :smile:

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!

Sorry, I don't get your question

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 12:59 PM
#12
minute avatar

minute

New Zenner

Join Date:
Dec 2007
Posts:
50
Plugin Contributions:
0

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

What I need: on the store I sell professional products, and non-professional products. The categories with professionals products I needed to be "price-hidden", the others - everybody see the prices.
Well, when a user want to register to be:
Customer Approval Status - Authorization Pending
Customer must be Authorized to shop
0= Not required
1= Must be Authorized to Browse
2= May browse but no prices unless Authorized
3= Customer May Browse and May see Prices but Must be Authorized to Buy

So, I have to approve a customer so he can buy. But to keep the prices on non-professionals producs displayed.

I don`t know if you understand, english is not my native language, and I am a little rusty on my "writing in english skills" (shcool long gone)

3 Nov 2010, 1:09 PM
#13
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

I don't think my little mod will do the trick for you.

You may want to look into something like the Dual Pricing mod. This may work for you - but I don't know, I never had a need for such a mod.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

3 Nov 2010, 4:03 PM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

Depending on whether a customer needs to be "approved" before being able to log in, you might be able to use a combination of
3= Customer May Browse and May see Prices but Must be Authorized to Buy
and this mod to hide certain prices from non-logged-in customers.

I don't have time to test the difference right now, but you could try setting those conditions and see if the non-approved customer can log in.

3 Nov 2010, 4:25 PM
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

You might also be able to substitute a test for customer's approval status instead of the simple login status.

2 Feb 2011, 2:37 AM
#16
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

I have played with this again and submitted a mod which allows the store owner to configure the restricted categories via admin. I will let you know if and when it is approved by the devs.

The next step would be to implement Glenn's ideas:

gjh42:

Depending on whether a customer needs to be "approved" before being able to log in, you might be able to use a combination of
3= Customer May Browse and May see Prices but Must be Authorized to Buy
and this mod to hide certain prices from non-logged-in customers.

I don't have time to test the difference right now, but you could try setting those conditions and see if the non-approved customer can log in.

and

gjh42:

You might also be able to substitute a test for customer's approval status instead of the simple login status.

This is an excellent idea - BUT: how do you set a customer's approval status to "3" for only the restricted categories and at the same time leave this customer's approval status at "0" for all the other categories??

It could probably be achieved by adding another column named something like customers_authorization_restricted into the customers table where status "3" is stored until the customer is approved to gain full access to restricted cats.... don't know....

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

2 Feb 2011, 4:49 AM
#17
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

My suggestion was for the specific case where every "Customer ... Must be Authorized to Buy" which will not be applicable to most stores (and maybe was not for the store under discussion - there wasn't enough info to be sure).

Any extension of your criteria would probably want to be in the direction of making a generic $price_display_criteria variable or perhaps a PRICE_DISPLAY_CRITERIA constant, such that the criteria to be applied can be set/selected once in the define file and applied in the product files.

For Categories Dressing's flexible category-hiding behavior I used a function that runs a switch and selects one of a number of calculation methods to decide if a category in the list will be displayed. It can have new, complex criteria added by writing a new case for the switch. That's another possible route to take.

3 Feb 2011, 11:53 AM
#18
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

The mod

Category Specific Access Restriction v1.0

has been approved and is now available for download from

http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_47&products_id=1861

What does this mod do?

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 single category / product detail page is treated the same way.

This mod allows you to specify individual categories which can only be accessed by authorized customers (conditions 1 or 2). The prices of these categories are hidden and the 'Buy Now' button is replaced with '..more info..'

These categories can be configured via admin and the configuration is stored in the database.

The whole store continues to work as normal, customers can browse, see prices, add products to the cart and check out - with the exception of the specified categories.

This mod has been tested to work with Zen Cart v1.3.9 but may work with prior versions - use at your own peril, better though: upgrade to v1.3.9


I am interested in your comments and suggestions how to improve this mod (no PM please - post your comments here for all to read)

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

5 Jun 2011, 3:53 AM
#19
ipanemasand avatar

ipanemasand

New Zenner

Join Date:
Nov 2010
Posts:
13
Plugin Contributions:
0

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

Hi Frank,

I was looking for something like this when I came upon your mod. Overall, what I'd like to do is restrict access to all of my categories to registered users. It's just that if I adjust the global "Customer Shop Status" to 1, even my general pages become inaccessible and the categories side bar becomes hidden, neither of which I want. In other words I just don't want unregistered users to be able to browse and see any of my products.

Now, I may be misunderstanding your mod's function: is it to hide only the prices in individual categories to registered users? Or to restrict browsing access?

I installed the mod but I'm not seeing any difference except in the restricted categories, this is appearing at the top of the body:

// ********* begin exclusion of access to restricted categories - added by frank18 ********** // ********* end exclusion of access to restricted categories - added by frank18 **********

I am still able to browse the categories, however. So does this mean I did it incorrectly? Or was that not the mod's function? Please have a look at https://www.hijean.ca/demo. The first three categories have been restricted using your mod.

Also, I was new to WinMerge and was a little confused about how to merge two files that were completely different. One was almost identical so no problem there but the other one was completely different so I just ended up using your file.

Thanks and I appreciate your help.
ipanemasand

5 Jun 2011, 4:46 AM
#20
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

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

Generally this mod allows you to specify selected categories which can only be accessed by authorized customers (conditions 1 or 2). The prices of these categories are hidden and the 'Buy Now' button is replaced with '..more info..'

The mod could probably be expanded to immediately redirect a customer to the login page when they click on a category name.

You are seeing the comment // ********* begin exclusion of access to restricted categories - etc because most likely the file includes/modules/YOUR_TEMPLATE/product_listing.php was not merged properly with your product_listing.php file.

I suggest you do the merging again using a copy of your backup product_listing.php file (don't use the backup itself, make a copy first and use the copy for merging). When done, upload the file again and re-test.

If done properly you should be redirected to the login page after clicking any headline in the listing of your first, second or third category (the ones you want to restrict).

You can **view an example here**. Just click on any image or headline and you are being redirected to the login page.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.