Delivery Drivers for WooCommerce – Delivery driver status always unavailable [Solved]


The problem:

The option that defines a delivery person as available was not working on the delivery person’s dashboard.

And on the client / delivery edit screen “on the Admin side” it only allowed to mark as available, after that it was no longer possible to uncheck the checkbox.

The question was posted by user cdealskollam (@cdealskollam) in the plugin forum at wordpress.org.

To copy the codes, Right click on the desired code and then click on “Inspect”.

Then, expand the option “<pre…” and “<code>” and select the code
.


The solution:

01 Correcting the client/delivery person’s editing screen.
Access the file:
/wp-content/plugins/delivery-drivers-for-woocommerce/admin/ddwc-woocommerce-driver-ratings.php

  • Approximately on line 200, comment out the code below:
// Update driver availability.
if ( isset( $driver_availability ) ) {
update_user_meta( $user_id, 'ddwc_driver_availability', esc_html( $driver_availability ) );
}
  • And add the following below:
// FIXING THE AVAILABLE DELIVERY CHECKBOX
if( isset($_POST['ddwc_driver_availability']) ){
update_user_meta($user_id, 'ddwc_driver_availability', true );
}else{
update_user_meta($user_id, 'ddwc_driver_availability', false );
}

02 Correcting in the Delivery Driver dashboard.
Access the file:
/wp-content/plugins/delivery-drivers-for-woocommerce/admin/class-ddwc-admin.php

  • Approximately on line 238, Replace the code below:
$meta_value = filter_input( INPUT_POST, 'metavalue' );

if ( 'checked' == $meta_value ) {
  $new_value = 'on';
  $old_value = '';
} else {
  $new_value = '';
  $old_value = 'on';
}
  • For this:
$meta_value = get_user_meta( $user_id, 'ddwc_driver_availability', true );

if ( '1' == $meta_value ) {
  $new_value = '';
  $old_value = '1';
} else {
  $new_value = '1';
  $old_value = '';
}

03 It is just that.
Save and test.

Soon I will publish other tips like:

Correcting contact buttons on the delivery person’s dashboard.
“The original code was not getting the customer’s phone number.”


Adding buttons to the delivery list of the delivery person’s dashborad and making adjustments to the table.

Did the tip work for you?
Leave your comment below!


Comentários