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)
-   -   Available stock to featured admin (https://forum.x-cart.com/showthread.php?t=62495)

N00dles 01-31-2012 05:46 AM

Available stock to featured admin
 
I want to be able to see if the product has stock available in the part I view in admin/categories.php where you add the featured items.

I am in the /skin/myskin/common/admin/featured_products.tpl
I have added a new colm in the part I want but when I try to use the smarty code for the query it wants to be a Y instead of the number available.
The Y/N has been subsituted for the available stock count VAR so now it is featured product = active true false, so will I need to do another query just for the avaiblity of stock itself ?

Is there another var / query / php I need to add for the available amount to show on the admin featured_products.tpl ?

How I think the var query is : table [field_productid]. field_valueneeded
v4.4.3

I have tried a few none work

Code:

{$products[prod_num].avail}
or
Code:

{$products[productid].avail}

But this does not work I have tried others to
Code:

{if $products[product].avail gt 0}{$lng.txt_items_available|substitute:"items":$products[product].avail}{else}{$lng.lbl_no_items_available}{/if}

Code:

{if $product.avail gt 0}IN STOCK{else}BACKORDERED{/if}


qualiteam 02-03-2012 05:15 AM

Re: Available stock to featured admin
 
You should alter the PHP script first (admin/categories.php) and add the required data selection, e.g. like this:
Code:

$products = func_query ("SELECT $sql_tbl[featured_products].productid, $sql_tbl[products].product, $sql_tbl[featured_products].product_order, $sql_tbl[featured_products].avail, $sql_tbl[products].product from $sql_tbl[featured_products], $sql_tbl[products].avail AS in_stock where $sql_tbl[featured_products].productid=$sql_tbl[products].productid AND $sql_tbl[featured_products].categoryid='$f_cat' order by $sql_tbl[featured_products].product_order");

After that you can use something like {$products[productid].in_stock} in the template.

Note: the example SQL wont work for products with variants due to the fact that variants stock is stored in another table. more complex SQL will be required.

You can find more info about X-Cart DB structure here.

N00dles 02-03-2012 05:44 AM

Re: Available stock to featured admin
 
Thank you for the help this will help me understand how xcart works more now.

If I add the code As in_stock to the query the featured products goes blank as if there are none set.
If I take it away from the query, I get the amount of products avaiable but the Featured Active is removed so no checked boxs to the active featured products.

Works to a limit with {$products[prod_num].avail} , no active check boxes

its conflicting with this {$products[prod_num].productid}][avail]"{if $products[prod_num].avail eq "Y"}
So now its the other way around i get what i want but the active is now not a Y or N

Code:

$products = func_query ("SELECT
 $sql_tbl[featured_products].productid,
 $sql_tbl[products].product,
 $sql_tbl[featured_products].product_order,
 $sql_tbl[featured_products].avail,
 $sql_tbl[products].avail
 from
 $sql_tbl[featured_products],
 $sql_tbl[products]
 where
 $sql_tbl[featured_products].productid=$sql_tbl[products].productid
 AND
 $sql_tbl[featured_products].categoryid='$f_cat'
 order by
 $sql_tbl[featured_products].product_order");


N00dles 02-03-2012 07:05 AM

Re: Available stock to featured admin
 
Ok got there in the end thanks for your help pointing me in the right direction. :-)
Now no need to look on the front page to see if its been added to the featured produsts or if its out of stock, as I do not show out of stock Items I do not know what has gone missing from the front.

Also the select featured product should have this because I am forever trying to find in stock items by name in the select featured products lists.
I think next I will either make a mod for just adding products to the featured products by productid or sku would be a much easier way, no searching massive lists then finding out its not in stock.

Query
Code:

$products = func_query ("SELECT
 $sql_tbl[featured_products].productid,
 $sql_tbl[products].product,
 $sql_tbl[featured_products].product_order,
 $sql_tbl[featured_products].avail,
 $sql_tbl[products].avail AS in_stock
 from
 $sql_tbl[featured_products],
 $sql_tbl[products]
 where
 $sql_tbl[featured_products].productid=$sql_tbl[products].productid
 AND
 $sql_tbl[featured_products].categoryid='$f_cat'
 order by
 $sql_tbl[featured_products].product_order");


Smarty Tag
Code:

{$products[prod_num].in_stock}


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

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