4

From Display on sale cart item formatted prices range in WooCommerce answer to my previous question, I was able to display on sale cart item formatted prices.

Unfortunately I was not able to use the product title filter to add the single product price below the product title in the checkout page. The first image shows what i try to achieve - the second how it looks like right now.

  1. My cart page already shows the price below the title: enter image description here

  2. My checkout page should show the price too: enter image description here

Any idea how to add the single product price html below the product title in the checkout page?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
evavienna
  • 1,059
  • 11
  • 29

1 Answers1

2

Based on your previous question answer, simply use also the following:

add_filter( 'woocommerce_checkout_cart_item_quantity', 'filter_checkout_cart_item_quantity', 10, 3 );
function filter_checkout_cart_item_quantity( $item_quantity, $cart_item, $cart_item_key ) {
    return $cart_item['data']->get_price_html() . ' ' . $item_quantity;
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Thx for your help. The $item_quantity returns a x before the quantity. i try to remove it - should i use str_replace for example or any easier way? – evavienna Feb 28 '21 at 17:20
  • 1
    @evavienna Simply replace `$item_quantity` with `$cart_item['quantity']` or with `' . $cart_item['quantity'] . ''`… – LoicTheAztec Feb 28 '21 at 17:24