This helped so just wanted to give you a solution to generate this dynamically for all your websites inside a multisite install 🙂

function my_robots_txt( $output, $public ) {

# Check if Woocommerce is active on the website for this request
if ( ! class_exists( 'woocommerce' ) )
return $output ;

# These are the endpoint names used by Woocommerce, not the real slug of the page
$endpoints = [ 'cart', 'checkout', 'myaccount' ];

foreach ( $endpoints as $endpoint ) {

$woo_page_id = wc_get_page_id( $endpoint );
# You need to get the slug => the slug field is "post_name"
$slug = get_post_field( 'post_name', $woo_page_id );
# Add the rule for this page
$output .= "Disallow: /{$slug}/\n";
}

return $output;
}
add_filter( 'robots_txt', 'my_robots_txt', 10, 2 );