function display_regular_price_in_mini_cart( $item_data, $cart_item ) {
$product = wc_get_product( $cart_item['product_id'] );
$quantity = $cart_item['quantity'];
if ( $product->is_type( 'variable' ) ) {
$variation_id = $cart_item['variation_id'];
$variation = wc_get_product( $variation_id );
$regular_price = $variation->get_regular_price();
} else {
$regular_price = $product->get_regular_price();
}
if ( $regular_price ) {
$item_data[] = array(
'key' => 'regular_price',
'value' => '<span class="test_quantity">'.$quantity.' × '.'</span><del>'.wc_price( $regular_price ).'</del><br/>',
'display' => '',
);
}
return $item_data;
}
add_filter( 'woocommerce_get_item_data', 'display_regular_price_in_mini_cart', 10, 2 );
function show_subtotal_with_regular_prices( $subtotal ) {
$cart = WC()->cart->get_cart();
$subtotal_sale = $subtotal;
$subtotal = 0;
foreach ( $cart as $cart_item_key => $cart_item ) {
$product_id = $cart_item['product_id'];
$product = wc_get_product( $cart_item['product_id'] );
$quantity = $cart_item['quantity'];
if ( $product->is_type( 'variable' ) ) {
$variation_id = $cart_item['variation_id'];
$variation = wc_get_product( $variation_id );
$regular_price = $variation->get_regular_price();
} else {
$regular_price = $product->get_regular_price();
}
$subtotal += $regular_price * $quantity;
}
return $subtotal_sale.'<del>'.wc_price($subtotal).'</del>';
}
add_filter( 'woocommerce_cart_subtotal', 'show_subtotal_with_regular_prices' );