/** * Method to update a download in the database. * * @param WC_Customer_Download $download */ public function update(&$download) { global $wpdb; $data = array('download_id' => $download->get_download_id(), 'product_id' => $download->get_product_id(), 'user_id' => $download->get_user_id(), 'user_email' => $download->get_user_email(), 'order_id' => $download->get_order_id(), 'order_key' => $download->get_order_key(), 'downloads_remaining' => $download->get_downloads_remaining(), 'access_granted' => date('Y-m-d', $download->get_access_granted()), 'download_count' => $download->get_download_count(), 'access_expires' => $download->get_access_expires() ? date('Y-m-d', $download->get_access_expires()) : 'NULL'); $format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s'); $wpdb->update($wpdb->prefix . 'woocommerce_downloadable_product_permissions', $data, array('permission_id' => $download->get_id()), $format); $download->apply_changes(); }