Skip to content

Commit

Permalink
MOL-664 Fix missing payment method title when checkout done with blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Feb 11, 2022
1 parent 107a640 commit 5f4a8e2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5f4a8e2

Please sign in to comment.