WordPress at Your Fingertips
function is not described

WC_AJAX::save_variations() public WC 1.0

Save variations via AJAX.

{} It's a method of the class: WC_AJAX{}

Return

null. Nothing.

Usage

$result = WC_AJAX::save_variations();

Code of WC_AJAX::save_variations() WC 5.9.0

public static function save_variations() {
	ob_start();

	check_ajax_referer( 'save-variations', 'security' );

	// Check permissions again and make sure we have what we need.
	if ( ! current_user_can( 'edit_products' ) || empty( $_POST ) || empty( $_POST['product_id'] ) ) {
		wp_die( -1 );
	}

	$product_id                           = absint( $_POST['product_id'] );
	WC_Admin_Meta_Boxes::$meta_box_errors = array();
	WC_Meta_Box_Product_Data::save_variations( $product_id, get_post( $product_id ) );

	do_action( 'woocommerce_ajax_save_product_variations', $product_id );

	$errors = WC_Admin_Meta_Boxes::$meta_box_errors;

	if ( $errors ) {
		echo '<div class="error notice is-dismissible">';

		foreach ( $errors as $error ) {
			echo '<p>' . wp_kses_post( $error ) . '</p>';
		}

		echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . esc_html__( 'Dismiss this notice.', 'woocommerce' ) . '</span></button>';
		echo '</div>';

		delete_option( 'woocommerce_meta_box_errors' );
	}

	wp_die();
}