fraizor Posted June 6, 2022 Share Posted June 6, 2022 I had been hitting my head with the wall for the previous 3 days trying to add a tracking code to an order through Prestashop webservice i tried POST and MODIFY requests but non are working every request i try either return the need of a unrelated data, or it caused the order page to crash ! PUT/POST request (causes the order page in BO to crash ! ) <prestashop>\n\t<order>\n\t\t<shipping_number>123</shipping_number><id_address_delivery>12352</id_address_delivery><id_address_invoice>12352</id_address_invoice><id_cart>26565</id_cart><id_currency>3</id_currency><id_lang>1</id_lang><id_customer>14186</id_customer><id_carrier>48</id_carrier><module>codwfeeplus</module><payment>Cash on delivery with fee (COD) PLUS</payment><total_paid>0.000000</total_paid><total_paid_real>0.000000</total_paid_real><total_products>0.400000</total_products><total_products_wt>0.420000</total_products_wt><conversion_rate>1.000000</conversion_rate><id>13430</id>\n\t</order>\n</prestashop> any one have a sample code of editing order's tracking code ? Link to comment Share on other sites More sharing options...
Hamilton Posted June 6, 2022 Share Posted June 6, 2022 This doesn't directly address the exact function you are asking about, but for the last years, I have been using this paid module to batch import tracking numbers and change the status to shipped: https://addons.prestashop.com/en/delivery-tracking/31050-tracking-numbers-import.html 1 Link to comment Share on other sites More sharing options...
zoombamboom Posted October 27 Share Posted October 27 I am looking at the same thing at the moment. Tracking number is located in the order_carrier table and the field is called tracking _number. It is not in the order table as your code suggests. Link to comment Share on other sites More sharing options...
WebDesk Solution Posted November 5 Share Posted November 5 @fraizor To add a tracking number to an order using the PrestaShop web service, please review the code provided below. Create a new PHP file and paste the below code: <?php // Configuration define('PS_SHOP_PATH', '{{YOUR_STORE_URL}}'); // Replace with your store URL define('PS_WS_AUTH_KEY', '{{YOUR_STORE_AUTH_KEY}}'); // Replace with your store’s API key require_once('./PSWebServiceLibrary.php'); // Include PrestaShop Web Service Library try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, false); // Specify the order carrier ID to update $orderCarrierId = {{ORDER_CARRIER_ID}}; // Replace with the actual order carrier ID // Retrieve the order carrier resource $opt = array( 'resource' => 'order_carriers', 'id' => $orderCarrierId ); $xml = $webService->get($opt); // Update the tracking number in the XML $xml->order_carrier->tracking_number = {{TRACKING_NUMBER}}; // Replace with the tracking number // Send the updated XML back to the web service $opt = array( 'resource' => 'order_carriers', 'id' => $orderCarrierId, 'putXml' => $xml->asXML() ); $webService->edit($opt); echo "Tracking number updated successfully!"; } catch (PrestaShopWebserviceException $ex) { echo 'Error: '. $ex->getMessage(); } ?> Enable the web service in the PrestaShop back office if it has not already been enabled. This solution should help you add tracking numbers successfully! 1 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