2017-02-05 4 views
0

配送ラベル名を調整するためのWooCommerceサブスクリプションプラグインに基づく文書を見つけるのは苦労しています。"FREE"を含まないように定期出荷ラベルを変更する

私は無料でという単語を削除したいと思います。

enter image description here

私は別のスタックオーバーフローのユーザーからこの機能を使用して試してみましたが、それも「カート」で火にいないようです:

/** 
* Remove shipping name from the label in Cart and Checkout pages 
*/ 
function sticky_wc_cart_totals_shipping_method_label($method) { 
    $label = $method->get_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 class="tax_label">' . 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 class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>'; 
      } 
     } 
    } 

    return apply_filters('woocommerce_cart_shipping_method_full_label', $label, $method); 
} 
add_filter('woocommerce_cart_shipping_method_full_label', 'sticky_wc_cart_totals_shipping_method_label', 10, 2); 

私はドン何これがカートの合計のみであり、定期的な合計出荷ではないかどうかは分かりません。

これについてのご意見はありますか?

答えて

0

解決策が見つかりました。サブスクリプションプラグインをダウンロードした後、関連するコードを見つけることができました。だから私はこのフィルタを作成し、うまく動作しているようだ。

/** 
* Remove shipping pricing from the label in Cart and Checkout pages 
*/ 
add_filter('wcs_cart_totals_shipping_method', 'wcs_method_label', 10, 2); 
function wcs_method_label($method, $cart) { 
    return $cart->label; 
} 
関連する問題