| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Redirect to Product Page when only One product in category | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Redirect to Product Page when only One product in category
For simple sites that don't use sub-categories, etc, this may come in handy! Further, this was my first success at defining a Smarty var in the actual .TPL template file, then referencing back in php. I'm sure there is an easier way to do this, but this was my first successful attempt.
A request was made to have all of our category links on the left link directly to the individual product page when there is only one product in the category. Adding the following code to the top of skin1/customer/main/subcategories.tpl does the trick! Thanks to darrenkierman for pointing out that adding the following code to the top of skin1/customer/main/search_result.tpl will also take you straight to the product page if your search returns only 1 result! Code:
__________________
X-Cart 4.0.16-.19 Gold [unix] / DSEFU |
|||||||||
#2
|
|||||||
|
|||||||
Yea, that is a nice one...saw someone looking for this a while back.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||
|
|||||||
It works! My bad.
The copy/paste on a mac sometimes adds whitespace when pasting into my preferred text editor (text wrangler)... Thanks to a suggestion from PhilJ, I looked at the code and for whatever reasons, mr. macintosh dropped some extra spaces in to the lines (also when copying from a mac browser like Safari, all kinds of bad things happen at line breaks) Re-formatting all the linebreaks and whitespace fixed this! YEAH BABY! Thank you moneysaver67! Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#4
|
|||||||
|
|||||||
What a BEAUTIFUL piece of code this is...
It also works in sub-cats - so if you make a sub-category with only 1 product, your customer does not have to visit the subcategory page first... This is especially useful if you are using a nested category menu, such as PhilJ's "True Three Level Vertical Category Flyout Menu" This code along with the flyout menus makes the interface fluid and what you (read: customer) expect. Very, very nice.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#5
|
|||||||||
|
|||||||||
Quote:
That is awesome. There I go, coding into the unknown again. LoL Care to post the sub-cat code for the sake of the topic? As always, Enjoy!
__________________
X-Cart 4.0.16-.19 Gold [unix] / DSEFU |
|||||||||
#6
|
|||||||
|
|||||||
Quote:
There's no extra code! My point was that your code automagically made the functionality of the sub-cats from the flyout menus even better, and exactly as you would expect -- it just worked... in my case, I have 3-deep sub-cats, but some of the sub-cats only have a single product -- and your code makes it so that when you navigate to the 3-deep sub-cat that only has a single product, you end up on the product detail page. THIS IS COOL. This is how it should work by default... thanks!!!!
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#7
|
|||||||||
|
|||||||||
Quote:
Rock on, and No problem!
__________________
X-Cart 4.0.16-.19 Gold [unix] / DSEFU |
|||||||||
#8
|
|||||||||
|
|||||||||
Add the same coding to the top of 'search_result.tpl' and you will get the same effect on your search results.
i.e. if there is only one search result, it will show full details. --- and use the following mod as well: Search by SKU/Product code in quick search - 4.1.1 http://forum.x-cart.com/viewtopic.php?t=29877 and you can have it so when someone puts in a SKU in the search box, the full details appear instantly.
__________________
Darren Kierman Carlisle Glass (http://www.carlisleglass.co.uk/) ... running X-Cart Gold 4.4.5 [unix] |
|||||||||
#9
|
|||||||||
|
|||||||||
One small bug .... lets say you have one product and 5 subcategories, it will not show the subcategories because it automatically jumps to the one product. To fix it :
Code:
__________________
Darren Kierman Carlisle Glass (http://www.carlisleglass.co.uk/) ... running X-Cart Gold 4.4.5 [unix] |
|||||||||
#10
|
|||||||
|
|||||||
Quote:
Isn't that the point of the mod? The goal is for a category (or subcat) with only one product, to not have the "speedbump" of the category or subcat page. The mod works exactly this way... Why would you want to see the subcategories, if there is only one product ina category? Isn't the goal to get the customer to the product detail page with minimum navigation? I am using PhilJ's "True Three Level Vertical Category Flyout Menu" - and by assigning a product to a sub-cat (even 3 deep) - by selecting the sub-cat, this mod takes you direct to the product detail (assuming it is the only product in the subcat). I think you want to modify your product detail page, to also include the subcategory links... ?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
|
|||
X-Cart forums © 2001-2020
|