Function to create order
Function Signature :- qtc_place_order($orderData)
This function is used to create/update order
Parameters : 1) $orderData
This function will take input as an object with following object data.
-
$orderData->userId -> This variable stores the id of user against whom order is being created. For guest checkout userId will be “0”.
-
$orderData->currency_code : (Optional) : 3 digit currency code. Current session currency will be used
-
$orderData->address-> This parameter should contain object of shipping and billing address. Shipping and billing address should contain all the information in object format as given below.
Shipping/Billing Address :
[id] => address Id
[user_id] => User against whom address is stored
[firstname] => First name of user
[middlename] => Middle name of user (Optional)
[lastname] => Last name of user
[vat_number] => Vat number (Optional)
[phone] => Contact number of user e.g 978546254
[address_title] => Title for address (Optional)
[user_email] => User email-id
[address] => Address of user
[land_mark] => Land mark for given address (Optional)
[zipcode] => Postal code for the address
[city] => City name
[country_code] => Country code
[state_code] => State Code
Response :
This method will return status inform of object for order being placed.
OrderStatus =>status = error/success
message = error message
order_id = Order id if order successfully created
Example
stdClass Object
(
// ‘products_data’ should contain all the information of products in order
[products_data] => Array
(
[0] => Array
(
[store_id] => 1
[product_id] => 2
[product_quantity] =>
// ‘ att_option’ should contain array with key as attribute id and value as selected attribute option
[att_option] => Array
(
[5] =>
[2] => 7
[6] => // Empty if attribute is not selected
[4] => 9
)
)
)
[userId] => 380
[address] => stdClass Object
(
[shipping] => (Only if shipping is enabled)
[billing] => stdClass Object
(
[id] => 1
[user_id] => 380
[firstname] => ankush
[middlename] => (Optional)
[lastname] => Maherwal
[vat_number] => 12345678901
[phone] => 1111111111
[address_title] => Office
[user_email] => ****@***.***
[address] => Office no 6, Silver Fern
[land_mark] => (Optional)
[zipcode] => (Optional)
[country_code] => 99
[state_code] => 1362
[city] => Pune
)
)
[coupon_code] =>Array
(
[0] => “SALE”
[1] => “BIGSALE”
[2] => “FREE”
)
)
Function to add/update shipping charges against order
For order level shipping
Array
(
[allowToPlaceOrder] => 1
[charges] => 30
[detailMsg] =>
[order_shipping_details] => {"allowToPlaceOrder":1,"charges":"30","detailMsg":""}
)
Function to apply/update tax charges against order
Function Signature :- qtc_apply_taxes ($taxDetails, $orderId)
Function Signature :- qtc_apply_shipping($shippingDetails, $orderId)
$orderId => order id
$shippingDetails =>
For item level shipping
Array
(
[allowToPlaceOrder] => 1
[charges] => 71.46 // Total shipping charges for all products and their respective units
[itemShipMethDetail] => Array
(
[0] => Array
(
[item_id] => 2
[methodId] => 1
[name] => express
[totalShipCost] => 34.2
[plugMethRateId] => 1
[product_attributes] => 4
[product_attribute_names] => color:green
[client] => qtc_default_zoneshipping
)
)
)
$orderId => order id
$taxDetails =>
stdClass Object
(
[charges] => 0
[orderTax] => 0
[itemsTaxDetail] => Array
(
// Array index for tems
[0] => Array
(
[item_id] => 2
[taxAmount] => 185.08
[product_attributes] => 4
[product_attribute_names] => color:green
[taxdetails] => Array
(
// index as tax rate id
[2] => Array
(
[taxrate_id] => 2
[name] => service tax
[rate] => 2.000
[amount] => 26.44
)
[1] => Array
(
[taxrate_id] => 1
[name] => vat
[rate] => 12.000
[amount] => 158.64
)
)
)
)
)