我正在建立一个简单的结帐流程,其中将购物车集成到结帐,并将购物车总额直接集成在购物车内。
为此,我在do_action('woocommerce_cart_contents');下面集成了cart-totals.php中的以下代码。钩子:
<!-- START ADD TOTAL -->
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th colspan="5"><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) :
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping()
? sprintf( ' <small>' . __( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
: '';
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
<th colspan="5"><?php echo esc_html( $tax->label ) . $estimated_text; ?></th>
<td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th colspan="5"><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; ?></th>
<td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_cart_totals_before_order_total' ); ?>
<tr class="order-total">
<th colspan="5"><?php _e( 'Total', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<!-- END ADD TOTAL -->
当我使用“订阅”时,我希望/需要将其合并为经常性总计。不幸的是,当我试图将来自recurring-totals.php的代码放入cart.php并产生大量错误时,它不起作用。
在此先感谢任何可以提供帮助的人。