Check if registration is needed

createaccount checkbox is not present when guest checkout is disabled
This commit is contained in:
Alex P 2021-10-20 10:13:27 +03:00
parent cf3b6e6ab1
commit 49bb1bc371
3 changed files with 26 additions and 2 deletions

View file

@ -115,7 +115,8 @@ return array(
$session_handler = $container->get( 'session.handler' );
$settings = $container->get( 'wcgateway.settings' );
$early_order_handler = $container->get( 'button.helper.early-order-handler' );
$logger = $container->get( 'woocommerce.logger.woocommerce' );
$registration_needed = $container->get( 'button.current-user-must-register' );
$logger = $container->get( 'woocommerce.logger.woocommerce' );
return new CreateOrderEndpoint(
$request_data,
$cart_repository,
@ -125,6 +126,7 @@ return array(
$session_handler,
$settings,
$early_order_handler,
$registration_needed,
$logger
);
},
@ -171,4 +173,15 @@ return array(
'button.helper.messages-apply' => static function ( ContainerInterface $container ): MessagesApply {
return new MessagesApply();
},
'button.is-logged-in' => static function ( ContainerInterface $container ): bool {
return is_user_logged_in();
},
'button.registration-required' => static function ( ContainerInterface $container ): bool {
return WC()->checkout()->is_registration_required();
},
'button.current-user-must-register' => static function ( ContainerInterface $container ): bool {
return ! $container->get( 'button.is-logged-in' ) &&
$container->get( 'button.registration-required' );
},
);