WC_Product_Variation::add_to_cart_url()publicWC 1.0

Get the add to url used mainly in loops.

Method of the class: WC_Product_Variation{}

Hooks from the method

Return

String.

Usage

$WC_Product_Variation = new WC_Product_Variation();
$WC_Product_Variation->add_to_cart_url();

WC_Product_Variation::add_to_cart_url() code WC 8.7.0

public function add_to_cart_url() {
	$url = $this->is_purchasable() ? remove_query_arg(
		'added-to-cart',
		add_query_arg(
			array(
				'variation_id' => $this->get_id(),
				'add-to-cart'  => $this->get_parent_id(),
			),
			$this->get_permalink()
		)
	) : $this->get_permalink();
	return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this );
}