Home › Forums › WoodMart support forum › WMPL can not translate woodmart single product layout › Reply To: WMPL can not translate woodmart single product layout
July 15, 2024 at 3:53 pm
#583441
Artem Temos
Keymaster
Try to add the following PHP code snippet to the child theme functions.php file to fix this
add_action(
'woocommerce_before_template_part',
function () {
global $product;
if ( wp_is_json_request() && ! $product ) {
$random_product = new WP_Query(
array(
'posts_per_page' => '1',
'post_type' => 'product',
)
);
while ( $random_product->have_posts() ) {
$random_product->the_post();
$product_id = get_the_ID();
}
wp_reset_postdata();
$product = wc_get_product( $product_id );
}
}
);