【问题标题】:Woocommerce change default order [method - price] shipping en CARTWoocommerce 更改默认订单 [method - price] shipping en CART
【发布时间】:2014-08-16 17:55:07
【问题描述】:

wc-cart-functions.php

function wc_cart_totals_shipping_method_label( $method ) {
    $label = $method->label;

    if ( $method->cost > 0 ) {
        if ( WC()->cart->tax_display_cart == 'excl' ) {
            $label .= ': ' . wc_price( $method->cost );
            if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) {
                $label .= ' <small>' . WC()->countries->ex_tax_or_vat() . '</small>';
            }
        } else {
            $label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
            if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
                $label .= ' <small>' . WC()->countries->inc_tax_or_vat() . '</small>';
            }
        }
    } elseif ( $method->id !== 'free_shipping' ) {
        $label .= ' (' . __( 'Free', 'woocommerce' ) . ')';
    }

    return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
}

函数返回$label,$method,我想显示$method,$label

无法更改顺序

我想更改[价格-送货方式]的顺序,因为系统显示[送货方式-价格]

目前,结帐页面如下所示:

        Cart Subtotal  $300.00
        Shipping  **Ship To An International Destination: $35.00** *CHANGE*
        Order Total $335.00

因为我可以将 CHECKOUT 页​​面更改为如下所示;

       Cart Subtotal           $300.00
       Shipping and Handling   **$35.00 Ship To An International Destination** *CHANGE*
       Order Total             $335.00

【问题讨论】:

  • cart-shipping.php 刚刚找到解决办法,这个函数的返回,wp_kses_post( wc_cart_totals_shipping_method_label( $method ) );我只是使用带有 split 功能的分隔符来更改出现的顺序。 谢谢

标签: woocommerce shipping


【解决方案1】:

你可以改变:

 $label .= ': ' . wc_price( $method->cost );

到

 $label = wc_price( $method->cost ) . ': ' . $label ;

也改变:

 $label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );

到

$label = wc_price( $method->cost + $method->get_shipping_tax() ) . ' : ' .$label;

希望以后可以帮助有同样问题的人:)

【讨论】:

    【解决方案2】:

    在

    cart-shipping.php

    我刚刚找到了解决办法,这个函数的返回,wp_kses_post(wc_cart_totals_shipping_method_label($method));我只是使用带有 split 功能的分隔符来更改出现的顺序。

      <?php if ( 1 === count( $available_methods ) ) : $method = current( $available_methods  );    $Leyenda=wp_kses_post( wc_cart_totals_shipping_method_label( $method ) );                 $palabras=split(":","$Leyenda"); echo "$palabras[1] $palabras[0]"; ?>
    

    谢谢

    【讨论】:

      猜你喜欢
      • 2022-09-30
      • 1970-01-01
      • 2017-04-02
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      • 2013-09-10
      • 2017-05-24
      • 2020-02-01
      相关资源
      最近更新 更多