Jump to content



Latest News: (loading..)

- - - - -

[Contribution] Cross Sell (X-Sell) Admin


  • Please log in to reply
556 replies to this topic

#541   dvharrison

dvharrison
  • Members
  • 326 posts
  • Real Name:Deb
  • Gender:Female
  • Location:Essex, UK

Posted 23 March 2012 - 11:38 AM

@Mort-lemur

Actually on the product info adjustment, you have one to many '}' listed.  So it should be

<?php
//added for cross -sell
	if ((USE_CACHE == 'true') && empty($SID)) {
	  echo tep_cache_xsell_products(3600); //added for Xsell
	  echo tep_cache_also_purchased(3600);
	} else {
	  include(DIR_WS_MODULES . FILENAME_XSELL_PRODUCTS); //added for Xsell
	  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
	}

?>

I have taken this out and the page at least shows.  I haven't a clue if the rest works as I'm still going through it.

Hope this helps.

Edited by dvharrison, 23 March 2012 - 11:39 AM.

Debbie Harrison

#542   chemist4

chemist4
  • Members
  • 98 posts
  • Real Name:Tim
  • Gender:Male
  • Location:Missouri

Posted 08 April 2012 - 08:54 PM

Any way I try to run the SQL I get this error:

Error
SQL query:
CREATE TABLE products_xsell(
ID INT( 10 ) NOT NULL AUTO_INCREMENT ,
products_id INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
xsell_id INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
sort_order INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
PRIMARY KEY ( ID )
) TYPE = MYISAM ;
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 7

This is on the latest version of MAMP. I have copied/pasted and imported and received the same error. I don't know enough about MySQL to fix it myself. Could anyone tell my what could be wrong?

#543   plumbrokeacres

plumbrokeacres
  • Members
  • 4 posts
  • Real Name:Andrew Toms

Posted 09 May 2012 - 05:10 PM

Hi There,

I have installed X_Sell_For_2.3.1_V3.0 onto OSC 2.3.1 I can add the cross sell items in the admin but when I look at the product  http://pbagraphics.com/product_info.php?cPath=22&products_id=34 I get an Error :"Error!

Unable to determine the page link!"

I have double checked all uploaded files as well as the updated files everything seems to be in order.

Does anyone have any ideas as to how I can fix it?

Thanks in advance
Andrew

#544   Gergely

Gergely
  • Community Team
  • 531 posts
  • Real Name:Gergely Tóth
  • Gender:Male

Posted 23 May 2012 - 01:37 PM

@plumbrokeacres

Fix cache first:
includes/function/cache.php

Change:
// try to open file
	if ($fp = @fopen($filename, 'r')) {
// read in serialized data
	  $szdata = fread($fp, filesize($filename));
	  fclose($fp);
// unserialze the data
	  $var = unserialize($szdata);
	  $success = true;
	}

To:
// try to open file
	if ( file_exists($filename) ) {
	  if ($fp = @fopen($filename, 'r')) {
// read in serialized data
		$szdata = fread($fp, filesize($filename));
		fclose($fp);
// unserialze the data
		$var = unserialize($szdata);
		$success = true;
	  }
	}


Next step

Fix includes/modules/xsell_products.php

Change to:
<?php
/*
$Id: xsell_products.php, v1  2002/09/11
// adapted for Separate Pricing Per Customer v4 2005/02/24
osCommerce, Open Source E-Commerce Solutions
<http://www.oscommerce.com>
Copyright (c) 2002 osCommerce
Released under the GNU General Public License
*/
// require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_XSELL_PRODUCTS);
if ((USE_CACHE == 'true') && empty($SID)) {
// include currencies class and create an instance
require_once(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
}
if ($HTTP_GET_VARS['products_id']) {
$xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price
from " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_PRODUCTS . " p on xp.xsell_id = p.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'
left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "'
and p.products_status = '1'
order by sort_order asc limit " . MAX_DISPLAY_XSELL);
  $num_products_xsell = tep_db_num_rows($xsell_query);
  if ($num_products_xsell > 0) {
?>
<!-- xsell_products //-->
<?php
	 $info_box_contents = array();
	 $info_box_contents[] = array('align' => 'left', 'text' => TEXT_XSELL_PRODUCTS);
	 new contentBoxHeading($info_box_contents);
	 $row = 0;
	 $col = 0;
	 $info_box_contents = array();
	 while ($xsell = tep_db_fetch_array($xsell_query)) {
   if (tep_not_null($xsell['specials_new_products_price'])) {
	$xsell_price =  '<s>' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br>';
		$xsell_price .= '<span class="productSpecialPrice">' . $currencies->display_price($xsell['specials_new_products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span>';
   } else {
	$xsell_price =  $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id']));
   }
	   $text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a><br>' . $xsell_price. '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&product_to_buy_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_draw_button( IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $xsell['products_id']));
	   $info_box_contents[$row][$col] = array('align' => 'center',
											  'params' => 'class="smallText" width="33%" valign="top"',
											  'text' => $text) ;
	$col ++;
	   if ($col > 2) {
		 $col = 0;
		 $row ++;
	   }
	 }
new contentBox($info_box_contents);
?>
<!-- xsell_products_eof //-->
<?php
  }
}
?>

Header Footer Content Modules
SCM
v3

and some rewrites :-)

#545   plumbrokeacres

plumbrokeacres
  • Members
  • 4 posts
  • Real Name:Andrew Toms

Posted 30 May 2012 - 12:50 AM

Thank You!
@Gergely It works great now

#546   14steve14

14steve14

    STORE OWNER NOT CODER

  • Members
  • 3,078 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Dorset UK

Posted 15 June 2012 - 04:33 PM

I have been playing with the includes.modules/xsell_products.php to try to get the look the same as the new prroducts module on 2.3.1.The below code works fine, but i would like others to see if i have misssed anything.

<?php
/*
  $Id$
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Copyright (c) 2010 osCommerce
  Released under the GNU General Public License
*/
  $xsell_query = tep_db_query("select distinct p.products_id, p.products_image, trim(substring(pd.products_description, 1, 90)) as products_description, pd.products_name, p.products_tax_class_id, products_price, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, specials_new_products_price
from " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_PRODUCTS . " p on xp.xsell_id = p.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'
left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "'
and p.products_status = '1'
order by sort_order asc limit " . MAX_DISPLAY_XSELL);
  if ($xsell_query > 0) {
	$counter = 0;
	$col = 0;
	$xsell_content = '<table border="0" width="100%" cellspacing="10" cellpadding="2">';
	while ($xsell = tep_db_fetch_array($xsell_query)) {
	  $counter++;
	  if ($col === 0) {
		$xsell_content .= '<tr>';
	  }
	  $xsell_content .= '<td width="33%" align="center" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '" class="product_name">' . $xsell['products_name'] . '</a><br /> '. strip_tags($xsell['products_description']) . '... <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']). '" class="read_more">' . LINK_READ_MORE . '</a><br /><span class="productPrice">' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span></td>';
	  $col ++;
	  if (($col > 2) || ($counter == $num_xsell)) {
		$xsell_content .= '</tr>';
		$col = 0;
	  }
	}
	$xsell_content .= '</table>';
?>
  <h2><?php echo (TEXT_XSELL_PRODUCTS); ?></h2>
  <div class="contentText">
	<?php echo $xsell_content; ?>
  </div>
<?php
  }
?>

REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder, so dont bother sending PMs asking for help as you wont get any.  

OSC has a steep learning curve, but in general the program does work.  If it doesnt work, the chances are it is something you have done.

#547 ONLINE   altoid

altoid
  • Community Sponsor
  • 741 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Hollidaysburg, Pennsylvania

Posted 16 June 2012 - 12:33 PM

View Post14steve14, on 15 June 2012 - 04:33 PM, said:

I have been playing with the includes.modules/xsell_products.php to try to get the look the same as the new prroducts module on 2.3.1.The below code works fine, but i would like others to see if i have misssed anything.


Steve, mine differs a bit, attached.

I did some work with cache in the file, as well, to get the box to display like the rest of the boxes in the shop I did some tweaking at the end as so:

<div class="ui-widget infoBoxContainer">
	<div class="ui-widget-header ui-corner-top infoBoxHeading">
	  <span><?php echo TEXT_XSELL_PRODUCTS; ?></span>
	</div>
	<?php echo $xsell_prods_content; ?>
  </div>

I also see my query name differs, a result of working through this back when,I can't recall why I came up with that.

Forgive the residual comment out lines, that's left over from when i was futzing with the code to get things cleaned up and testing.[attachment=1264:xsell_products.php]
I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.
I remember what it was like when I first started with osC.  It can be overwhelming.
However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.
There are several good pros here on osCommerce.  Look around, you'll figure out who they are.

#548   lblanks240

lblanks240
  • Members
  • 26 posts
  • Real Name:lenard blanks

Posted 22 June 2012 - 06:00 PM

how do i fix tis error

thanks
lenard

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX_DISPLAY_XSELL' at line 7

select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, specials_new_products_price from products_xsell xp left join products p on xp.xsell_id = p.products_id left join products_description pd on p.products_id = pd.products_id and pd.language_id = '1' left join specials s on p.products_id = s.products_id where xp.products_id = '120035' and p.products_status = '1' order by sort_order asc limit MAX_DISPLAY_XSELL

[TEP STOP]


#549   zeus_r6

zeus_r6
  • Members
  • 93 posts
  • Real Name:john smith
  • Gender:Male
  • Location:Milwaukee, WI

Posted 25 June 2012 - 11:01 PM

View Postchemist4, on 08 April 2012 - 08:54 PM, said:

Any way I try to run the SQL I get this error:

Error
SQL query:
CREATE TABLE products_xsell(
ID INT( 10 ) NOT NULL AUTO_INCREMENT ,
products_id INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
xsell_id INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
sort_order INT( 10 ) UNSIGNED NOT NULL DEFAULT  '1',
PRIMARY KEY ( ID )
) TYPE = MYISAM ;
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 7

This is on the latest version of MAMP. I have copied/pasted and imported and received the same error. I don't know enough about MySQL to fix it myself. Could anyone tell my what could be wrong?

Having the same issue when running the sql query via phpmyadmin

#550   14steve14

14steve14

    STORE OWNER NOT CODER

  • Members
  • 3,078 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Dorset UK

Posted 26 June 2012 - 07:38 AM

Try changing

TYPE = MYISAM

to

Engine=MyISAM

I had a similar problem with something but to be honest cannot remember what, but that is the change i had to make.
REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder, so dont bother sending PMs asking for help as you wont get any.  

OSC has a steep learning curve, but in general the program does work.  If it doesnt work, the chances are it is something you have done.

#551 ONLINE   altoid

altoid
  • Community Sponsor
  • 741 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Hollidaysburg, Pennsylvania

Posted 08 July 2012 - 11:35 AM

After updating a shops php 5.2.* to php version 5.3.13 I am getting these errors pertaining to xsell after doing a product edit:

Quote


Warning: Invalid argument supplied for foreach() in /home/myname/public_html/myshopsadmin/includes/functions/general.php on line 1292

Warning: Cannot modify header information - headers already sent by (output started at /home/myname/public_html/myshopsadmin/includes/functions/general.php:1292) in /home/myname/public_html/myshopsadmin/includes/functions/general.php on line 65

I suspect it has something to do with this in the admins general.php as follows:

function tep_reset_cache_block($cache_block) {
  global $cache_blocks;

  $pid = '*';
  if ($cache_block == 'xsell_products') {
   $pid = '';
	if (isset($_GET['add_related_product_ID']) ) {
	 $pid =  $_GET['add_related_product_ID'];
	}
	if ( !$pid ) $pid = '*';
  }
  for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {
	if ($cache_blocks[$i]['code'] == $cache_block) {
	  $glob_pattern = preg_replace('#-language.+$#', '-*', $cache_blocks[$i]['file']);
	  foreach ( glob(DIR_FS_CACHE . $glob_pattern . '.cache' . $pid) as $cache_file ) {
		 @unlink($cache_file);
	  }
	  break;
	}
  }
}

Specifically around here?

	  $glob_pattern = preg_replace('#-language.+$#', '-*', $cache_blocks[$i]['file']); <--line 1291 in general.php
	  foreach ( glob(DIR_FS_CACHE . $glob_pattern . '.cache' . $pid) as $cache_file ) {  <--line 1292 in general.php

with the preg_replace part.  Just guessing.   Any ideas?
I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.
I remember what it was like when I first started with osC.  It can be overwhelming.
However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.
There are several good pros here on osCommerce.  Look around, you'll figure out who they are.

#552 ONLINE   altoid

altoid
  • Community Sponsor
  • 741 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Hollidaysburg, Pennsylvania

Posted 10 July 2012 - 09:57 PM

View Postaltoid, on 08 July 2012 - 11:35 AM, said:

Any ideas?

Yea...took some serious mining but @ecartz a solution here
I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.
I remember what it was like when I first started with osC.  It can be overwhelming.
However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.
There are several good pros here on osCommerce.  Look around, you'll figure out who they are.

#553   newburns

newburns
  • Members
  • 90 posts
  • Real Name:Ray Burns
  • Gender:Male
  • Location:Texas

Posted 08 August 2012 - 09:40 PM

@Gergely
Why isn't this code included into the instructions? This was the only way I could get mine to work without any errors.
Thanks A LOT

#554   Irin

Irin
  • Members
  • 789 posts
  • Real Name:Irina
  • Gender:Female
  • Location:Texas

Posted 04 September 2012 - 01:00 AM

I'm trying to adapt this add-on for use with 2.3.2. Below is the code from my includes/modules/xsell_products.php. The only problem is that only one cross-sell product is displayed, no matter how many are specified to show in admin. Any ideas?
<?php
/*
$Id: xsell_products.php, v1  2002/09/11
// adapted for Separate Pricing Per Customer v4 2005/02/24
osCommerce, Open Source E-Commerce Solutions
<http://www.oscommerce.com>
Copyright (c) 2002 osCommerce
Released under the GNU General Public License
*/
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_XSELL_PRODUCTS);
if ((USE_CACHE == 'true') && empty($SID)) {
// include currencies class and create an instance
require_once(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
}
if (isset($HTTP_GET_VARS['products_id'])) {
  $xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, specials_new_products_price
from " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_PRODUCTS . " p on xp.xsell_id = p.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'
left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "'
and p.products_status = '1'
order by sort_order asc limit " . MAX_DISPLAY_XSELL);
$num_products_xsell = tep_db_num_rows($xsell_query);
if ($num_products_xsell > 0) {
	 $counter = 0;
	 $col = 0;
	 $xsell_products_content = '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="ui-widget-content ui-corner-bottom">';
	while ($xsell = tep_db_fetch_array($xsell_query)) {
	  $counter++;
	  if ($col === 0) {
		$xsell_products_content .= '<tr>';
	  }
   if (tep_not_null($xsell[$x]['specials_new_products_price'])) {
	$xsell_price =  '<s>' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br />';
		$xsell_price .= '<span class="productSpecialPrice">' . $currencies->display_price($xsell['specials_new_products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span>';
   } else {
	$xsell_price =  $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id']));
   }
	   $xsell_products_content = '<td width="33%" align="center" valign="top"><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a><br />' . $xsell_price. '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&product_to_buy_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&product_to_buy_id=' . $xsell['products_id'], 'NONSSL')) .'</a></td>';
	$col ++;
	   if (($col > 2) || ($counter == $num_products_xsell)) {
		 $xsell_products_content .= '</tr>';
		 $col = 0;
	   }
	 }
	  $xsell_products_content .= '</table>';
?>
  <br /><br /><br />
  <div class="ui-widget infoBoxContainer" style="text-align: center">
	<div class="ui-widget-header ui-corner-top infoBoxHeading" style="text-align: left">
	  <span><?php echo TEXT_XSELL_PRODUCTS; ?></span>
	</div>
	<?php echo $xsell_products_content; ?>
  </div>
<?php
   }
}
?>


#555   Sardonic76

Sardonic76
  • Members
  • 98 posts
  • Real Name:D. Tsamadou
  • Gender:Female
  • Location:Athens, Greece

Posted 18 January 2013 - 04:52 PM

Hi! :)

I'm trying to get the x-sell products to display a certain way on the product info page, but I can't seem to figure out what I need to do.
Basically I want them displayed like in the "what's new" page (have a look here: http://dory.gr/2013h/index.php). Pink boxes symmetrically divided and with spacing between them.
What I am getting at the moment is this: http://dory.gr/2013h/product_info.php?cPath=26&products_id=30.

Any ideas as to what I need to change??? :wacko:


------------------
Never mind!!!! I got it. Switched the file with a file that was posted in a previous post and tweaked it a little.

Edited by Sardonic76, 18 January 2013 - 05:00 PM.


#556   Gergely

Gergely
  • Community Team
  • 531 posts
  • Real Name:Gergely Tóth
  • Gender:Male

Posted 21 January 2013 - 08:42 PM

@Sardonic76

probably you need "equalheight" script. Look after in webcontents or ask a web designer.
Header Footer Content Modules
SCM
v3

and some rewrites :-)

#557   brt32

brt32
  • Members
  • 5 posts
  • Real Name:Bartek

Posted 01 March 2013 - 06:51 PM

Hello,
I want my X-Sell to show ONLY active products on list in admin... Because i have really mess here... Could anyone tell me how to do it?
Sorry for my bad english, but i think that you understood ;)

Thx :)

Edited by brt32, 01 March 2013 - 06:51 PM.