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

product's sequence number

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-27-2012, 12:44 AM
 
Stizerg Stizerg is offline
 

Senior Member
  
Join Date: Apr 2008
Location: Sydney, Australia
Posts: 195
 

Default product's sequence number

Is there an easy way to get product's sequence number in current category?
For example if I open 5th product I need to get something like $current_product=4 (considering it starts with 0), so then I can pass it to javascript.
I know I can go through $products or $cat_products to get this number, I just was wondering if that number already exists somewhere.
It's for v.4.4.4
__________________
X-Cart Gold Plus 4.6.6
A lot of custom mods
Reply With Quote
  #2  
Old 02-27-2012, 04:47 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,062
 

Default Re: product's sequence number

Possibly the closest you could get to doing this with some pre-existing code/variables would be if you set the product positions in the category, then use the order_by variable.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #3  
Old 02-27-2012, 04:14 PM
 
Stizerg Stizerg is offline
 

Senior Member
  
Join Date: Apr 2008
Location: Sydney, Australia
Posts: 195
 

Default Re: product's sequence number

Nice idea, unfortunately order_by is available only for categories in $categories_menu_list, I don't know how to include it into $product.
__________________
X-Cart Gold Plus 4.6.6
A lot of custom mods
Reply With Quote
  #4  
Old 02-28-2012, 12:43 AM
 
Stizerg Stizerg is offline
 

Senior Member
  
Join Date: Apr 2008
Location: Sydney, Australia
Posts: 195
 

Default Re: product's sequence number

OK, that was simple.
in product.php
PHP Code:
// product's sequence number in current category - by Stizerg
if (is_array($products)) 
    foreach(
$products as $x=>$pr)
        if (
$pr['productid'] == $productid) {
            
$product_info["seq_number"] = $x+1;
            break;
        }
// 
before
PHP Code:
$smarty->assign('product'$product_info); 

In my design I display products of current category at the bottom of product area so
PHP Code:
include './products.php'
must be included somewhere in the beginning of product.php, otherwise it wouldn't work.
And now I can use {$product.seq_number} in my templates.
__________________
X-Cart Gold Plus 4.6.6
A lot of custom mods
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 06:37 PM.

   

 
X-Cart forums © 2001-2020