View Single Post
  #19  
Old 12-14-2005, 02:33 AM
 
sundance sundance is offline
 

Member
  
Join Date: Oct 2004
Posts: 27
 

Default

Ok,

I haven't really tidied it up very much... sorry - got to go out to lunch (it's a tough life). It hasn't got a proper mod layout, it is all just embedded in the products.tpl using {php} brackets (I know! I know!), and it is probably not as efficient as it could be in its use of arrays.

EDIT: Still bug-fixing - currently have fixes for:
displaying wholesale prices when there aren't any (especially in search results)


It does work for me, though.... I promise I will tidy it up later - I just thought you might like to see it!

Here is my mod for products.tpl

You have to put this code in your products.tpl where you want the table to appear... obviously a table may not suit your needs - my next release of the mod will be tidier and hopefully clearer to see how you can customize it to your won look and feel.

Code:
{assign var="pid" value=$products[product].productid} {* sundance:extra_fields start *} {assign var="pid" value=$products[product].productid} {* get wholesale wholesale pricing data for product *} {php} $prodid=$this->_tpl_vars['pid']; $results = func_query("SELECT * FROM xcart_pricing WHERE productid='$prodid' ORDER BY quantity"); $this->assign("sv_val",$results); {/php} {* clear count and array values for each product to appear *} {php}$i=0; $boqu=""; $bopr=""; {/php} {* scan through each set of wholesale pricing *} {foreach from=$sv_val item=field} {php} $boqu[]=$this->_tpl_vars['sv_val'][$i]['quantity'] ; $bopr[]=$this->_tpl_vars['sv_val'][$i]['price'] ; $i++; {/php} {/foreach} <table bgcolor="#e9e9e9" border="0" cellspacing="5" cellpadding="0"> <tr> {* set up before-and-after array keys and delimiters for display quantiity values *} {php} foreach ($boqu as $key => $entry) { $pre = " - ".($entry-1); $prerec = ($key-1); $next = ($key+1); if ($boqu[$next]!="") { $nextrec = " - ".($boqu[$next]-1); } else { $nextrec = "+"; } {/php} {* setup initial price and discount colums *} {php}if ($prerec==0) { {/php} <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> {php} echo "Quantity Purchased:"; {/php} </td> </tr> <tr> <td> {php} echo "Unit Price:"; {/php} </td> </tr> </table> </td> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> {php} echo "$boqu[$prerec]$pre"; {/php} </td> </tr> <tr> <td> {php} echo "$bopr[$prerec]"; {/php} </td> </tr> </table> </td> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> {php} echo "$boqu[$key]$nextrec"; {/php} </td> </tr> <tr> <td> {php} echo "$bopr[$key]"; {/php} </td> </tr> </table> </td> {php} } {/php} {* display additional columns for multiple prices: *} {php} if ($prerec>=1) { {/php} <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="DialogTitle"> {php} echo "$boqu[$key]$nextrec"; {/php} </td> </tr> <tr> <td> {php} echo "$bopr[$key]"; {/php} </td> </tr> </table> </td> {php}}{/php} {php} } // foreach end {/php} </tr> </table>

So fiddle about with it - comments and questions are welcome.... I accept that the formatting won't suit everybodys products.tpl layout, and even more that it is a dirty hack - I will work on making it more digestible later,

Rob.
__________________
Xcart 4.0.17
Reply With Quote