atwebmaster Posted July 22, 2016 Share Posted July 22, 2016 hello all , It has been weeks now since im searching for a solution to this issue ... i'm trying to create an order within a web service call . This is the php code that i had : $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); // Here we set the option array for the Webservice : we want customers resources $id_address = $_POST['id_address']; $total_paid = $_POST['amount']; //$products = $_POST["products"]; $id_cart = $_POST["id_cart"]; $id_currency = $_POST['id_currency']; $id_customer = $_POST['id_customer']; $id_carrier = $_POST['id_carrier']; $product_id = $_POST['product_id']; $totalproducts = sizeof($product_id); //$product_attribute_id = $_POST['product_attribute_id']; $product_quantity = $_POST['product_quantity']; $id_lang = $_POST['id_lang']; //$channel = $_POST['channel']; //$secure_key = $_POST['secure_key']; // CREATE Order // CREATE Order $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/orders?schema=blank')); $xml->order->id_customer = $id_customer; $xml->order->id_address_delivery = $id_address; $xml->order->id_address_invoice = $id_address; $xml->order->id_cart = $id_cart; $xml->order->id_currency = $id_currency; $xml->order->id_lang = $id_lang; $xml->order->id_carrier = 3; $xml->order->current_state = 3; $xml->order->valid = 0; $xml->order->payment = 'PFX'; $xml->order->module = 'MOLPay'; $xml->order->total_paid = $total_paid; $xml->order->total_paid_tax_incl = $total_paid; $xml->order->total_paid_tax_excl = $total_paid; $xml->order->total_paid_real = $total_paid; $xml->order->total_products = $total_paid; $xml->order->total_products_wt = $total_paid; $xml->order->conversion_rate = '1'; $i=0; foreach ($product_id as $value) { $xml->order->associations->order_rows->order_row[$i]->product_id = $value; $xml->order->associations->order_rows->order_row[$i]->product_quantity = $product_quantity[$i]; $i++; } try { $opt = array('resource' => 'orders'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); $result = $xml; $id['order'] = $xml->order->id; $id['secure_key'] = $xml->order->secure_key; $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/order_histories?schema=blank')); $xml->order_history->id_order = $id['order']; $xml->order_history->id_order_state = '3'; $opt = array('resource' => 'order_histories'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); //var_dump($result); } catch(PrestaShopWebserviceException $ex) { $trace = $ex->getTrace(); $errorCode = $trace[0]['args'][0]; if ($errorCode==401) { echo 'Mauvaise cle authentification curl'; } else { echo 'Autre erreur : <br />'; echo $ex->getMessage().'<br />'; echo 'Code : '.$ex->getCode().'<br />'; echo 'Trace : '.print_r($ex->getTrace()).'<br />'; echo $ex->getFile().'<br />'; echo $ex->getLine().'<br />'; } } ?> and im getting this error </div>Autre erreur : <br />This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error. <br />Code : 0 <br />Array ( [0] => Array ( [file] => /home/zackrymf/public_html/mobile/customwebservices/PSWebServiceLibrary.php [line] => 241 [function] => checkStatusCode [class] => PrestaShopWebservice [type] => -> [args] => Array ( [0] => 500 ) ) [1] => Array ( [file] => /home/zackrymf/public_html/mobile/customwebservices/createOrder.php [line] => 74 [function] => add [class] => PrestaShopWebservice [type] => -> [args] => Array ( [0] => Array ( [resource] => orders [postXml] => your help is really appreciated . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now