'Bookzenix bookings', 'callback' => array( $this, 'export' ) ); return $list; } public function erasers( $list ) { $list['bookzenix'] = array( 'eraser_friendly_name' => 'Bookzenix bookings', 'callback' => array( $this, 'erase' ) ); return $list; } public function export( $email, $page = 1 ) { $c = Repository::customer_by_email( $email ); if ( ! $c ) { return array( 'data' => array(), 'done' => true ); } $items = array(); $items[] = array( 'group_id' => 'bookzenix-customer', 'group_label' => 'Booking profile', 'item_id' => 'bkz-customer-' . $c['id'], 'data' => array( array( 'name' => 'Name', 'value' => trim( $c['first_name'] . ' ' . $c['last_name'] ) ), array( 'name' => 'Email', 'value' => $c['email'] ), array( 'name' => 'Phone', 'value' => (string) $c['phone'] ), ), ); foreach ( Repository::appointments( array( 'customer_id' => $c['id'], 'limit' => 1000 ) ) as $a ) { $data = array( array( 'name' => 'Service', 'value' => $a['service_name'] ), array( 'name' => 'Date', 'value' => $a['date_local'] . ' ' . $a['time_local'] ), array( 'name' => 'Status', 'value' => $a['status'] ), array( 'name' => 'Price', 'value' => (string) ( $a['price'] - ( $a['discount'] ?? 0 ) ) ), array( 'name' => 'Your note', 'value' => (string) $a['customer_note'] ), ); $items[] = array( 'group_id' => 'bookzenix-appointments', 'group_label' => 'Appointments', 'item_id' => 'bkz-appt-' . $a['id'], 'data' => $data ); } return array( 'data' => $items, 'done' => true ); } /** Anonymises instead of deleting, so business records (revenue, history) stay intact. */ public function erase( $email, $page = 1 ) { global $wpdb; $c = Repository::customer_by_email( $email ); if ( ! $c ) { return array( 'items_removed' => false, 'items_retained' => false, 'messages' => array(), 'done' => true ); } $anon = 'deleted-' . $c['id'] . '@invalid.invalid'; $wpdb->update( Plugin::table( 'customers' ), array( 'first_name' => 'Deleted', 'last_name' => 'customer', 'email' => $anon, 'phone' => '', 'note' => '', 'wp_user_id' => null, 'access_token' => Repository::token() ), array( 'id' => $c['id'] ) ); $wpdb->update( Plugin::table( 'appointments' ), array( 'customer_note' => '' ), array( 'customer_id' => $c['id'] ) ); return array( 'items_removed' => true, 'items_retained' => false, 'messages' => array( 'Booking history kept anonymously for accounting.' ), 'done' => true ); } public function policy() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( 'Bookzenix', '
When you book an appointment we store your name, email, phone number, your note and the details of your booking, so we can provide the service and email you confirmations. This information stays on this website and is not sent to other services. You can ask us to export or erase your data at any time.
' ); } }