xxxxxxxxxx
// Remove prices
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
// Move title in new container, move "formatted price" in the same container
remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 ); // Remove title form original position
add_action('woocommerce_shop_loop_item_title', 'abChangeProductsTitle', 10 ); // Insert title in new position ( out of main container )
function abChangeProductsTitle() {
$price = get_post_meta( get_the_ID(), '_regular_price', true); // Retrive products regular price
$formatted_price = wc_price( $price ); // Formatted price by adding decimal
echo '<a class="be_prod_title" href="'.get_the_permalink().'"><h2 class="woocommerce-loop-product__title">' . get_the_title() . '</h2><span class="price"><span class="woocommerce-Price-amount amount">'. $formatted_price .'</span></span></a>'; // Print new html with title and price
}
xxxxxxxxxx
// Remove prices
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
// Move title in new container, move "formatted price" in the same container
remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 ); // Remove title form original position
add_action('woocommerce_shop_loop_item_title', 'abChangeProductsTitle', 10 ); // Insert title in new position ( out of main container )
function abChangeProductsTitle() {
$price = get_post_meta( get_the_ID(), '_regular_price', true); // Retrive products regular price
$formatted_price = wc_price( $price ); // Formatted price by adding decimal
echo '<a class="be_prod_title" href="'.get_the_permalink().'"><h2 class="woocommerce-loop-product__title">' . get_the_title() . '</h2><span class="price"><span class="woocommerce-Price-amount amount">'. $formatted_price .'</span></span></a>'; // Print new html with title and price
}