2020-04-08 08:00:31 +00:00
|
|
|
/**
|
|
|
|
* Get the number of packages in a shippingRates array.
|
|
|
|
*
|
|
|
|
* @param {Array} shippingRates Shipping rates and packages array.
|
|
|
|
*/
|
|
|
|
export const getShippingRatesPackageCount = ( shippingRates ) => {
|
2020-04-08 10:19:05 +00:00
|
|
|
return shippingRates.length;
|
2020-04-08 08:00:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the number of rates in a shippingRates array.
|
|
|
|
*
|
|
|
|
* @param {Array} shippingRates Shipping rates and packages array.
|
|
|
|
*/
|
|
|
|
export const getShippingRatesRateCount = ( shippingRates ) => {
|
2020-09-07 17:31:10 +00:00
|
|
|
return shippingRates.reduce( function ( count, shippingPackage ) {
|
2020-04-08 08:00:31 +00:00
|
|
|
return count + shippingPackage.shipping_rates.length;
|
|
|
|
}, 0 );
|
|
|
|
};
|