Here's an XML file you can upload.
As extra steps, you must do the following:
1 - In PHPMyAdmin, go to your main category table and execute the following query in the SQL tab:
Note: Rename oc_ to your real prefix name (or remove if you don't have one).
2 - In your catalog/view/theme/<your_theme>/template/module/category.tpl file,
find:
replace with:
Then, find:
replace with:
3 - In your catalog/view/theme/<your_theme>/template/common/header.tpl file,
find:
replace with:
Then, find:
replace with:
4 - Go to your admin - > catalog - > categories - > insert or edit - > data. You will see at the bottom:
Set to yes from that desired category.
5 - Go to your store-front end and test the category in two ways:
- Click on the category straight. You should be redirected to the common/home page when restricted.
- Click on a unrestricted category and then, from the tree on your left, click on the restricted category. You should see a popup message box stating the category is restricted to registered customers only.
Note: This contribution requires that you have the category module installed from your admin - > extensions - > modules - > category and also enabled over the category and products.
Also take note that the sub-categories can also be inclusive in those restrictions. If the root category is restricted, the sub-categories will also be restricted.
As extra steps, you must do the following:
1 - In PHPMyAdmin, go to your main category table and execute the following query in the SQL tab:
Code: Select all
ALTER TABLE `oc_category` ADD `registered_customer_categories` INT(1) NOT NULL DEFAULT '0' AFTER `column`;
2 - In your catalog/view/theme/<your_theme>/template/module/category.tpl file,
find:
Code: Select all
<?php if ($category['category_id'] == $category_id) { ?>
<a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>
Code: Select all
<?php if ($category['category_id'] == $category_id) { ?>
<?php if ((int)$category['registered_customer_categories'] == 1 && !$this->customer->isLogged()) { ?>
<a href="#" onclick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"> - <?php echo $category['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
<?php } ?>
<?php } else { ?>
<?php if ((int)$category['registered_customer_categories'] == 1 && !$this->customer->isLogged()) { ?>
<a href="#" onclick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"> - <?php echo $category['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>
<?php } ?>
Code: Select all
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="active"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>"> - <?php echo $child['name']; ?></a>
<?php } ?>
Code: Select all
<?php if ($child['category_id'] == $child_id) { ?>
<?php if (((int)$category['registered_customer_categories'] == 1 || (int)$child['registered_customer_categories'] == 1) && !$this->customer->isLogged()) { ?>
<a href="#" onclick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="active"> - <?php echo $child['name']; ?></a>
<?php } ?>
<?php } else { ?>
<?php if (((int)$category['registered_customer_categories'] == 1 || (int)$child['registered_customer_categories'] == 1) && !$this->customer->isLogged()) { ?>
<a href="#" onclick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>"> - <?php echo $child['name']; ?></a>
<?php } ?>
<?php } ?>
find:
Code: Select all
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
Code: Select all
<?php if ((int)$category['registered_customer_categories'] == 1 && !$this->customer->isLogged()) { ?>
<li><a href="#" onClick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"><?php echo $category['name']; ?></a>
<?php } else { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>
Code: Select all
<li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
Code: Select all
<?php if (((int)$category['registered_customer_categories'] == 1 || (int)$category['children'][$i]['registered_customer_categories'] == 1) && !$this->customer->isLogged()) { ?>
<li><a href="#" onClick="alert('<?php echo $text_reg_cust_restrict; ?>'); return false;"><?php echo $category['children'][$i]['name']; ?></a></li>
<?php } else { ?>
<li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
<?php } ?>
Code: Select all
Only to registered customers:
Only registered customers will have access to this category.
5 - Go to your store-front end and test the category in two ways:
- Click on the category straight. You should be redirected to the common/home page when restricted.
- Click on a unrestricted category and then, from the tree on your left, click on the restricted category. You should see a popup message box stating the category is restricted to registered customers only.
Note: This contribution requires that you have the category module installed from your admin - > extensions - > modules - > category and also enabled over the category and products.
Also take note that the sub-categories can also be inclusive in those restrictions. If the root category is restricted, the sub-categories will also be restricted.
Attachments
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
HI Straightlight,
Thank you for taking the time to reply to my post.
I have tried searching for the code you mentioned in step 3. But I cant find the reference in the header.tpl
Can you please send me the instructions again.
Thanks,
Vincent
Thank you for taking the time to reply to my post.
I have tried searching for the code you mentioned in step 3. But I cant find the reference in the header.tpl
Can you please send me the instructions again.
Thanks,
Vincent
These instructions are for OpenCart v1.5.1.3.1 release. If you don't see these codes from step 3, it either means you're using a lower version or you may use the latest but with a custom template. On either case, you'd need to post your header.tpl file as an attachment so that I can take a look at it.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Can you share a screenshot or link to a store where this has been actioned? I would like to see how it works. I am thinking of having a 'members only' website whereby the site is only accessible to those who are authorised members. I am considering having a single homepage that explains who we are and allows the visitor to contact us to apply for access and then if we make them an account they will have access.
Alternatively, wouldn't it be easier to just have a site but make all products viewable only to certain customer groups. Thus if they are not an 'approved' customer they can't see products/prices. That would work right?
Alternatively, wouldn't it be easier to just have a site but make all products viewable only to certain customer groups. Thus if they are not an 'approved' customer they can't see products/prices. That would work right?
This little contribution has been coded on a previous version of OC. I will see what I can do for recent releases.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
i was reading up how to create an "only registered user account" i went through your write upstraightlight wrote:This little contribution has been coded on a previous version of OC. I will see what I can do for recent releases.
while i was using oc 1.5.1.3.1 the mod worked fine now i updated to the latest oc one and keep getting errors. please help i would be very grateful. sent you my header.pl. via pm thanks in advance
Who is online
Users browsing this forum: No registered users and 24 guests