After lot of research, finally got a function for adding brand name to Product URL, please check below.
add_filter( ‘post_type_link’, ‘wp_vinay_product_link’, 10, 2 );
function wp_vinay_product_link( $permalink, $post ) {
if( $post->post_type == ‘product’ ) {
$default_term = ‘no_brand’;
$terms = wp_get_post_terms( $post->ID, ‘pwb-brand’ );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) )
$term = current( $terms )->slug;
else
$term = $default_term;
$permalink = str_replace( ‘%pwb-brand%’, $term, $permalink );
}
return $permalink;
}
add this code to your themes functions.php file, Then Go to settings > Permalinks
and in Product permalinks section add the %pwb-brand% term to Custom base Field.
for example: /brand/%pwb-brand%/