【发布时间】:2018-09-02 12:43:26
【问题描述】:
我有一个不知道如何解决自己的小问题。我已经在我的商店里设置了单独显示价格和运费,但总的来说显示我的价格很差。
例如,我的产品成本为 24.99 欧元 + 运费:3,95 欧元 = 28.94 欧元,但在购物车页面的计算中计算的是:24.99 欧元 + 3.95 欧元 - 0.26 欧元,这是怎么回事。
我发现总价是通过这个函数计算出来的:
<td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
这是控制该部分的功能: 来自模板中的 cart-totals.php,下面是来自 wc-cart-functions.php
的函数function wc_cart_totals_order_total_html() {
$value = '<strong>' . WC()->cart->get_total() . '</strong> ';
// If prices are tax inclusive, show taxes here.
if ( wc_tax_enabled() && WC()->cart->display_prices_including_tax() ) {
$tax_string_array = array();
$cart_tax_totals = WC()->cart->get_tax_totals();
if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
foreach ( $cart_tax_totals as $code => $tax ) {
$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
}
} elseif ( ! empty( $cart_tax_totals ) ) {
$tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
}
if ( ! empty( $tax_string_array ) ) {
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping()
? sprintf( ' ' . __( 'estimated for %s', 'woocommerce' ), WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
: '';
$value .= '<small class="includes_tax">' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) . $estimated_text ) . '</small>';
}
}
echo apply_filters( 'woocommerce_cart_totals_order_total_html', $value );
}
所以我的问题是如何以总价添加 1.63E,这样才能得到正确的价格。谢谢
编辑:发现与我的here 相同的问题,但答案似乎没有改变。
【问题讨论】:
-
仅此一段代码可能还不够。可以将此问题发布到 WooCommerce,也可以在他们的论坛上发布,如果他们有的话。
-
我也在那里打开过,但也在这里问,因为有大量的 Woocommerce 开发人员,所以可能会得到一些答案或提示。
标签: wordpress woocommerce