Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Ajax Buy Now


azer

Recommended Posts

anyone have any ideas??? i'm pulling my hair out trying to figure this out. I would really like to include it in my store...

 

I know that the script is for some reason just not updating the 'divShoppingCard' div... any ideas?

 

Here are the elements involved (I just mentioned the opening tags, assuming you know where the closing ones are)

 

one source:

 

<div id="fly_img">, which contains the product image

 

two targets divs, place just before the shopping cart

 

<div id="flyDiv"></div><div id="divShoppingCard">

 

and of course, the call to the script: <script language="javascript" src="includes/ajax_sc.js">, placed at the top of the shopping cart BOX

and the css style:

 

#flyDiv {
 position: absolute;
 top: 0;
 left: 0;
 width: 0;
 height: 0;
 margin: 0;
 padding: 0;
}

 

if it's still not working, try to move your cart box on into the right column, who knows?

 

Hope the hair will grow back after this, because it's not worth getting bald because of that useless gadget (as it has been called by some ;)

Link to comment
Share on other sites

if it's still not working, try to move your cart box on into the right column, who knows?

 

I tried changing my template to one that uses both left and right columns and it still doesn't seem to work, but I'm wondering if it has to do with the added code in the /includes/functions/general.php under function tep_redirect as it's just not refreshing the <div id="divShoppingCard"> for some reason... I can't pinpoint why either? any other ideas...

Link to comment
Share on other sites

  • 2 months later...

Is there (PLEASE!!! :'( ) somebody who can update the contribution (+install.txt) to make it complete with the flying image?? I've tried all kind of things mentioned in this thread but.............no luck (or knowledge...hehe).'

greetings,

Chris

Link to comment
Share on other sites

  • 2 weeks later...
The flying image is not part of the original MOD's code. How to modidy the mod is explained earler in this thread

 

Hello,

 

I have installed this contribution and got it working except for

the flying image.(with the wheel and tick followed by updating

the cart with quantity)

Despite a couple of requests by others for a clear explanation

of how to implement the fly effect, the only answer seems to be yours referring

perhaps to posts 35- 36 where the differences between

cool version and the contribution version have been highlighted.

 

But the post has mentioned that swapping the code didn't work.

 

Reading through the posts and looking at working sites, I have

seen that your www.thefrenchybee.com is the only other site

where the flying image effect is working.

 

Could you please explain, for everyone's benefit if swapping

the code as in posts 35-36 is way ?

 

There seems to be some confusion about the division "flyimg"

which is also reffered as fly_img (in product_info) and flyDiv (to insert in the css)

 

Are they the same ? ( I mean is there only ONE correct). There is no

mention of this in the readme file.

 

There is also no mention if you need to define in the stylesheet a

div id="divShoppingCard" which appears in the read me file.

 

It is a nice contribution, but need the flying effect or some other

strong trick to catch the attention of the customer that the

cart has been updated.

Link to comment
Share on other sites

It is a nice contribution, but need the flying effect or some other

strong trick to catch the attention of the customer that the

cart has been updated.

 

That would sure be nice. I have been waiting since May 2006 to implement this contribution.

Link to comment
Share on other sites

Hi,

 

I just installed this contribution on a clean oscommerce site, but I got this error whenever clicked on the buy now button on the product listings:

 

JavaScript code generated by backend is invalid! // BEGIN Subsys_JsHttpRequest_Js Subsys_JsHttpRequest_Js.dataReady( '11725666761723', // this ID is passed from JavaScript frontend '\n \n

 

This error is in the position where the shopping cart is located. However the product was added into the cart after a refreshing of the page. Can anyone help me to fix this problem? Thank you.

Link to comment
Share on other sites

Hey, I got no experience with ajax so just got some fast questions:

 

1) Will I need some program installed for ajax to work (like java)

 

2) Im working on a store for downloads at the moment, can this contribution add products from product listing even if it the product got one attribute?

Link to comment
Share on other sites

  • 2 weeks later...

Hey again, I now now what ajax is... quite well. Anyways I also now how to get buy now to work with attributes but I still got a question.

 

First of all I would like to give you people a tips :)

In column_right.php you sould change the statement to this:

	if  (basename ($PHP_SELF,".php") != 'shopping_cart') {
?>
 <tr>
   <td style="padding: 0">
   <script language="JavaScript" src="includes/ajax_sc.js"></script>

	 <div id="divShoppingCard"><table border="0" width="100%" cellspacing="0" cellpadding="2"><?php  require(DIR_WS_BOXES . 'shopping_cart.php'); ?>
	 </table></div>
   </td>
 </tr>
<?php
} else {

require(DIR_WS_BOXES . 'shopping_cart.php');

}

This way you will update the cart on the shopping_cart page (otherwise you would just update the box)

 

Okay now heres my question:

In my shopping cart I got remove_product also so I was wondering how to get this to act like add product? They both are quite similar one remove and the other add and you still define the product id and so on but when I try to just change the add with remove it will still send me to the shopping cart page.

 

For example here is my action for removing products:

'action=remove_product&products_id='

And here is the action for adding products:

'action=buy_now&products_id='

shoudnt I be able to get this to work kinda easy?

 

PS: do you you also get sent to shopping cart when using IE 6.0?

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

We are also using this contribution and we have some issues when the site is running under Apple Safari browser?

Under IE 6+ and Firefox it works great.

 

Do you guys have ever seen this issue ?

 

Is there anything I need to change on the code to make it compatible?

I was thinking about the XMLHTTPRequest object...

 

Thanks in advance for all your help.

Link to comment
Share on other sites

Hi,

 

We are also using this contribution and we have some issues when the site is running under Apple Safari browser?

Under IE 6+ and Firefox it works great.

 

Do you guys have ever seen this issue ?

 

Is there anything I need to change on the code to make it compatible?

I was thinking about the XMLHTTPRequest object...

 

Thanks in advance for all your help.

 

No problem on Safari on my end, everything seems to be cross browser compatible.

I still can't get the flying effect working in the listing page (JavaScript code generated by backend is invalid, like betty88)

Link to comment
Share on other sites

  • 4 weeks later...
Hi,

 

We are also using this contribution and we have some issues when the site is running under Apple Safari browser?

Under IE 6+ and Firefox it works great.

 

Do you guys have ever seen this issue ?

 

Is there anything I need to change on the code to make it compatible?

I was thinking about the XMLHTTPRequest object...

 

Thanks in advance for all your help.

 

Im also having this problem, but when viewing other peoples sites it works fine.

 

 

anybody help me out?

Link to comment
Share on other sites

Right, this is a nightmare. I love the way the ajax works on the site and it is something i actually really need because you don't lose your place on the page when scrolling down.

 

Here is the link:

 

My Site

 

Please, if somebody can help out with the problem with safari (loading.gif just spins and even on refresh nothing is added to the cart!) i would be truely grateful!

 

Although it works fine on the product_info.php, just not the index.php.

 

I know it can be fixed as the problem doesn't exist on the source site.

 

Thanks

Edited by majorp
Link to comment
Share on other sites

  • 2 weeks later...

Hi There!

 

I having some problems with inserting the ajax code in my html_output..!

 

Any help would be great!!

 

<?php
/*
 $Id: html_output.php,v 1.56 2003/07/09 01:15:48 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

////
// Ultimate SEO URLs v2.1
// The HTML href link wrapper function
 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
	global $seo_urls;				
			if ( !is_object($seo_urls) ){
					if ( !class_exists('SEO_URL') ){
							include_once(DIR_WS_CLASSES . 'seo.class.php');
					}
					global $languages_id;
					$seo_urls = new SEO_URL($languages_id);
			}
	return $seo_urls->href_link($page, $parameters, $connection, $add_session_id);
 }


////
// The HTML image wrapper function
 function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  return false;
}
// begin radders added
 $src = tep_image_resample($src,$width,$height);
//end radders added


// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';

if (tep_not_null($alt)) {
  $image .= ' title=" ' . tep_output_string($alt) . ' "';
}

if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
  if ($image_size = @getimagesize($src)) {
	if (empty($width) && tep_not_null($height)) {
	  $ratio = $height / $image_size[1];
	  $width = $image_size[0] * $ratio;
	} elseif (tep_not_null($width) && empty($height)) {
	  $ratio = $width / $image_size[0];
	  $height = $image_size[1] * $ratio;
	} elseif (empty($width) && empty($height)) {
	  $width = $image_size[0];
	  $height = $image_size[1];
	}
  } elseif (IMAGE_REQUIRED == 'false') {
	return false;
  }
}

  if (tep_not_null($width) && tep_not_null($height)) {
  $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
} 

/*	// BEGIN Code Keep Image Proportions
if (tep_not_null($width) && tep_not_null($height)) {
  if (IMAGE_CONSTRAIN_PROPORTIONS == 'true') {
	$image_size = @getimagesize($src);
	if ($image_size[0] <> 0) {
	  $ratio = $width / $image_size[0];
	  if ($image_size[1]*$ratio > $height) {
		$ratio = $height / $image_size[1];
		$width = $image_size[0] * $ratio;
	  }
	  else {
		$height = $image_size[1] * $ratio;
	  }
	}
	$image .= ' width="' . tep_output_string($width) . '" height="' .
tep_output_string($height) . '"';
  }
}
else {
  $image .= ' width="' . tep_output_string($width) . '" height="' .
tep_output_string($height) . '"';
}
*/// END Code Keep Image Proportions

if (tep_not_null($parameters)) $image .= ' ' . $parameters;

$image .= '>';

return $image;
 }

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
 function tep_image_submit($image, $alt = '', $parameters = '') {
global $language;

$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

$image_submit .= '>';

return $image_submit;
 }

////
// Output a function button in the selected language
 function tep_image_button($image, $alt = '', $parameters = '') {
global $language;

return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);
 }

////
// Output a separator either through whitespace, or with an image
 function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
 }




////
// Output a form
 function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
$form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';

if (tep_not_null($parameters)) $form .= ' ' . $parameters;

$form .= '>';

return $form;
 }

////
// Output a form input field
 function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
$field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
  $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
} elseif (tep_not_null($value)) {
  $field .= ' value="' . tep_output_string($value) . '"';
}

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

return $field;
 }

////
// Output a form password field
 function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
return tep_draw_input_field($name, $value, $parameters, 'password', false);
 }

////
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
 function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
$selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';

if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
  $selection .= ' CHECKED';
}

if (tep_not_null($parameters)) $selection .= ' ' . $parameters;

$selection .= '>';

return $selection;
 }

////
// Output a form checkbox field
 function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
 }

////
// Output a form radio field
 function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);
 }

////
// Output a form textarea field
 function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
$field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
  $field .= stripslashes($GLOBALS[$name]);
} elseif (tep_not_null($text)) {
  $field .= $text;
}

$field .= '</textarea>';

return $field;
 }

////
// Output a form hidden field
 function tep_draw_hidden_field($name, $value = '', $parameters = '') {
$field = '<input type="hidden" name="' . tep_output_string($name) . '"';

if (tep_not_null($value)) {
  $field .= ' value="' . tep_output_string($value) . '"';
} elseif (isset($GLOBALS[$name])) {
  $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
}

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

return $field;
 }

////
// Hide form elements
 function tep_hide_session_id() {
global $session_started, $SID;

if (($session_started == true) && tep_not_null($SID)) {
  return tep_draw_hidden_field(tep_session_name(), tep_session_id());
}
 }

////
// Output a form pull down menu
 function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<select name="' . tep_output_string($name) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

for ($i=0, $n=sizeof($values); $i<$n; $i++) {
  $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
  if ($default == $values[$i]['id']) {
	$field .= ' SELECTED';
  }

  $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';
}
$field .= '</select>';

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
 }

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = '', $parameters = '') {
$countries_array = array(array('id' => '204', 'text' => 'Switzerland'));
$countries = tep_get_countries();

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }
// begin radders added
function tep_image_resample($src,$width,$height) {

define(JPEGQUALITY, 90);
define(ALLOWSQUASH,0.10);
if ($src=='') {
	return $src;
	}
$i = @getimagesize( $src );   // 1-gif (ignore), 2-jpeg, 3-png

if (!(($width == SMALL_IMAGE_WIDTH) && ($height == SMALL_IMAGE_HEIGHT))) {
	return $src; // can amend to work with other images
	}
if (!( ($i[2] == 3) || ($i[2] ==2))) {
	return $src;
	}

$file = eregi_replace( '\.([a-z]{3,4})$', "-{$width}x{$height}.\\1", $src );  // name of resampled image
if (is_file( $file ) ) {	
	return $file;
}

$scr_w	 =  $i[0];
$scr_h	 = $i[1];
if (($scr_w * $scr_h * $width * $height) == 0) {
	return $src;
	}

$howsquashed = ($width / $height * $scr_h / $scr_w);
if (((1 / (1 + ALLOWSQUASH)) < $howsquashed) && ($howsquashed < (1 + ALLOWSQUASH))) $simpleway='true';
$scalefactor = min($width/$scr_w, $height/$scr_h);		  
$scaled_w	= (int)($scr_w * $scalefactor);
$scaled_h	 = (int)($scr_h * $scalefactor); 
$offset_w	= max(0,round(($width - $scaled_w) / 2,0));
$offset_h	 = max(0,round(($height - $scaled_h) / 2)); 
	$dst = DIR_FS_CATALOG . '/' . $file; 
  	$dstim = @imagecreatetruecolor ($width, $height);
$background_color = imagecolorallocate ($dstim, 255, 255, 255);
imagefilledrectangle($dstim, 0, 0, $width, $height, $background_color);
if ( $i[2] == 2) {
	$srcim = @ImageCreateFromJPEG ($src); // open
}
elseif ( $i[2] == 3) {
	$srcim	 = @ImageCreateFromPNG ($src);
}
if ($simpleway == 'true') {	
	imagecopyresampled ($dstim, $srcim, 0, 0, 0, 0, $width, $height, $scr_w, $scr_h);	
}
else {
	$intim = @imagecreatetruecolor ($width, $height); 
	imagecopyresampled ($intim, $srcim, $offset_w, $offset_h, 0, 0, $scaled_w, $scaled_h, $scr_w, $scr_h);
	imagecopy ( $dstim, $intim, $offset_w, $offset_h, $offset_w, $offset_h, $scaled_w, $scaled_h);
	imagedestroy ($intim);
}
if ( $i[2] == 2) {
	imagejpeg ($dstim , $dst , JPEGQUALITY);  
}
elseif ( $i[2] == 3) {
	imagepng ($dstim , $dst);
}
imagedestroy ($srcim);
imagedestroy ($dstim);
return $file;				 // Use the newly resampled image
}
// end radders added
////rmh referral
// Creates a pull-down list of sources
 function tep_get_source_list($name, $show_other = false, $selected = '', $parameters = '') {
$sources_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$sources = tep_get_sources();

for ($i=0, $n=sizeof($sources); $i<$n; $i++) {
  $sources_array[] = array('id' => $sources[$i]['sources_id'], 'text' => $sources[$i]['sources_name']);
}

if ($show_other == 'true') {
  $sources_array[] = array('id' => '9999', 'text' => PULL_DOWN_OTHER);
}

return tep_draw_pull_down_menu($name, $sources_array, $selected, $parameters);
 }

?>

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

 

I have the same problem than a.niedermann

 

The code sequence to replace doesn't exist anymore in html_output. Already replaced by SEO tep_href_link function.

 

Does Ajax buy now works with SEO ?

 

Thanks,

Edited by guinnessboy
Link to comment
Share on other sites

  • 2 weeks later...
I have also disabled GZIP Compression and inserted that line yet i have an unusual problem.

 

When i click on "Buy Now" the rotating button comes and keeps rotating. If i reload the page then the item is added to the cart.

 

Has anyone got this to work with STS v4.2 (Latest Version)

 

Please help in this matter.

 

 

I'm using STS 4.5 and I got it working by changing

if (strstr($scriptbasename, "popup")|| strstr($scriptbasename, "info_shopping_cart"))

in sts_default to

if (strstr($scriptbasename, "popup")|| strstr($scriptbasename, "info_shopping_cart") || strstr($scriptbasename, "ajax"))  

 

I enabled infoboxes and created infobox_shopping_cart.php.html and wrapped like so:

 

     <tr>
      <td style="padding: 0">
      <script language="JavaScript" src="includes/ajax_sc.js"></script>
        <div id="divShoppingCard"><table border="0" width="100%" cellspacing="0" cellpadding="2">$content</table></div>
      </td>
    </tr>

 

Hope this helps Someone

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...