Perhaps i missed this in the demo or in the documentation, however, is there a way that you can force the user to login with an account prior to purchasing? Lets say when they hit proceed to checkout from their cart?
Basically the desired flow would be thus
Click proceed to checkout from cart -> check if user is logged in -> if logged in go to checkout flow, if not force them to log in and redirect to checkout flow
There is nothing explicitly for this in Vendr itself, but this is were we see people using the power of Umbraco.
As Umbraco already supports members, we suggest that people use those existing features and integrate them into their checkout flow however they see fit.
We don't do anything explicitly within Vendr as checkout flows work in many different ways and so we leave that to the implementors and just expose API's to assist along side Umbraco's own APIs.
I have done this exact thing for a recent project. I implemented a RenderMvc controller for the checkout doc types and performed the check in there, along with a few other checks (for example, checking that the order has order items before taking billing info).
Here's an example:
The base class:
public class CheckoutControllerBase : RenderMvcController
{
protected readonly ISessionManager SessionManager;
public static string[] RequiredFields =
{
"billingFirstName",
"billingLastName",
"billingAddressLine1",
"billingAddressLine2",
"billingCountry",
"billingZipCode"
};
public StoreReadOnly Store => CurrentPage.GetStore();
public OrderReadOnly Order => SessionManager.GetCurrentOrder(Store.Id);
public IPublishedContent Product => Order
.OrderLines
.Select(x => UmbracoContext
.Content.GetById(Guid.Parse(x.ProductReference)))
.FirstOrDefault();
public CheckoutControllerBase(ISessionManager sessionManager)
{
SessionManager = sessionManager;
}
public override ActionResult Index(ContentModel model)
{
return !EnsureUserAndOrder(out var redirect) ? redirect : CurrentTemplate(model);
}
public bool EnsureUserAndOrder(out ActionResult redirect)
{
if (!Members.IsLoggedIn())
{
redirect = RedirectToLogin();
return false;
}
if (Order == null || !Order.OrderLines.Any())
{
redirect = RedirectToCart();
return false;
}
redirect = null;
return true;
}
public bool IsValidOrder()
{
return RequiredFields.Any(x => string.IsNullOrWhiteSpace(Order.Properties[x]));
}
public ActionResult RedirectToCart()
{
var basket = CurrentPage
.Root()
.Descendants<CartPage>()
.FirstOrDefault();
return new RedirectResult(basket.Url());
}
public ActionResult RedirectToLogin()
{
var registerPage = CurrentPage
.Root()
.Descendants<Login>()
.FirstOrDefault();
return new RedirectResult(registerPage.UrlWithRedirect(CurrentPage.Url()));
}
public ActionResult RedirectToBillingInfo()
{
var orderInfoPage = CurrentPage
.Root()
.Descendants<CheckoutOrderInformationPage>()
.FirstOrDefault();
return new RedirectResult(orderInfoPage.Url());
}
}
And for each doc type just inherit from the base:
public class CheckoutPaymentMethodsPageController : CheckoutControllerBase
{
public CheckoutPaymentMethodsPageController(ISessionManager sessionManager) : base(sessionManager)
{
}
}
Thanks for this, it is along the lines of what I was thinking of doing. Glad I am not the only one who wants users to have an account prior to purchasing!
Do you also handle checking out as guest in a similar manner with your valid order checking?
Make user create an account prior to purchasing
Perhaps i missed this in the demo or in the documentation, however, is there a way that you can force the user to login with an account prior to purchasing? Lets say when they hit proceed to checkout from their cart?
Basically the desired flow would be thus
Click proceed to checkout from cart -> check if user is logged in -> if logged in go to checkout flow, if not force them to log in and redirect to checkout flow
Thanks,
Kyle
Hi Kyle,
There is nothing explicitly for this in Vendr itself, but this is were we see people using the power of Umbraco.
As Umbraco already supports members, we suggest that people use those existing features and integrate them into their checkout flow however they see fit.
We don't do anything explicitly within Vendr as checkout flows work in many different ways and so we leave that to the implementors and just expose API's to assist along side Umbraco's own APIs.
Hope this helps
Matt
Hi Kyle,
I have done this exact thing for a recent project. I implemented a RenderMvc controller for the checkout doc types and performed the check in there, along with a few other checks (for example, checking that the order has order items before taking billing info).
Here's an example:
The base class:
And for each doc type just inherit from the base:
Phillip,
Thanks for this, it is along the lines of what I was thinking of doing. Glad I am not the only one who wants users to have an account prior to purchasing!
Do you also handle checking out as guest in a similar manner with your valid order checking?
-Kyle
Hi Kyle,
For this project we don't allow checkout as a guest, but yeah I probably would do the validation still - just seems like good practice.
Cheers
Phil
is working on a reply...