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)

donavichi 04-04-2011 04:51 AM

Re: common if/then modifications I make to x-cart...
 
X-Cart 4.4.x currently, but probably all previous versions are compatible also - I can't remember. Let me know if any problems...

Better Search Box:
If you want a custom search box on your X-Cart store that has an initial value of 'Search for products..." displayed, that when clicked turns blank so the user can type their search term without having to remove the text by hand & then when the search results are displayed, retains the term they just entered until they click back inside the box again, do this:

in customer/search.tpl find the following code (around line 20):

Code:

<input type="text" name="posted_data[substring]" class="text" value="{$search_prefilled.substring|escape}" />

and replace it with this:
Code:


<input type="text" name="posted_data[substring]" class="text" {if $main ne "search"}value="Search for products..." onfocus="if(this.value==this.defaultValue) this.value='';"{else}value="{$search_prefilled.substring|escape}" onfocus="if(this.value==this.defaultValue) this.value='';"{/if} />


Just done this for the nth time and thought it might help, in case anyone missed it.

CanadaPOS 04-08-2011 09:45 AM

Re: common if/then modifications I make to x-cart...
 
Trying to show an image on product.tpl only if wholesale prices are available for that product.

Is there an if statement that covers something like that?

Thanks in advance.

donavichi 04-08-2011 09:55 AM

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

{if $product_wholesale ne ""}...your image here...{/if}

that should do it.

Quote:

Originally Posted by CanadaPOS
Trying to show an image on product.tpl only if wholesale prices are available for that product.

Is there an if statement that covers something like that?

Thanks in advance.


CanadaPOS 04-08-2011 03:31 PM

Re: common if/then modifications I make to x-cart...
 
Thanks ... works great!!

mizNRG 04-13-2011 08:25 AM

Re: common if/then modifications I make to x-cart...
 
I'm looking for and if/then statement that would either clear out the email field if it equals dummyemail@email.com (thus requiring the customer to fill it in) or require the email field to be changed upon initial login if membership id = 8.

What I'm looking to accomplish is to import a large list of customers when I do not have their email addresses. I've come to the conclussion that I'll have to do this with a dummy email instead. However, I need to require the customer to change this so that they will properly receive notifications rather than the dummy email receiving them.

Any help on this would be greatly appreciated!!

upupcreative 04-16-2011 06:10 PM

Re: common if/then modifications I make to x-cart...
 
This may already have come up in this thread but I can't find it. I'm using 4.4.x and I don't seem to have a $user_membership variable. I want to use an if/then like the one above to show one thing on a static page if the user is a wholesale customer and something else if the user is not.

anandat 04-21-2011 11:03 PM

Re: common if/then modifications I make to x-cart...
 
I want if else statement for static page.
For example if visitor click on static page link. The following javascript should be load

Code:

<head>
<script language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('US')==0)
{
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://www.SomeDomain.com'>");
}
</script>
</head>


In short what if/else condition I should put between <head> </head> so that above javascript function load if person open static page id=1 ?

PhilJ 04-21-2011 11:33 PM

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

{if $smarty.get.pageid eq "1"}
...
{/if}


godfatherantiques 06-02-2011 06:04 AM

Register as customer and provider on front end of site
 
What is needed to allow anybody to register as a customer and a provider. I'm thinking I need an {if statement to accomplish this, but I'm not quite sure what is needed. I'm hoping someone can point me in the right direction or tell me what needs to be done. I don't want the admin in control of creating provider accounts, but I would like to approve the providers as they sign up. Any help would be much appreciated.

dmpinder 07-29-2011 04:27 AM

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

Originally Posted by upupcreative
This may already have come up in this thread but I can't find it. I'm using 4.4.x and I don't seem to have a $user_membership variable. I want to use an if/then like the one above to show one thing on a static page if the user is a wholesale customer and something else if the user is not.


This should be close to what you need. I was having the same problem on my v4.3.1, and here is the solution:

1. In the file \include\check_useraccount.php find the following:
Code:

$mail_smarty->assign("usertype",$current_area);

... and paste underneath:
Code:

$smarty->assign("user_membership",$user_account["membership"]);
$smarty->assign("user_membershipid",$user_account["membershipid"]);



This allows you to call {$user_membership} or {$user_membershipid} in the Smarty template to generate the name and ID number.

Note: You can create other variables by using the $user_account database request on line 155.

Hope this helps!

Darren

Yalokin 12-13-2011 11:25 AM

Load Script and Images on ONE Page
 
Hello I need to load scripts and images only if user on one page and I can not specify page Id because it custom made module and all categories shown there as:

custom.php?cat=7000 or custom.php?cat=3450 and so on

Load script only on all of the module.php page with cat ID from 1 to 10000.

or simply custom.php page


thank you.

Yalokin 12-20-2011 09:36 AM

Re: common if/then modifications I make to x-cart...
 
Hello did you figure this out.

I try to do the same but with more scripts and css.

Also how to define page in if/else if it custom.php for example.


thank you



Quote:

Originally Posted by anandat
I want if else statement for static page.
For example if visitor click on static page link. The following javascript should be load

Code:

<head>
<script language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('US')==0)
{
    document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://www.SomeDomain.com'>");
}
</script>
</head>


In short what if/else condition I should put between <head> </head> so that above javascript function load if person open static page id=1 ?


obac01 02-15-2012 06:28 PM

Re: common if/then modifications I make to x-cart...
 
Hi I customized the Fulfilment account to be able to add products, works great, now my client wants to hide some options from the add/edit product page, I would like the help of you guys to let me know an If/then statment to hide the options to the fulfilment staff. I have almost 3 days working on it and I cann't find the varieble to do this.

Thanks

totaltec 02-18-2012 11:28 PM

Re: common if/then modifications I make to x-cart...
 
Hi OBO1,
I haven't tried this bu I know that include/security.php assigns the user account flag to smarty:
$smarty->assign('current_membership_flag', $user_account['flag']);
and fulfillment staff's flag is FS I believe.

So maybe:
{if $current_membership_flag ne "FS"}
Show this stuff to regular admins.
{elseif $current_membership_flag eq "FS"}
Show this stuff only to Fulfillment Staff.
{/if}

obac01 02-21-2012 12:10 PM

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

Originally Posted by totaltec
Hi OBO1,
I haven't tried this bu I know that include/security.php assigns the user account flag to smarty:
$smarty->assign('current_membership_flag', $user_account['flag']);
and fulfillment staff's flag is FS I believe.

So maybe:
{if $current_membership_flag ne "FS"}
Show this stuff to regular admins.
{elseif $current_membership_flag eq "FS"}
Show this stuff only to Fulfillment Staff.
{/if}



Thank you Totaltec!! works Great!.
:D

Jon 05-31-2012 12:26 PM

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

Originally Posted by PhilJ
Code:

{if $smarty.get.pageid eq "1"}
...
{/if}



Better to use this code in case they are using CDSEO or clean urls which won't have the pageid in the url:

Code:

{if $page_data.pageid eq 'X'}
I am on page X.
{/if}


pauline 09-07-2012 06:07 PM

Re: common if/then modifications I make to x-cart...
 
Hi, could anyone please point me in the right direction, I'm trying to hide the add to cart, update, price and amount for products in just one category in the wishlist using if/else statement. I think I should be editing wl_products.tpl, would anyone know if this is correct.

Thank you,
Pauline.

totaltec 09-08-2012 06:51 PM

Re: common if/then modifications I make to x-cart...
 
Pauline, use webmaster mode to determine what template to edit. Follow the tutorial link in my signature if you don't know what I mean.

pauline 09-09-2012 09:03 AM

Re: common if/then modifications I make to x-cart...
 
Will Do,
thanks Mike.

Jon 10-11-2012 10:39 AM

Re: common if/then modifications I make to x-cart...
 
I added a list of some common statements I use in a tutorial at: X-Cart Common Smarty Statements.

xtech 11-12-2012 02:14 AM

Re: common if/then modifications I make to x-cart...
 
Hi,
I have created a static page whose content is to display by login or register.When a customer fist time register then it directly goes into address book page I want to display the static page content after initial registration.That means after initially registration(not entering address book data) it redirects to that static page remaining functions remains the same.

How to achieve that?

totaltec 11-12-2012 03:09 AM

Re: common if/then modifications I make to x-cart...
 
Look near line 1274 of include/register.php
Code:

// Redirect just registered customer
        if ($isAutoLogin) {
            $script = 'address_book.php';
        } else {
            $script = 'home.php';
        }


xtech 11-12-2012 03:17 AM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
Is this for particular static page or after registration only? Actually I want when a customer comes to that static page ,register then after registration it will redirected to that static page.The other functionality after registration remains as before.

totaltec 11-12-2012 03:51 AM

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

Originally Posted by xtech
Hi Mike,
Is this for particular static page or after registration only?

I just pointed you to the code that redirects the user after signup. Forgot to say that it is /include/register.php

If you want to got to a different page, just put your page there in place of address_book.php. Haven't tested this yet.

If you need to assign a custom variable from the previous page, just pass it in the URL: register.php?custom=yes

Untested example:
Code:

// Redirect just registered customer
        if ($isAutoLogin) {
          if ($custom == 'yes'){
            $script = 'pages.php?pageid=2'
          }else {
            $script = 'address_book.php';
          }
        } else {
            $script = 'home.php';
        }

This probably won't work but you can give it a shot. :-)

xtech 11-12-2012 03:59 AM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
My static page is https://www.health-shoppe.com/HelpAge.html but in order to view the static page content I have to register I want after inital registration it will again redirects to https://www.health-shoppe.com/HelpAge.html instead of address book if there is no product in the cart added.

This is applicable for this page only the other functionality that is after adding products to cart and registration process like before remains the same.

This will be applicable for this page only.How to achieve it?

Please help..

totaltec 11-12-2012 05:36 AM

Re: common if/then modifications I make to x-cart...
 
Have you tried my suggestion above?

I'll explain it again. :-)

Create a static page containing:
Code:

{if $login eq ''}
Yes you have to register. Go here: <a href="register.php?custom=yes">Register</a>
{else}
You are registered and logged in! Congratulations!
{/if}

Make sure you have "parse smarty tags" enabled. Take note of the pageid of the custom page.

Now look in include/register.php
Find this line:
Code:

$script = 'address_book.php';
Change it to:
Code:

if ($custom == 'yes') {
  $script = 'pages.php?pageid=7';
}else{
  $script = 'address_book.php';
}

Change the pageid to your custom page's id.

Works on my test site here: http://trainingpen.com/Special.html

xtech 12-05-2012 12:13 AM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
You are the man... Thanks a lot...One things need to add I want to add login page also in static page and after login (if customer stays on that static page) the customer remains in that page not in home page or in cart page.

This will be applicable means that can be applicable for static page only that is after login stays on that static page.Remaining functions remains the same.

How to achieve that?

totaltec 12-05-2012 10:09 AM

Re: common if/then modifications I make to x-cart...
 
Thanks for the kudos.

If we need to pass special variables to login.php, we would need to do it in the same way by adding ?custom=yes or something like that.

I am not sure if this will work in your version, but it does in mine. I updated my test page linked above.
Code:

{if $login eq ''}
If you have an account Please <a href="http://trainingpen.com/login.php" title="Sign in" onclick="javascript: return !popupOpen('login.php');">Sign in</a>!
Or you have to register. Go here: <a href="register.php?custom=yes">Register</a>
{else}
You are registered and logged in! Congratulations!
{/if}


xtech 12-05-2012 11:31 PM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
Thanks for your reply.But nothing to change in login.php like register.php?Because when a customer remains in static page when they click login.php if he is on that static page then after login that customer goes to post page not in home page.

How to do that?

totaltec 12-05-2012 11:38 PM

Re: common if/then modifications I make to x-cart...
 
Are you using the popup sign in link like I demonstrated above?
http://trainingpen.com/Special.html - it works fine on my test site.

xtech 12-07-2012 03:55 AM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
I have added this in my static page but in pop it throws the error please have alook


totaltec 12-07-2012 06:38 AM

Re: common if/then modifications I make to x-cart...
 
It looks like your version does not include the sign-in popup. I guess it was a later version that included this, like 4.4.4

Hmmm, well then you are going to need to do the same as the register page. Include a special variable in the URL, and direct them back to the special page after login.

Where does the login page take you now? I suspect it is either the home page, or if you have items in your cart, the cart page.

Take a look at the code that performs this function, and include a catch for your special variable. Just like we did for registration.

xtech 12-08-2012 12:00 AM

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

Originally Posted by totaltec

Where does the login page take you now? I suspect it is either the home page, or if you have items in your cart, the cart page.

Take a look at the code that performs this function, and include a catch for your special variable. Just like we did for registration.


Hi Mike,
My version is 4.4.2 Pro.is this a bug? Yes u r right Where does the login page take you now? I suspect it is either the home page, or if you have items in your cart, the cart page.

I want when a customer is in a static page then when he or she login then he will redirected to the next page but remaining functionality of going into cart if some products in cart and redirected to home page functionality remains the same.

Please provide me the codes.

Thanks..

xtech 12-11-2012 02:08 AM

Re: common if/then modifications I make to x-cart...
 
Hi Mike,
Can you please look into this matter?

totaltec 12-11-2012 07:28 AM

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

Originally Posted by xtech
Hi Mike,
Can you please look into this matter?

I am helping you, but I am also trying to get you to understand. I am willing to help for free, but not simply provide the code. This is not paid support. :-)

I am trying to guide you, so that you can make modifications like this without help. Remember how we solved this last time? We are going to do the same!

Open up your /include/login.php Take a look at the file and actually read it, Open it up in a real code editor like Notepad++. Very near to the top of the file, we see:
Code:

if ($REQUEST_METHOD == 'POST') {
This starts the actions that are supposed to happen when a user "Posts" the form submitting their credentials. Next see (near line 84 in my file)
Code:

if ($mode == 'login') {
This IF statement is the main meat of this file. You can see its closing bracket, down around line 440 (in my file). First you see some error checking being performed, next you see the Image verification for Captcha.

Then it checks to see if their if the user exists and if the account is active or suspended (lines 117, 134). From line 141 down to about 229, you can see it performing functions for admin users, suspending accounts that are inactive, forcing password changes, and checking for admin IP restrictions.

Line 231 checks the password, but near line 243 we see this:
Code:

if ($allow_login) {
Now we are getting close! See the next statement near line 259:
Code:

if ($login_type == 'C') {

Near line 264 we see the note // Redirect to saved URL
After that you can see it checking for cart contents and remembered data, and finally near line 286:
Code:

$redirect_url = $remember_data['URL'];

If you use CTRL F to search in the file for this variable "$redirect_url", you will see it mentioned in several places. There are several points along this chain that you can use our code from before:
Code:

if ($custom == 'yes') {
  $script = 'pages.php?pageid=7';
}else{
  $script = 'address_book.php';
}

But it will have to be changed. Consider this code:
Code:

if ($custom == 'yes') {
  $redirect_url = 'pages.php?pageid=7';
}

You can see several examples of this type of logic being applied throughout the existing code. Now we know what code we want to insert, we just have to find the right place to put it.You should be wondering, where is this information from this variable used, so I can cut it off and have my code take priority?

Look down through the document. See:
Code:

func_header_location($redirect_url);
Suspicious right? What happens if you place the code directly above this statement? (I haven't tried it)

Now don't forget to include the ?custom=yes at the end of your link.

anandat 02-21-2013 09:31 PM

Re: common if/then modifications I make to x-cart...
 
hello I want {if} {else} statement for following customization.

In the customer invoice just after product name I want to display manufacturer name: {product Name} by {manufacturer}

Also in above if product has got thumbnail then I want to display simple "." (DOT) after {manufacturer}, (This is just for internal purpose so that I can see which products doesn't have images)

So following will be logic for products with manufacturer & thumbnail
Code:

{product Name} by {manufacturer} {.}

And following will be logic for products with manufacturer WITHOUT thumbnail
Code:

{product Name} by {manufacturer}

I guess it should be real simple to achieve with proper variable & if/else statement.

Note: I am looking this for 4.5.4...can one help me on this :-) ?

suseela 02-25-2013 10:37 PM

Re: common if/then modifications I make to x-cart...
 
How can i remove the Goodies tab from the providers area

joannet 09-11-2013 05:30 PM

Re: common if/then modifications I make to x-cart...
 
I would like to add an if/then statement so that when there is text in a language variable it is displayed. If there is no text in the language variable, then the the language variable does not display. Is this possible?

Thanks in advance!

while.e.kyote 09-11-2013 06:59 PM

Re: common if/then modifications I make to x-cart...
 
if (lng.variable != '')

cflsystems 09-11-2013 09:12 PM

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

Originally Posted by while.e.kyote
if (lng.variable != '')


missing the $ and this code looks more of a php than smarty so it won't work in templates

{if $lng.your_variable_name ne ''}{$lng.your_variable_name}{/if}


All times are GMT -8. The time now is 07:03 AM.

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