shop.order.calculate
Viewing of order parameters without saving them to database.
Parameters
-
id
POST
Order ID.
-
items
POST
Optional
Order items data array. Each items’s sub-array can contain the following values:
- []['sku_id']: ID of a product variant to which an order item is related.
- []['quantity']: ordered product variant’s quantity in the decimal(15,3) format. If this value is not specified then 1 is set by default.
- []['price']: ordered product variant’s price, expressed in the order currency, in the decimal(15,4) format. If this value is not specified then the current variant price from the 'shop_product_skus' table is set by default in the case if the variant has not been deleted from the product catalog.
- []['total_discount']: amount of discount applied for the entire quantity of a particular order item, expressed in the order currency, in the decimal(15,4) format.
- []['stock_id']: ID of the stock from which ordered variant’s quantity must be withdrawn. If this value is not specified then one of the existing stock IDs is used by default.
- []['virtual_stock_id']: ID of the virtual stock from which ordered variant’s quantity must be withdrawn. If this value is not specified then one of the existing virtual stock IDs is used by default.
- []['services']: array of data related to the services associated with an ordered product variant.
- []['services'][]['item_id']: ID of an order item representing a service. If an ID is specified then this method updates information about the corresponding service of a particular order item. If this value is empty, and values 'items'[]['services'][]['service_id'] and 'items'[]['services'][]['service_variant_id'], are specified, then either an existing service for the particular order item is updated or a new service with these values is added to that item. Services whose 'items'[]['services'][]['item_id'] values are missing in a POST request for the particular order item are removed by this method.
- []['services'][]['price']: service cost, expressed in the order currency, in the decimal(15,4) format.
- []['services'][]['total_discount']: discount applied to a service, expressed in the order currency, in the decimal(15,4) format. -
customer
POST
Optional
Customer data array.
-
shipping_address
GET
Optional
Associative array of shipping address fields.
-
billing_address
GET
Optional
Associative array of billing address fields.
-
discount
POST
Optional
Discount information in one the following formats:
- Discount amount in order currency.
- null, if discount shold not be changed.
- true, if discount must be re-calculated automatically. -
params
POST
Optional
Array of order parameters for shop_order_params table.
-
currency
POST
Optional
Order’s 3-letter currency code.
-
payment_params
POST
Optional
Associative array of payment method parameters.
-
shipping_params
POST
Optional
Associative array of shipping variant parameters.
-
shipping
POST
Optional
Shipping cost, expressed in the order currency.
-
tax
POST
Optional
Tax value saving mode. String value 'calculate' requires to re-calculate a tax amount. Empty value (null) means to retain a previously calculated tax amount.
-
format
GET
Optional
Sets response format. Available options:
json
(default),xml
.
Return value
Order data array with the following keys:
- id int Order ID.
- contact_id int Customer contact ID.
- create_datetime datetime Order creation date and time.
- update_datetime datetime Latest order update date and time.
- state_id string Order status identifier.
- total float Total order cost, expressed in the order currency, in the
decimal(15,4)
format. - currency string Order currency identifier in the ISO 4217 format.
- rate float Order currency rate relative to the main store currency.
- tax float Amount of applied tax, expressed in the order currency, in the
decimal(15,4)
format. - shipping float Shipping cost, expressed in the order currency, in the
decimal(15,4)
format. - discount float Discount amount, expressed in the order currency, in the
decimal(15,4)
format. - paid_year int Year number from the order payment date.
- paid_quarter int Year quarter number from the order payment date.
- paid_month int Year month number from the order payment date.
- paid_date date Order payment date in the
yyyy-mm-dd
format. - auth_date date Payment authorization date in the
yyyy-mm-dd
format. - is_first int Flag (0 or 1) denoting customer’s first paid order.
- unsettled int Flag (0 or 1) denoting whether the order is unsetlled.
- comment string Comment to order left by the customer.
- shipping_datetime datetime Date and time corresponding to the end of the period selected in the Courier shipping field when the “Edit shipping details” action is executed.
- params array Order parameters array.
- params['shipping_id'] int Selected shipping option’s ID.
- params['payment_id'] int Selected payment option’s ID.
- params['referer_host'] string Domain of the referrer website from which the customer entered the storefront to place the order.
- params['departure_datetime'] datetime Date and time since which the order is considered ready for shipping.
- params['coupon_id'] int ID of applied discount coupon.
- params['sales_channel'] string Sales channel: 'backend:' (if the order was created in the store backend), 'storefront:...' (if the order was placed by a customer in the storefront), 'buy_button:' (if the order was placed via a “Buy button” widget).
- params['shipping_address...'] string Shipping address fields.
- params['shipping_name'] string Shipping option name.
- params['payment_plugin'] string Payment plugin identifier.
- params['payment_name'] string Payment option name.
- params['shipping_currency'] string Currency identifier, in which the shipping cost is expressed, in the ISO 4217 format.
- params['reduced'] int Flag (0 or 1) denoting that the stock quantities of ordered product variants were reduced during the order processing history.
- params['reduce_times'] int The number of times stock quantities of ordered product variants were reduced during the order processing history.
- contact array Customer data array with the following keys:
- contact['id'] int Contact ID.
- contact['name'] string Full name.
- contact['email'] string Email address.
- contact['phone'] string Phone number.
- contact['registered'] bool Flag denoting whether the customer is registered and can log into their account with a password.
- contact['photo_50x50'] string URL of the customer photo or a link to their Gravatar image.
- items array List of ordered product variants and services:
- items[]['id'] int Order item ID.
- items[]['order_id'] string Order ID.
- items[]['name'] string Order item name.
- items[]['product_id'] int ID of the product associated with the order item.
- items[]['sku_code'] string Ordered product variant’s code.
- items[]['sku_id'] int Ordered product variant’s ID.
- items[]['type'] string Order item type — 'product' or 'service'.
- items[]['service_id'] int Service ID if the order item is a service.
- items[]['service_variant_id'] int Service variant ID if the order item is a service.
- items[]['price'] float Order item price, expressed in the order currency, in the decimal(15,4) format.
- items[]['quantity'] float Order item’s quantity in the decimal(15,3) format.
- items[]['quantity_denominator'] int Available precision for stock quantities. Acceptable values: 1 (whole pieces), 10 (precision to tenths), 100 (precision to hundredths), 1000 (precision to thousandths).
- items[]['stock_id'] int ID of the stock selected for ordered variant’s stock counts update in the order properties.
- items[]['virtual_stock_id'] int ID of the virtual stock from which the ordered variant’s stock counts must be withdrawn.
- items[]['purchase_price'] float Purchase price of the order item’s associated variant, expressed in the order currency, in the decimal(15,4) format.
- items[]['total_discount'] float Discount amount applied to the entire quantity of the ordered product variant, expressed in the order currency, in the decimal(15,4) format.
- items[]['tax_percent'] float Percentage of the applied tax, if any, in the decimal(15,4) format.
- items[]['tax_included'] int Flag (0 or 1) denoting whether applied tax is included in the ordered product’s price.
- items[]['stock_unit_id'] int ID of the stock quantity unit from the ordered product variant’s properties.