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)
-   -   HELP! ADD TO CART BUTTON ON PRODUCTS.TPL (https://forum.x-cart.com/showthread.php?t=818)

ciava 11-29-2002 05:55 AM

HELP! ADD TO CART BUTTON ON PRODUCTS.TPL
 
Hi

I by no means a programmer, ive been trying to add the add to cart button on the products.tpl, but keep on coming up with error.

I have tried implementing the following smarty.php code, but still gets error on page.

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="144">
<form name=orderform_{$product.productid} method=post action="cart.php?mode=add">
<tr bgcolor="666666">
<td height="1" colspan="5"></td>
</tr>
<tr bgcolor="cccccc">
<td height="14" colspan="5">{$products[product].product|escape}</font></td>
</tr>
<tr bgcolor="666666">
<td height="1" colspan="5"></td>
</tr>
<tr>
<td height="14" colspan="5"></td>
<tr>
<td width="86" height="12"><font class="product_fields_tittle">Efind no:</font></td>
<td width="277" height="12" align="left" class=product_fields_input>{$products[product].productcode}</td>
<td width="440" height="12"></td>
<td width="111" height="12" align="left"><font class="product_fields_tittle">Availability:</font></td>
<td width="217" height="12" align="left" class=product_fields_input>{$products[product].avail}</td>
</tr>
<tr>
<td width="86" height="12"><font class="product_fields_tittle">Manufacturer:</font></td>
<td width="277" height="12" class=product_fields_input align="left">{$products[product].param00}</td>
<td width="440" height="12"></td>
<td width="111" height="12" align="left"><font class="product_fields_tittle">Price ex VAT:</font></td>
<td width="217" height="12" align="left"><font class=TableCenterProductTitleRed>{include
file="currency.tpl" value=$products[product].price}</font></td>
</tr>
<tr>
<td width="86" height="15"><font class="product_fields_tittle">Mfr Sku no:</font></td>
<td width="277" height="15" align="left" class=product_fields_input>{$products[product].param02}</td>
<td width="440" height="15"></td>
<td width="111" height="15" align="left"><font class="product_fields_tittle">Price Inc VAT:</font></td>
<td width="217" height="15" align="left" class=TableCenterProductTitleBlk>{$products[product].param01}</td>
</tr>
<tr valign="middle" align="center">
<td height="1"> </td>
<td height="1"></td>
<td height="1"></td>
<td height="1" colspan="2"> </td>
</tr>
<tr valign="middle" align="center">
<td height="1" colspan="5">
<table width="70%" border="0" cellspacing="0" cellpadding="0" height="1">
<tr>
<td bgcolor="ff6600" ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="24"> </td>
<td height="24"></td>
<td height="24"></td>
<td height="24" colspan="2" valign="bottom"><a href="javascript:if (FormValidation()) document.orderform.submit()">{include
file="buttons/add_to_cart.tpl"}</a> </td>
</tr>
<tr align="right">
<td height="20" colspan="5">


</p>
</td>
</tr>
<tr>
<td height="9" colspan="5">
<input type=hidden name=mode value=add>
<div align="left">{if $active_modules.Subscriptions ne "" and $products[product].catalogprice}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else} {if $products[product].price ne 0} {if $products[product].discount
ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s>{math equation="(price/(100-discount))*100"
price=$products[product].price discount=$products[product].discount
format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font>

{/if} <font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl"
alter_currency_value=$products[product].price}</font>{if $products[product].discount
ne 0}, save {$products[product].discount}%{/if} {else} <font class=TableCenterProductTitleOrange>{$lng.lbl_ente r_your_price}</font>
{/if} {/if} </div>
</td>
</tr>
<tr bgcolor="cccccc">
<td height="1" colspan="5"></td>
</tr>
<tr>
<td height="10" colspan="5"></td>
</tr>

</form>
</table>
{/section}


Any help would be grateful.

Many thanks
anton

funkydunk 11-30-2002 10:33 AM

Just doing this myself.

Just add the following into the product.tpl template where you want it.

<form name=orderform_{%product.index%} method=post action="cart.php?mode=add">
<td align=left width=25%><a href="javascript: document.orderform_{%product.index%}.submit()">
{include file="buttons/add_to_cart.tpl"}</a>
<input type=hidden name=amount value=1>
<input type=hidden name=mode value=add>
<input type=hidden name=productid value="{$products[product].productid}">
<input type=hidden name=cat value="{$smarty.get.cat}">
<input type=hidden name=page value="{$smarty.get.page}">
</td>
</form>

ciava 12-02-2002 12:52 AM

Many thanks

I will get on with it...

once again many thanks.
Anton

nev 02-04-2003 11:10 AM

Interest in complete product.tpl
 
I would be extremly interest to see your final product.tpl especially to show the price as Exc and Inc Vat.

disneyana 02-04-2003 09:50 PM

I'm curious as to how many people are using this in their stores. I have implemented this in all of my stores, but have recently discovered the following problems:
1) The Add to Cart button still appears even if the item is Out of Stock. This happens when products are added to the cart, but the checkout has not been completed. For instance, if you have a product with 1 item available and 1 customer adds it to their cart, another customer can also add the item to their cart by clicking on the Add to Cart button. If they click on the product title or See Details link, the detailed product page will display Out of Stock. Has anyone figured out a way to only display the Add to Cart button ONLY when product is available to Add to Cart?
2) Another problem exists when the customer wants more than 1 of an item and does the following:
- clicks Add to Cart and is forwarded to the Your Shopping Cart page
- click the back button in their browser and click the Add to Cart button for the same product (the Add to Cart button is displayed even though the quantity is set to 1)

When they click the Add to Cart button, the cart gets totally screwed up!
- The Items display as 1 (even though the customer thinks they added 2 products)
- The Total is now listed at $ 0.00
- There are NO products displayed in the Items section of Your Shopping Cart
There are only 2 ways that I know of to get the cart back to a working state after this happens:
1) Admin increases the product quantity to more or equal to what was initially added to the cart
2) Customer adds another product to the cart which now shows:
- The Items display as 2 (even though the customer thinks they added 3 products)
- The Total is now listed at the price of the last item added to the cart
- The only product displayed in the Items section of Your Shopping Cart is the last item added
If the customer clicks on the Delete item, the cart really deletes the existing two (or 1??) items and then displays the last item that was added again. At this point the cart is returned back to it's normal state.

Have I lost anyone? All of you? If so, try it and you'll see. While this may seem like a rare and unusual occurance, it does happen. Just think how many times this may happen to customers who then get frusterated and end up never reporting it.

ciava 02-05-2003 01:11 AM

Hello New

you can find our final product(s).tpl at the following link.

http://www.savatrader.com/products/customer/home.php

with regards to the inc/ex vat the simplest way to show this is by adding a math equation on the price, as i initially added an extra field for the inc VAT price, but this caused me problems, when updating inventory by price, as it would change the ex but not inc.

hope this helps


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

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