Jump to content

Webservice Order Creation


Recommended Posts

Hi,

I'm developing a module for taking orders from a different website.

The customer, cart and order are created via the prestashop webservice.
Everything works fine, but not the creation of the order.

There are two cases. Case 1 use Carrier 1, Case 2 use Carrier 2.
If the order is case 1 and the default carrier is carrier 1 it works.

But if the order is case 2 and the default carrier is carrier 1, prestashop will use the default carrier instead using carrier 2.

These both carriers have the nearly the same settings except for the price.

Example:
Default carrier is carrier 1.

Customer is created. Cart also with id_carrier = Carrier 2 ID

Cart has also the id_carrier in the database.
Order creation with the following xml:
 

<order>
	<id_address_delivery required="true" format="isUnsignedId">666</id_address_delivery>
	<id_address_invoice required="true" format="isUnsignedId">666</id_address_invoice>
	<id_cart required="true" format="isUnsignedId">485</id_cart>
	<id_currency required="true" format="isUnsignedId">1</id_currency>
	<id_lang required="true" format="isUnsignedId">1</id_lang>
	<id_customer required="true" format="isUnsignedId">500</id_customer>
	<id_carrier required="true" format="isUnsignedId">15</id_carrier>
	<current_state format="isUnsignedId">12</current_state>
	<module required="true" format="isModuleName">sofortbanking</module>
	<invoice_number/>
	<invoice_date/>
	<delivery_number/>
	<delivery_date/>
	<valid>0</valid>
	<date_add format="isDate"/>
	<date_upd format="isDate"/>
	<shipping_number notFilterable="true" format="isTrackingNumber"/>
	<id_shop_group format="isUnsignedId">1</id_shop_group>
	<id_shop format="isUnsignedId">1</id_shop>
	<secure_key format="isMd5"/>
	<payment required="true" format="isGenericName">sofortbanking</payment>
	<recyclable format="isBool"/>
	<gift format="isBool"/>
	<gift_message format="isMessage"/>
	<mobile_theme format="isBool"/>
	<total_discounts format="isPrice"/>
	<total_discounts_tax_incl format="isPrice"/>
	<total_discounts_tax_excl format="isPrice"/>
	<total_paid required="true" format="isPrice">160.37</total_paid>
	<total_paid_tax_incl format="isPrice">160.37</total_paid_tax_incl>
	<total_paid_tax_excl format="isPrice"/>
	<total_paid_real required="true" format="isPrice">160.37</total_paid_real>
	<total_products required="true" format="isPrice">146.38</total_products>
	<total_products_wt required="true" format="isPrice">146.38</total_products_wt>
	<total_shipping format="isPrice">13.99</total_shipping>
	<total_shipping_tax_incl format="isPrice">13.99</total_shipping_tax_incl>
	<total_shipping_tax_excl format="isPrice"/>
	<carrier_tax_rate format="isFloat"/>
	<total_wrapping format="isPrice"/>
	<total_wrapping_tax_incl format="isPrice"/>
	<total_wrapping_tax_excl format="isPrice"/>
	<round_mode format="isUnsignedId"/>
	<round_type format="isUnsignedId"/>
	<conversion_rate required="true" format="isFloat">1</conversion_rate>
	<reference/>
<associations>
<order_rows nodeType="order_row" virtualEntity="true">
	<order_row>
	<id/>
	<product_id required="true">8</product_id>
	<product_attribute_id required="true"/>
	<product_quantity required="true">1</product_quantity>
	<product_name read_only="true" readOnly="true"/>
	<product_reference read_only="true" readOnly="true"/>
	<product_ean13 read_only="true" readOnly="true"/>
	<product_upc read_only="true" readOnly="true"/>
	<product_price read_only="true" readOnly="true"/>
	<unit_price_tax_incl read_only="true" readOnly="true"/>
	<unit_price_tax_excl read_only="true" readOnly="true"/>
	</order_row>
</order_rows>
</associations>
</order>
</prestashop>


The shipping costs of Carrier 2 are 13.99. The order is created successfully - but with wrong carrier and shipping costs.
Also in database there are the wrong values. 4.99 instead of 13.99 and the wrong carrier id in ps_order_carrier.

 

I saw this post, but there were no solution:
https://www.prestashop.com/forums/topic/481475-webservices-create-order-and-carrier-error/

Also I read that:

http://forge.prestashop.com/browse/PSCFV-10980
"That is a normal behavior.
When you create an order with the webservices, it will not add it directly in the database but use the PaymentModule::validateOrder() method so you need to associate the carrier to your cart prior to add the order."

I checked my ps_cart table and looked for the right customer's cart and saw that it has the id of carrier 2. But the order has id of carrier 1. In the ps_orders table, the order has also the right cart id.

I assume, that if you create an order via prestashop webservices, the order will always use the default carrier.
Is that right and how to fix it?

Link to comment
Share on other sites

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...