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

Quick code snippet please :)

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-04-2004, 10:38 PM
 
idesign123 idesign123 is offline
 

Advanced Member
  
Join Date: Jan 2004
Posts: 58
 

Default 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
__________________
version 4.0.18 (+ several cool mods)
Reply With Quote
  #2  
Old 04-07-2004, 01:04 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

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
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 04-08-2004, 11:14 PM
 
idesign123 idesign123 is offline
 

Advanced Member
  
Join Date: Jan 2004
Posts: 58
 

Default

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

Thanks for the lead!

:Stacey
__________________
version 4.0.18 (+ several cool mods)
Reply With Quote
  #4  
Old 04-10-2004, 05:17 AM
  leed's Avatar 
leed leed is offline
 

Senior Member
  
Join Date: Nov 2002
Location: England (UK)
Posts: 128
 

Default 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
__________________
Why a mouse when it spins ......
X-Cart Gunslingers - For Hire!!
http://forum.x-cart.com/viewtopic.php?t=8615
Reply With Quote
  #5  
Old 01-04-2005, 07:38 PM
 
ecollier2012 ecollier2012 is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 85
 

Default 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}
Reply With Quote
  #6  
Old 01-05-2005, 03:31 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

try

Code:
{if $cat eq 20} blah blah {/if}
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #7  
Old 01-05-2005, 05:53 PM
 
ecollier2012 ecollier2012 is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 85
 

Default 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?
Reply With Quote
  #8  
Old 01-05-2005, 06:00 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

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
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #9  
Old 01-05-2005, 06:36 PM
 
ecollier2012 ecollier2012 is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 85
 

Default 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
Reply With Quote
  #10  
Old 01-05-2005, 07:15 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

{$products[num].categoryid}

something like that

you have to reference it from the section (loop) its in
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
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 08:06 PM.

   

 
X-Cart forums © 2001-2020