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)
-   -   Quick code snippet please :) (https://forum.x-cart.com/showthread.php?t=7011)

idesign123 04-04-2004 10:38 PM

Quick code snippet please :)
 
I need to put a line of text on the first checkout page, but ONLY if the customer has a certain product in their cart.
Would someone please give me a quick code snippet (I could take it from there)?

VERY ROUGH EXAMPLE:
{if product number 10 is in this cart}
Show this Text
{else}

{/if}

Thanks!
:Stacey

B00MER 04-07-2004 01:04 AM

Code:

{section name=cartloop loop=$cart}
{if $cart[cartloop].productid eq "10"}
Text shown
{else}
...
{/if}
{/section}


:!: NOTE: Not tested so let me know if it bombs ;)

idesign123 04-08-2004 11:14 PM

Didn't work right off, but it does give me a starting point :)

Thanks for the lead!

:Stacey

leed 04-10-2004 05:17 AM

Code snippet
 
Depends a lot on what mode you're using (standard checkout or anonymous checkout).

To save changing more than 1 section of code, a good place to put this code is in cart_details.tpl (skin1/customer/main/cart_details.tpl}.

Look for the section of code like this

Code:

{section name=prod_num loop=$products}
<tr>
<td class=ProductPriceSmall>{if $config.Appearance.allow_update_quantity_in_cart eq "N" or ($active_modules.Egoods and $products[prod_num].distribution) or ($active_modules.Subscriptions and $products[prod_num].sub_plan)}{$products[prod_num].amount}{else}<input type=text size=3 name="productindexes[{$products[prod_num].cartid}]" value="{$products[prod_num].amount}">{/if}</td>
<td>{$products[prod_num].productcode}</td>
<td>{$products[prod_num].product|truncate:30:"...":true}</td>
<td class=ProductPriceSmall align=right>{include file="currency.tpl" value=$products[prod_num].price}</td>
<td class=ProductPriceSmall align=right>{include file="currency.tpl" value=$products[prod_num].total}</td>
</tr>
{/section}


Just before the {/section}

add these lines

Code:

{if $products[prod_num].productid eq "10" and $checkout_step eq "1" }
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when product 10 is selected</font></p></td></tr>
{/if}


Depeding on how you've based your products, you may have to change productid to productcode.
You can change the message appearance to whatver you want with CSS or font ..oh!, can also change the message!



LeeD

ecollier2012 01-04-2005 07:38 PM

Code Snippet Help
 
Is it possible to do the same thing based on category or subcategory id instead of product id.

I have tried just about every possible option based on the example posted earlier and can't seem to get it to work...it only works if use product ID.

Here is what I have tried thus far

Code:


{if $subcategories[cat_num].category eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 60 is selected</font></p></td></tr>
{/if}
{if $subcategories[cat_num].category eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 82 is selected</font></p></td></tr>
{/if}
{if $subcategories[cat_num].category eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 95 is selected</font></p></td></tr>
{/if}

{if $subcategories[cat_num].categoryid eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 60 is selected</font></p></td></tr>
{/if}
{if $subcategories[cat_num].categoryid eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 82 is selected</font></p></td></tr>
{/if}
{if $subcategories[cat_num].categoryid eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat 95 is selected</font></p></td></tr>
{/if}

{if $categories[cat_num].categoryid eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 60 is selected</font></p></td></tr>
{/if}
{if $categories[cat_num].categoryid eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 82 is selected</font></p></td></tr>
{/if}
{if $categories[cat_num].categoryid eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 95 is selected</font></p></td></tr>
{/if}

{if $categories[cat_num].category eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 60 is selected</font></p></td></tr>
{/if}
{if $categories[cat_num].category eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 82 is selected</font></p></td></tr>
{/if}
{if $categories[cat_num].category eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 95 is selected</font></p></td></tr>
{/if}

{if $categories eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 60 is selected</font></p></td></tr>
{/if}
{if $categories eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 82 is selected</font></p></td></tr>
{/if}
{if $categories eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 95 is selected</font></p></td></tr>
{/if}

{if $category eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 60 is selected</font></p></td></tr>
{/if}
{if $category eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 82 is selected</font></p></td></tr>
{/if}
{if $category eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 95 is selected</font></p></td></tr>
{/if}

{if $categoryid eq "60"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 60 is selected</font></p></td></tr>
{/if}
{if $categoryi eq "82"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 82 is selected</font></p></td></tr>
{/if}
{if $categoryid eq "95"}
<tr><td align="center" colspan="{$colspan}">

<font color="red">This only appears when cat2 95 is selected</font></p></td></tr>
{/if}


shan 01-05-2005 03:31 AM

try

Code:

{if $cat eq 20}
blah blah
{/if}


ecollier2012 01-05-2005 05:53 PM

Quick code snipped
 
Did not work either. I am a newbie so please excuse my ignorance..

Is it possible that the category varibles are not avail in the cart_details.tpl?

shan 01-05-2005 06:00 PM

read this post to see how to see what variables are available on each page

http://forum.x-cart.com/viewtopic.php?t=14481&highlight=debug

ecollier2012 01-05-2005 06:36 PM

Code snippet
 
Thanks Shan,

Im running the debug console now...

I noticed earlier that if I looked for a a cat id=0 it would work...

Running debug - and reviewing the varibles - I found one that may work ( categoryid => 95) ...but Im not sure how to check for it...


$products
Array (1)
0 => Array (63)
cartid => 1
productid => 223
amount => 1
options => Array (0)
free_price => 0.00
productcode => Vendo 63 Instant Download Vers
product => Vendo 63 Service Manual Instant Downl...
distribution => /downloads/Vendo-63-90-126-SM.pdf
vat => 0
product_type => N
price => 10.95
options_surcharge => 0.00
product_options => empty
discount => 0
coupon_discount => 0
discounted_price => 10.95
subtotal => 10.95
provider => master
brand => empty
model => empty
weight => 0.00
categoryid => 95

shan 01-05-2005 07:15 PM

{$products[num].categoryid}

something like that

you have to reference it from the section (loop) its in


All times are GMT -8. The time now is 08:38 AM.

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