protected function set_shipping( $order, $shipping, $action ) {

        // total must be a positive float
        if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) {
            throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 );