'product',
'post_status' => 'publish',
'posts_per_page' => '1',
'paged' => $paged,
);
$my_posts = new WP_Query( $args );
if ( $my_posts->have_posts() ) :
?>
have_posts() ) : $my_posts->the_post();
if ( 'yes' === $skuautoffxf_auto_id ) {
$skuautoffxf_id = get_the_id();
} else {
$skuautoffxf_id = '';
}
global $product;
$skuautoffxf_auto_variant = get_option( 'skuautoffxf_auto_variant' );
?>
is_type( 'variable' ) && 'no' === $skuautoffxf_auto_variant ) {
echo ' ';
}elseif( isset( $_GET['checked'] ) && $_GET['checked'] === '0' ){
if ( get_post_meta( get_the_ID(), '_sku', true ) ){
echo '';
}else{
echo '';
}
}elseif( isset( $_GET['checked'] ) && $_GET['checked'] === '1' ){
echo ' ';
}else{
echo ' ';
}
the_title();
?>
is_type( 'variable' ) && 'no' === $skuautoffxf_auto_variant ) {
// Include the file with the custom function.
require_once 'functions-plugin.php'; // Replace with the correct path to your functions.php file.
// Use the custom function to get the variation separator value.
$separator_value = get_variation_separator_value();
$parent_sku = get_post_meta( get_the_ID(), '_sku', true );
$children_ids = $product->get_children();
$count = 0;
// Loop through the variations Ids.
foreach ( $children_ids as $child_id ) {
$count++;
// Get an instance of the WC_Product_Variation object.
$variation = wc_get_product( $child_id );
// Set the prefix lenght based on variations count.
$prefix = sizeof( $children_ids ) < 100 ? sprintf( '%02d', $count) : sprintf( '%03d', $count);
// Geberate and set the sku.
try {
$variation->set_sku( $parent_sku . $separator_value . $prefix );
} catch ( WC_Data_Exception $e ){
}
// Save variation.
$variation->save();
}
}
?>