1
votes

I'm using the following script on my WooCommerce website:

Quantity: . apply_filters( 'woocommerce_cart_item_quantity', $cart_item_quantity, $cart_item_key, $cart_item ) .

Price: . apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $woofc_product ), $cart_item, $cart_item_key ) .

I am trying to multiply the Quantity by the product Price or to get it directly from an existing code. (But I could n't find it).

How can I apply a multiplication from product price with the quantity?


Edit:

I have find a way to get the quantity with your answer code but it doesn't display the Multiplication of price by Quantity, as WC()->cart->get_product_price( $woofc_product ) gives the formatted price with currency symbol.

$cart_html .= '<span class="woofc-item-price">' . $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $woofc_product ), $cart_item, $cart_item_key ) . ' - Toplam: ' . $cart_item['quantity'] * $product_price . '</span>';
$cart_html .= '</div>';
1

1 Answers

1
votes

Updated regarding the product price without currency symbol

There are some mistakes in your code, try the following to get the correct display:

$quantity   = apply_filters( 'woocommerce_cart_item_quantity', $cart_item['quantity'], $cart_item_key, $cart_item );
$raw_price  = (float) wc_get_price_to_display( $woofc_product ); // Product raw display price 

$cart_html .= '<span class="woofc-item-price">' . apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $woofc_product ), $cart_item, $cart_item_key );
$cart_html .= ' - Toplam: ' . wc_price( $quantity * $raw_price ) . '</span>';
$cart_html .= '</div>';

It should better work.