woocommerce/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/utils.js

20 lines
580 B
JavaScript
Raw Normal View History

/**
* Get the number of packages in a shippingRates array.
*
* @param {Array} shippingRates Shipping rates and packages array.
*/
export const getShippingRatesPackageCount = ( shippingRates ) => {
return Object.keys( shippingRates ).length;
};
/**
* Get the number of rates in a shippingRates array.
*
* @param {Array} shippingRates Shipping rates and packages array.
*/
export const getShippingRatesRateCount = ( shippingRates ) => {
return shippingRates.reduce( function( count, shippingPackage ) {
return count + shippingPackage.shipping_rates.length;
}, 0 );
};