X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   "Buy Now" button without the "Quantity" (https://forum.x-cart.com/showthread.php?t=12466)

artinion 02-27-2005 11:58 PM

"Buy Now" button without the "Quantity"
 
I would like to remove the "Quantity" drop down list. The purpose is to have users click on the "Buy Now" button with the default value of "1" to pass on to the shopping cart. How can that be done?

Searched for posts on this, haven't found any answers.

Please help. :(

Art

Jon 02-28-2005 12:03 AM

You can edit out the quantity areas of your templates and instead use:

<input type="hidden" name="amount" value="1">

artinion 02-28-2005 12:26 AM

RE: "Buy Now" button without the "Quantity&qu
 
I got it. Thanks. This is the code from "customer/main/buy_now.tpl".

Art :)

Code:


{* $Id: buy_now.tpl,v 1.8.2.2 2004/12/09 12:42:16 max Exp $ *}
{if $js_enabled}
<table border=0 width=100% cellpadding=0 cellspacing=0>
  {if ($active_modules.Product_Options ne "" and $product.product_options) or
  $product.price eq 0}
  <tr>
    <td height=25> <a href="product.php?productid={$product.productid}&cat={$cat}&page={$smarty.get.page|escape:"html"}">{include
      file="buttons/buy_now.tpl" style="button"}</a> </td>
    <td></td>
    <td></td>
  </tr>
  {else}
  <FORM name="orderform_{$product.productid}_{$product.add_date}" method=post action="cart.php?mode=add">
    <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"}">
    <tr> {if $product.distribution eq ""}
      <td height=25 width=5% nowrap>{$lng.lbl_quantity} </td>
      <td width=15%> {if $config.General.unlimited_products ne "Y" 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=1} {/if} {math equation="min(maxquantity+minamount,
        productquantity+1)" assign="mq" maxquantity=$config.Appearance.max_select_quantity
        minamount=$minamount productquantity=$product.avail} {/if}
                <input type=hidden name="amount" value="1">










        {/if} </td>
      {else}

      {/if}
      <td> </td>
    </tr>
    <tr>
      <td> <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} <a href="javascript: document.orderform_{$product.productid}_{$product.add_date}.submit()">{include
        file="buttons/buy_now.tpl" style="button"}</a>  {if $login
        ne "" and $active_modules.Wishlist ne ""} <a href="javascript:document.orderform_{$product.productid}_{$product.add_date}.mode.value='add2wl'; document.orderform_{$product.productid}_{$product.add_date}.submit()">{include
        file="buttons/add_to_wishlist.tpl" style="button"}</a> {/if} {else} {include
        file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if}
  </FORM>
  {if $product.min_amount gt 1} </td> </tr>
  <tr>
    <td><FONT class=ProductDetailsTitle>{$lng.txt_need_min_amount} {$product.min_amount}
      {$lng.lbl_items}</FONT> </td>
  </tr>
  {/if} {/if}
</table>
{/if}



Jon 02-28-2005 12:32 AM

If you paste your entire ORIGINAL template I'll paste you back a version to use.

artinion 02-28-2005 01:38 AM

RE: "Buy Now" button without the "Quantity&qu
 
Okay, here it is "buy_now.tpl:

Code:


{* $Id: buy_now.tpl,v 1.8.2.2 2004/12/09 12:42:16 max Exp $ *}
{if $js_enabled}
<table border=0 width=100% cellpadding=0 cellspacing=0>
{if ($active_modules.Product_Options ne "" and $product.product_options) or $product.price eq 0}
<tr>
<td height=25>
{include file="buttons/buy_now.tpl" style="button"}
</td>
</tr>
{else}
<FORM name="orderform_{$product.productid}_{$product.add_date}" method=post action="cart.php?mode=add">
<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"}">
<tr>
{if $product.distribution eq ""}
<td height=25 width=15% nowrap>{$lng.lbl_quantity}
</td>
<td width=20%>
{if $config.General.unlimited_products ne "Y" 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=1}
{/if}
{math equation="min(maxquantity+minamount, productquantity+1)" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail}
{/if}
<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>
{/if}
</td>
{else}

<input type=hidden name="amount" value="1">
{/if}
<td height=25>
<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}
{include file="buttons/buy_now.tpl" style="button"}

{if $login ne "" and $active_modules.Wishlist ne ""}
{include file="buttons/add_to_wishlist.tpl" style="button"}
{/if}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart}
{/if}
{/if}
</td>
</tr>
</FORM>
{if $product.min_amount gt 1}
<tr>
<td colspan=3><FONT class=ProductDetailsTitle>{$lng.txt_need_min_amount} {$product.min_amount} {$lng.lbl_items}</FONT>
</td>
</tr>
{/if}
{/if}
</table>
{/if}


Jon 02-28-2005 08:43 AM

Try this:

Code:

{* $Id: buy_now.tpl,v 1.8.2.2 2004/12/09 12:42:16 max Exp $ *}
{if $js_enabled}
<table border=0 width=100% cellpadding=0 cellspacing=0>
{if ($active_modules.Product_Options ne "" and $product.product_options) or $product.price eq 0}
<tr>
<td height=25>
{include file="buttons/buy_now.tpl" style="button"}
</td>
</tr>
{else}
<FORM name="orderform_{$product.productid}_{$product.add_date}" method=post action="cart.php?mode=add">
<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"}">
<input type=hidden name="amount" value="1">
<tr>
<td height=25>
<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}
{include file="buttons/buy_now.tpl" style="button"}
 
{if $login ne "" and $active_modules.Wishlist ne ""}
{include file="buttons/add_to_wishlist.tpl" style="button"}
{/if}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart}
{/if}
{/if}
</td>
</tr>
</FORM> 
{/if}
</table>
{/if}


artinion 02-28-2005 04:30 PM

RE: "Buy Now" button without the "Quantity&qu
 
Thank you. That really helped.

Art

kirsten 03-01-2005 05:32 AM

I would also like to get rid of the drop down quantity field but my code is different than the above, I tried to use the code jon gave but it did not work on x cart version, because when you clicked on buy now it directed you back to the xcart entry page ?
Here is my /customer/main/buy_now.tpl , can anyone please tell me what to take out to get rid of the drop down quantity and have a default of one item placed into the cart

Quote:

{* $Id: buy_now.tpl,v 1.15.2.7 2004/12/01 15:15:49 mclap Exp $ *}
<TABLE border="0" width="100%" cellpadding="0" cellspacing="0" >
{if $product.price eq 0}
<TR>
<TD height="25">
{assign var="button_href" value=$smarty.get.page|escape:"html"}
{include file="buttons/buy_now.tpl" style="button" href="product.php?productid=`$product.productid`&c at=`$cat`&page=`$button_href`"}
</TD>
</TR>
{else}
<FORM name="orderform_{$product.productid}_{$product.add _date}" method="post" action="{if $product.is_product_options eq 'Y' && $config.Appearance.buynow_with_options_enabled eq 'Y'}product.php?productid={$product.productid}{els e}cart.php?mode=add{/if}">
<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"}">
{if $product.is_product_options ne 'Y' || $config.Appearance.buynow_with_options_enabled ne 'Y'}
<TR>
{if $product.distribution eq ""}
<TD height="25" width="15%" nowrap>{$lng.lbl_quantity}
</TD>
<TD width="20%" nowrap>
{if $config.General.unlimited_products ne "Y" 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=1}
{/if}
{math equation="min(maxquantity+minamount, productquantity+1)" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail}
{/if}
<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>
{/if}
</TD>
{else}
<INPUT type="hidden" name="amount" value="1">
{/if}
<TD width="100%" height="25" valign="middle">
<INPUT type="hidden" name="mode" value="add">
{include file="customer/main/product_prices.tpl"}
</TD>
</TR>
{/if}
<TR>
<TD colspan="3">
{if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)}


<TABLE border="0" cellpadding="0" cellspacing="0"><TR>
{if $js_enabled}
{if $special_offers_add_to_cart eq 'Y'}
<TD>{include file="buttons/add_to_cart.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product. add_date`.submit();"}</TD>
{else}
<TD>{include file="buttons/buy_now.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product. add_date`.submit();"}</TD>
{/if}
{if $login ne "" and $active_modules.Wishlist ne "" and $special_offers_add_to_cart eq ""}
{if $product.is_product_options ne 'Y' || $config.Appearance.buynow_with_options_enabled ne 'Y'}
<TD></TD>
<TD>{include file="buttons/add_to_wishlist.tpl" style="button" href="javascript:document.orderform_`$product.prod uctid`_`$product.add_date`.mode.value='add2wl'; document.orderform_`$product.productid`_`$product. add_date`.submit()"}</TD>
{/if}
{/if}
{else}
<TD>{include file="submit_wo_js.tpl" value=$lng.lbl_buy_now}</TD>
{/if}
</TR></TABLE>
{/if}
</TD>
</TR>
</FORM>
{if $product.min_amount gt 1}
<TR>
<TD colspan="3"><FONT class="ProductDetailsTitle">{$lng.txt_need_min_amo unt} {$product.min_amount} {$lng.lbl_items}</FONT>
</TD>
</TR>
{/if}
{/if}
</TABLE>



Thanx
Kirsten

Jon 03-01-2005 01:20 PM

Hi Kirstin, I'm still awaiting your purchase of ezCheckout/ezUpsell ;)

Try this code. Be sure to back first as it's hard for me without testing the code.

Code:

{* $Id: buy_now.tpl,v 1.15.2.7 2004/12/01 15:15:49 mclap Exp $ *}
<TABLE border="0" width="100%" cellpadding="0" cellspacing="0" >
{if $product.price eq 0}
<TR>
<TD height="25">
{assign var="button_href" value=$smarty.get.page|escape:"html"}
{include file="buttons/buy_now.tpl" style="button" href="product.php?productid=`$product.productid`&cat=`$cat`&page=`$button_href`"}
</TD>
</TR>
{else}
<FORM name="orderform_{$product.productid}_{$product.add_date}" method="post" action="{if $product.is_product_options eq 'Y' && $config.Appearance.buynow_with_options_enabled eq 'Y'}product.php?productid={$product.productid}{else}cart.php?mode=add{/if}">
<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"}">
{if $product.is_product_options ne 'Y' || $config.Appearance.buynow_with_options_enabled ne 'Y'}
<TR>

<INPUT type="hidden" name="amount" value="1">
 
<TD width="100%" height="25" valign="middle">
<INPUT type="hidden" name="mode" value="add">
{include file="customer/main/product_prices.tpl"}
</TD>
</TR>
{/if}
<TR>
<TD>
{if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)}

 
<TABLE border="0" cellpadding="0" cellspacing="0"><TR>
{if $js_enabled}
{if $special_offers_add_to_cart eq 'Y'}
<TD>{include file="buttons/add_to_cart.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product.add_date`.submit();"}</TD>
{else}
<TD>{include file="buttons/buy_now.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product.add_date`.submit();"}</TD>
{/if}
{if $login ne "" and $active_modules.Wishlist ne "" and $special_offers_add_to_cart eq ""}
{if $product.is_product_options ne 'Y' || $config.Appearance.buynow_with_options_enabled ne 'Y'}
<TD></TD>
<TD>{include file="buttons/add_to_wishlist.tpl" style="button" href="javascript:document.orderform_`$product.productid`_`$product.add_date`.mode.value='add2wl'; document.orderform_`$product.productid`_`$product.add_date`.submit()"}</TD>
{/if}
{/if}
{else}
<TD>{include file="submit_wo_js.tpl" value=$lng.lbl_buy_now}</TD>
{/if}
</TR></TABLE>
{/if}
</TD>
</TR>
</FORM>
{if $product.min_amount gt 1}
<TR>
<TD><FONT class="ProductDetailsTitle">{$lng.txt_need_min_amount} {$product.min_amount} {$lng.lbl_items}</FONT>
</TD>
</TR>
{/if}
{/if}
</TABLE>


kirsten 03-01-2005 01:45 PM

Thanx Jon that worked!!!

Just one small thing there is now a large break where the quantity drop down box used to be and the buy now button is not centered

How can i adjust this??


www.silverimports.com.au/shop/home.php


Thanx kirsten

Ps I will be contacting you regarding the ezupsell and ezzcheckout very soon, I just want to get all the small changes done here first


All times are GMT -8. The time now is 05:04 PM.

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