X-Cart 4 Knowledge Base

Tricks

Restrict Edit by IP

Want to test some change on a live, but only for yourself? First determine your IP address, then use it in this code:

{if $smarty.server.REMOTE_ADDR eq "74.13.297.86"}
Only I can see this.
{/if}

Delete Duplicate User Accounts

X-Cart 4 (Classic) allows two user authentication modes, Username or Email. Email is vastly preferred these days, but many instances of X-Cart 4 are still setup to use usernames. If you want to switch you may be prevented by user accounts that have been setup under different usernames, but with the same email address. You can check your current situation by going to Tools -> Maintenance.

Deleting them manually can be a pain, especially if there are lots of them, but these SQL patches will delete duplicate accounts in one go!

Make a database backup first, or at the very least, backup the ‘xcart_customers’ table!

OPTION 1 – Keep the oldest account, apply this SQL patch…

DELETE x1 FROM xcart_customers x1, xcart_customers x2 WHERE x1.id > x2.id AND x1.email = x2.email AND x1.username != 'admin' AND x1.username != 'provider' AND x1.username != 'master';

OPTION 2 – Keep the newest account, apply this SQL patch…

DELETE x1 FROM xcart_customers x1, xcart_customers x2 WHERE x1.id < x2.id AND x1.email = x2.email AND x1.username != 'admin' AND x1.username != 'provider' AND x1.username != 'master';

Note the ending code…
Add more admin / provider account usernames if necessary, so they are left untouched!

Tested. X-Cart Classic only. Hope it helps.

-From Phil at xcartmods.co.uk

Create Module

Creating a module in X-Cart 4 is surprisingly easy. First you need to create the module folder, in {XcartDir}/modules. Name your folder the same as your module name like this: My_Module. The first file to create there is func.php

Second you need to execute an sql statement in the data base:

DELETE FROM xcart_modules WHERE module_name = 'My_Module';
INSERT INTO xcart_modules (module_name,module_descr,active) VALUES ('My_Module','My cool custom module','Y');

That’s it for now, I hope to expand and expound upon this in the future

Need help? Contact the Guru!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>