HomeHome Product Discus... Product Discus...RazorCartRazorCartChanging a customer in the model mid-processChanging a customer in the model mid-process
Previous
 
Next
New Post
12/19/2018 8:39 PM
 
I am working on a b2b site using RazorCart. I use Smith_Customer to represent the customer's company, and the DNN users have the customer ID in their User Profile so I know which Smith_Customer they are with (and we are selling to). A Smith_Customer record has a 1:1 relationship with a DNN User ID, so there will be times when a DNN user logs in and theirs is not the DNN User ID in a customer record so in the model the Customer data is not valid.

I can, through SQL against the database, work from the Portal ID and DNN User ID to get the Smith_Customer record I want to use. Is there a way to push the desired customer data into the model so it's in place later when the completed order is processed? If not, do you have any suggestions?

Thank you,
George Butler
 
New Post
12/20/2018 6:49 PM
 
We already have a DNNLogin field for the customers object to associate it with the DNN user, also the order model has DNNUserID.
Are you asking about getting the customer info in the checkout module and pass it to the angular controller after submitting the order?
You can do it like this:

@{
    var customer = RazorCart.Service.Data.Repository.Instance.GetCustomerByUser(Dnn.User.Username, Dnn.PortalSettings.PortalId);
}
<script type="text/javascript">
    let container@(Dnn.ModuleContext.ModuleId) = angular.element(document.getElementById('rzcContainer_@(Dnn.ModuleContext.ModuleId)'));
    container@(Dnn.ModuleContext.ModuleId).ready(function () {
        var scope = container@(Dnn.ModuleContext.ModuleId).scope();
        var vm = container@(Dnn.ModuleContext.ModuleId).controller();
        vm.customer = JSON.parse('@Html.Raw(Json.Encode(customer))');
        scope.$apply(function () { });
    });
</script>
 
Previous
 
Next
HomeHome Product Discus... Product Discus...RazorCartRazorCartChanging a customer in the model mid-processChanging a customer in the model mid-process