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}

Jon 10-09-2008 12:15 PM

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


[code]
{assign var="truncCode" value=$products[product].productcode|truncate:2:""}
{if $truncCode eq "C-"}do this{else}do this instead{/if}
{/code}

Brian Schade 10-23-2008 03:56 PM

Re: common if/then modifications I make to x-cart...
 
I need to format the invoices, both web-based and e-mail, to display information about how to pay via Check or Money Order (COMO). However, I only want this information to display if the person actually PAID by COMO. If the customer did not pay via COMO (in other words, paid by Gift Certificate, PayPal, or Credit Card) then the information specific to COMOs does not need to be shown or included in the e-mail.

I figured this would be a simple IF statement situation. But I'm not sure where to put the IF statement, or even on the syntax.

I have set up a new variable in my admin named eml_como. I figured the system would simply check the Payment Method variable and if it equalled "Check or Money Order" then it would simply display the eml_como value. I tried placing this IF statement in the signature.tpl file and using the $order.payment_method variable to check for the payment method. This appears to be the same variable that is used to display the payment method when generating the invoice to begin with. However, when I place the following code in my signature.tpl file;

Quote:

{if $order.payment_method == "Check or Money Order"}
{$lng.eml_como}
{/if}

I get no response at all.

I'm wondering if the problem lies in the fact that signature.tpl is a seperate template file than the template file that actually holds the value for that variable? The signature.tpl file, so far as I can tell, is called from two other templates; order_customer_processed.tpl and order_customer_complete.tpl. I'm guessing that this is the case. If this is true, where would be the best place to put the IF statement?

I really need to have this functionality built into our system. Any help would be greatly appreciated.

Kara 11-06-2008 12:32 PM

Re: common if/then modifications I make to x-cart...
 
We are trying to hide our coupon code box from our wholesale customers.

We moved the coupon template to display just below the subtotal in cart_totals.tpl. This seems to work best because people are logged in when they have a chance to put in their coupon code, and it is much more visible to those trying to find where to enter the code.

This is what we have in cart_totals.tpl:

{if $membership_levels ne "Wholesale"}
{include file="modules/Discount_Coupons/add_coupon.tpl"}
{/if}

also tried {if $membership_levels.membership ne "Wholesale"}

It is still displaying the coupon box when logged in as a wholesale customer. Anyone have any ideas here? : )

(x-cart 4.1.8)

Kara 11-06-2008 01:11 PM

Re: common if/then modifications I make to x-cart...
 
figured it out:

{if $active_modules.Discount_Coupons ne "" and $userinfo.membership ne "Wholesale"}
{include file="modules/Discount_Coupons/add_coupon.tpl"}
{/if}

---------------------------------

Took me all day, but it works! Remember, this is in cart_totals.tpl where we moved the coupon code. -- not in cart.tpl where it normally is.

ChrisP05 12-02-2008 02:21 PM

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

I am working on a x-cart v. 4.19 and the customer wants to have paid membership without having to manually assign customers to membership level. He has 3 levels active: Silver, Gold, and Platinum. The wholesale is not active but is still there.

Obviously, I can have the select memebrship level if I enable sign up for membership, but that would display all the levels. So if they chose to buy a silver level they could pick platinum at that stage. More manual work which is not wanted.

What I can come up with in theory is this:

1. The membership level selector has to be active, but hidden and selected by the product id in cart. Something like this:

if productid in cart is equal to "Silver" then the hidden select membership box = to silver.
if I could get that type of code even to work, would that automatically assign in the admin that user to that level?

Then on repeat orders that code would have to be inapplicable to platinum members with putting if product id is upgrade to Gold or Upgrade to platinum then hidden selector is = to gold or platinum {else} {if $login eq ""}comment out code {/if}

If that would even work, would that cause error in that since sign up for membership is enabled, would the cart be looking for that code?

To complicate things even further he has the customer loyalty points mod by bce and wants those points to be automatically credited to that new member on that purchase.

Thoughts?

Thanks

Chris

HWT 12-07-2008 10:37 AM

Re: common if/then modifications I make to x-cart...
 
Here's and {if} that I believe I've seen alluded to, but I haven't figured out how to make happen.

Say I want to display something on products.tpl and/or product.tpl if a certain extra field has a particular value. How would one go about that?

eg:
Code:

{if $extrafield eq "0"}Choose ground shipping for Christmas delivery
{elseif $extrafield eq  "3"}Choose 3 day select for Chrismas delivery
{elseif $extrafield eq  "2"}Choose 2nd day air for Chrismas delivery
{elseif $extrafield eq  "1"}Choose next day air for Chrismas delivery
{/if}


donavichi 12-18-2008 03:25 PM

if section = FAQ / Terms / Contact etc...
 
I was looking for a solution to help me add content into a page which would change depending on which section of the help zone i was in.

I found plenty of questions asking for the same solution, but no answers.

I took a few moments out to deduce it myself and here is the solution:

Code:

{if $main eq "help" and $help_section eq "FAQ"}
show this
{elseif $main eq "help" and $help_section eq "contactus"}
show something else
{elseif $main eq "help" and $help_section eq "business"}
show something different again...
{/if}


...and so on.


To determine which areas of the help zone to alter, refer to skin1/help/index.tpl for the various parts of x-cart's help zone.

hope this helps

:D/

balinor 12-18-2008 04:22 PM

Re: common if/then modifications I make to x-cart...
 
Good one for this thread, so I'm moving it here :)

iWD 01-19-2009 01:44 PM

Re: common if/then modifications I make to x-cart...
 
I have been trying to get a if/then statement working and so far I'm at a loss.
I want to have an image for the background on the regular pages, but when you got the cart portion (where all your menus disappear) that it is just plain white (or that the image turns off).

How and where do I make the if then statement to make this work?

any help would be appreciated!
thanks!

Jon 01-19-2009 01:50 PM

Re: common if/then modifications I make to x-cart...
 
You'd make the if statement around your image code:

{if $main ne "cart" AND $mode ne "checkout" AND $mode ne "order_message"}
Show the background image
{/if}

balinor 01-19-2009 01:57 PM

Re: common if/then modifications I make to x-cart...
 
or around a class, like this:

<div {if $main ne "cart" AND $mode ne "checkout" AND $mode ne "order_message"}class="class1"{else}class="class2" {/if}>

iWD 01-20-2009 05:24 AM

Re: common if/then modifications I make to x-cart...
 
okay maybe "background" is the wrong terminology.
Or I'm putting it in the wrong place?

in the CSS it is table.container that I am adding the "background" image to.

What file would I put this code in?
the CSS?
the home.tpl?

And is that a "ne" not equals?
If so then is this code saying that if those menus are not there, then the image isn't?
'Cause that's right, I'm just making sure I understand it somewhat.

in any case I've done something wrong as it's not working.
Or the image is just not there in all accounts?

carpeperdiem 01-20-2009 05:30 AM

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

Originally Posted by iWD
I have been trying to get a if/then statement working and so far I'm at a loss.
I want to have an image for the background on the regular pages, but when you got the cart portion (where all your menus disappear) that it is just plain white (or that the image turns off).

How and where do I make the if then statement to make this work?

any help would be appreciated!
thanks!


Are you saying that you would LIKE your page to be different once you get to Fast Lane Checkout? If so, you should know that FLC has its own css file.

/skin1/modules/Fast_Lane_Checkout/skin1.css

This is where you could determine color or images of the container for FLC pages.

Not really an if/then issue...

iWD 01-20-2009 05:55 AM

Re: common if/then modifications I make to x-cart...
 
I don't believe it is the Fast Lane Check Out?
It has the image from my regular skin1.css file?
So I am assuming they are connected together?

But when you hit "buy now" (or other place it in the cart buttons) you move to your shopping cart.
At that point, and through the rest of the purchase I need the background (table.container) turned off because I am lacking in the menus that it is based on.

iWD 01-22-2009 05:59 AM

Re: common if/then modifications I make to x-cart...
 
Okay, for those of you that are interested.
After much ado, here's what ended up happening for the change of the "table.container" from "cart pages" versus the "product pages" with an if/then statement.
This should be able to done with any changes you want to have done from the CSS to the "cart pages" versus the "product pages", but don't hold me to that, I'm new at this too!

First you will need two CSS files.
One for the Cart [skin1.css] and one for the Non-Cart [skin1_cart.css].

Then you need to make a copy of your customer/home.tpl (always save the original file, just incase this doesn't work with something else you've changed ;))

Then with the customer/home.tpl you need to find your CSS line.

Should look like this:
<link rel="stylesheet" type="text/css" href="{$SkinDir}/skin1.css" />

Then right after it you need to
{if $main eq "cart" AND $mode eq "checkout" AND $mode eq "order_message"}
<link rel="stylesheet" type="text/css" href="{$SkinDir}/skin1_cart.css />
{/if}


This worked for me, hope it helps someone out there too!
enjoy ;)
and thanks for the help everyone who was involved!
great job!

Psychobilly 01-23-2009 10:53 AM

Re: common if/then modifications I make to x-cart...
 
I've gone through this thread (as well as others) and I'm unable to hide the "Market Place" price from wholesale customers. Seems like this should be default. Any help would be appreciated.

Thanks

Momtreprenuer 06-29-2009 07:45 PM

Re: common if/then modifications I make to x-cart...
 
Ok, I'm a little frustrated. It seems like whenever I ask a question, there is very little or no response, yet I see other questions that get many, many responses. I guess I'm either asking a difficult question, posting in the wrong place, or ...well I have no idea.

I'm sure that there is some forbidden rule about double posting or whatever, but I really need help so I'm trying in another location. The original question is here: http://forum.x-cart.com/showthread.php?t=48337 but I am also asking here in hopes that there will be some response. :(

Here's my problem:

All of the "if" membership statements are great but what would I code for a subscription status? For example, I have 3 subscription types: A, B, and C. I have a static page that is for current subscribers only that needs to show different content based upon the type of subscriber.


Is there a way to tweak the following to be able to use it for subscription types instead of membership types:

{if $user_membership eq '1'}
Content for 1
{elseif $user_membership eq '2' or $user_membership eq '3'}
Content for 2 and 3
{else}
sorry, membership needed for access.
{/if}

I've tried every version of subscriptionid, subscription, productid etc. I've been going around and around with this for weeks trying to figure it out on my own. ](*,) I know with all the pros here on this board, there's gotta be some easy resolution! I would even be willing to pay a reasonable fee. Please help if you can!!

Thanks in advance,
Momtrepreneur
X-cart Version 4.1.12

carpeperdiem 06-30-2009 02:35 AM

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

Originally Posted by Momtreprenuer
I've tried every version of subscriptionid, subscription, productid etc. I've been going around and around with this for weeks trying to figure it out on my own. ](*,)


Here's a tip that will point you towards your goal:

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

By using this technique, you can pinpoint the exact variable that is being called for the membership. And then your if/else will work.

Momtreprenuer 06-30-2009 09:18 AM

Re: common if/then modifications I make to x-cart...
 
Thanks carpeperdiem for your reply. I tried that one already and while I was able to see lots of variables, I couldn't see any new ones that I hadn't already tried. I think that I may have the right variable but the wrong syntax (or whatever it is called) so it doesn't work. :(

Thank you so much for your effort in replying though. For an example of subscriptions 1, 2 here's what I've been playing around with:
Code:


{if subscription eq '1'}
show me content for 1
{esleif subscription eq '2'}
show me content for 2
{else}
Sorry, you must have a sub to view this content.
{/if}


I've tried using " or just '. I've tried subscriptions, subscriptionid, subsscription_pay_period_type, subscription_status, productid and many others. I've also taken direct code from subscription.tpl. I've also tried: {if subscription ne ""} which just shows the content to anyone logged in.

I know this should work. I may just need to add more code to another file maybe??

pairodimes 07-15-2009 01:03 PM

Re: common if/then modifications I make to x-cart...
 
Love this post - thanks

CooperDooper 10-05-2009 07:07 PM

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

This is a great thread, lots of good info.

However, I can't seem to get #9 to work, we would like one of our static pages (support.html) to only be accessible to those with a membership (after we manually confirm their membership in the User Profiles section).

We have two types of memberships, Returning Customers and Distributors. We would like both types of memberships to have access to the Support page once they are logged in.

I believe a lot of the solutions posted here are the pre 4.2 versions and thats why the solutions in this thread are proving unsuccessful. Were running 4.2.2.

This should be a simple if statement however we're useless with x-cart ;)

We would greatly appreciate your help! Cheers,

FTI 04-30-2010 09:35 AM

Re: common if/then modifications I make to x-cart...
 
Hi there, great thread. I'm have a problem with the flyout menus in v4.3.1. My customer wants the following thing and I believe it can happen with it/then modification. She wants when a client is on a particular category of the menu, all other categories and subcategories to dissapper. For example, the ones in the green are visible, the ones in red are not visible:

Category 1
Subcategory 1
Subcategory 2


Category 2
Subcategory 1
Subcategory 2

Category 3
Category 4


Any ideas, I've been trying to do this for 4 days already and I'm puzzled... Thanks in advance!

fioppy 09-23-2010 10:00 AM

Re: common if/then modifications I make to x-cart...
 
I'm applying IF statement condition on language variable I have added to two language on my website."

I had set store_language as variable and it's value in english website as EN and in arabic as AR.

I have now the below condition should be applied true when the website is in English but it never comes true, it switches always to ELSE condition.

Please this is me only ask to be solved, help in this

HTML Code:

{if $lng.store_language eq "EN"}
<div style="text-align:center;width:250px;"><a href="javascript:void(window.open('http://manalifashion.com/Livezilla/chat.php','','width=590,height=580,left=0,top=0,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes'))"><img src="http://manalifashion.com/Livezilla/image.php?id=01" width="250" height="100" border="0" alt="LiveZilla Live Help"></a><noscript><div><a href="http://manalifashion.com/Livezilla/chat.php" target="_blank">Start Live Help Chat</a></div></noscript><div style="margin-top:2px;"><a href="http://www.livezilla.net" target="_blank" title="LiveZilla Live Help" style="font-size:10px;color:#bfbfbf;text-decoration:none;font-family:verdana,arial,tahoma;">LiveZilla Live Help</a></div></div><!-- http://www.LiveZilla.net Chat Button Link Code --><!-- http://www.LiveZilla.net Tracking Code --><div id="livezilla_tracking" style="display:none"></div><script type="text/javascript">
<!-- DONT PLACE IN HEAD ELEMENT -->
var script = document.createElement("script");script.type="text/javascript";var src = "http://manalifashion.com/Livezilla/server.php?request=track&output=jcrpt&nse="+Math.random();setTimeout("script.src=src;document.getElementById('livezilla_tracking').appendChild(script)",1);</script><!-- http://www.LiveZilla.net Tracking Code -->
{else}
{$lng.store_language}
{/if}


Italian Glassman 09-23-2010 10:13 AM

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

This is the code I use. Hope it helps.

{if $shop_language eq"EN"}
Insert Condition #1 here
{else}
Insert Condition #2 here
{/if}

fioppy 01-08-2011 09:05 PM

Re: common if/then modifications I make to x-cart...
 
I need to custiomized the product options to serve a special task in my website.

I want to create a Drop down list which is normal and available now on website for ex:
Size:(1,2,3,4,5, Customize)

I will create different Text options too like: Hips, Arm, Waist, Bust as test field to options products.

If customer selected "customize" from drop down list dynamicaly the Test fields above should be displayed below it. or then they should be hidden all time unless customer picked Customize from Size drop down list.

Please advice what change required to reach this option

Regards

Omron Khan 02-14-2011 08:18 PM

Re: common if/then modifications I make to x-cart...
 
Guys i wnat to display a image only in the login page. any idea how to write a if condition for this?

masada3336 03-03-2011 04:37 PM

Re: common if/then modifications I make to x-cart...
 
Hi Instinctual,
Is there an if statement to have something show on every category BUT one specific one? I tried using
{if cat eq "254"}
nothing goes here - empty

{else}

the regular code would go here

{/if}

but it didn't seem to affect products_t.tpl

Basically, I have only one category where I want to omit the "buy now" button - the rest it's good to go on.

Thanks!

cflsystems 03-03-2011 07:33 PM

Re: common if/then modifications I make to x-cart...
 
You can use $current_category.categoryid

masada3336 03-03-2011 08:30 PM

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

Originally Posted by cflsystems
You can use $current_category.categoryid

Hmm...ok - how can I use that if to omit the buy_now button and will it be *only* on the category page (not on the product pages?)
Thanks! I'm totally clueless here with the programming statements

cflsystems 03-04-2011 03:20 AM

Re: common if/then modifications I make to x-cart...
 
Buy Now button is only on products list pages, not on product pages. You need to place the if statement in the correct template - products_t.tpl or products_list.tpl - depending on how your categories pages are listed


All times are GMT -8. The time now is 01:34 AM.

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