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

If <item X in basket> then

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-24-2007, 09:57 AM
 
sho ryu ken sho ryu ken is offline
 

Senior Member
  
Join Date: Nov 2005
Location: England
Posts: 150
 

Default If <item X in basket> then

I wonder if there a way to run an {if} check to see if a specific item is in the basket? some sort of smarty check or something?

I would be checking it at the 'cart' stage.

e.g.

{if <item X is in basket> } EXECUTE THIS {/if}

thanks
Reply With Quote
  #2  
Old 04-24-2007, 01:19 PM
 
sho ryu ken sho ryu ken is offline
 

Senior Member
  
Join Date: Nov 2005
Location: England
Posts: 150
 

Default Re: If <item X in basket> then

ok, so I have figured half of it out.

{section name=product loop=$products}
{if $products[product].productid eq "17137"}

Thank you. Gift wrapping has now been added to your order.<br />

{/if}
{/section}




BUT.. I also want to run something like:



{if $products[product].productid NE "17137"}
If you would like to add gift wrapping click here blah blah etc.
{/if}

But if I do this in a 'section' then it executes the code once for every single in the basket . So if I have 4 items in the basket it will execute that code 4 times. Any wayto make it only execute once?
Reply With Quote
  #3  
Old 04-24-2007, 01:41 PM
 
sho ryu ken sho ryu ken is offline
 

Senior Member
  
Join Date: Nov 2005
Location: England
Posts: 150
 

Default Re: If <item X in basket> then

OK,looks like im talking to myself but I did it using smarty variables and it works absolutely sweet. To those who are looking for a giftwrapping mod check out what i've done at www.watchshopuk.com (add something to basket then try adding and removing gift wrapping).. I am well pleased with it.
Reply With Quote
  #4  
Old 04-24-2007, 01:47 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: If <item X in basket> then

very nice!

May I suggest, instead of the text, "Add gift wrapping to this order" -- this should be an image -- it gets lost in all the text. A "gift box" type image with "Gift Wrap? Click Here..." would take the clutter out of the lower part of the page.

Just an idea.

How did you get the code to only execute once?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #5  
Old 04-24-2007, 01:50 PM
 
sho ryu ken sho ryu ken is offline
 

Senior Member
  
Join Date: Nov 2005
Location: England
Posts: 150
 

Default Re: If <item X in basket> then

thanks for the suggestion.. I did it by assigning a variable called "giftwrapped" a value of either 1 or 0 depending on if the gift wrapping is in the cart.

here is the complete code:


Code:
<strong>Gift wrapping ё1.95</strong> <br /> {section name=product loop=$products } {assign var="giftwrapped" value=0} {if $products[product].productid eq "17137"} {assign var="giftwrapped" value=1} <strong>Gift wrapping has now been added to your order.</strong><br /> <br /> {/if} {/section} {if ($giftwrapped == 0)} If you would like us to gift wrap this item before posting it, please click the following link. You only need to add this once and we will gift wrap all of your items individually for just ё1.95 <br /> <a href="cart.php?mode=add&productid=17137&amount=1"><font color="#0033FF"><u>Add gift wrapping to this order</u></font></a> <br /><br /> <small>Note: When gift wrapping is selected we will not include an invoice in the package so you can send it to a friend.</small><br /> <small>Note: Gift wrapping may vary from the picture</small> <br /> {/if}
Reply With Quote

The following user thanks sho ryu ken for this useful post:
maineiac (04-21-2012)
  #6  
Old 04-24-2007, 04:18 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If <item X in basket> then

Nice one Moving to Completed Custom Mods.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #7  
Old 04-27-2007, 02:44 AM
 
Serdar Serdar is offline
 

Advanced Member
  
Join Date: Nov 2006
Posts: 36
 

Default Re: If <item X in basket> then

I would like to make a comparison kind of like this in a php file. How can I get the productid to do so?
Thanks.
__________________
X-Cart Gold Version 4.1.3
Reply With Quote
  #8  
Old 04-28-2007, 12:04 AM
 
sho ryu ken sho ryu ken is offline
 

Senior Member
  
Join Date: Nov 2005
Location: England
Posts: 150
 

Default Re: If <item X in basket> then

Serdar, someone else may have more chance of answering you as I dont know what you mean without some sort of clarification or example.

on a side note, 4 gift wrapping orders in 2 days. Could work out to an extra few hundred quid a year. Buys a couple of extra pints. I'm going to write this up as a full mod I think, including a gift message facility. Im thinking I may as well give something back to the x-cart community after 100 odd posts of asking questions.
Reply With Quote
  #9  
Old 06-04-2007, 11:35 AM
 
maineiac maineiac is offline
 

Member
  
Join Date: Jun 2005
Location: USA
Posts: 29
 

Default Re: If <item X in basket> then

Thank You sho ryu ken for this excellent mod!! This has been a long time coming for the gift wrap option at checkout...

Looking forward to the gift message facility!
__________________
maineiac

x-cart gold v4.0.18
x-cart gold v4.1.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:56 PM.

   

 
X-Cart forums © 2001-2020