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)

instinctual 11-30-2005 12:26 PM

Dan - can't you accomplish that by simply specifying that certain categories are available to only certain membership levels in the backend? In that manner, if you're registered as a membership level, you'll see those categories and products, and if you're not, you'll only see products in categories that are specified for "all".

Lemme know - not exactly clear on what yer doin' ;)

danbass 12-01-2005 06:48 AM

Ideally what I would like is when people first come to the site and are not registered or logged in to see the Retail group items. After they log in then they would see either the retail group or wholesale group depending on their membership level. All I see available right now for unregistered members is the "All" group. Unless I am missing this setting somewhere. The problem with the "All" group is that it appears to the Wholesale group when they are logged in and I don't want the items in that group available when Wholesale group members are shopping. Is this possible?
Thanks

Circle3 01-11-2006 09:11 PM

Ok, this has been a helpful thread and it demonstrates some good examples in using IF statements in smarty.

What I don't understand is how to find out about all of the variables that I have at my disposal with smarty?

Is there a list somewhere?

Anonymous999 07-07-2006 01:27 AM

Quote:

Originally Posted by Circle3
Ok, this has been a helpful thread and it demonstrates some good examples in using IF statements in smarty.

What I don't understand is how to find out about all of the variables that I have at my disposal with smarty?

Is there a list somewhere?


A list i found interesting

http://www.php-editors.com/smarty_manual/

ecommerce 08-12-2006 01:59 PM

In the customer proile page/registration page,


Have the label and field box for COUNTY invisble (not part of the form), but

{IF } billing STATE is CALIFORNIA,

then

show the label and field box. (they appear like magic).

I have tried editing with if statements the register_billing.tpl

county.tpl

and state.tpl


I've been unsuccessful.

I have a feeling it can be done.


[/img]

ecommerce 08-15-2006 07:17 PM

bump

HWT 04-10-2007 09:03 AM

Re: common if/then modifications I make to x-cart...
 
I have a quick question in regards to #8

Quote:

Originally Posted by instinctual
8. Similar to the above - what about if you want to show something specific to the category you're on? Well, similar situation:


Code:
{if $cat eq "9"}show this{/if}



Can this be set to a range of categories instead of one specific category?

example:

I want categories 250 - 290 to use a different subcategories.tpl

in customer/home_main.tpl I have:

Code:

{elseif $cat eq "250" or $cat eq "251" or $cat eq "252" or $cat eq "253" or $cat eq "254" or $cat eq "255" etc...  }
{include file="customer/main/subcategories_2.tpl" cat=$cat}


is there any way to shorten that {elseif . . .} up to include the whole range?

TIA

BizzyB 04-11-2007 05:21 AM

Re: common if/then modifications I make to x-cart...
 
I don't know smarty at all but.....

{elseif $cat > "249" and $cat < "291"}

would may do want you want rather than {elseif $cat eq "250" or $cat eq "251" or $cat eq "252" or $cat eq "253" etc etc etc

Where '>' represents 'gt' (greater than) and '<' represents 'lt' or (less than). Whatever is the correct syntax for smarty.

Just a thought.

HWT 04-11-2007 05:37 AM

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

Originally Posted by BizzyB
{elseif $cat > "249" and $cat < "291"}


Worked perfectly. Thank you for the great explanation. That really helps with my thought process that I can apply in other circumstances. Lack of experience with some of the simpler ideas is the problem with being a self taught (or forum taught :wink: ) smarty code editor.

BizzyB 04-11-2007 06:30 PM

Re: common if/then modifications I make to x-cart...
 
Your very welcome.

As I said I don't know smarty, but if that code worked for you it is is worth bearing in mind that if it is part of a more complex if/then or elseif/then coding it is always a good idea to isolate that type of expression by enclosing it in brackets.

By that I mean your argument would look more like:-
{elseif ($cat > "249" and $cat < "291") [more code here]}

For example :-
{elseif ($cat > "249" and $cat < "291") or ($cat >= "300" and $cat <= "340") }

Cheers

tony galfano 05-15-2007 12:54 PM

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

Great stuff here! I'm a newbie with xcart and smarty and am having some problems hiding the pricing and buying abilty from all but one membership group. I have a category with 42 subcategories with 12 products in each that are only for sale to Wholesale members. However, the client wants all visitors to see these products and only make them available for sale to wholesale members. So, he wants to hide the prices from regular visitors.

I was reall encouraged by this post and am trying to use if/then logic based on one of the examples above to accomplish this. Seems to me that the products _t.tpl and the products.tpl need to be modified?

Here's what I tried in the products_t.tpl:

{if $user_membership eq "Wholesale"}
<font class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].taxed_price}</font><br /><font class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</font>{if $discount gt 0}{if $config.General.alter_currency_symbol ne ""},{/if} {$lng.lbl_save_price} {$discount}%{/if}
{if $products[product].taxes}<br />{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes}{/if}
{if $active_modules.Special_Offers ne "" and $products[product].use_special_price ne ""}
{include file="modules/Special_Offers/customer/product_special_price.tpl" product=$products[product]}
{/if}
{else}
<font class="ProductPrice">{$lng.lbl_enter_your_price}</font>
{/if}
{/if}
{else}
Wholesale Only
{/if}

I was trying to get the price to show up only if the user is logged in as a Wholesale member, and if not, to show "Wholesale Only". But this just causes the page to display code where images should be and blows the page formatting apart.

The solution can't be far from this and I'm continueing to hack away. Any help is greatly appreciated.

Thanks in advance,

Tony

balinor 05-15-2007 01:03 PM

Re: common if/then modifications I make to x-cart...
 
Tony, try this thread:

http://forum.x-cart.com/showthread.php?t=30979

tony galfano 05-15-2007 01:37 PM

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

Wow, thanks for the quick response! I tried that and couldn't get it to work either, though it did fix the page destruction issues. But what happens is that the prices don't show up for anyone in all of the categories.

I just want to have the products in the one category to have prices show up for only wholesale members. I still hacking away and am trying variations of the if/then statements and the placement of them in the code to see if I can get this to work.

Thanks for you help and if you can think of anything else fire away!

Thanks,

Tony

tony galfano 05-15-2007 10:32 PM

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

Thanks for the great help. I've got this one licked now. I used a combination of balinar's code and on of the examples earlier on in this thread. My mistake was that I was not addressing the subcategory, but the root category. The code on the product.tpl only relates to the subcaetgory if the product is not in a root category.

Once I fixed it your code worked like a charm!

Thanks,

Tony

smek 07-11-2007 07:24 AM

Re: common if/then modifications I make to x-cart...
 
2 Attachment(s)
Thanks everyone, this thread has saved me countless hours! However, I am having a small cosmetic problem...I setup a long list of "if statements" so that each category would show a specific flash banner. This works well, however, since it is several lines of code, the first IFSTATEMENT goes into effect it is fine because it is the first line. BUT if lets say the last piece of code goes into effect there is a big space above it where the other inactive coding was. Its best to look at the pictures: Here are some attached examples.

EXAMPLE:
Code:

{if $cat eq "1"} FLASH BANNER FOR FRAGRANCES WILL GO HERE {/if}

I've tried adding the code to a sepearte TPL file but that woudlnt parse correctly.
There must be an easy not to have the inactive code take up space....heres a brain buster for you experts but im sure this has been asked before....although i coudl not find anyting about this on this forum.


Thanks in ADVANCE!

smek 07-12-2007 09:09 AM

Re: common if/then modifications I make to x-cart...
 
nevermind it wasnt parsing correctly because of a typo...

the spaces can be seen in FIREFOX but dont exist in IE...any ideas?

phoenixrider 08-10-2007 07:40 AM

Re: common if/then modifications I make to x-cart...
 
smek - could you elaborate a bit more on how this works, or perhaps show some example code? This is what I am wanting to do as well. I tried it as a test on my site with what you had shown, didn't work.

Edit - get it. I had the wrong cat id# Cool.

smek 08-10-2007 08:18 AM

Re: common if/then modifications I make to x-cart...
 
i put all the if statements into a sepearate TPL file and call it from the home.tpl file....
but it still shows a space in firefox where the "unused code" is..perfect in IE though.

typologist 12-31-2007 10:37 PM

Re: common if/then modifications I make to x-cart...
 
I wanted to show something ONLY in the product.tpl pages and this code worked:
{if $product.productid ne "" }hello{/if}

davej2k 02-02-2008 03:26 AM

Re: common if/then modifications I make to x-cart...
 
Hi,
I want to add an extra line at the checkout summary page depending upon the value of a field called 'prodlocation'
The code I've insterted is:
Quote:

{if $products[prod_num].prodlocation eq "Dave"} show this {/if}

But the message isn't displayed.

If I enter:
{if $products[prod_num].prodlocation eq ""} show this {/if}

The message is shown which is strange as the value of prodlocation is Dave.

Any ideas?

typologist 02-11-2008 07:20 AM

Re: common if/then modifications I make to x-cart...
 
Please, i know this should be easy, but help! I want to show an image ONLY if customer is in SEARCH.PHP

{if $smarty.get.section eq "search.php"}SHOW THIS {/if}

Thanks!!

balinor 02-11-2008 07:23 AM

Re: common if/then modifications I make to x-cart...
 
{if $main eq "search"}

Italian Glassman 03-12-2008 09:21 AM

Re: common if/then modifications I make to x-cart...
 
What about an if/then function for the welcome page?
I want to have a JS code but only for the main page. Can anyone help me?

balinor 03-12-2008 09:22 AM

Re: common if/then modifications I make to x-cart...
 
{if $main eq "catalog" and $current_category.category eq ""}

Italian Glassman 03-12-2008 10:03 AM

Re: common if/then modifications I make to x-cart...
 
Thank you Balinor -- worked great!

chrisinoz 03-13-2008 11:09 PM

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

In a 4.017 cart of mine I used this to show content only to a CLUB member

{if $membershiplevel eq 'Seriously Gourmet CLUB'}
Text Here
{/if}



I am working on a 4.19 cart

The above does not work.

I think 4.19 now refers to id numbers so then I tried

{if $membershipid eq '2'}Text Here<br>{/if}

This did not work either.


Any ideas what I could be doing wrong?

Thanks

chrisinoz 03-23-2008 02:30 PM

Re: common if/then modifications I make to x-cart...
 
This works for 4.019 for me - got tech help from xcart

You should use the following part of code for the 4.1.9 version of x-cart:

if ($user_account['membershipid'] == '2') {
<necessary code here>
}

in php scripts, but if you want the variable be accessible in smarty templates please follow the instructions below:

1. add the following part of code to the end of your '<x-cart root directory>/auth.php' file:

$smarty->assign("current_customer_membershipid", $user_account['membershipid']);

after the following strings:

$smarty->assign("printable", $printable);
$smarty->assign("logout_user", $logout_user);

2. then the following part of code can be used in templates:

{if $current_customer_membershipid eq '2'}
Text Here
{/if}

Cheers
Chris

Italian Glassman 04-03-2008 11:52 AM

Re: common if/then modifications I make to x-cart...
 
Would anyone know how to do this in the cart section:

If (subtotal is smaller than $75),
then (code here).

Mario

carpeperdiem 04-03-2008 05:40 PM

Re: common if/then modifications I make to x-cart...
 
{if $cart.subtotal <75}

Italian Glassman 04-04-2008 06:08 AM

Re: common if/then modifications I make to x-cart...
 
Thank you carpeperdiem!

deadzebrainc 04-09-2008 09:02 AM

Re: common if/then modifications I make to x-cart...
 
Trying to do something (relatively?) simple, but I'm new to smarty so I need a bit of help.

I want to be able to change things in the category 1 products list (products.tpl) IF the product is also a member of a specific subcategory (3).


{if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y" and $products[product].categoryid "3"}
*things to change would go here*
{/if}

Maybe I need to do an extra AND to include category 1, or is there a .subcategoryid variable? Not really sure what to do here :) Use an array and check the second ID?

hooter 04-12-2008 10:16 PM

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

From the xcart instructions you quoted:
Quote:

1. add the following part of code to the end of your '<x-cart root directory>/auth.php' file:
You should be adding those codes to auth.php, not auth.tpl

rkdiddy 04-13-2008 11:36 AM

Re: common if/then modifications I make to x-cart...
 
Thanks Hooter. You must have posted that right after I removed my post.

Thanks!

amadecs 05-30-2008 12:18 PM

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

I know what these equal:

{if $main eq "catalog" and $current_category.category eq ""} = home page

{if $main eq "catalog" and $current_category.category ne ""} = any catalog page except the home page

Does anyone know what the code is for "Any product page?"

Thanks

balinor 05-30-2008 12:25 PM

Re: common if/then modifications I make to x-cart...
 
{if $main eq "product"}

Have a look at customer/home-main.tpl and common_templates.tpl - they have a lot of the $main values.

beetlejuice 06-28-2008 06:02 PM

Re: common if/then modifications I make to x-cart...
 
I have one last task to do for a client and that is have different "Welcome" text depending whether customers are logged in or not.

I created a welcomenl.tpl (nl stands for not logged) and tried to call it in the home_main.tpl with:

{if $login ne ' ' }
{include file=customer/main/welcomenl.tpl}
{/if}

Doesn't work so I've tried to call a different text file based on the above

{if $login ne ' ' }
{inlcude file="$lng_txt_welcomenl}

that nada also.

Can anyone give me aheads up

Thanks

HWT 06-29-2008 05:40 AM

Re: common if/then modifications I make to x-cart...
 
This is how I would handle it:
Code:

{if $login ne""}
Whatever you want logged in customers to see.
{else}
Whatever you want not logged in visitors to see.
{/if}


so in your case:
Code:

{if $login ne""}
{include file=customer/main/welcome.tpl}
{else}
{include file=customer/main/welcomenl.tpl}
{/if}


I believe it's simply the "" vs. the ' ' after the {if $login ne that's messing you up.

HTH

beetlejuice 06-29-2008 02:46 PM

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

you're on the money, I'm still not sure what the difference between "" & '' is to be honest.

Following your example I added the code to home_main.tpl and it initially made no difference probably due to this being active by default:

{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcome.tpl" f_products=$f_products}

So I added the code after the above, added the f_products etc to each, deleted {include file="customer/main/welcome.tpl" f_products=$f_products}

and wallah it works, thanks for the heads up again HWT.

Now can you tell me what the difference is between " " and ' '?

Thanks

HWT 06-30-2008 04:53 AM

Re: common if/then modifications I make to x-cart...
 
I forgot that that part was in home_main.tpl. Sorry about that.

Have you tried replacing

Code:

{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcome.tpl" f_products=$f_products}


with

Code:

{elseif $main eq "catalog" and $current_category.category eq "" and $login ne""}
{include file="customer/main/welcome.tpl" f_products=$f_products}
 
{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcomenl.tpl" f_products=$f_products}


all I did was add in the condition of and $login ne"" to display one of the welcome messages, and left the condition out to display the other. Might work?

For those that might refer to this later, the welcome.tpl should be displayed to logged in users, and the welcomenl.tpl should be displayed to any site visitor who is not logged in.

benhoffman 07-10-2008 05:59 AM

Re: common if/then modifications I make to x-cart...
 
Hey guys, what if I want to remove the header on ONLY one page? I tried something like {if $cat != 249} {include file="head_customer.tpl" } {/if} but it won't work. Maybe because it's in the customer/home.tpl?

Nevermind...I figured it out. I was able to add:

{if $main eq "product" and $cat eq "294"}
{else}
{include file="head_customer.tpl" }
{/if}

And now the header loads on all the pages except category 294.


All times are GMT -8. The time now is 11:26 AM.

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