Avenir | Drupal Development | Joomla Development | Magento Development | OsCommerce Development

Thursday, 1 March 2012

Add to wishlist module for oscommerce 2.x

Step 1:

Excuete the below SQL in your DB

CREATE TABLE `customers_wishlist` (
`products_id` tinytext NOT NULL,
`customers_id` int(13) NOT NULL default '0'
) TYPE=MyISAM;



CREATE TABLE `customers_wishlist_attributes` (
`customers_wishlist_attributes_id` int(11) NOT NULL auto_increment,
`customers_id` int(11) NOT NULL default '0',
`products_id` tinytext NOT NULL,
`products_options_id` int(11) NOT NULL default '0',
`products_options_value_id` int(11) NOT NULL default '0',
PRIMARY KEY (`customers_wishlist_attributes_id`)
) TYPE=MyISAM;




INSERT INTO `configuration_group` ( `configuration_group_id` , `configuration_group_title` , `configuration_group_description` , `sort_order` , `visible` ) VALUES ( '12954', 'Wish List Settings', 'Settings for your Wish List', '25', '1' );
INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) VALUES ( '', 'Max Wish List', 'MAX_DISPLAY_WISHLIST_PRODUCTS', '12', 'How many wish list items to show per page on the main wishlist.php file', '12954', '', now(), now(), NULL , NULL );
INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) VALUES ( '', 'Max Wish List Box', 'MAX_DISPLAY_WISHLIST_BOX', '4', 'How many wish list items to display in the infobox before it changes to a counter', '12954', '', now(), now(), NULL , NULL );
INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) VALUES ( '', 'Display Emails', 'DISPLAY_WISHLIST_EMAILS', '10', 'How many emails to display when the customer emails their wishlist link', '12954', '', now(), now(), NULL , NULL );
INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) VALUES ( '', 'Wishlist Redirect', 'WISHLIST_REDIRECT', 'No', 'Do you want to redirect back to the product_info.php page when a customer adds a product to their wishlist?', '12954', '', now(), now(), NULL , 'tep_cfg_select_option(array(\'Yes\', \'No\'),' );


Step 2:

include/languages/english/product_info.php

add the below code

//WISHLIST ADDITION
define('PRODUCT_ADDED_TO_WISHLIST', 'Product has been successfully added to your wishlist');

at end of the ?>

Step 3

in this file checkout_process.php

Find the code " $payment_modules->after_process(); " below this code add this " $wishList->clear(); "

Step 4

In this file product_info.php

find the below code

if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '
[' . $product_info['products_model'] . ']';
} else {
$products_name = $product_info['products_name'];
}

and replace the below code

if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '
[' . $product_info['products_model'] . ']';
} else {
$products_name = $product_info['products_name'];
}
//DISPLAY PRODUCT WAS ADDED TO WISHLIST IF WISHLIST REDIRECT IS ENABLED
if(tep_session_is_registered('wishlist_id')) {
?>




Step 5:

In this file create_account.php

Find the below code

// restore cart contents
$cart->restore_contents();


and replace the below code

// restore cart contents
$cart->restore_contents();
// restore wishlist to sesssion
$wishList->restore_wishlist();

Step 6:

in this file include/filesnames.php

add the below code at before end of ?>

/// WISHLIST

define('FILENAME_WISHLIST', 'wishlist.php');
define('FILENAME_WISHLIST_HELP', 'wishlist_help.php');
define('FILENAME_WISHLIST_PUBLIC', 'wishlist_public.php');

Step 7: include/database_tables.php

add the below code at before end of ?>

/// WISHLIST
define('TABLE_WISHLIST', 'customers_wishlist');
define('TABLE_WISHLIST_ATTRIBUTES', 'customers_wishlist_attributes');


Step 8: include/application_top.php

find the below code

// include shopping cart class
require(DIR_WS_CLASSES . 'shopping_cart.php');

and replace the below code

// include shopping cart class
require(DIR_WS_CLASSES . 'shopping_cart.php');

// include wishlist class
require(DIR_WS_CLASSES . 'wishlist.php');

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

find the below code

// action recorder
include('includes/classes/action_recorder.php');

and replace the below code

// action recorder
include('includes/classes/action_recorder.php');
// wishlist data
if(!tep_session_is_registered('wishList')) {
tep_session_register('wishList');
$wishList = new wishlist;
}

//Wishlist actions (must be before shopping cart actions)
if(isset($HTTP_POST_VARS['wishlist_x'])) {
if(isset($HTTP_POST_VARS['products_id'])) {
if(isset($HTTP_POST_VARS['id'])) {
$attributes_id = $HTTP_POST_VARS['id'];
tep_session_register('attributes_id');
}
$wishlist_id = $HTTP_POST_VARS['products_id'];
tep_session_register('wishlist_id');
}
tep_redirect(tep_href_link(FILENAME_WISHLIST));
}

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


Add the below
//Wishlist actions (must be before shopping cart actions)
case 'add_wishlist':
if(isset($HTTP_POST_VARS['products_id'])) {
if(isset($HTTP_POST_VARS['id'])) {
$attributes_id = $HTTP_POST_VARS['id'];
tep_session_register('attributes_id');
}
$wishlist_id = $HTTP_POST_VARS['products_id'];
tep_session_register('wishlist_id');
}
tep_redirect(tep_href_link(FILENAME_WISHLIST));
return;
break;



Step 9: in login.php

find the below code

// restore cart contents
$cart->restore_contents();


and replace the below code
// restore cart contents
$cart->restore_contents();
// restore wishlist to sesssion
$wishList->restore_wishlist();

Step 10:

in logoff.php

find the below code
$cart->reset();

and replace the below code
$cart->reset();
$wishList->reset();

2 comments:

  1. Which version of Wishlist are you using here. I tried to upload wishlist 5 and have some issues around the case 'add_wishlist' statement. Thanks

    ReplyDelete