We have added the below code which is working with other themes but not with the Xstore store theme. Let us know the correct code. We need to display the weight the same as displayed on the homepage categories tabs.
add_action('woocommerce_after_shop_loop_item_title', 'show_weight', 20);
add_action('woocommerce_single_product_summary', 'show_weight', 20);
function show_weight() {
global $product;
// Ensure $product is defined on category/archive pages
if ( ! is_object( $product ) ) {
$product = wc_get_product( get_the_ID() );
}
$weight_unit = get_option('woocommerce_weight_unit');
if ( $product->has_weight() ) {
echo '<p><strong>Weight: ' . esc_html( $product->get_weight() . ' ' . $weight_unit ) . '</strong></p>';
}
}
Looking forward to your response.
best Regards,
Abhijit