Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Display sub categories in top level category

Display sub categories in top level category

Locked

Views: 3,108

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
19 Dec 2011, 3:59 PM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Display sub categories in top level category

I need a way to display all sub category products in a top level category. So how would I do this?

The reason for this is because of a postage problem and basically products have to be broken down into First Class Post and Track and Trace Post. The cart has been set up so that people ordering track and trace only get the option to select track and trace at the cart. People ordering first class get both postage options. This relies on the categories being broken in two, however I don't want the customer to know about the First Class and Track and Trace sub categories which is why I need all sub category products listed in the top level category.

This is how the category tree is built

Chemicals

  • First Class
  • Track and Trace

So basically I need all products which are inside the 'First Class' and 'Track and Trace' categories to be listed in the Chemicals category on the site, but in the admin listed in 'First Class' and 'Track and Trace'.

19 Dec 2011, 4:28 PM
#2
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

Before you address the first question, there may be better ways to solve your underlying issue.

How are you going to decide which customers get to see which set of options before adding to cart? Are certain products track & trace only? Are certain customers limited to what method they can use?

19 Dec 2011, 4:37 PM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display sub categories in top level category

certain products are track and trace only and when a customer adds a product to the cart they only see that option. Other products give the customer the option of First Class and Track and trace.

I know I could manually code shipping options so track and trace shows as the only option but because this cart is not for me it has to be coded according to which category a customer selects a product from.

However when on the site a customer must not see the categories First Class and Track and Trace.

They must only see the top level category with no sub categories beneath. And all products listed in sub categories must show on the site in a top level category.

19 Dec 2011, 5:12 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

If your client can place new products in the correct "track & trace" subcategory, surely they could select a switch somewhere in admin (maybe on the product editing page) which would set a "track" flag for the product. If you are coding for which shipping option to present anyway, distinguishing on a product field level shouldn't be so different from using a product's category, and the client won't see any of that logic anyway. What happens if there are both kinds of products in the cart? Does the whole shipment have to be tracked, or can it be broken into two shipments (presumably saving money in shipping)?

I think making the required custom back-end coding do the whole job is better than also requiring custom front-end coding.

19 Dec 2011, 5:54 PM
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display sub categories in top level category

I've looked at backend coding and creating some kind of switch to select whichever postage method a product will go at but wouldn't know where to start on the backend to do that.

If the cart contains a first class item and a track and trace item then the whole shipment goes track and trace.

What your saying about creating a switch to select the correct postage would get around my problem so if you can shed some light on what I would need to do then I would be really greatful.

19 Dec 2011, 5:59 PM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

There is a mod in Free Addons for "product extra fields" which will let you add a new field to the product editing page. Then there are various wiki articles, possibly tutorials and certainly forum threads about modifying cart or checkout actions based on a product (or a product with a certain field value) being in the cart.

19 Dec 2011, 6:02 PM
#7
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display sub categories in top level category

ok, well I know about the product extra fields mod but not sure if it will do the job. will have a look though.

19 Dec 2011, 6:05 PM
#8
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

It will definitely add a field to the db and the possibility to enter something in the admin product page. What you do with that is the subject of the articles/threads/etc. A db field can be tested for and retrieved with the right SQL statement.

19 Dec 2011, 6:58 PM
#9
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display sub categories in top level category

ok well I've just had a look and it adds extra fields but they are text boxes and I would need to have a dropdown, radio buttons or tickboxes and then they would have to select the correct postage table (I'm using two table rates for first class and track and trace).

19 Dec 2011, 8:12 PM
#10
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

The essential function of the field would be to distinguish between tracked products and general products. Without modifying the field code, you could set it up so that any entry in that field is interpreted as "track me" and null as "general".

The support thread for that mod may have some discussion of changing the field type.

19 Dec 2011, 8:35 PM
#11
gjh42 avatar

gjh42

Black Belt

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

Re: Display sub categories in top level category

Okay, I searched the support thread and there is no relevant mention of dropdown or radiobutton.
However, it should certainly be possible to substitute dropdown, radiobutton or checkbox code for text input code in the mod, following the example of existing files in admin (like the one that handles the product page). You can dispense with any front end output code, as you only want to put the info in the db and handle it in checkout.

19 Dec 2011, 9:06 PM
#12
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display sub categories in top level category

I've found a solution to this which is a bit of a dirty fix, however it works and thats all that matters.

Linda McGrath (Ajeh) has also been helping me with this so credit to her.

See this thread about a mass products duplication tool she has been developing, works a treat.

http://www.zen-cart.com/forum/showthread.php?t=180447&page=1

So what I did was download this tool and install it firstly.

Then I moved my first class and track and trace categories to a category which is switched off called Chemicals Admin Category. First Class and Track and Trace are switched on inside this category as are all the products listed inside them. Then all products listed inside my Chemicals Admin Category have been duplicated to another category called Chemicals (the category where the products should all display. This means that all the products inside my First Class and Track and Trace categories are now mixed in the same category but when I put them through the cart it selects the correct postage method for the product in the cart. This is because my shipping/table1.php (first class) has code in it telling the cart to switch off first class if a Track and Trace item is added to the cart.

Bit of a dirty fix but it works.