Jump to content

Webservices Create order and carrier error


avatarusswtor

Recommended Posts

I have some problem with creating order via webservices is prestashop. I finaly manage to create order (client, addres and cars too), but there is something wrong with setting id_carrier. Despite what id_carrier i will set in order XML, order is created with default carrier (what is saved in preferences) Whats seems to be the problem?

Here is code I use to create order:

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
                                                      $xml = $webService->get(array('url' => PS_SHOP_PATH .'api/orders/?schema=synopsis'));

                                                    $xml->order->id_address_delivery = $id_adresu;
                                                    $xml->order->id_address_invoice  = $id_adresu;
                                                    $xml->order->id_cart = $id_koszyka;
                                                    $xml->order->id_currency = 1;
                                                    $xml->order->id_lang = 1;
                                                    $xml->order->id_customer = $id_klienta;
                                                    $xml->order->id_carrier = 25; 
                                                    //$xml->order->current_state = $current_state;
                                                    //$xml->order->order_states = $current_state;
                                                    $xml->order->module = $module;
                                                    $xml->order->valid = 0;
                                                    //$xml->order->id_shop_group = 1;
                                                    //$xml->order->id_shop = 1;
                                                    $xml->order->payment = $payment;
                                                    $xml->order->total_discounts = 0;
                                                    $xml->order->total_discounts_tax_incl = 0;
                                                    $xml->order->total_discounts_tax_excl = 0;
                                                    $xml->order->total_paid = $total_paid;
                                                    $xml->order->total_paid_tax_incl = $total_paid_tax_incl;
                                                    $xml->order->total_paid_tax_excl = 0;
                                                    $xml->order->total_paid_real = $total_paid_real;
                                                    $xml->order->total_products = $total_products;
                                                    $xml->order->total_products_wt = $total_products_wt;
                                                    $xml->order->total_shipping = $total_shipping;
                                                    $xml->order->total_shipping_tax_incl = $total_shipping_tax_incl;
                                                    $xml->order->total_shipping_tax_excl = 0;
                                                    $xml->order->conversion_rate = 1;
                                                    $opt = array('resource' => 'orders');
                                                    $opt['postXml'] = $xml->asXML();
                                                    $xml = $webService->add($opt);

and here is screen from my carriers in presta (with IDs)

carrier.png

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...