bulk_actions = $bulk_actions; add_action( 'admin_notices', [ $this, 'show_bulk_action_admin_notice' ] ); } /** * Show bulk action admin notice. */ public function show_bulk_action_admin_notice() { $this->bulk_actions->showBulkActionAdminNotice( 'delete_customers' ); } /** * Prepare the items for the table to process * * @return Void */ public function prepare_items() { $columns = $this->get_columns(); $hidden = $this->get_hidden_columns(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $query = $this->table_data(); if ( is_wp_error( $query ) ) { $this->error = $query->get_error_message(); $this->items = []; return; } $this->set_pagination_args( [ 'total_items' => $query->pagination->count, 'per_page' => $this->get_items_per_page( 'customerss' ), ] ); $this->items = $query->data; } /** * Override the parent columns method. Defines the columns to use in your listing table * * @return array */ public function get_columns() { return array_merge( [ 'cb' => '', 'name' => __( 'Name', 'surecart' ), 'email' => __( 'Email', 'surecart' ), 'created' => __( 'Created', 'surecart' ), 'mode' => '', ], parent::get_columns() ); } /** * Displays the checkbox column. * * @param Customer $customer The customer model. */ public function column_cb( $customer ) { ?> array( 'title', false ) ); } /** * Get the table data * * @return object|\WP_Error */ private function table_data() { $mode = sanitize_text_field( wp_unslash( $_GET['mode'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $conditions = array( 'query' => $this->get_search_query(), ); if ( ! empty( $mode ) ) { $conditions['live_mode'] = 'live' === $mode; } return Customer::where( $conditions ) ->paginate( [ 'per_page' => $this->get_items_per_page( 'customers' ), 'page' => $this->get_pagenum(), ] ); } /** * Nothing found. * * @return void */ public function no_items() { if ( $this->error ) { echo esc_html( $this->error ); return; } echo esc_html_e( 'No customers found.', 'surecart' ); } /** * The customer email. * * @param \SureCart\Models\Customer $customer The customer model. * * @return string */ public function column_email( $customer ) { return sanitize_email( $customer->email ); } /** * Name column * * @param \SureCart\Models\Customer $customer Customer model. * * @return string */ public function column_name( $customer ) { $pending_record_ids = $this->bulk_actions->getRecordIds( 'delete_customers', 'pending' ); $processing_record_ids = $this->bulk_actions->getRecordIds( 'delete_customers', 'processing' ); $succeeded_record_ids = $this->bulk_actions->getRecordIds( 'delete_customers', 'succeeded' ); $bulk_status = ''; if ( ! empty( $pending_record_ids ) && in_array( $customer->id, $pending_record_ids, true ) ) { $bulk_status = 'pending'; } elseif ( ! empty( $processing_record_ids ) && in_array( $customer->id, $processing_record_ids, true ) ) { $bulk_status = 'processing'; } elseif ( ! empty( $succeeded_record_ids ) && in_array( $customer->id, $succeeded_record_ids, true ) ) { $bulk_status = 'succeeded'; } ob_start(); ?> name ?? $customer->email ); ?> getRowActions( $customer, $bulk_status ) ); ?> ' . esc_html__( 'Successfully deleted.', 'surecart' ) . ''; } if ( 'pending' === $bulk_status || 'processing' === $bulk_status ) { return '