【问题标题】:Shipping methods select getting duplicated in Woocommerce运输方式选择在 Woocommerce 中重复
【发布时间】:2015-10-29 15:49:42
【问题描述】:

我正在建立一个 Woocommerce 商店。

在结帐页面中,就在订单审核 (Your Order) 的正上方,默认情况下会出现重复选择的送货方式/费用。

这是多余的,因为用户已经在购物车页面上选择了方法/成本。不仅如此,每次用户更改结帐页面中的运输选项时,选择都会重复。

添加产品后进入购物车即可看到效果:http://cccctanger.com/openwalls/catalog/

知道会发生什么吗?

理想的做法是完全删除 Order Review 中的选择,因为它是多余的,但我在 Checkout 页面代码中没有看到它!

// filter hook for include new pages inside the payment method
$get_checkout_url = apply_filters( 'woocommerce_get_checkout_url', WC()->cart->get_checkout_url() ); ?>

<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( $get_checkout_url ); ?>" enctype="multipart/form-data">

    <?php if ( sizeof( $checkout->checkout_fields ) > 0 ) : ?>

        <?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>

        <div class="row" id="customer_details">
            <div class="col-md-6">
                <?php do_action( 'woocommerce_checkout_billing' ); ?>
            </div>

            <div class="col-md-6">
                <?php do_action( 'woocommerce_checkout_shipping' ); ?>
            </div>
        </div>

        <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>

        <h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3>

    <?php endif; ?>

    <?php do_action( 'woocommerce_checkout_before_order_review' ); ?>

    <div id="order_review" class="woocommerce-checkout-review-order">
        <?php do_action( 'woocommerce_checkout_order_review' ); ?>
    </div>

    <?php do_action( 'woocommerce_checkout_after_order_review' ); ?>

</form>

<?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    我已经解决了它!

    首先,我使用 CSS 隐藏结帐页面中的 Select(s)。 它们始终是相同的 ID,因此非常简单:

    form.checkout select#shipping_method_0{
        display: none;
    }
    

    然后,在 review-order.php 中,我添加一个表格行来显示 Subtotal 和 Total 之间的总运费:

    <tr class="order-total">
        <th><?php _e( 'Shipping', 'woocommerce' ); ?></th>
        <td><?php echo WC()->cart->get_cart_shipping_total(); ?></td>
    </tr> 
    

    瞧!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 2020-10-08
      • 2017-10-20
      • 2019-02-03
      相关资源
      最近更新 更多