X-Cart Mods, X-Cart Addons - WebsiteCM
 
X-Cart Excellence eZine
Subscribe for proven tips and special discounts!
   Forum Search
Forum Menu
Quick Links
Forum Login
Username:

Password

Remember Me
Forum Expert(s)
X-Cart Mods, X-Cart Addons - WebsiteCM
Developing websites since the early-to-mid 90's, and working extensively with e-commerce since 2001, Jon Peters of WebsiteCM is equipped to assist you with your design, programming, e-commerce, and x-cart specific questions.

xvbIntegration - X-Cart and vBulletin Integration Guideline

About this Thread:
You are viewing the thread xvbIntegration - X-Cart and vBulletin Integration Guideline in the eCommerce forum.

Reply
 
Thread Tools
  #1  
Old January 8th, 2008, 10:57 AM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 98
Default xvbIntegration - X-Cart and vBulletin Integration Guideline

xvbIntegration - X-Cart + vBulletin Integration
X-Cart Mods, X-Cart Addons: [url]http://www.websitecm.com/[/url]
--------------------------------------------------------------------------

What this is:
The following is a guideline for x-cart and vbulletin integration. It works by transferring all user aspects (registration/update/login/lostpass) to x-cart, and then using x-cart to keep the vbulletin database up-to-date. It provides the necessary class file for user functions and instructions for installation of the class file, a script to migrate users from x-cart to vbulletin, and a guideline for integration into your vbulletin templates.

What this is not:
This is not a step-by-step how-to for x-cart and vbulletin integration, rather it is a guideline with reference to our integration, to allow you to more easily understand what is required for your specific integration.

Notes: Integration does not perform user deletions. Admin deletions must be manually performed in both x-cart and vbulletin separately.

Modification requires x-cart and vbulletin to share a database.

------------------------------------------------------------
Upload Provided Files
------------------------------------------------------------

Download the attached files and upload the files provided (except for readme.txt) to the corresponding x-cart directory on your server.

------------------------------------------------------------
User Migration
------------------------------------------------------------

It is necessary to ensure that the same username/email/password is present on both your x-cart and your vbulletin. For the purpose of this integration we assume your x-cart has customers, and you do not yet have any vbulletin non-admin users (i.e. it is a new installation). If you have an existing vbulletin, you will need to synch your databases.

You can either run the following script via your browser, or via SSH. Personally I recommend SSH (with a 'screen' if your savvy) as browsers can sometimes have load issues with larger stores.

In your browser, type: [url]http://www.yourdomain.com/xcart-dir/admin/xvbUsers.php[/url] (change your domain name and xcart directory)
If running via SSH, change into your x-cart admin directory, and type: php ./xvbUsers.php

IMPORTANT: Delete the xvbUsers.php from your admin folder when complete.

If all went well, you will now have the same users in your x-cart database, as in your vbulletin. Do not proceed until this is in place.

We will now make the necessary changes to update vbulletin whenever a change in x-cart takes place.

------------------------------------------------------------
Open include/register.php
------------------------------------------------------------
FIND:

Code:
		}
		else {
			#
			# Add new person to customers table
			#
BEFORE ADD:

Code:
			// xvbIntegration - Update
			if (!$anonymous_user && $login_type == "C") {
				include $xcart_dir."/modules/xvbIntegration/class.vbreg.php";
				$xvb = new xvbIntegration();
				$newuser_info = func_userinfo($login, $login_type, true);
				unset($vbInsert);
				$vbInsert['username'] = $login;
				$vbInsert['email'] = $newuser_info['email'];
				$vbInsert['password'] = text_decrypt($newuser_info['password']);
				$xvb->xvbUpdate($vbInsert);
			}
			// / xvbIntegration - Update
FIND:

Code:
		}

		if (!empty($active_modules['SnS_connector']) && $usertype == 'C' && defined("AREA_TYPE") && constant("AREA_TYPE") == 'C') {
BEFORE ADD:

Code:
			// xvbIntegration - Register
			if (!$anonymous_user && $usertype == "C") {
				include $xcart_dir."/modules/xvbIntegration/class.vbreg.php";
				$xvb = new xvbIntegration();
				unset($vbInsert);
				$vbInsert['username'] = $profile_values['login'];
				$vbInsert['email'] = $profile_values['email'];
				$vbInsert['password'] = text_decrypt($profile_values['password']);
				$xvb->xvbRegister($vbInsert);
			}
			// / xvbIntegration - Register
------------------------------------------------------------
Open include/login.php
------------------------------------------------------------

FIND:

Code:
			db_query("UPDATE $sql_tbl[customers] SET last_login='$tm' WHERE login='$login'");
			db_query("REPLACE INTO $sql_tbl[login_history] (login, date_time, usertype, action, status, ip) VALUES ('$username','$tm','$usertype','login','success','$REMOTE_ADDR')");
AFTER ADD:

Code:
			// xvbIntegration - Login
			include $xcart_dir."/modules/xvbIntegration/class.vbreg.php";
			$xvb = new xvbIntegration();
			$xvb->xvbLogin($login,$remember);
			// / xvbIntegration - Login
FIND:

Code:
	x_session_register("login_redirect");
	$login_redirect = 1;
AFTER ADD:

Code:
	// xvbIntegration - Logout
	include $xcart_dir."/modules/xvbIntegration/class.vbreg.php";
	$xvb = new xvbIntegration();
	$xvb->xvbLogout();
	// / xvbIntegration - Logout
------------------------------------------------------------
vBulletin Template Changes
------------------------------------------------------------

Your vbulletin users table will now be updating whenever changes in x-cart take place, and logging in and out of x-cart will also log a user in and out of x-cart. It is now necessary to update your vbulletin login/register areas to access x-cart instead of vbulletin. This is a very complex modification that cannot be documented step-by-step as it will vary from store to store.

Here's a guideline of how I performed our integration:

--------------------------------
Login
--------------------------------

I viewed source on our x-cart registration page, and then I cleaned up the code, and pasted it into our vbulletin HEADER template to appear on our side navigation. In the form code, I added this line of code to indicate to our x-cart that we were logging in from the forum:

Code:
<input type="hidden" name="redirect2" value="forum" />
I also added this code from the default vbulletin to pass the current page url:

Code:
<input type="hidden" name="url" value="$scriptpath" />
I updated the following x-cart templates similarily:

STANDARD_ERROR
STANDARD_ERROR_LITE
STANDARD_ERROR_LOGIN

To redirect the user back to the forum on login and/or error, I modified our include/login.php to check for the existence of $redirect2 to determine whether or not to send them to the forum, and checked the existence of $HTTP_POST_VARS['url'] to determine if there was an exact url back to which to send them.

On error, I appended &error=1 to the url and then modified our above mentioned vbulletin templates to display a login error message when $_GET['error'] == 1.

--------------------------------
Register
--------------------------------

This was a difficult process for integration. I contemplated modifying the register.php of the forum to redirect to our main x-cart registration, but this would have taken a user off the forum registration layout, and forced them to fill in billing/shipping information, etc., which I didn't feel was necessary for a simple forum registration. Instead, I opted to customize the register vbulletin template.

I created a new form that contained the necessary/desired fieldnames in x-cart, and had the form post to a new x-cart registration file which I called register_forum.php. To create this register_forum.php file, I took the default x-cart register.php and replaced the include/register.php line in the file with the actual content from include/register.php. I then stripped down the contents of the file to what was necessary (this code is very bloated as it serves many different purposes) and ensured that the file could only be used for new registrations by inserting a redirect at the top of the file when $mode was specified or when the user was already logged in. I also forced this file to not work for anonymous logins, or any user type other than a customer.

Upon successful registration, I used the following code to register the user in vbulletin also, and then log them into the forum:

Code:
// xvbIntegration - Register
include $xcart_dir."/modules/xvbIntegration/class.vbreg.php";
$xvb = new xvbIntegration();
unset($vbInsert);
$vbInsert['username'] = $profile_values['login'];
$vbInsert['email'] = $profile_values['email'];
$vbInsert['password'] = text_decrypt($profile_values['password']);
$xvb->xvbRegister($vbInsert);
// / xvbIntegration - Register
Wanting vbulletin to display messages generated by my internal error checking, I used the following code to pass an error variable back to the forum:

Code:
unset($reg_error);
if (!empty($fillerror)) $reg_error="missing_fields";
if (!empty($uerror)) $reg_error="username_taken";
if (!empty($error)) $reg_error="username_invalid";
if (!empty($emailerror)) $reg_error="email_invalid";
$redirect = "/forum/register.php?do=register&agree=Y&firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname) . "&email=" . urlencode($email) . "&uname=" . urlencode($uname) . "&password=" . urlencode($password) . "&reg_error=$reg_error";
func_header_location($redirect);
The $redirect variable passes the information back to vbulletin in an error string, along with the registration error, and then re-populates the fields and displays a message corresponding with the appropriate error type.

In order to pass the variables from the query string to the vbulletin registration form for re-population, I made this change in my vbulletin register.php:

FIND:

Code:
// Variables that are used in templates
AFTER ADD:

Code:
$uname = $_GET['uname'];
etc. for all form fields that I used.

On successful registration I again checked the existence of $HTTP_POST_VARS['url'] for url redirection, or sent them to the forum homepage.

--------------------------------
Checkout Check
--------------------------------

Since the user is able to register on the forums with minimal information, when the user attempts to checkout of x-cart they will not have a billing/shipping address and similar information entered. To correct this I added the following code to our cart.php which checks for the existence of a billing country, and if not present forces them to update their profile with a provided explanation at the top of the page:

FIND:

Code:
$smarty->assign("partner", $partner);
AFTER ADD:

Code:
// xvb - Forum Registrations must fill out all information to proceed
if ($mode == "checkout" && $login && $userinfo['b_country'] == "") {
	$top_message['type'] = "I";
	$top_message['content'] = "Please complete the required fields below to proceed with your purchase.";
	func_header_location("register.php?mode=update&action=cart&paymentid="); exit;
}
--------------------------------
Lost Pass
--------------------------------

I modified our lostpw vbulletin template to link to our x-cart password retrieval popup.

--------------------------------
Link Updates
--------------------------------

I then searched through our vbulletin templates and made necessary changes to any links to register.php login.php or areas where username, email, or password could be updated. These included:

modifyoptions
modifyprofile
USERCP_SHELL

--------------------------------
Test! Test! Test!
--------------------------------

If, after all your swearing, head-shaking, and blaming the computer for your mistakes, things went well, you will now have an integrated x-cart and vbulletin.

Good luck!
Attached Files
File Type: zip xvbIntegration.zip (4.0 KB, 29 views)

Last edited by admin : January 15th, 2008 at 02:50 PM. Reason: Added note about sharing an xcart/vbulletin database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old January 15th, 2008, 07:41 AM
7thdesire 7thdesire is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
Default

has anyone got this to work i have a few issues it seems to have something todo with sessions

Warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/html/forum/includes/class_core.php on line 1550




Unable to add cookies, header already sent.
File: /var/www/html/include/logging.php
Line: 526





Warning: mysql_query() [function.mysql-query]: Access denied for user '#####'@'localhost' (using password: NO) in /var/www/html/include/func/func.db.php on line 81

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/html/include/func/func.db.php on line 81
INVALID SQL: 1045 : Access denied for user '#########'@'localhost' (using password: NO)
SQL QUERY FAILURE:UPDATE xcart_sessions_data SET data='a:40:{s:17:\"_saved_session_fg\";s:32:\"b37f b97200b91cb51fa0a741c6aefc1f\";s:11:\"editor_mode\ ";s:0:\"\";s:8:\"is_robot\";s:1:\"N\";s:5:\"robot\ ";s:0:\"\";s:11:\"is_location\";s:0:\"\";s:9:\"ada ptives\";a:11:{s:4:\"isJS\";s:1:\"Y\";s:5:\"isDOM\ ";s:1:\"Y\";s:8:\"isStrict\";s:1:\"Y\";s:6:\"isJav a\";s:1:\"Y\";s:7:\"browser\";s:4:\"MSIE\";s:7:\"v ersion\";s:3:\"7.0\";s:8:\"platform\";s:5:\"Win32\ ";s:8:\"isCookie\";s:1:\"Y\";s:8:\"screen_x\";s:4: \"1680\";s:8:\"screen_y\";s:4:\"1050\";s:14:\"is_f irst_start\";s:0:\"\";}s:23:\"offer_products_prior ity\";a:0:{}s:4:\"cart\";s:0:\"\";s:5:\"login\";s: 6:\"master\";s:10:\"login_type\";s:1:\"P\";s:18:\" new_offers_message\";s:0:\"\";s:25:\"customer_avai lable_offers\";a:0:{}s:22:\"antibot_validation_val \";a:4:{s:17:\"on_send_to_friend\";a:2:{s:4:\"code \";s:5:\"AUZUI\";s:4:\"used\";s:1:\"N\";}s:13:\"on _contact_us\";a:2:{s:4:\"code\";s:5:\"YVSSW\";s:4: \"used\";s:1:\"N\";}s:8:\"on_login\";a:2:{s:4:\"co de\";s:5:\"XSKKY\";s:4:\"used\";s:1:\"N\";}s:10:\" on_reviews\";a:2:{s:4:\"code\";s:5:\"TKPIH\";s:4:\ "used\";s:1:\"N\";}}s:11:\"logout_user\";s:0:\"\"; s:26:\"session_failed_transaction\";s:0:\"\";s:16: \"add_to_cart_time\";s:0:\"\";s:17:\"always_allow_ shop\";b:1;s:11:\"search_data\";a:1:{s:8:\"product s\";s:0:\"\";}s:4:\"wlid\";s:0:\"\";s:10:\"js_enab led\";s:1:\"Y\";s:11:\"top_message\";s:0:\"\";s:15 :\"referer_session\";b:0;s:11:\"identifiers\";a:2: {s:1:\"P\";a:2:{s:5:\"login\";s:6:\"master\";s:10: \"login_type\";s:1:\"P\";}s:1:\"A\";a:2:{s:5:\"log in\";s:6:\"master\";s:10:\"login_type\";s:1:\"P\"; }}s:6:\"logged\";s:0:\"\";s:14:\"remember_login\"; b:0;s:13:\"remember_data\";s:0:\"\";s:7:\"old_lng\ ";s:0:\"\";s:15:\"wcm_cartchecked\";i:1;s:10:\"wcm _cartid\";s:0:\"\";s:13:\"export_ranges\";s:0:\"\" ;s:16:\"current_language\";s:2:\"US\";s:17:\"merch ant_password\";s:0:\"\";s:16:\"file_upload_data\"; s:0:\"\";s:8:\"username\";s:0:\"\";s:16:\"login_an tibot_on\";b:0;s:19:\"previous_login_date\";s:10:\ "1200413244\";s:13:\"login_attempt\";s:0:\"\";s:19 :\"intershipper_recalc\";s:1:\"Y\";s:11:\"antibot_ err\";b:0;s:7:\"bf_mode\";s:0:\"\";}' WHERE sessid='e0ff32c1ba21ba9131c27730a3abb6c3'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old January 15th, 2008, 12:06 PM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 98
Default

You should disable warnings from being output on your server. This is something your host can usually do for you. This should take care of the first 2 issues.

With regard to the last issue, do you have your xcart and vbulletin sharing the same database?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old January 15th, 2008, 12:07 PM
7thdesire 7thdesire is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
Default

no they are in diffrent DB
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old January 15th, 2008, 02:49 PM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 98
Default

They need to be in the same database, otherwise you will get disconnected from one when connecting to the other.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old January 16th, 2008, 02:04 AM
7thdesire 7thdesire is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
Default

dame it tryed that still getting similar errors
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old January 16th, 2008, 07:01 AM
wcm wcm is offline
Junior Member
 
Join Date: Jan 2008
Posts: 1
Default

Try putting this in your auth.php after <?php

Code:
 error_reporting(E_ERROR | E_PARSE);
Then post the exact error message, as well as what you are doing at the time of the error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old January 16th, 2008, 08:19 AM
7thdesire 7thdesire is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
Default

i have given up i am getting a quote off XCART as jons not taking on work right now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old January 16th, 2008, 08:57 AM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 98
Default

I'd help you if I could!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old January 16th, 2008, 09:00 AM
7thdesire 7thdesire is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
Default

i know mate you have always helped me when you could

it still looks like a conflict with anon cart every error is todo with sessions data
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Site Map