woocommerce/packages/js/api-core-tests/data/order.js

86 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-08-23 17:39:03 +00:00
const { customerBilling, customerShipping } = require('./shared');
/**
* A basic order.
*
* For more details on the order properties, see:
*
* https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties
*/
2021-09-07 22:20:44 +00:00
const order = {
payment_method: '',
payment_method_title: '',
status: 'pending',
set_paid: false,
currency: 'USD',
customer_note: '',
customer_id: 0,
billing: customerBilling,
shipping: customerShipping,
line_items: [],
shipping_lines: [],
fee_lines: [],
coupon_lines: [],
};
2021-08-23 17:39:03 +00:00
const productLineItems = {
2021-08-24 01:25:07 +00:00
name: '',
2021-09-08 01:02:58 +00:00
product_id: 93,
2021-08-23 17:39:03 +00:00
variation_id: 0,
2021-09-08 01:02:58 +00:00
quantity: 2,
2021-08-24 01:25:07 +00:00
tax_class: '',
subtotal: '',
total: '',
2021-09-07 22:20:44 +00:00
};
2021-08-23 17:39:03 +00:00
const shippingLines = {
2021-09-08 01:02:58 +00:00
method_title: 'Flat rate',
2021-09-07 22:20:44 +00:00
method_id: 'flat_rate',
2021-09-08 01:02:58 +00:00
total: '10.00',
2021-09-07 22:20:44 +00:00
};
2021-08-23 17:39:03 +00:00
const feeLines = {
2021-09-07 22:20:44 +00:00
name: 'Fee',
2021-08-24 01:25:07 +00:00
tax_class: '',
2021-09-07 22:20:44 +00:00
tax_status: 'none',
2021-08-24 01:25:07 +00:00
total: '',
2021-09-07 22:20:44 +00:00
};
2021-08-23 17:39:03 +00:00
const couponLines = {
2021-09-07 22:20:44 +00:00
code: '10off',
};
2021-08-23 17:39:03 +00:00
2021-09-08 01:02:58 +00:00
/**
* Builds an example order request.
*
* @returns {Object} Sample Order payload.
*/
const getOrderExample = () => {
let orderExample = {
id: 0,
payment_method: 'cod',
payment_method_title: 'Cash on Delivery',
status: 'processing',
set_paid: false,
currency: 'USD',
customer_note: 'A customer provided note.',
customer_id: 0,
billing: customerBilling,
shipping: customerShipping,
line_items: [ productLineItems ],
shipping_lines: [ shippingLines ],
fee_lines: [ feeLines ],
coupon_lines: [ couponLines ],
};
return orderExample;
}
2021-08-23 17:39:03 +00:00
module.exports = {
order,
productLineItems,
shippingLines,
feeLines,
couponLines,
2021-09-08 01:02:58 +00:00
getOrderExample,
2021-09-07 22:20:44 +00:00
};