Do not display gateways if subscription in cart and user is not logged in

This commit is contained in:
dinamiko 2021-10-25 16:27:05 +02:00
parent 1782c4fe16
commit 3c237b6315
6 changed files with 42 additions and 30 deletions

View file

@ -23,7 +23,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
use WooCommerce\PayPalCommerce\ApiClient\Repository\CartRepository;
use WooCommerce\PayPalCommerce\Button\Helper\EarlyOrderHandler;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
@ -118,11 +117,6 @@ class CreateOrderEndpoint implements EndpointInterface {
*/
protected $logger;
/**
* @var SubscriptionHelper
*/
protected $subscription_helper;
/**
* CreateOrderEndpoint constructor.
*
@ -147,8 +141,7 @@ class CreateOrderEndpoint implements EndpointInterface {
Settings $settings,
EarlyOrderHandler $early_order_handler,
bool $registration_needed,
LoggerInterface $logger,
SubscriptionHelper $subscription_helper
LoggerInterface $logger
) {
$this->request_data = $request_data;
@ -161,7 +154,6 @@ class CreateOrderEndpoint implements EndpointInterface {
$this->early_order_handler = $early_order_handler;
$this->registration_needed = $registration_needed;
$this->logger = $logger;
$this->subscription_helper = $subscription_helper;
}
/**
@ -203,7 +195,7 @@ class CreateOrderEndpoint implements EndpointInterface {
$this->set_bn_code( $data );
if ( 'checkout' === $data['context'] ) {
if ( $this->registration_needed || $this->subscription_helper->cart_contains_subscription() || ( isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) ) {
if ( $this->registration_needed || ( isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) ) {
$this->process_checkout_form_when_creating_account( $data['form'], $wc_order );
}