Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

xajax in osCommerce


youcool51

Recommended Posts

Dear all,

 

I've been surfing but nothing about xajax & osc issue(probably)

Have u guys ever use xajax in your shop? I was looking for

 

First, i'm newbie with coding, but i really wanna try ajax in my shop (attributes...etc...), so i found xajax (server side) and based it in product_info.php with attributes.

If i got something like shirt, it comes with Color(Red,Green,Blue) and Size(XL,L,M,S) options, so i tried to effect when i click the thumbnail, the product image and pulldown menu's option will be change asynchronous, stock also will be shown in option.

 

Now, i think it's half to success, anyone tried this before?

 

 

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

if i post the wrong area, please remove it and sorry for any inconvenience.

Link to comment
Share on other sites

I try this already

 

But can u explain a little bit more what you looking for.

 

1. Fisrt thing u need to understand how oscommerce work (the code)

2. And also how oscommerce save the information into the DB

3. Create the object xmlHttp

4. Create your landing php file

 

And go to go

Erwin D. Padilla

Web Developer and Linux Admin

Link to comment
Share on other sites

1. Fisrt thing u need to understand how oscommerce work (the code)

2. And also how oscommerce save the information into the DB

3. Create the object xmlHttp

4. Create your landing php file

 

And go to go

 

hi, thanks for reply!

try xajax already! you did? that's was great!

how u query your data from xajax function? i try no response....

 

1. In product_info.php, customer can select color & size via just one products_id, add to cart or notifly if out stock.

 

2. I also insert some columns into attributes table in DB

 

3. As i know, xajax is an open source PHP class library, seems just writing the PHP functions and returning xajax XML responses.

 

4. Just xajax<=>product.php, request<=>respones

Link to comment
Share on other sites

Everythime you make a change or Click event on the form. You need to call your xmlhttpd object (javascript file).

 

Create the function depending what you need.

Get the value of the form.

 

Call your php file. (work as background)

Here you make the function that you want to do.

U can update information, delete, insert, etc.

 

have luck

Erwin D. Padilla

Web Developer and Linux Admin

Link to comment
Share on other sites

i got a problem about data query with xajax function...

 

<?
require('includes/application_top.php');
require ('xajax.inc.php');
function abc(){ 

$objResponse = new xajaxResponse();
$p_options_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . "  where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
$p_options = tep_db_fetch_array($p_options_query);
 $objResponse->addAssign("outputDiv","innerHTML",$p_options['products_id']);
 return $objResponse;

$xajax = new xajax(); 
$xajax->registerFunction("abc");
$xajax->processRequests();

}
?>

 

  
<html><head>
<?php $xajax->printJavascript(''); ?>
</head><body>
<div id="outputDiv"></div><br/>
<button onClick="xajax_abc();" >Test Me</button>
</body></html>

 

it doesn't work, when i click that button...

but if i take off osc's database query code, function worked...

is any one can help me to resolve this?

Link to comment
Share on other sites

I can help you but i actually use ajax.

 

And it work fine.

 

Hey ruizerwin, sorry i gotta some question

 

how you select / query your database in ajax function? how's it coding?

 

i tried to use osc's query in the xajax function but it dosen't work

 

my ajax runs perfectly without any sql request

 

did i get something wrong with that?

Link to comment
Share on other sites

You need to know what you want example:

To save a specific shipping address on your address_book table:

1. Select all address book available on the DB

2. here will update the address book as primary default.

3. On change call the fucntion in javascript

<div>

<select name="users" onChange="updateAddress(this.value)">

<option value="">- Choose -</option>

<?php

$a_query = tep_db_query ("SELECT address_book_id, entry_street_address FROM " . TABLE_ADDRESS_BOOK . " WHERE cust_account = '" . (int)$cust_account . "'order by address_book_id");

while($a_result = tep_db_fetch_array($a_query))

{

?>

<option value="<?=$a_result[address_book_id];?>"><?=$a_result[address_book_id];?></option>

<?php

}

?>

 

4. your javascript fuction take the values also call the php file.

 

</select>

<div id="txtHint"></div>

<input type="text" name="cust_account" id="cust_account" value="<?= (int)$cust_account;?>" style="display:none;"/>

<div id='ajaxDiv'></div>

</div>

 

var xmlHttp

function updateAddress(str)

{

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert ("Browser does not support HTTP Request")

return

}

var url="Filename.php"

url=url+"?q="+str

url=url+"&sid="+Math.random()

xmlHttp.onreadystatechange=stateChanged

xmlHttp.open("GET",url,true)

xmlHttp.send(null)

location.reload();

}

 

function stateChanged()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{

document.getElementById("txtHint").innerHTML=xmlHttp.responseText

}

}

 

function GetXmlHttpObject()

{

var xmlHttp=null;

try

{

// Firefox, Opera 8.0+, Safari

xmlHttp=new XMLHttpRequest();

}

catch (e)

{

//Internet Explorer

try

{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e)

{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

}

return xmlHttp;

}

 

 

5. Your php file:

 

//***************************** UPDATE THE DEFAULT ADDRESS

if( $address_book_id !="")

{

tep_db_query("update " . TABLE_ADDRESS_BOOK . " SET address_book_id ='" . $address_book_id . "' where cust_id='" . (int)$customer_id . "'");

}

?>

Erwin D. Padilla

Web Developer and Linux Admin

Link to comment
Share on other sites

Hey ruizerwin, sorry i gotta some question

 

how you select / query your database in ajax function? how's it coding?

 

i tried to use osc's query in the xajax function but it dosen't work

 

my ajax runs perfectly without any sql request

 

did i get something wrong with that?

 

just to clarify a few things....

 

javascript cannot execute an sql query. since javascript runs in the browser it doesn't have access to the mysql database on the server. that's where the XLMHttpRequest object comes in. your javascript can use this object to make a request to some php code on your server to perform an sql query on it's behalf. then it receives some xml as a response with the information it needs. think of it as a proxy: javascript askes php to do the work, it can't do the work itself.

 

also from your code it looks like you might be confusing php and javascript. while you can use php to generate javascript dynamically, just like your html content is generated, don't confuse php code syntax with javascript code syntax. they are not the same.

 

i hope that helps.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...