Thanks for writing back.
Although 1-1 code customization assistance is beyond the scope of support that we can provide over the support forum, we do our best to guide you in the right direction whenever possible.
I see your website has the following custom code, to update the product price when the form is submitted:
function func_custom_update_product_regular_price($post_id, $form_data) {
// if a specific form
if ($form_data['id']==15) {
update_post_meta($post_id,'_regular_price', 50);
update_post_meta($post_id,'_price', 50);
}
}
add_action('cred_save_data', 'func_custom_update_product_regular_price', 10, 2);
In theory, extending that code to the following should work to update the product's title and slug to also include the "SKU" at the beginning:
function func_custom_update_product_regular_price($post_id, $form_data) {
// if a specific form
if ($form_data['id']==15) {
update_post_meta($post_id,'_regular_price', 50);
update_post_meta($post_id,'_price', 50);
$sku = get_post_meta($post_id, '_sku', true);
$title = get_the_title($post_id);
$new_title = $sku.' '.$title;
$slug = sanitize_title($new_title);
$my_post_data = array(
'ID' => $post_id,
'post_title' => $new_title,
'post_name' => $slug,
);
// Update the post into the database
wp_update_post( $my_post_data );
}
}
add_action('cred_save_data', 'func_custom_update_product_regular_price', 10, 2);
However, there is a limitation on the part of the "Easy Auto SKU Generator for WooCommerce" plugin. It can only generate and update the product 'SKU' if the product is created from the post-edit screen in the admin area. In this case, where you're using a front-end form to generate the product, it doesn't generate and save the 'SKU' value, which is why it may look like the code is not working.
(the actual reason will be that the 'SKU' value is empty when the product is generated through the form)
To overcome this limitation, you can either:
1. Get in touch with the "Easy Auto SKU Generator for WooCommerce" plugin's support to see if it can be made to generate SKU, no matter how a product is created.
OR
2. You can switch this plugin with a different one that generates the 'SKU', irrespective of how a product is created.
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/