function returnsuccess() { // mandatory function $orderid = JRequest::getVar("custom"); // orderid coming back from PP $txn_id = JRequest::getVar("txn_id"); // pp transaction ID $cfg = new sc_configuration(); $statuses = explode("\r\n", $cfg->get("ostatus")); $status = $statuses[count($statuses) - 1]; // set the status to the last one in the list $scorder = new order(); $scorder->load($orderid); $scorder->ordercode = $txn_id; $scorder->status = $status; $scorder->store(); return; }
function store_new_order($cart, $ship) { if (count($cart) == 0) { return; } // $db =& JFactory::getDBO(); //get statuses $cfg = new sc_configuration(); $statuses = explode("\n", trim($cfg->get("ostatus"))); // get the first status from the list $status = isset($statuses[0]) ? trim($statuses[0]) : JText::_('SC_NO_STATUS'); $juser = JFactory::getUser(); //create order info from the details page $o = new order(); $o->bind($_POST); $o->id = null; // ensure a new order is created here $o->j_user_id = $juser->id; // add the user id $o->orderdt = mktime(); $o->status = $status; $o->customfields = serialize($_REQUEST); if ($ship['enabled']) { $o->shipCost = $ship['cost']; $o->shipRegion = $ship['region']; } $o->store(); $orderid = $o->_db->insertid(); $gtotal = 0; //create order details from cookie foreach ($cart as $key => $product) { unset($odet); $odet = new orderdetail(); $odet->id = null; $odet->orderid = $orderid; $odet->prodcode = $product->prodcode; $odet->qty = $product->quantity; $odet->unitprice = $product->finalprice; $odet->total = $product->quantity * $product->finalprice; $odet->shorttext = $product->prodname; $odet->option = $product->option; $odet->store(); $gtotal = $gtotal + $odet->total; //$db->insertObject("#__sc_odetails", $odet); } // get taxes based on shipping region (if any) $ctax = new taxes(); $taxrate = $ctax->getTax(@$ship['region']); $o = new order(); $o->load($orderid); $o->total = $gtotal; $o->tax = $gtotal * $taxrate; // $o->id=$orderid; $o->store(); // $db->updateObject("#__sc_orders", $o, "id"); // echo $db->getErrorMsg(); return $orderid; }