X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   If <item X in basket> then (https://forum.x-cart.com/showthread.php?t=30674)

sho ryu ken 04-24-2007 09:57 AM

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

sho ryu ken 04-24-2007 01:19 PM

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?

sho ryu ken 04-24-2007 01:41 PM

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.

carpeperdiem 04-24-2007 01:47 PM

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?

sho ryu ken 04-24-2007 01:50 PM

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}


balinor 04-24-2007 04:18 PM

Re: If <item X in basket> then
 
Nice one :) Moving to Completed Custom Mods.

Serdar 04-27-2007 02:44 AM

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.

sho ryu ken 04-28-2007 12:04 AM

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.

maineiac 06-04-2007 11:35 AM

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!


All times are GMT -8. The time now is 05:44 AM.

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