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

Priced from using lowest wholesale price

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-02-2006, 04:44 PM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Priced from using lowest wholesale price

I've been struggling with this for hours on the products_t.tpl. I've found the code to create an array containg the wholsale pricing in modules/Wholesale_Trading/product,php

How do I call this in products_t.tpl . I have tried this but it doesn't work

<font class="ProductPrice">{$lng.lbl_our_price}:
{include file="product.php"}
{if $product_wholesale ne ""}fred
{/if}

Any help would be much appreciated

Ant

Version 4.1.3
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote
  #2  
Old 09-03-2006, 12:26 PM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Priced from using lowest wholesale price

Worked that out.

Include needs enclosing in {php}{/php} tags

Still won't work though.

I've tried this more clumsy method of cutting all the code from modules/Wholesale_Trading/product.php and inserting it thus

<code>
{* $Id: products_t.tpl,v 1.30.2.2 2006/08/11 12:18:08 max Exp $ *}
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>

<table width="100%" cellpadding="5" cellspacing="5" border="1px" border-color="black">

{math equation="floor(100/x)" x=$config.Appearance.products_per_row assign="width"}

{section name=product loop=$products}
{assign var="discount" value=0}

{if %product.index% is div by $config.Appearance.products_per_row}
<tr>
{assign var="cell_counter" value=0}
{/if}

{math equation="x+1" x=$cell_counter assign="cell_counter" }

<td width="{$width}%" class="PListCell">

<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_p age}" class="ProductTitle">{$products[product].product}</a><br />
{if $config.Appearance.display_productcode_in_list eq "Y" and $products[product].productcode ne ""}
{$lng.lbl_sku}: {$products[product].productcode}<br />
{/if}
<table cellpadding="3" cellspacing="0" width="100%">
<tr>
<td height="100" nowrap="nowrap">
<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_p age}">{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$config.Appearance.thumbnail_width product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{/if}
</td>
</tr>
</table>
<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_p age}">{$lng.lbl_see_details}</a>
{if $products[product].product_type ne "C"}
<br />
<br />
{if $active_modules.Subscriptions ne "" and $products[product].catalogprice}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else}
{if $products[product].taxed_price ne 0}
{if $products[product].list_price gt 0 and $products[product].taxed_price lt $products[product].list_price}
{math equation="100-(price/lprice)*100" price=$products[product].taxed_price lprice=$products[product].list_price format="%3.0f" assign=discount}
{if $discount gt 0}
<font class="MarketPrice">{$lng.lbl_market_price}: <s>
{include file="currency.tpl" value=$products[product].list_price}
</s></font><br />
{/if}
{/if}
<font class="ProductPrice">{$lng.lbl_our_price}:
{php}
#
# Generate wholesale pricing table********* inseted here****************************************
#
$wresult = func_query ("SELECT $sql_tbl[pricing].quantity, MIN($sql_tbl[pricing].price) as price FROM $sql_tbl[pricing] WHERE $sql_tbl[pricing].productid=$products[product].productid AND $sql_tbl[pricing].membershipid IN ('$user_account[membershipid]', 0) AND $sql_tbl[pricing].quantity>1 AND $sql_tbl[pricing].variantid=0 GROUP BY $sql_tbl[pricing].quantity ORDER BY $sql_tbl[pricing].quantity");

if ($wresult) {
foreach ($wresult as $wk => $wv) {
$_taxes = func_tax_price($wv["price"], $productid);
$wresult[$wk]["taxed_price"] = $_taxes["taxed_price"];
$wresult[$wk]['taxes'] = $_taxes['taxes'];

if ($wk > 0) {
$wresult[$wk-1]["next_quantity"] = $wv["quantity"]-1;
if ($product_info['min_amount'] > $wresult[$wk-1]["next_quantity"]) {
unset($wresult[$wk-1]);

} elseif ($product_info['min_amount'] > $wresult[$wk-1]["quantity"]) {
$wresult[$wk-1]["quantity"] = $product_info['min_amount'];
}
}
}
$wresult = array_values($wresult);
if (count($wresult) > 0)
$wresult[count($wresult)-1]["next_quantity"] = 0;

$smarty->assign ("product_wholesale", $wresult);
}
{/php}

{if $product_wholesale eq ""}fred
{/if}
{*{include file="currency.tpl" value=$products[product].taxed_price}*}</font><br /><font class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</font>{if $discount gt 0}{if $config.General.alter_currency_symbol ne ""},{/if} {$lng.lbl_save_price} {$discount}%{/if}
{if $products[product].taxes}<br />{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes}{/if}
{if $active_modules.Special_Offers ne "" and $products[product].use_special_price ne ""}
{include file="modules/Special_Offers/customer/product_special_price.tpl" product=$products[product]}
{/if}
{else}
<font class="ProductPrice">{$lng.lbl_enter_your_price}</font>
{/if}
{/if}
{if $active_modules.Feature_Comparison ne '' && $products[product].fclassid > 0}
<div align="center" style="width: 100%; padding-top: 10px;">
{include file="modules/Feature_Comparison/compare_checkbox.tpl" id=$products[product].productid}
</div>
{/if}
{*** Uncomment it if you need 'Buy Now' button ***
{if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"}
{include file="customer/main/buy_now.tpl" product=$products[product]}
{/if}
*** Uncomment it if you need 'Buy Now' button ***}
{/if}
</td>

{capture name=prod_index}
{math equation="index+x+1" index=%product.index% x=$config.Appearance.products_per_row}
{/capture}
{if $smarty.capture.prod_index is div by $config.Appearance.products_per_row }
</tr>
{/if}

{/section}

{if $cell_counter lt $config.Appearance.products_per_row}
{section name=rest_cells loop=$config.Appearance.products_per_row start=$cell_counter}
<td class="SectionBox">&nbsp;</td>
{/section}
</tr>
{/if}

</table>
</td>
</tr>
</table>
{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y' && $products_has_fclasses}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}

</code>

Unfortunately this doesn't workeither. I'm getting an SQL error

<code>
INVALID SQL: 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' MIN(.price) as price FROM WHERE .productid=.productid AND .me
SQL QUERY FAILURE:SELECT .quantity, MIN(.price) as price FROM WHERE .productid=.productid AND .membershipid IN ('', 0) AND .quantity>1 AND .variantid=0 GROUP BY .quantity ORDER BY .quantity
fred
</code>

Sadly this means little to me and maybe some one could point me in the right direction.

I think maybe this isn't the ideal solution as it is going to query the database so many times and perhapsd the use of an extra field may be advantagous, but then that's a bit clumsy too as it means manually checking wholesale and lowest price.

If anyone can think of a more elegant solution let me know!!

Ant
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
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 06:08 AM.

   

 
X-Cart forums © 2001-2020