X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   product's sequence number (https://forum.x-cart.com/showthread.php?t=62780)

Stizerg 02-27-2012 12:44 AM

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

pauldodman 02-27-2012 04:47 AM

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.

Stizerg 02-27-2012 04:14 PM

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.

Stizerg 02-28-2012 12:43 AM

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.


All times are GMT -8. The time now is 06:37 PM.

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