この回答のコード:How to get minimum order amount for free shipping in woocommerce
は、WooCommerceバージョン2で廃止されたです。 6 +が、この機能的な答えに役立ちました...
検索といくつかの試行をした後、私は、特定のゾーンの送料無料の方法で設定されている最小注文量を得る方法を見つけました(地方):
// Here you get (as you already know) the used shipping method reference
$chosen_methods = WC()->session->get('chosen_shipping_methods');
// Replacing inside the string ':' by '_'
$option_value = str_replace(':', '_', $chosen_methods[0]);
// We concatenate the string with additional sub-strings
$option_value = 'woocommerce_'.$option_value.'_settings';
// Just a test => outputting the string to see what we get
echo $option_value; echo '<br>';
// Now we can get the options values with that formatted string
$free_shipping_settings = get_option($option_value);
// Just for test => we output the (pre-formatted) array of values to check
echo '<pre>'; print_r($free_shipping_settings); echo '</pre><br>';
// Here we get the value of the order min amount (Finally!)
$order_min_amount = $free_shipping_settings['min_amount'];
// We output the value (to check)
echo 'Order min amount: '.$order_min_amount;
ビンゴ:ここ
は作業テストコード(説明は内側コメントしている)です!あなたはそれを手に入れます。
可能な重複(http://stackoverflow.com/questions/26582039/how-to-get-minimum-order-amount-for-free [woocommerceで送料無料のための最小注文量を取得する方法] wi-ocommerce) –
私の説明をもう一度読んでください。私はそれを(あなたのリンク)好きですが、それはNULLの結果を返します。私は次のようにしています: $ selected_methods = WC() - >セッション - > get( 'selected_shipping_methods'); \t \t $ chosen_shipping = $ selected_methods [0]; 選択した方法が送料無料の場合、どのようにmin_amountを取得できますか? – huykon225
@LoicTheAztecあなたは質問や説明を変更する必要があるという意味ですか? 私が欲しいもの全て:チェックアウトページに来て、配送方法を選択すると送料が無料になります。手伝って頂けますか ? – huykon225