X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to redirect to product page directly? (https://forum.x-cart.com/showthread.php?t=73005)

sinobest 11-03-2015 11:54 AM

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.

razortw 11-04-2015 05:24 AM

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}


Eyeglasses Expert 11-29-2015 07:20 PM

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?

www.cheapglasses.net 02-14-2016 03:49 AM

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.

razortw 02-17-2016 03:30 PM

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

www.cheapglasses.net 02-17-2016 04:04 PM

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

qualiteam 02-18-2016 07:26 AM

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.


All times are GMT -8. The time now is 08:21 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.