Create the table in the joomla data base as
CREATE TABLE `Database_name`.`iphon_cart` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`device_id` VARCHAR( 50 ) NOT NULL ,
`product_id` INT( 11 ) NOT NULL ,
`sizeData` VARCHAR( 50 ) NOT NULL ,
`widthData` INT( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(__FILE__)) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
$mainframe =& JFactory::getApplication('site');
select1($table,$row,$where);
$this->items = count($results);
//echo "narehs==".$product_id."
";
for($k=0 ; $k<$this->items; $k++){
$cart = array();
$description = '';
if($results[$k][1]){
$description .= 'Size:'.$results[$k][1].'
';
}
if($results[$k][2]){
$description .= 'Width:'.$results[$k][2].'';
}
$_SESSION['cart']['idx'] =$this->items;
//$_SESSION['cart']['idx']=1;
if($_SESSION['cart']){ // ---------------------Runs when Cart Has more than One Items
$pushCart = array();
$pushCart['quantity']=1;
$pushCart['product_id']=$results[$k][0];
$pushCart['parent_id']='';
$pushCart['category_id']='';
$pushCart['description']=$description ;
//echo "".print_r($_SESSION['cart'])."
";
array_push($_SESSION['cart'],$pushCart);
}
else{ // ---------------------------Runs when Cart is totaly Empty
$cart[0]['quantity']=1;
$cart[0]['product_id']=$results[$k][0];
$cart[0]['parent_id']='';
$cart[0]['category_id']='';
$cart[0]['description']=$description ;
$_SESSION['cart'] = $cart;
}
//$this->items=$_SESSION['__default']['session.timer.start'];
//$this->xmlDocument('cartXML');
}
if($this->delete($table,$where)){
header ('location:../index.php?page=shop.cart&Itemid=1&option=com_virtuemart&cartReset=N&redirected=1&Itemid=1' );
}
else{
return false;
}
}
public function addToCart($table,$data){
if($data['product_id']){
$this->insert($table,$data);
}
$where = "device_id = '".$data['device_id']."'";
$results = $this->select1($table,"*",$where);
$this->items = count($results);
$this->xmlDocument('cartXML','xml');
}
public function cartXML(XMLWriter $xml, $data=0){
$xml->writeElement("items",$this->items);
}
}
$virtualCart = new cart('C');
$virtualCart->connect();
if($_REQUEST['command']=='showCart'){
$device_id = $_REQUEST['device_id'];
$where = "device_id = '$device_id'";
$virtualCart->showCart('iphon_cart',$where);
}
if($_REQUEST['command']=='addToCart'){
$data =array();
$data['device_id'] = $_REQUEST['device_id'];
$data['product_id'] = $_REQUEST['product_id'];
$data['sizeData'] = $_REQUEST['sizeData'];
$data['widthData'] = $_REQUEST['widthData'];
$virtualCart->addToCart('iphon_cart',$data);
}
//echo "
".print_r($_SESSION)."
";
DIRECTOIONS TO USE API:-
Lets suppose Device Uniqe Id UDID = 555 and Product Id =77.
(1) To add Product into CART Pass the variable in URL as given below:- |
http://www.everythingforyourfeet.com/abc123/apiCart.php?command=addToCart&device_id=555&product_id=77
(2) To Show Cart On browser :-
http://www.everythingforyourfeet.com/abc123/apiCart.php?command=showCart&device_id=555

5 comments:
i m looking for this code. thanks it helps me alot
Thanks Dude . u solved my problem .Million Thanks 2 u
Thanks for this! - bookmarked the thread :-)
good share, great article, very useful for us...thank you
Joomla websites are very impressive to use. As there are various joomla real estate component which can be used to design a joomla website. The real estate websites designed in joomla are very user friendly.
Post a Comment