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)
-   -   add to cart link? (https://forum.x-cart.com/showthread.php?t=9569)

Emerson 09-27-2004 06:20 AM

add to cart link?
 
Do you guys know how I can add an add to cart text link on the products.tpl file?

Thanks ;)

Jon 09-27-2004 07:12 AM

Version :D ?

Emerson 09-27-2004 07:14 AM

DOH!
Sorry Jon :lol:
4.0.4

Jon 09-27-2004 07:26 AM

4.0 doesn't have an add to cart there ? 8O

I pulled some key code from the product.tpl that you can try adding to the products.tpl

No idea if this will work but backup and give it a try :)

Code:


{* MUST SHOW FORM POST (Note the form name is modified for each product)*}
<FORM name="orderform-{$product.productid}" method="post" action="cart.php?mode=add" OnSubmit="javascript: return FormValidation();">

{* MUST SHOW HIDDEN FIELDS *}
<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"}">

{* To show subscription information *}
{if $active_modules.Subscriptions ne "" and $subscription}
{include file="modules/Subscriptions/subscription_info.tpl"}
{/if}

{* To show product options *}
{if $active_modules.Product_Options ne ""}
{ include file="modules/Product_Options/customer_options.tpl"}
{/if}

{* To show amount text box*}
{if $product.distribution eq ""}
<input type="text" name="amount">
{/if}

{* Submit Button *}
{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/button.tpl" button_title=$lng.lbl_pconf_add_to_configuration style="button" href="javascript:if(FormValidation()) `$ldelim`document.orderform.productid.value='`$smarty.get.pconf`';document.orderform.action='pconf.php';document.orderform.submit()`$rdelim`"}
{/if}
{if $product.forsale ne "B"}
{include file="buttons/add_to_cart.tpl" style="button" href="javascript:if (FormValidation()) document.orderform.submit()"}
{else}
{$lng.txt_pconf_product_is_bundled}
{/if}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart}
{/if}

{* MUST SHOW FORM END *}
</FORM>


Emerson 09-27-2004 07:41 AM

Nope, that didn't do it :(

Jon 09-27-2004 07:50 AM

How did u implement it?

Emerson 09-27-2004 07:53 AM

I copied the code above into the products.tpl file.
Tryed a couple of different things but no matter what I do I get a JS error)object expected) when I click the button.

Emerson 09-27-2004 08:12 AM

Here it is:
Code:

Add to Cart

This will add the product to the cart from the products.tpl file.

Now if I could figure out how to get the extra fields to display on the products.tpl my store would be finished :)

Jon 09-27-2004 09:17 AM

Pretty sure you need a form field in order to do product options, amounts, etc. I have it functioning well on my store with the 3.5.x version.

You can't just copy the code I provided exactly, you have to take those components and implement them skillfully so that they appear around each product.

If you'd like some assistance and have MSN Messenger you can PM me your MSN email :)

Emerson 09-27-2004 09:38 AM

Hi Jon,
I got the link to work with the code I posted above.

Thanks ;)


All times are GMT -8. The time now is 11:37 PM.

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