WC_AJAX::link_all_variations
Link all variations via ajax function.
Method of the class: WC_AJAX{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_AJAX::link_all_variations();
WC_AJAX::link_all_variations() WC AJAX::link all variations code WC 10.8.1
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();
}