Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

How to redirect to product page directly?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 11-03-2015, 11:54 AM
 
sinobest sinobest is offline
 

X-Adept
  
Join Date: Nov 2009
Posts: 461
 

Default How to redirect to product page directly?

If a category only has 1 product, how to let the category page redirect to the product page directly?

tks.
__________________
X-Cart Version: 4.7.12 GOLD
www.cheapglasses123.com prescription glasses online at discounted prices.
prescriptionglassesusa.com
www.loupesusa.com X-Cart Version: 4.7.11 GOLD PLUS
Reply With Quote
  #2  
Old 11-04-2015, 05:24 AM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

Default Re: How to redirect to product page directly?

Quote:
Originally Posted by sinobest
If a category only has 1 product, how to let the category page redirect to the product page directly?

tks.
Hi.
Try to insert this to the /light_responsive/customer/home.tpl right after the opening <body> tag.
Code:
{if $main eq 'catalog' and $cat_products|@count eq 1} <script type="text/javascript"> window.location.href = "{$cat_products[0].page_url}"; </script> {/if}
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote
  #3  
Old 11-29-2015, 07:20 PM
 
Eyeglasses Expert Eyeglasses Expert is offline
 

eXpert
  
Join Date: May 2010
Posts: 306
 

Default Re: How to redirect to product page directly?

i think it is not good use js to redirect the category page to product page.

at www.loupesusa.com, category of Feather LED Headlight, the url is http://www.loupesusa.com/feather-led-headlight/, when i clip the category, www.loupesusa.com/feather-led-headlight/ will be display first, then jump to product page of http://www.loupesusa.com/feather-super-light-led-headlight.html. very bad for seo


how about like this:

if a category has only 1 product, just let the product page url as category page url. i think it is better for seo.

category of Feather LED Headlight only has 1 product, then let http://www.loupesusa.com/feather-led-headlight/ be this category's url directly. not need using http://www.loupesusa.com/feather-led-headlight as its url.

how to meet this demands, pls?
Reply With Quote
  #4  
Old 02-14-2016, 03:49 AM
 
www.cheapglasses.net www.cheapglasses.net is offline
 

Advanced Member
  
Join Date: Dec 2015
Posts: 77
 

Default Re: How to redirect to product page directly?

Quote:
Originally Posted by razortw
Hi.
Try to insert this to the /light_responsive/customer/home.tpl right after the opening <body> tag.
Code:
{if $main eq 'catalog' and $cat_products|@count eq 1} <script type="text/javascript"> window.location.href = "{$cat_products[0].page_url}"; </script> {/if}

how to use php code to meet the same function?

not use js.
Reply With Quote
  #5  
Old 02-17-2016, 03:30 PM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

Default Re: How to redirect to product page directly?

Quote:
Originally Posted by www.cheapglasses.net
how to use php code to meet the same function?

not use js.
Hello.
You can try to use the header('Location: function
* http://php.net/manual/en/function.header.php
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote
  #6  
Old 02-17-2016, 04:04 PM
 
www.cheapglasses.net www.cheapglasses.net is offline
 

Advanced Member
  
Join Date: Dec 2015
Posts: 77
 

Default Re: How to redirect to product page directly?

{if $main eq 'catalog' and $cat_products|@count eq 1}
{php}
header("{$cat_products[0].page_url}");
{/php}
{/if}

not working
Reply With Quote
  #7  
Old 02-18-2016, 07:26 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: How to redirect to product page directly?

Quote:
not working
1. The code is for X-Cart 4, not X-Cart 5.
2. You should use the header() PHP function in PHP scripts, not in template files.
3. I believe you should hire someone to do custom modifications for you.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:31 PM.

   

 
X-Cart forums © 2001-2020