ShoppingCartController - StartCheckout doubt

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
So, I need to customize some code to manage rental products! But I encountered these lines in the StartCheckout method from the ShoppingCartController:


var anonymousPermissed = _orderSettings.AnonymousCheckoutAllowed
                                     && _customerSettings.UserRegistrationType == UserRegistrationType.Disabled;

            if (anonymousPermissed || !await _customerService.IsGuestAsync(customer))
                return RedirectToRoute("Checkout");

            var cartProductIds = cart.Select(ci => ci.ProductId).ToArray();
            var downloadableProductsRequireRegistration =
                _customerSettings.RequireRegistrationForDownloadableProducts && await _productService.HasAnyDownloadableProductAsync(cartProductIds);

            if (!_orderSettings.AnonymousCheckoutAllowed || downloadableProductsRequireRegistration)
            {
                //verify user identity (it may be facebook login page, or google, or local)
                return Challenge();
            }


My question in here is, why is there the negation sign ! in the conditions to check if the current customer is a guest and to check if the AnonymousCheckoutAllowed option is true? Because if the result is false, for example, If my user is not a guest, here, in the condition, the code is going to return true meaning that I am a guess. So what's the purpose of that code in the conditions?
1 year ago
That code says...

        if  AnonymousCheckoutAllowed OR  NOT Guest
            it's ok to proceed to checkout
1 year ago
Hi,

The ! negotiation sign is actually stands for NOT. The code to which you're reffering to is decoded below:

IF ((Checkout_Allowed_Without_Registration AND Registration_Is_Disabled) AND (Current_Customer_Is_Not_Registered)) THEN
Redirect to checkout page
ELSE
Execute next code..

Hope this helps!

Best regards,
Atul
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.