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)
-   -   3.5.7 Product Sort Solution (https://forum.x-cart.com/showthread.php?t=7583)

arabayaservis.com 05-15-2004 02:35 AM

3.5.7 Product Sort Solution
 
customer/products.php


old;
Code:

$products = func_search_products($search_query, !empty($user_account['membership'])?$user_account['membership']:"", $first_page,$current_category["product_count"]);

new:
Code:

$products = func_search_products($search_query, !empty($user_account['membership'])?$user_account['membership']:"", $first_page,$current_category["product_count"],0,$orderby);

old;
Code:

$smarty->assign("products",$products);

new
Code:

$smarty->assign("orderby",$orderby);
$smarty->assign("products",$products);



customer/home.php?cat=105&orderby=price

you will see sorting products

laureon 05-15-2004 03:42 AM

good little mod, how might we go about sorting by price ascending rather than the default descending?

arabayaservis.com 05-15-2004 04:18 AM

please goto admin area and click to general settings

select apperance options

find : List products in reversed order

check/uncheck <-> asc/dsc

ok?

arabayaservis.com 05-15-2004 04:23 AM

customer/main/sortProduct.tpl (new page, please add)

Code:


{literal}
<script Language="Javascript">
function sortOnh(sortTypeNameOnh){
{/literal}       
        document.location.href = "{$smarty.server.PHP_SELF}?cat={$cat}&page=1&orderby="+sortTypeNameOnh;
{literal}               
}
</script>
{/literal}
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><form name="srchFrmOnh"><td align="right"><select name="srchTypeOnh" OnChange="sortOnh(this.value)">
{if $orderby eq "product"}
        <option selected value="product">Product Sort</option>
{else}
        <option value="product">Product Sort</option>
{/if}
{if $orderby eq "price"}
        <option selected value="price">Price Sort</option>
{else}
        <option value="price">Price Sort</option>
{/if}
{if $orderby eq "add_date"}
        <option selected value="add_date">Add Date Sort</option>
{else}
        <option value="add_date">Add Date Sort</option>
{/if}
</select>
</td></form></tr></table>



customer/main/products.tpl

add new line on top or whereever you want

Code:

{if $products}
        {if $main eq "catalog"}
                {include file="customer/main/sortProduct.tpl"}
        {/if}
{/if}


Little but important mod from Turkey!

xcell67 05-20-2004 11:51 AM

I found this in include/func.php:

Code:

#                                array_multisort($result_p,($orderby=="orderby" && $config["Appearance"]["product_order_reversed"]=="Y"?SORT_DESC:SORT_ASC),SORT_STRING, $productorderbys,($orderby=="orderby" && $config["Appearance"]["product_order_reversed"]=="Y"?SORT_DESC:SORT_ASC),SORT_NUMERIC,$productorderbyname,SORT_STRING);
                                array_multisort($result_p,($config["Appearance"]["product_order_reversed"]=="Y"?SORT_DESC:SORT_ASC),SORT_STRING,$productorderbys,($config["Appearance"]["product_order_reversed"]=="Y"?SORT_DESC:SORT_ASC),SORT_REGULAR,$productorderbyname,SORT_STRING);


My question is, how can we add a drop down menu so the user can choose to have the product sort displayed as ascending or descending?

B00MER 05-20-2004 12:06 PM

:arrow: http://www.cart-lab.com/lab/customer/product.php?productid=7

Product Sort, with ascending,descending dropdowns as well as configurable field types or fields from the products database dynamically.

Demo: http://www.cart-lab.com/lab/customer/search.php?substring=

xcell67 05-20-2004 04:14 PM

thanks for the recommendation boomer but I've already got the product sort down thanks to the mod above, the only thing I need is the Ascending/Descending bit.

nice looking site by the way =)

shua 07-19-2004 11:53 AM

mod modification?
 
cool mod, very handy, but when there are multiple pages (as in a list that goes beyond the users prefered quantity per page) the sorting breaks (ie, returns to alphebetical by title)

Any thoughts on how to remedy this?

B00MER 07-19-2004 11:58 AM

The Max Nav. pages shouldn't ever got past, I don't get what you mean exactly? :?

shua 07-19-2004 12:27 PM

let me rephrase
 
Hey Boomer.

What I mean is that I sort by lets say price. There are 51 products in my category, 10 are displayed at a time. To view the next 10 you must click the small arrow or the page number. I have been working on getting these links to use the sort code from above, but have been unsuccessful so far.

does that clear it up?

Thanks for the quick reply!!!


All times are GMT -8. The time now is 04:50 AM.

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