get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery $wpdb->prepare( "SELECT reason_label, comment, created_at FROM {$wpdb->prefix}subscrpt_cancellation_feedback WHERE subscription_id = %d ORDER BY id DESC LIMIT 1", (int) $subscription_id ), ARRAY_A ); return $row ? $row : null; } /** * Show the customer's cancellation reason on the admin subscription details page * (bottom of the right-hand column). * * Renders only for cancelled / pending-cancellation subscriptions that have a * recorded feedback row. * * @param array $ctx Subscription details context. * @return void */ public function render_admin_feedback_card( $ctx ) { $subscription_id = (int) ( $ctx['subscription_id'] ?? 0 ); $status = $ctx['status'] ?? ''; if ( ! in_array( $status, [ 'cancelled', 'pe_cancelled' ], true ) ) { return; } $feedback = self::get_feedback( $subscription_id ); if ( ! $feedback ) { return; } $reason = (string) ( $feedback['reason_label'] ?? '' ); $comment = (string) ( $feedback['comment'] ?? '' ); $when = ''; if ( ! empty( $feedback['created_at'] ) ) { $when = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( get_date_from_gmt( $feedback['created_at'] ) ) ); } ?>
[] ] ); ?>
' . esc_html( $effective ) . '' ); } else { esc_html_e( 'This subscription is scheduled to be cancelled at the end of the current billing period. You can continue accessing it until then.', 'subscription' ); } ?>