From 5f4a8e2d95bb17d5b55d7fcf21ea698c58ef8c35 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Fri, 11 Feb 2022 15:19:52 +0100 Subject: [PATCH] MOL-664 Fix missing payment method title when checkout done with blocks --- src/Gateway/GatewayModule.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index f60942613..1ba8419a1 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -211,15 +211,19 @@ static function () { $this->molliePayPalButtonHandling($paypalGateway, $notice, $logger, $pluginUrl); $checkoutBlockHandler = new CheckoutBlockService($container->get('settings.data_helper')); $checkoutBlockHandler->bootstrapAjaxRequest(); - add_action( 'woocommerce_blocks_checkout_update_order_meta', function($order) use($gatewayInstances){ - $orderPaymentMethod = $order->get_payment_method(); - $title = $orderPaymentMethod? $gatewayInstances[$orderPaymentMethod]->title: ''; + add_action( 'woocommerce_rest_checkout_process_payment_with_context', function($paymentContext){ + if(strpos($paymentContext->payment_method, 'mollie_wc_gateway_') === false){ + return; + } + $title = isset($paymentContext->payment_data['payment_method_title'])?$paymentContext->payment_data['payment_method_title']:false; if(!$title){ - return $order; + return ; } - $order->update_meta_data('_payment_method_title', $title); - return $order; + $order = $paymentContext->order; + $order->set_payment_method_title( $title ); + $order->save(); } ); + return true; }