woocommerce/packages/js/api-core-tests/data/shipping-method.js

30 lines
633 B
JavaScript

/**
* Constructs a shipping method based on the given `methodId` and `cost`.
*
* `methodId` should be one of the following:
* - `free_shipping`
* - `flat_rate`
* - `local_pickup`
*
* @param methodId
* @param cost
* @return shipping method object that can serve as a request payload for adding a shipping method to a shipping zone.
*/
const getShippingMethodExample = ( methodId, cost ) => {
const shippingMethodExample = {
method_id: methodId,
};
if ( cost !== undefined ) {
shippingMethodExample.settings = {
cost,
};
}
return shippingMethodExample;
};
module.exports = {
getShippingMethodExample,
};