WC_AJAX::link_all_variations()public staticWC 1.0

Link all variations via ajax function.

Method of the class: WC_AJAX{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_AJAX::link_all_variations();

WC_AJAX::link_all_variations() code WC 8.7.0

public static function link_all_variations() {
	check_ajax_referer( 'link-variations', 'security' );

	if ( ! current_user_can( 'edit_products' ) ) {
		wp_die( -1 );
	}

	wc_maybe_define_constant( 'WC_MAX_LINKED_VARIATIONS', 50 );
	wc_set_time_limit( 0 );

	$post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;

	if ( ! $post_id ) {
		wp_die();
	}

	$product        = wc_get_product( $post_id );
	$number_created = self::create_all_product_variations( $product );

	echo esc_html( $number_created );

	wp_die();
}