Skip to content

Instantly share code, notes, and snippets.

@TanvirHasan19
Created March 3, 2026 03:34
Show Gist options
  • Select an option

  • Save TanvirHasan19/eeaef336c972eaa63c75a9f5b76e1592 to your computer and use it in GitHub Desktop.

Select an option

Save TanvirHasan19/eeaef336c972eaa63c75a9f5b76e1592 to your computer and use it in GitHub Desktop.
Translate "pending" status in Wholesale Payments
/**
* Start output buffer before Wholesale Payments section is rendered.
*/
add_action( 'woocommerce_order_details_after_order_table', function( $order ) {
// Only on front-end order view (e.g. My Account → View order).
if ( ! is_account_page() && ! is_order_received_page() ) {
return;
}
if ( $order->get_payment_method() !== 'wc_wholesale_payments' ) {
return;
}
ob_start();
}, 1 );
/**
* Flush buffer and replace raw "pending" with translated label.
*/
add_action( 'woocommerce_order_details_after_order_table', function( $order ) {
if ( ! is_account_page() && ! is_order_received_page() ) {
return;
}
if ( $order->get_payment_method() !== 'wc_wholesale_payments' ) {
return;
}
$buffer = ob_get_clean();
if ( $buffer === false || $buffer === '' ) {
return;
}
$label = __( 'Pending', 'woocommerce-wholesale-payments' );
// Replace every "pending" only inside the Wholesale Payments table.
$buffer = preg_replace_callback(
'/(<table class="wholesale-payments-progress"[^>]*>)(.*?)(<\/table>)/is',
function ( $m ) use ( $label ) {
return $m[1] . str_replace( '>pending<', '>' . esc_html( $label ) . '<', $m[2] ) . $m[3];
},
$buffer
);
echo $buffer; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts above.
}, 99999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment