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

Available stock to featured admin

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-31-2012, 05:46 AM
 
N00dles N00dles is offline
 

Advanced Member
  
Join Date: Jul 2011
Posts: 43
 

Default 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}
__________________
x-cart 4.4.3
Reply With Quote
  #2  
Old 02-03-2012, 05:15 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default 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.
__________________
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
  #3  
Old 02-03-2012, 05:44 AM
 
N00dles N00dles is offline
 

Advanced Member
  
Join Date: Jul 2011
Posts: 43
 

Default 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");
__________________
x-cart 4.4.3
Reply With Quote
  #4  
Old 02-03-2012, 07:05 AM
 
N00dles N00dles is offline
 

Advanced Member
  
Join Date: Jul 2011
Posts: 43
 

Default 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}
__________________
x-cart 4.4.3
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 05:51 PM.

   

 
X-Cart forums © 2001-2020