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)
-   -   common if/then modifications I make to x-cart... (https://forum.x-cart.com/showthread.php?t=8881)

qrichou 07-25-2008 09:22 AM

Re: common if/then modifications I make to x-cart...
 
Hi,

Does anyone know if you can use like with smarty?

We want to say {if $products[product].productcode like "C-"}do this{else}dothis{/if}

Thanks

carpeperdiem 07-25-2008 11:27 AM

Re: common if/then modifications I make to x-cart...
 
Quote:

Originally Posted by qrichou
Hi,

Does anyone know if you can use like with smarty?

We want to say {if $products[product].productcode like "C-"}do this{else}dothis{/if}

Thanks


Like?

Here are the smarty functions rules: http://www.smarty.net/manual/en/language.function.if.php

If you use numerical productID as your var, then you can easily constrain an if to give you the correct results. Why not use the numerical ID? Am I missing what you're trying to do here?

qrichou 07-29-2008 08:30 AM

Re: common if/then modifications I make to x-cart...
 
In "like" i mean like in SQL eg - SELECT * from orders where items like '%electronic%'

Basically we mark all products that are variants with a productcode that begins "C-" and i want to show a field based on this.

Hope that makes sense.

benhoffman 08-05-2008 07:48 PM

Re: common if/then modifications I make to x-cart...
 
Any idea how to use $cat variables on the Cart page? For example, you can use:

{if $cat eq "X"} SHOW THIS {/if}

on other pages, but it doesn't work on the cart page.

anela2003 08-17-2008 01:42 PM

Re: common if/then modifications I make to x-cart...
 
What if instead of {if=a}html1{else}html2{/if} you wanted something like this:
{if=a}html1{if=b}html2{else}html3{/if}?

ReadytoCover 10-06-2008 05:03 PM

Re: common if/then modifications I make to x-cart...
 
Quote:

Originally Posted by benhoffman
Any idea how to use $cat variables on the Cart page? For example, you can use:

{if $cat eq "X"} SHOW THIS {/if}

on other pages, but it doesn't work on the cart page.


Anyone have a response to this?

I have tried

{if $products[product].categoryid eq "3"} and
{if $products[product].catid eq "3"}

and neither work...I am trying to display a specific message in the cart if the customer has a product from that category in their cart.

Thanks!!!!!!

robertswww 10-08-2008 01:04 PM

Re: common if/then modifications I make to x-cart...
 
I use this on the product.tpl for categories and it works there... give it a try on your cart page:

{if $product.categoryid == 3}

Robert

ReadytoCover 10-09-2008 05:58 AM

Re: common if/then modifications I make to x-cart...
 
Thanks but unfortunately that doesn't work.

If anyone else has a suggestion feel free to pass it along. Thank you.

Jon 10-09-2008 12:10 PM

Re: common if/then modifications I make to x-cart...
 
You have to ensure you are using a variable in a section loop. For example:
Code:

{section name=prod_num loop=$products}
{$products[prod_num].product}: {$products[prod_num].categoryid}<br />
{/section}


Not sure if the categoryid is in the cart $products variable as I didn't test it.

Jon 10-09-2008 12:11 PM

Re: common if/then modifications I make to x-cart...
 
Quote:

Originally Posted by anela2003
What if instead of {if=a}html1{else}html2{/if} you wanted something like this:
{if=a}html1{if=b}html2{else}html3{/if}?


Code:

{if $x eq 'a'}html1{elseif $x eq 'b'}html2{else}html3{/if}


All times are GMT -8. The time now is 04:58 AM.

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