0

I need to disable the Date Created textbox on the Edit Orders page of Woocommerce. I try to do pointer-events: none; but it didn't work.

Date Created needs to be disabled.

enter image description here

Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32
  • pointer-events: none; should work, did you check you are referring to the correct element? also check the browser compatibility – Vidya L Jan 25 '19 at 06:08
  • pointer-events: none; works only when you hovering the textbox. But when you click it several times the textbox works again. – Alexis Cartago Jan 25 '19 at 07:00

1 Answers1

2

This worked for me... Create a new js file and equeue it admin panel

/**
 * 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' );

In the js file add this below code

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);
});

enter image description here

Alaksandar Jesus Gene
  • 6,523
  • 12
  • 52
  • 83