| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Function for sorting array | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() Hello,
I am trying to implement a table to show product variants so a customer doesn't have to click the dropdown to see the price. I have the table functioning, however, I would like it to be sorted by price (lowest first). This is how it is appearing now: http://mermaids-natural-skin-care.com/images/Sizes.gif Does anybody know how I can put a sort (lowest price 1st) into the following code: {***BEGIN Mod to add Variant Table***} {if $variants ne ""} <tr id="product_weight_box"> <td width="30%"> </td> <td nowrap="nowrap"> </td> </tr> <table width="100%" cellpadding="0" cellspacing="0"><tr><td colspan="4"><b><font class="ProductDetailsTitle">{$lng.lbl_AvailableSiz es}</font></b></td></tr> <tr><td class="Line" height="1" colspan="4"><img src="{$ImagesDir}/spacer.gif" class="Spc" alt="" /><br></td></tr> <tr><td colspan="4"> </td></tr> <tr> {foreach name=variants from=$variants item=tempVar} <td colspan="4"> {foreach from=$tempVar.options item=tempOpt} <tr> <td width="45%"> {$tempOpt.option_name} </td> <td align="left" width="5%"> {include file="currency.tpl"} </td> <td align="right" width="10%"> {$tempVar.price} </td> <td align="right" > </td> </tr> {/foreach} </td> {if $smarty.foreach.variants.iteration is div by 3} </tr> <tr> {elseif not $smarty.foreach.variants.last} <td width="30%"></td> {/if} {/foreach} </tr> </table> {/if} {***END Mod to Add Variant Table***} Thanks so much! ![]()
__________________
toomnyhats X-Cart Gold 4.1.9 (Unix) X-SpecialOffers DSEFU (disabled) |
|||||||
#2
|
|||||||
|
|||||||
![]() have a look at http://www.phpinsider.com/smarty-forum/viewtopic.php?t=1079
or you can sort it in php using something like 'usort' and pass that array to smarty |
|||||||
#3
|
|||||||
|
|||||||
![]() Thanks! I actually saw the thread on the other forum but didn't read far enough. I'm going to give it a try (I'm really new to php) so I may be back with more questions!
![]()
__________________
toomnyhats X-Cart Gold 4.1.9 (Unix) X-SpecialOffers DSEFU (disabled) |
|||||||
#4
|
|||||||
|
|||||||
![]() I'm having a bit of trouble with this. Can anybody tell me which php file I would put the sort function in? Also, what would be the smarty syntax to call the function in which an array is being passed to the function, sorted, and returned? Thanks so much!
__________________
toomnyhats X-Cart Gold 4.1.9 (Unix) X-SpecialOffers DSEFU (disabled) |
|||||||
|
|||
X-Cart forums © 2001-2020
|