dongll0502 2016-07-19 09:23
浏览 74
已采纳

Woocommerce 2.6.2添加了禁用属性以更新购物车按钮

I am using Wordpress 4.5.3 and Woocommerce 2.6.2 .

Code inside woocommerce/cart/cart.php

 <input type="submit" class="button" id="update_cart_button" name="update_cart" value="<?php esc_attr_e( 'Update Cart', 'woocommerce' ); ?>" />

    <?php do_action( 'woocommerce_cart_actions' ); ?>

    <?php wp_nonce_field( 'woocommerce-cart' ); ?>

Which generates following html:

<input type="submit" class="button" id="update_cart_button" name="update_cart" value="Winkelmand bijwerken" disabled="">
<input type="hidden" id="_wpnonce" name="_wpnonce" value="847e1da0f8">
<input type="hidden" name="_wp_http_referer" value="/winkelmand/">

So the strange thing is that inside the input field the 'disabled' attribute is added. When i remove the disabled value with developer tools i can click the button and the cart is updated correctly.

So i want to remove this attribute, what i have tried:

Attempt 1

<script>
 document.getElementById('update_cart_button').disabled = false;
</script>

Attempt 2

<script>
 jQuery('#update_cart_button').prop('disabled', false);
</script>

Attempt 3

<script>
 jQuery('#update_cart_button').removeAttr('disabled'); 
</script>

but none of the solutions remove the disabled attribute.

  • 写回答

5条回答 默认 最新

  • doujiu6976 2016-07-19 12:42
    关注

    You can try below code-

    jQuery(document).ready(function() {
    jQuery( '.shop_table.cart' ).closest( 'form' ).find( 'input[name="update_cart"]' ).removeProp( 'disabled');
      });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示