Jump to content



Latest News: (loading..)

- - - - -

(Contribution) Ajax Attribute Price change


  • Please log in to reply
13 replies to this topic

#1   crossbow888

crossbow888
  • Members
  • 1 posts
  • Real Name:Bowen Huang

Posted 10 March 2011 - 05:57 AM

Hi All,

I just installed Ajax Attribute Price Change. Basically the price shown on the product page should dynamically change based on what attributes a customer chooses before they even add to the shopping cart. The contribution is for OSC 2.2, but I'm using OSC 2.3.1. The code it modifies (I used manual installation) in product_info.php is basically the same as the OSC2.2 version. I uploaded the required ajax_onchange_price.php to my catalog directory too. But when I tested it out, I get an error on line 64 with the error details saying:

----------------------------------
Message: Unknown runtime error
Line: 64
Char: 5
Code: 0
URI: http://scoutdigitalusa.elementfx.com/catalog/product_info.php/products_id/29
----------------------------------

When I view the source code on the page, line 64 is part of this contribution's javascript in the <head> section inside the following "if" statement:

if(xmlHttpObj.readyState==4)
  {

THIS IS LINE 64 ==>    document.getElementById("display_price").innerHTML =  xmlHttpObj.responseText;

  }

This is a great contribution that many people were probably looking for, for a long time now. I have enough coding skill to make interface changes and such, but not in-depth in PHP and javascript. Any help will be great!

#2   ssoeb

ssoeb
  • Members
  • 116 posts
  • Real Name:soeb
  • Gender:Male
  • Location:India

Posted 01 April 2011 - 12:44 PM

View Postcrossbow888, on 10 March 2011 - 05:57 AM, said:

Hi All,

I just installed Ajax Attribute Price Change. Basically the price shown on the product page should dynamically change based on what attributes a customer chooses before they even add to the shopping cart. The contribution is for OSC 2.2, but I'm using OSC 2.3.1. The code it modifies (I used manual installation) in product_info.php is basically the same as the OSC2.2 version. I uploaded the required ajax_onchange_price.php to my catalog directory too. But when I tested it out, I get an error on line 64 with the error details saying:

----------------------------------
Message: Unknown runtime error
Line: 64
Char: 5
Code: 0
URI: http://scoutdigitalusa.elementfx.com/catalog/product_info.php/products_id/29
----------------------------------

When I view the source code on the page, line 64 is part of this contribution's javascript in the <head> section inside the following "if" statement:

if(xmlHttpObj.readyState==4)
  {

THIS IS LINE 64 ==>    document.getElementById("display_price").innerHTML =  xmlHttpObj.responseText;

  }

This is a great contribution that many people were probably looking for, for a long time now. I have enough coding skill to make interface changes and such, but not in-depth in PHP and javascript. Any help will be great!

Thanks and Regards

Soeb Shaikh

#3   ssoeb

ssoeb
  • Members
  • 116 posts
  • Real Name:soeb
  • Gender:Male
  • Location:India

Posted 01 April 2011 - 01:03 PM

please follow the manual installation.txt, also put ajax_onchange_price.php in your root folder where product_info.php is situated. i have tested also in osc2.3.1. and it will running nicely.
Thanks and Regards

Soeb Shaikh

#4   figue

figue
  • Members
  • 4 posts
  • Real Name:Fernando

Posted 05 April 2011 - 02:38 PM

Hi ssoeb, sorry for my bad English, is a translation of google.
I tried your contribution but does not work with the prices of the products on offer.
I refer to the version 2.2

Have you checked this?


Thanks for your help.

Greetings,
figue

#5   PupStar

PupStar
  • Members
  • 562 posts
  • Real Name:Mark
  • Gender:Male

Posted 05 April 2011 - 07:14 PM

Hi,

I am trying to integrate this into 2.3.1 which has QTPro installed and I am struggling with adapting the following line

$out.='<tr><td align="right" class=main><strong>'.$attributes[$o]['oname'].":</strong></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']),$attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n";

to incorporate this line from the manual installation txt file.

echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, 		  $selected_attribute,' id="cmbooption_'.$opt_count.'"  onchange="getPrice('.$product_info['products_price'].','.(int)$HTTP_GET_VARS['products_id'].','.$all_option_js.')"'); ?></td>

Any help would be appreciated.

Thanks

Mark

#6   matevzl

matevzl
  • Members
  • 4 posts
  • Real Name:Matevz Likar

Posted 11 April 2011 - 12:56 PM

Hi,

I integrated the contribution in my shop and it works, but it changes the currency symbol (€) to an unknown symbol (�).
It looks like a mismatch of the encoding tables. I am running my shop on utf-8, but if I change the character encoding in browser to 8859-1 I get the € sign back.
I tried with the encoding of the ajax_onchange_price.php but had no success. Is there a place in the code itself that I could change to get it working?

Any help will be great!

#7   demonhunter704

demonhunter704
  • Members
  • 7 posts
  • Real Name:Ernie

Posted 19 April 2011 - 03:31 PM

I get the following error when using your productinfo.php supplied. The script works fine, but i have this annoying error at the top of my screen.


"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pandpi5/public_html/www.headercardpackaging.com/catalog/product_info.php:1) in /home/pandpi5/public_html/www.headercardpackaging.com/catalog/includes/functions/sessions.php on line 102"

Any help would be greatly appreciated. Thanks!

Edited by demonhunter704, 19 April 2011 - 03:31 PM.


#8   PLUGGER

PLUGGER
  • Members
  • 34 posts
  • Real Name:Plugger
  • Gender:Male
  • Location:Λουτράκι, Κορινθίας, Ελλάς

Posted 16 June 2011 - 07:18 PM

View Postdemonhunter704, on 19 April 2011 - 03:31 PM, said:

I get the following error when using your productinfo.php supplied. The script works fine, but i have this annoying error at the top of my screen.


"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pandpi5/public_html/www.headercardpackaging.com/catalog/product_info.php:1) in /home/pandpi5/public_html/www.headercardpackaging.com/catalog/includes/functions/sessions.php on line 102"

Any help would be greatly appreciated. Thanks!


Remove

<script type="text/javascript">
function getxmlHttpObj()
{
		var xmlHttp;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		return xmlHttp;
}

function getPrice(price,product_id,attr_arr)
{
		opt_id = document.getElementById("optionsid").value;

		xmlHttpObj = getxmlHttpObj();

		xmlHttpObj.onreadystatechange=function()
		{
			if(xmlHttpObj.readyState==4)
			{
				document.getElementById("display_price").innerHTML =  xmlHttpObj.responseText;
			}
		}
		xmlHttpObj.open("GET","ajax_onchange_price.php?price="+price+"&option_id="+opt_id+"&product_id="+product_id+"&product_opt="+attr_arr,true);
		xmlHttpObj.send();
		
}
</script>

from the product_info.php page (OSC231 only) and add this code to the includes/template_top.php file before the </head>
If it don't fit - Get a bigger hammer

#9   DirkTromp

DirkTromp
  • Members
  • 17 posts

Posted 08 July 2011 - 01:55 PM

Anybody have this contribution working with Option Types V2?

#10   myvapefix

myvapefix
  • Members
  • 4 posts
  • Real Name:Shawn Sanders
  • Gender:Male

Posted 29 December 2011 - 05:24 PM

Is there an actual manual install.txt for 2.3.1?  I kept getting T_String error and I know this has to do with a missing element, but without help I could not transpose between the two versions.  Please help!

Thanks.

View Postssoeb, on 01 April 2011 - 01:03 PM, said:

please follow the manual installation.txt, also put ajax_onchange_price.php in your root folder where product_info.php is situated. i have tested also in osc2.3.1. and it will running nicely.


#11   fan4chevy

fan4chevy
  • Members
  • 367 posts
  • Real Name:Charles

Posted 21 February 2012 - 07:22 AM

In osc 2.3.1 there is no <head> in product_info.php making the directions not able to be followed where it begins by saying:

Change the following set of codes in your product_info.php page.

Place the following code for AJAX in your <head> tag.

#12   fan4chevy

fan4chevy
  • Members
  • 367 posts
  • Real Name:Charles

Posted 21 February 2012 - 07:45 AM

I see that you had a note that said to put the <head> statement into  includes/template_top.php. However, as you go further with the instructions you will find that very few things in the instructions are for 2.3.1. The files are not in there.

I would not install this until there is instructions for 2.3.1 as it does not work.

#13   NimaP

NimaP
  • Members
  • 146 posts
  • Real Name:wdwad
  • Gender:Male

Posted 03 March 2012 - 07:59 AM

i got this to work on 2.2 which is great because the other contributions had problems.

quick question though, there seems to be a number formating problem. when going through the drop down choices of different attributes. If you go through the list and return to another attribute, the number doesn't round up to the hundredths.

Instead of showing $27.95 it will show $27.949999999999992

http://www.alcotesters.com/safeway-disposable-breathalyzer-p-47.html

here is my page to see the problem in action. any suggestion would be great. thanks!

#14   leopard330

leopard330
  • Members
  • 1 posts
  • Real Name:richard

Posted 06 June 2012 - 11:51 AM

You must use the sprintf function.

sample, if you have in ajax_onchange_prince.php this:

echo '<td class="main" align="right" colspan=3 id="display_price"><h3>' . $products_price . '</h3></td>';

change it to.

$products_price2 = sprintf("%01.2f", $products_price);
echo '<td class="main" align="right" colspan=3 id="display_price"><h3>' . $products_price2 . '</h3></td>';

Also add:
$products_price2 = sprintf("%01.2f", $products_price);

And change $products_price to $products_price2