Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Cross Sell (X-Sell) Admin


dreamscape

Recommended Posts

That's it!

new infoBox($info_box_contents);

 

Replace the line

new contentBox($info_box_contents);

in catalog\includes\modues\xsell_products.php with your code:

new infoBox($info_box_contents);

I think everything will look OK.

 

UPD. And check in all your other boxes such "multi-image add on" for this modification. All boxes should have white body after that.

Edited by RusNN
Link to comment
Share on other sites

That's it!

 

 

Replace the line

new contentBox($info_box_contents);

in catalog\includes\modues\xsell_products.php with your code:

new infoBox($info_box_contents);

I think everything will look OK.

 

UPD. And check in all your other boxes such "multi-image add on" for this modification. All boxes should have white body after that.

 

 

I tried that the other day and figured I'd give it another shot today but still nothing. When I replace that code your product template seems to disappear. Meaning replacing the code with the one you mention seems to hide the product that is currently being displayed.

 

As this image shows:

fix.jpg

 

Also I reeeeaaaallly do appreciate all your help so far. I'm sure it's frustrating. Cause it's really frustrating me that I can't figure out what's going wrong here. Also to show you this is code from my 'new product' php..... it uses the "new contentBox($info_box_contents);" so yea lol

 

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

<?php

/*

$Id: new_products.php 1806 2008-01-11 22:48:15Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

*/

?>

<!-- new_products //-->

<?php

// $info_box_contents = array();

// $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

// new contentBoxHeading($info_box_contents);

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

$row = 0;

$col = 0;

$info_box_contents = array();

while ($new_products = tep_db_fetch_array($new_products_query)) {

// ----------

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

$product = tep_db_fetch_array($product_query);

$p_id = $product['products_id'];

 

$p_pic = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

 

$p_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a>';

 

$p_desc = ''.substr(strip_tags($product['products_description']), 0, MAX_DESCR_1).' ...';

 

$p_price = '<span class="productSpecialPrice">'.$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'</span>';

 

$p_details = '<a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button('button_details.gif', '', ' class="btn1"').'</a>';

$p_buy_now = '<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart2.gif', '', ' class="btn2"').'</a>';

 

 

 

$info_box_contents[$row][$col] = array('align' => 'left',

'params' => ' style="width:33%;"',

'text' => ''.tep_draw_prod2_top().'

<table cellpadding="0" cellspacing="0" border="0">

<tr><td class="name name2_padd">'.$p_name.'</td></tr>

<tr><td class="price2_padd">'.$p_price.'</td></tr>

<tr><td class="pic2_padd">'.tep_draw_prod_pic_top().''.$p_pic.''.tep_draw_prod_pic_bottom().'</td></tr>

<tr><td class="desc desc2_padd">'.$p_desc.'</td></tr>

<tr><td class="button2_padd button2_marg">'.$p_details.'<br />'.$p_buy_now .'</td></tr>

</table>

'.tep_draw_prod2_bottom().'');

 

$col ++;

if ($col > 2) {

$col = 0;

$row ++;

}

}

new contentBox($info_box_contents);

?>

<!-- new_products_eof //-->

Link to comment
Share on other sites

I can't figure out what's going wrong here.

So do I. Everything is look OK. I cant understand why both contentBox and infoBox classes do same on diffrent boxes and do not on We Also Recommend. I need to see html code of pages with both contentBox and infoBox results. May be incorrect html-tags are present.

You can email me or PM.

Edited by RusNN
Link to comment
Share on other sites

So do I. Everything is look OK. I cant understand why both contentBox and infoBox classes do same on diffrent boxes and do not on We Also Recommend. I need to see html code of pages with both contentBox and infoBox results. May be incorrect html-tags are present.

You can email me or PM.

 

 

Hey bud I sent you an email the other day :)

Link to comment
Share on other sites

Hey dude... I was just screwin with the code and had no luck an thought i'd see if you've had luck at tryin it out if you've had time? If not yet that's fine just thinking bout you! lol

 

 

hmmm not sure what happened. We just let a company do some tweaks to our site for security and what not so many they edited a file but when I hit edit so that I can delete and item (I added 3 pieces I only wanted 2) I get a blank screen with no database of the item like i use to. Where should I start looking so that I can get this up I'm seeing every thing is ok?

 

they changed the 'admin' folder to 'pladmink' would that change anything? Every thing else I have installed still works great so this kinda sucks... Anyways I double checked the install notes and every thing is in there as it was suppose to be. Sorry to add a new thing to you bud!

Link to comment
Share on other sites

sourpickles

I read your letter. Check admin\xsell.php onse again and found two different query on a line, which I didn't notice earlier. Bad coding, but I only support code, not rewrite that due to less time. So, try again:

 

admin\xsell.php

Near line 183 find

    $products_query_raw = 'select p.products_id, p.products_model, p.products_price, p.products_tax_class_id, p.products_image, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and pd.products_name like "%' . tep_db_input($search) . '%" order by pd.products_name asc';}else{$products_query_raw = 'select p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_name asc';}

and REPLACE with

    $products_query_raw = 'select p.products_id, p.products_model, p.products_price, p.products_tax_class_id, p.products_image, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and (pd.products_name like "%' . tep_db_input($search) . '%" or p.products_model like "%' . tep_db_input($search) . '%") order by p.products_model';}else{$products_query_raw = 'select p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_model';}

 

Near line 278 find

      $products_query_raw = 'select p.products_id, p.products_image, p.products_model, p.products_price, pd.products_name from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and pd.products_name like "%' . tep_db_input($search) . '%" order by pd.products_name asc';}else{$products_query_raw = 'select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_price from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_name asc';}

and REPLACE with

      $products_query_raw = 'select p.products_id, p.products_image, p.products_model, p.products_price, pd.products_name from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and (pd.products_name like "%' . tep_db_input($search) . '%" or p.products_model like "%' . tep_db_input($search) . '%") order by p.products_model';}else{$products_query_raw = 'select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_price from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_model';}

Now should sort by model number correctly.

 

The guys you hired do right thing by renaming admin. I have renamed too and everything in the shop works fine. But if they began filtered parameters or do something with queries to sanitize parameters or something else there is no way to understand what happend only by your words. Need to see the code and test.

Link to comment
Share on other sites

sourpickles

I read your letter. Check admin\xsell.php onse again and found two different query on a line, which I didn't notice earlier. Bad coding, but I only support code, not rewrite that due to less time. So, try again:

 

admin\xsell.php

Near line 183 find

    $products_query_raw = 'select p.products_id, p.products_model, p.products_price, p.products_tax_class_id, p.products_image, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and pd.products_name like "%' . tep_db_input($search) . '%" order by pd.products_name asc';}else{$products_query_raw = 'select p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_name asc';}

and REPLACE with

    $products_query_raw = 'select p.products_id, p.products_model, p.products_price, p.products_tax_class_id, p.products_image, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and (pd.products_name like "%' . tep_db_input($search) . '%" or p.products_model like "%' . tep_db_input($search) . '%") order by p.products_model';}else{$products_query_raw = 'select p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_model';}

 

Near line 278 find

      $products_query_raw = 'select p.products_id, p.products_image, p.products_model, p.products_price, pd.products_name from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and pd.products_name like "%' . tep_db_input($search) . '%" order by pd.products_name asc';}else{$products_query_raw = 'select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_price from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_name asc';}

and REPLACE with

      $products_query_raw = 'select p.products_id, p.products_image, p.products_model, p.products_price, pd.products_name from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" and (pd.products_name like "%' . tep_db_input($search) . '%" or p.products_model like "%' . tep_db_input($search) . '%") order by p.products_model';}else{$products_query_raw = 'select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_price from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_model';}

Now should sort by model number correctly.

 

The guys you hired do right thing by renaming admin. I have renamed too and everything in the shop works fine. But if they began filtered parameters or do something with queries to sanitize parameters or something else there is no way to understand what happend only by your words. Need to see the code and test.

 

Yup yup got it working finally. Still trying to get the BOX to show up. I really am not sure what was up with the add on it just stopped working. I reinstalled and it works great now. Thanks man...an and if you do ever figure out why the BOX aint showin I'm all ears still lol :)

Link to comment
Share on other sites

Hi Peter,

 

Thanks for keeping up with this add-on. I just installed v2.7.2 and it works great.

 

As per a general forum post I made the other day (http://www.oscommerce.com/forums/topic/364233-cross-selling/), I'm using

Optional Related Products for things like replacement parts and plan on using XSell for actual cross selling.

 

The one thing I've noticed is that the XSell box takes stylesheet attributes from whatever boxes in the columns are

using. Optional Related Products has (or can have) its own stylesheet entry for easy customization. Of course the

code here is pretty different.

 

I noticed that someone tried to allow for box customization back in 2007 (page 17 here), many versions ago, but is

there any easy way to customize the colors used in the box?

 

Thanks,

 

Nick

Link to comment
Share on other sites

Hi, Nick

 

I never use ORP only see some screenshots in release of early 2005. Seems like XSell have better admin side, its more fluent. But there is no contribution made x-sells in admin side very usable.

 

About your question of stylesheet. Of cource it is possible to let your XSell box look and fill as you want. There is 2 way to do that.

1. You may rewrite code in catalog\includes\modules\xsell_products.php which do output, but don't modify queries. The code will look like in ORP.

2. You may define new Box class and let it use your own stylesheet. In this way you need to modify only 2 lines in catalog\includes\modules\xsell_products.php. I recommend this way, because it is more easy and you may than use new Box classes in other places of your shop.

 

You may also get some styling by putting in different

$info_box_contents[] = array('params' => 'class="<HERE IS YOUR STYLE>"');

in catalog\includes\modules\xsell_products.php

Edited by RusNN
Link to comment
Share on other sites

Hi, Nick

 

I never use ORP only see some screenshots in release of early 2005. Seems like XSell have better admin side, its more fluent. But there is no contribution made x-sells in admin side very usable.

 

About your question of stylesheet. Of cource it is possible to let your XSell box look and fill as you want. There is 2 way to do that.

1. You may rewrite code in catalog\includes\modules\xsell_products.php which do output, but don't modify queries. The code will look like in ORP.

2. You may define new Box class and let it use your own stylesheet. In this way you need to modify only 2 lines in catalog\includes\modules\xsell_products.php. I recommend this way, because it is more easy and you may than use new Box classes in other places of your shop.

 

You may also get some styling by putting in different

$info_box_contents[] = array('params' => 'class="<HERE IS YOUR STYLE>"');

in catalog\includes\modules\xsell_products.php

 

Thanks for the reply Peter. Great advice...I'm looking to try the 2nd method you described. I'm reading up on how to add a new box class (http://216.92.47.228/kb/osCommerce/Catalog_Area/Boxes/248), but could you tell me exactly which 2 lines in includes/modules/xsell_products.php I would change?

Link to comment
Share on other sites

Thanks for the reply Peter. Great advice...I'm looking to try the 2nd method you described. I'm reading up on how to add a new box class (http://216.92.47.228/kb/osCommerce/Catalog_Area/Boxes/248), but could you tell me exactly which 2 lines in includes/modules/xsell_products.php I would change?

You need to replace this

new contentBoxHeading($info_box_contents);

and this

new contentBox($info_box_contents);

according to your new box classes.

Link to comment
Share on other sites

I've just installed the v2_7_2 and It seemed to work until I actually tried to add a recommended product and got the following error

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11) in /home/electric/public_html/oscommerce/includes/functions/database.php on line 19

Unable to connect to database server!

 

any ideas what I've done?

Link to comment
Share on other sites

I've just installed the v2_7_2 and It seemed to work until I actually tried to add a recommended product and got the following error

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11) in /home/electric/public_html/oscommerce/includes/functions/database.php on line 19

Unable to connect to database server!

 

any ideas what I've done?

I've posted earlier that v2.7.3 is unstable and unsupported. You should use only v2.7.2. If you have problems with connections to database you should double check your installation, but before you must carefully uninstall 2.7.3.

 

On what page do you get the error?

Link to comment
Share on other sites

Hi,

 

Installed v2.7.2 as advised above and it works like a dream without problem.

 

However, one anomaly I have found is that I also use IP Trap contribution by fimble. When I use X-Sell to link products on the admin side and then go to my store to check them out, I find that I have been banned by the IP Trap and have to remove my IP from the banned list to access my store.

 

Not a big issue, but a pain if I dont already have filezilla open to edit the banned ip file.

 

Any Idea what could be causing this?

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

 

However, one anomaly I have found is that I also use IP Trap contribution by fimble. When I use X-Sell to link products on the admin side and then go to my store to check them out, I find that I have been banned by the IP Trap and have to remove my IP from the banned list to access my store.

Are you shure you have been banned only after using XSell?

 

I'am not use any kind of IP Trap, so it might be a slightly difficult to understand what's wrong. What version of IP Trap are you using?

 

Could you exactly follow step by step you use of XSell checking after each step have you become banned?

Link to comment
Share on other sites

Hi,

 

I become Banned after clicking the cross sell link in the adsmin/catalog box and my IP address is added to the IP_Trapped.txt file.

 

Does the x-sell have any hard coded references to admin ?

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

OK,

 

This is strange, I found the code that was causing the problem, it was a piece of code in my .htaccess file that I use to direct "unwelcome" gueats to a file where they go into the iIP Trap. Removed the code and X Sell does not now ban me.

 

This is the code I had at the end of the .htaccess file:

ErrorDocument 403 /a_folder/index.php

 

Why would x sell cause a 403 error and so go into the IP trap?

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

OK,

 

Im going to post in the security threads - something in my error logs does not look right....

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...