Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Multibanco Payment Instructions in Order Details page #10469

Open
wants to merge 3 commits into
base: feature/multibanco
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions includes/class-wc-payments-order-success-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct() {
add_action( 'woocommerce_before_thankyou', [ $this, 'register_payment_method_override' ] );
add_action( 'woocommerce_before_thankyou', [ $this, 'maybe_render_multibanco_payment_instructions' ] );
add_action( 'woocommerce_order_details_before_order_table', [ $this, 'unregister_payment_method_override' ] );
add_action( 'woocommerce_order_details_before_order_table', [ $this, 'maybe_render_multibanco_payment_instructions' ] );
add_filter( 'woocommerce_thankyou_order_received_text', [ $this, 'add_notice_previous_paid_order' ], 11 );
add_filter( 'woocommerce_thankyou_order_received_text', [ $this, 'add_notice_previous_successful_intent' ], 11 );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
Expand All @@ -41,6 +42,11 @@ public function register_payment_method_override() {
* @param int $order_id The order ID.
*/
public function maybe_render_multibanco_payment_instructions( $order_id ) {
if ( is_order_received_page() && current_filter() === 'woocommerce_order_details_before_order_table' ) {
// Prevent rendering twice on order received page.
return;
}

$order = wc_get_order( $order_id );

if ( ! $order || $order->get_payment_method() !== 'woocommerce_payments_' . Payment_Method::MULTIBANCO || 'on-hold' !== $order->get_status() ) {
Expand All @@ -65,7 +71,12 @@ public function maybe_render_multibanco_payment_instructions( $order_id ) {
<img src="<?php echo esc_url_raw( plugins_url( 'assets/images/payment-methods/multibanco-instructions.svg', WCPAY_PLUGIN_FILE ) ); ?>" alt="<?php esc_attr_e( 'Multibanco', 'woocommerce-payments' ); ?>">
</div>
<div class="payment-details">
<div class="payment-header"><?php echo $formatted_order_total; ?></div>
<div class="payment-header">
<?php
/* translators: %s: order number */
printf( esc_html__( 'Order #%s', 'woocommerce-payments' ), $order->get_order_number() );
?>
</div>
<div class="payment-expiry">
<?php
printf(
Expand Down Expand Up @@ -345,7 +356,7 @@ private function format_addtional_thankyou_order_received_text( string $addition
* Enqueue style to the order success page
*/
public function enqueue_scripts() {
if ( ! is_order_received_page() ) {
if ( ! is_order_received_page() && ! is_view_order_page() ) {
return;
}

Expand Down
Loading