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

Help me modify and if/else statement PLEASE

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-16-2004, 09:52 AM
  Christopher728's Avatar 
Christopher728 Christopher728 is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: CA
Posts: 46
 

Default Help me modify and if/else statement PLEASE

Could someone help me modify this chunk of code from product.tpl Please.
Code:
{if $product.forsale ne "B"} {include file="buttons/add_to_cart.tpl" style="button"} {if $login ne "" and $active_modules.Wishlist ne ""} {include file="customer/add2wl.tpl"} {/if} {else} {$lng.txt_pconf_product_is_bundled} {/if} {else} {include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if}

I want to incorporate this some how:
Code:
{if $products[product].param00 eq ""} {include file="customer/main/buy_now.tpl" product=$products[product]} {else} {if $products[product].param00 eq Y} {include file="customer/main/call.tpl"}

My goal is to replace the buy now button only on certain products with with a separate tpl I made (call.tpl) containing instructions to call and order.
I got it to work in my products.tpl but I can't seem to get it right in the product.tpl

Thanks for any help!
__________________
X-cart versions 4.1.11, 4.1.9 & 4.1.8
Reply With Quote
  #2  
Old 11-16-2004, 10:45 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Code:
{if $product.forsale ne "B"} {if $product.param00 eq Y} {include file="customer/main/call.tpl"} {else} {include file="buttons/add_to_cart.tpl" style="button"} {if $login ne "" and $active_modules.Wishlist ne ""} {include file="customer/add2wl.tpl"} {/if} {else} {$lng.txt_pconf_product_is_bundled} {/if} {else} {include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if} {/if}
Reply With Quote
  #3  
Old 11-16-2004, 11:30 AM
  Christopher728's Avatar 
Christopher728 Christopher728 is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: CA
Posts: 46
 

Default

Thanks for helping. It didn't quite do the trick though. With the change I get nothing on the screen where the product should be.

I'm posting the original full page code below and then I'll post it with the change, if that helps. The section in question starts about 2/3rds the way down.

Thanks again

Code:
{* $Id: product.tpl,v 1.78.2.4 2004/02/27 13:47:00 mclap Exp $ *} {include file="check_product_options_js.tpl"} {include file="location.tpl"} {if $product.product_type eq "C"} {include file="modules/Product_Configurator/pconf_customer_product.tpl"} {else} {capture name=dialog} <table border=0 width=100%> <form name=orderform method=post action="cart.php?mode=add" OnSubmit="javascript:if (!FormValidation()) return false"> <tr> <td valign=top align=left rowspan=2 width=100> {include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url} </td> <td valign=top> <span class=> {if $product.fulldescr ne ""}{$product.fulldescr}{else}{$product.descr}{/if} </span> <table width=100% cellpadding=0 cellspacing=0 border=0> <tr><td colspan=2><font class=ProductDetailsTitle>{$lng.lbl_details}</font></td></tr> <tr><td class=Line height="1" colspan=2>[img]{$ImagesDir}/spacer.gif[/img]</td></tr> <tr><td colspan=2></td></tr> {if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <tr><td width=30%>{$lng.lbl_quantity}</td><td nowrap>{if $product.avail gt 0}{$product.avail}{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</td></tr> {/if} {if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{$product.weight} {$config.General.weight_symbol}</td></tr>{/if} {if $active_modules.Extra_Fields ne ""} {include file="modules/Extra_Fields/product.tpl"} {/if} {if $active_modules.Subscriptions ne "" and $subscription} {include file="modules/Subscriptions/subscription_info.tpl"} {else} <tr><td class=ProductPriceConverting>{$lng.lbl_price}:</td> <td> {if $product.price ne 0} <font class=ProductDetailsTitle>{include file="currency.tpl" value=$product.price}</font><font class=MarketPrice> {include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.price}</font>{if $config.Taxes.use_vat eq "Y" and $product.vat gt "0"}, {$lng.lbl_including_vat} {$product.vat}%{/if} {else} <input type=text size=7 name=price> {/if} </td> </tr> {/if} </table> <table border=0 width=100% cellpadding=0 cellspacing=0> <tr><td colspan=2> <font class=ProductDetailsTitle>{$lng.lbl_options}</font> </td></tr> <tr><td class=Line height="1" colspan=2>[img]{$ImagesDir}/spacer.gif[/img]</td></tr> <tr><td colspan=2></td></tr> {if $active_modules.Product_Options ne ""} { include file="modules/Product_Options/customer_options.tpl"} {/if} <tr><td height=25 width=30%>{$lng.lbl_quantity}{if $product.min_amount gt 1} <FONT class=ProductDetailsTitle>{$lng.txt_need_min_amount} {$product.min_amount} {$lng.lbl_items}</FONT>{/if}</td> <td> {if $config.General.unlimited_products eq "N" and ($product.avail le 0 or $product.avail lt $product.min_amount)} {$lng.txt_out_of_stock} {else} {if $config.General.unlimited_products eq "Y"} {math equation="x+1" assign="mq" x=$config.Appearance.max_select_quantity} {else} {math equation="x/y" x=$config.Appearance.max_select_quantity y=$product.min_amount assign="tmp"} {if $tmp<2} {assign var="minamount" value=$product.min_amount} {else} {assign var="minamount" value=0} {/if} {math equation="min(maxquantity+minamount, productquantity)+1" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail} {/if} {if $product.distribution eq ""} <select name=amount> {if $product.min_amount le 1} {assign var="start_quantity" value=1} {else} {assign var="start_quantity" value=$product.min_amount} {/if} {section name=quantity loop=$mq start=$start_quantity} <option value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</option> {/section} </select> {else} <font class=ProductDetailsTitle>1</font><input type=hidden name=amount value=1> {$lng.txt_product_downloadable} {/if} {/if} </td></tr> <tr><td colspan=2> <input type=hidden name=mode value=add> {include file="customer/main/product_prices.tpl"} {if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)} {if $js_enabled} {if $smarty.get.pconf ne ""} <INPUT type=hidden name="slot" value="{$smarty.get.slot}"> <INPUT type=hidden name="addproductid" value="{$product.productid}"> {include file="buttons/pconf_add_to_configuration.tpl" style="button"} {/if} {if $product.forsale ne "B"} {include file="buttons/add_to_cart.tpl" style="button"} {if $login ne "" and $active_modules.Wishlist ne ""} {include file="customer/add2wl.tpl"} {/if} {else} {$lng.txt_pconf_product_is_bundled} {/if} {else} {include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if} <input type=image src="{$ImagesDir}/null.gif" width=10 height=10 border=0 align=top> </td> </tr></table> </td> <td align=right valign=top width=60> {if $product.list_price gt 0 and $product.price lt $product.list_price}<table border=0 width=60><tr><td width=55 height=56 class="SaveMoneyLabel" background="{$ImagesDir}/save_money.gif" align=center valign=middle> {math equation="100-(price/lprice)*100" price=$product.price lprice=$product.list_price format="%d" assign=discount} { $discount }% </td></tr></table>{/if} </td> </tr> <input type=hidden name=productid value="{$product.productid}"> <input type=hidden name=cat value="{$smarty.get.cat|escape:"html"}"> <input type=hidden name=page value="{$smarty.get.page|escape:"html"}"> </form> </table> {/capture} {include file="dialog.tpl" title=$product.product content=$smarty.capture.dialog extra="width=100%"} {/if} {if $active_modules.Detailed_Product_Images ne ""} {include file="modules/Detailed_Product_Images/product_images.tpl" } {/if} {if $active_modules.Upselling_Products ne ""} {include file="modules/Upselling_Products/related_products.tpl" } {/if} {if $active_modules.Recommended_Products ne ""} {include file="modules/Recommended_Products/recommends.tpl" } {/if} {if $active_modules.Customer_Reviews ne ""} {include file="modules/Customer_Reviews/vote_reviews.tpl" } {/if}

Code:
{* $Id: product.tpl,v 1.78.2.4 2004/02/27 13:47:00 mclap Exp $ *} {include file="check_product_options_js.tpl"} {include file="location.tpl"} {if $product.product_type eq "C"} {include file="modules/Product_Configurator/pconf_customer_product.tpl"} {else} {capture name=dialog} <table border=0 width=100%> <form name=orderform method=post action="cart.php?mode=add" OnSubmit="javascript:if (!FormValidation()) return false"> <tr> <td valign=top align=left rowspan=2 width=100> {include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url} </td> <td valign=top> <span class=> {if $product.fulldescr ne ""}{$product.fulldescr}{else}{$product.descr}{/if} </span> <table width=100% cellpadding=0 cellspacing=0 border=0> <tr><td colspan=2><font class=ProductDetailsTitle>{$lng.lbl_details}</font></td></tr> <tr><td class=Line height="1" colspan=2>[img]{$ImagesDir}/spacer.gif[/img]</td></tr> <tr><td colspan=2></td></tr> {if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <tr><td width=30%>{$lng.lbl_quantity}</td><td nowrap>{if $product.avail gt 0}{$product.avail}{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</td></tr> {/if} {if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{$product.weight} {$config.General.weight_symbol}</td></tr>{/if} {if $active_modules.Extra_Fields ne ""} {include file="modules/Extra_Fields/product.tpl"} {/if} {if $active_modules.Subscriptions ne "" and $subscription} {include file="modules/Subscriptions/subscription_info.tpl"} {else} <tr><td class=ProductPriceConverting>{$lng.lbl_price}:</td> <td> {if $product.price ne 0} <font class=ProductDetailsTitle>{include file="currency.tpl" value=$product.price}</font><font class=MarketPrice> {include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.price}</font>{if $config.Taxes.use_vat eq "Y" and $product.vat gt "0"}, {$lng.lbl_including_vat} {$product.vat}%{/if} {else} <input type=text size=7 name=price> {/if} </td> </tr> {/if} </table> <table border=0 width=100% cellpadding=0 cellspacing=0> <tr><td colspan=2> <font class=ProductDetailsTitle>{$lng.lbl_options}</font> </td></tr> <tr><td class=Line height="1" colspan=2>[img]{$ImagesDir}/spacer.gif[/img]</td></tr> <tr><td colspan=2></td></tr> {if $active_modules.Product_Options ne ""} { include file="modules/Product_Options/customer_options.tpl"} {/if} <tr><td height=25 width=30%>{$lng.lbl_quantity}{if $product.min_amount gt 1} <FONT class=ProductDetailsTitle>{$lng.txt_need_min_amount} {$product.min_amount} {$lng.lbl_items}</FONT>{/if}</td> <td> {if $config.General.unlimited_products eq "N" and ($product.avail le 0 or $product.avail lt $product.min_amount)} {$lng.txt_out_of_stock} {else} {if $config.General.unlimited_products eq "Y"} {math equation="x+1" assign="mq" x=$config.Appearance.max_select_quantity} {else} {math equation="x/y" x=$config.Appearance.max_select_quantity y=$product.min_amount assign="tmp"} {if $tmp<2} {assign var="minamount" value=$product.min_amount} {else} {assign var="minamount" value=0} {/if} {math equation="min(maxquantity+minamount, productquantity)+1" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail} {/if} {if $product.distribution eq ""} <select name=amount> {if $product.min_amount le 1} {assign var="start_quantity" value=1} {else} {assign var="start_quantity" value=$product.min_amount} {/if} {section name=quantity loop=$mq start=$start_quantity} <option value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</option> {/section} </select> {else} <font class=ProductDetailsTitle>1</font><input type=hidden name=amount value=1> {$lng.txt_product_downloadable} {/if} {/if} </td></tr> <tr><td colspan=2> <input type=hidden name=mode value=add> {include file="customer/main/product_prices.tpl"} {if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)} {if $js_enabled} {if $smarty.get.pconf ne ""} <INPUT type=hidden name="slot" value="{$smarty.get.slot}"> <INPUT type=hidden name="addproductid" value="{$product.productid}"> {include file="buttons/pconf_add_to_configuration.tpl" style="button"} {/if} {if $product.forsale ne "B"} {if $product.param00 eq Y} {include file="customer/main/call.tpl"} {else} {include file="buttons/add_to_cart.tpl" style="button"} {if $login ne "" and $active_modules.Wishlist ne ""} {include file="customer/add2wl.tpl"} {/if} {else} {$lng.txt_pconf_product_is_bundled} {/if} {else} {include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if} {/if} <input type=image src="{$ImagesDir}/null.gif" width=10 height=10 border=0 align=top> </td> </tr></table> </td> <td align=right valign=top width=60> {if $product.list_price gt 0 and $product.price lt $product.list_price}<table border=0 width=60><tr><td width=55 height=56 class="SaveMoneyLabel" background="{$ImagesDir}/save_money.gif" align=center valign=middle> {math equation="100-(price/lprice)*100" price=$product.price lprice=$product.list_price format="%d" assign=discount} { $discount }% </td></tr></table>{/if} </td> </tr> <input type=hidden name=productid value="{$product.productid}"> <input type=hidden name=cat value="{$smarty.get.cat|escape:"html"}"> <input type=hidden name=page value="{$smarty.get.page|escape:"html"}"> </form> </table> {/capture} {include file="dialog.tpl" title=$product.product content=$smarty.capture.dialog extra="width=100%"} {/if} {if $active_modules.Detailed_Product_Images ne ""} {include file="modules/Detailed_Product_Images/product_images.tpl" } {/if} {if $active_modules.Upselling_Products ne ""} {include file="modules/Upselling_Products/related_products.tpl" } {/if} {if $active_modules.Recommended_Products ne ""} {include file="modules/Recommended_Products/recommends.tpl" } {/if} {if $active_modules.Customer_Reviews ne ""} {include file="modules/Customer_Reviews/vote_reviews.tpl" } {/if}
__________________
X-cart versions 4.1.11, 4.1.9 & 4.1.8
Reply With Quote
  #4  
Old 11-19-2004, 05:39 AM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default fix...

Chris, I believe what you are trying to do is this:

{if $product.productid == 10 || $product.productid == 12 || $product.productid == 17}

{include file="customer/main/NEW_buy_now.tpl" product=$products[product]}

{else}

{include file="customer/main/buy_now.tpl" product=$products[product]}

{/if}

Notice that all I'm doing is depending on the productid in the database, showing a different buy_now.tpl - you can create a new one of those calling the correct button. You can either lookup the productid in the database for the products in question, or look in the url string when you are on that product and you will see what the productid is...the code I have above is saying if the productid equals any of those values, show the code below it...

I may not have the "inclue" for the buy_now button correct for your version of x-cart - check yours in 3.5.9 - but you get the idea - you just need to surround the button call with the code above. You can also do it with 2 separate {if} statements if the {else} screams at you for some reason...

Lemme know if this helps :0) and cheers...
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 02:43 PM.

   

 
X-Cart forums © 2001-2020