【问题标题】:WooCommerce: Disable Date on Edit OrdersWooCommerce:在编辑订单上禁用日期
【发布时间】:2019-06-18 22:44:54
【问题描述】:

我需要在 Woocommerce 的“编辑订单”页面上禁用“创建日期”文本框。我尝试做pointer-events: none;,但没有成功。

需要禁用创建日期。

【问题讨论】:

  • 指针事件:无;应该工作,你检查你指的是正确的元素吗?还要检查浏览器的兼容性
  • 指针事件:无;仅当您悬停文本框时才有效。但是当你点击它几次时,文本框又可以工作了。

标签: javascript css wordpress woocommerce


【解决方案1】:

这对我有用...创建一个新的 js 文件并将其排入管理面板

/**
 * Enqueue a script in the WordPress admin, excluding edit.php.
 *
 * @param int $hook Hook suffix for the current admin page.
 */
function wpdocs_selectively_enqueue_admin_script( $hook ) {
    // if ( 'edit.php' != $hook ) {
    //     return;
    // }
    wp_enqueue_script( 'my_custom_woocommerce_script', get_template_directory_uri() . '/woocommerce/assets/meta-boxes-order.js', array(), '1.0' );
}
add_action( 'admin_enqueue_scripts', 'wpdocs_selectively_enqueue_admin_script' );

在js文件中添加以下代码

jQuery(document).ready(function(){
    alert("ok"); // only for testing purpose that this file is loaded
    jQuery(".order_data_column_container .order_data_column p:eq(0) input").attr('disabled', true);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 2022-01-18
    相关资源
    最近更新 更多