add_to_cart_url() public method

Get the add to url used mainly in loops.
public add_to_cart_url ( ) : string
return string
    function add_sponsorship_project_to_cart()
    {
        global $post;
        $args = array('post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'numberposts' => -1, 'orderby' => 'id', 'order' => 'asc', 'post_parent' => $post->ID);
        $levels = get_posts($args);
        do_action('woocommerce_before_add_to_cart_button');
        ?>
		<div class="sp-levels">
			<?php 
        foreach ($levels as $level) {
            $level_product = new WC_Product_Variation($level->ID);
            $level_data = get_post_custom($level->ID);
            ?>
				<form id="level-<?php 
            echo $level->ID;
            ?>
-form" enctype="multipart/form-data" method="post" class="cart" action="<?php 
            echo $level_product->add_to_cart_url();
            ?>
">
					<a class="sp-level" rel="<?php 
            echo $level->ID;
            ?>
">
						<div class="sp-level-title">
							<?php 
            echo get_the_title($level->ID);
            ?>
							<div class="sp-level-amount">
								<strong>$<?php 
            echo isset($level_data['_price'][0]) ? $level_data['_price'][0] : 0;
            ?>
</strong>
							</div>
						</div>		
						<div class="sp-level-description">
							<?php 
            echo $level->post_content;
            ?>
						</div>
					</a>
				</form>
			<?php 
        }
        ?>
		</div>
		<script>
			jQuery('.sp-level').click(function() {
				var levelId = jQuery(this).attr('rel');
				jQuery('#level-' + levelId + '-form').submit();
				return false;
			})
		</script>
		<?php 
        do_action('woocommerce_after_add_to_cart_button');
    }
?>
</div>
				<span class="sp-project-duration-label text">days to go</span>
			</h5>
		</div>
	</div>
	<?php 
if (isset($min_level)) {
    ?>
	<div class="sp-project-contribute">
		<div>
			<form id="level-<?php 
    echo $min_level_id;
    ?>
-form" enctype="multipart/form-data" method="post" class="cart" action="<?php 
    echo $min_level->add_to_cart_url();
    ?>
">
				<a id="sp-project-min-pledge-button" rel="<?php 
    echo $min_level_id;
    ?>
">
					Back This Project
					<small>$<?php 
    echo isset($min_level_data['_price'][0]) ? $min_level_data['_price'][0] : 0;
    ?>
 minimum pledge</small>
				</a>
			</form>
		</div>
	</div>