Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am currently experiencing a strange problem I was hoping you might be able to shed some light on.
Firstly I am running Umbraco v7.4.3 and Teacommerce 3.1.1 as well as utilising the shoppingCart.js and teaCommerceEvents.js files from the example site. I have added some CustomPrice and CustomOrderLine calculators which sit in the AppCode/TeaCommerce folder as well.
The issue I am having is that everything works fine when browsing the site as normal, such as viewing products, variants, basket, etc. but then randomly I start getting problems with the AddToBasket, increase quantity buttons, etc. in that I receive 500 errors from the form post.
I have analysed using the developer tools to see what is happening on the Ajax posts and the errors are occuring in the custom calculators.
Basically I create a membershiphelper based on the current UmbracoContext and normally this is picking up the user I am logged in as when browsing the site normally. However when I click the AddToBasket, Increase Qty buttons which have the Ajax calls, the user being returned is 'admin' which errors admin is an Umbraco user and not a member and the referenced properties do not exist.
The crux of it is, do you have any idea why the 'admin' user is being returned rather than the current logged in member when creating a membershiphelper in a custom calculator from an Ajax call??
Example code is shown below:
MembershipHelper mHelper = new MembershipHelper(UmbracoContext.Current);
var helper = new UmbracoHelper(UmbracoContext.Current);
var countries = TeaCommerce.Umbraco.Web.TC.GetCountries(1);
decimal basePrice = Convert.ToDecimal(helper.TypedContent(productIdentifier).GetPropertyValue("price"));
decimal discountLevel = 0;
discountLevel = Convert.ToDecimal(mHelper.GetCurrentMember().GetPropertyValue("discount"));
That sounds a bit weird. We only have something in TC where we temp switch the order id when doing admin edit in the backoffice of Tea Commerce, but nothing with changing members. Its pretty weird that it happens when the Ajax is being used, but then again - its not a true full stack Umbraco server request and response. So maybe there is a case that Umbraco hasen't covered when a AJAX request is made.
Have you tried to use the Membership API of .NET and not use the Umbraco API for it? Maybe that will make it work.
Or try to update Umbraco so you have the latest version where most bugs will be fixed.
Many thanks for the reply. I have tried using the Membership API of .Net such as the following:
var member = Membership.GetUser()
However when performing the same Ajax calls (e.g. add qty, delete line item, etc.) this is returning null. If I perform a non Ajax action (e.g. login) then the member variable is not null and contains the user that is logging in. It seems that when performing the Ajax call the correct member context is not being returned and for the life of me I cannot work out why. I have used the code from this TeaCommerce documentation page:
But have added code to return the current user and it is when doing the Ajax call and this code is hit that the member is showing as null.
Any further ideas as I have also updated to the latest version and the issue still remains?
I also forgot to mention that this issue seems to only happen when using Google Chrome. If I clear the history and cookies from the browser then everything works fine for a short time and then randomly the issue re-appears.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted