2017-01-27 4 views
1

私のテーマでは、数量を変更する2つのボタンを追加したカスタムquantity-form.phpがあります。カートページに行くと、 - 、+ボタンで数量が変更されますが、カートの更新ボタンは有効になりません。キーボードで数量値を変更すると、更新カートボタンが有効になります。私は、woocommerceプラグインを使用します。woocommerceのアップデート後、数量ボタンでカート更新ボタンが有効になりません

答えて

0

これは、この質問が誰かに1年前に尋ねられたように助けてくれることを願っています。

これにより、ページの読み込み、Ajax、数量ドロップダウンの更新ボタンの無効なプロパティが削除されます。

REF:https://gist.github.com/mikaelz/f41e29c6a99a595602e4

add_action('wp_footer', 'cart_update_qty_script', 1000); 
function cart_update_qty_script() { 
    if (is_cart()) : 
     ?> 
     <script type="text/javascript"> 
       jQuery(document).ready(function($) { 
      // Enable update cart button upon successful ajax call 
      $(document).ajaxSuccess(function() { 
      $('div.woocommerce > form input[name="update_cart"]').prop('disabled', false); 
     }); 
     // Enable update cart button on initial page load 
     $('div.woocommerce > form input[name="update_cart"]').prop('disabled', false); 

     // Update cart when quantity pulldown is changed 
     $('body').on('change', '#quantity_pulldown', function() { 
         var quantity_selected = $("#quantity_pulldown option:selected").val(); 
       $('#product_quantity').val(quantity_selected); 

       jQuery("[name='update_cart']").removeAttr('disabled'); 
       jQuery("[name='update_cart']").trigger("click"); 

      }); 

    }); 

     </script> 
     <?php 
    endif; 
} 
関連する問題