drne47241
2019-02-26 16:08
浏览 66
已采纳

WooCommerce:以购物车/迷你卡显示产品总价而不是产品价格

I am using WooCommerce on my Wordpress site and I want to display the total price per product in my cart/minicart (e.g.: 'Product Quantity' x 'Product Price' = 'Product Total Price'). The code I am using right now is working, but there are rounding errors.

Expected:

  • Product #1
  • Quantity: 2
  • Price: 3,50
  • Total Price: 7,00

Displayed:

  • Product #2
  • Quantity: 2
  • Price: 3,50
  • Total Price: 6,00

Here is the code I am using:

<?php $new_product_price_old = number_format((float)wp_kses( woocommerce_price( $_product->get_price() ), array() ) * $cart_item['quantity'], 2, ',', '.'); ?>
<?php echo '<span class="sidecart-item-price">' . $new_product_price ?>&nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span>

Is there a simple way to fix this or maybe another piece of code? Or a hook I am missing? Total beginner here...

Thanks in advance

1条回答 默认 最新

相关推荐 更多相似问题