2016-07-08 72 views
1

我WooCommerce模板默認cart-shipping.php看到:WooCommerce車-shipping.php模板 - 單選按鈕,而不是選擇框

<select name="shipping_method[<?php echo $index; ?>]" data-index="<?php echo $index; ?>" id="shipping_method_<?php echo $index; ?>" class="shipping_method"> 
    <?php foreach ($available_methods as $method) : ?> 
     <option value="<?php echo esc_attr($method->id); ?>" <?php selected($method->id, $chosen_method); ?>><?php echo wp_kses_post(wc_cart_totals_shipping_method_label($method)); ?></option> 
    <?php endforeach; ?> 
</select> 

我怎樣才能改變它從選擇框單選按鈕?

回答

1

可能是,您沒有woocommmerce/cart/cart-shipping.php的正確模板版本,因爲我沒有看到您的代碼,但是這一個(已經是單選按鈕)。

所以原因可能是您的主題中有一個定製的舊版woocommerce模板。
這是cart-shipping.php實際代碼(模板版本2.5.0)的摘錄:

 <ul id="shipping_method"> 
      <?php foreach ($available_methods as $method) : ?> 
       <li> 
        <?php 
         printf('<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s /> 
          <label for="shipping_method_%1$d_%2$s">%5$s</label>', 
          $index, sanitize_title($method->id), esc_attr($method->id), checked($method->id, $chosen_method, false), wc_cart_totals_shipping_method_label($method)); 
         do_action('woocommerce_after_shipping_rate', $method, $index); 
        ?> 
       </li> 
      <?php endforeach; ?> 
     </ul> 

正如你可以看到你在默認情況下有單選按鈕。

你應該更新你的主題(也是WooCommerce插件)。

參考文獻:Github code source - woocommerce/templates/cart/cart-shipping.php