Multi Store Support fro Nop 2.2- Store front

Posted: October 18, 2011 at 5:43 AM Quote #51971
I'm about to finish the Multi store support
I have some problems that needs to be fixed, and help will be appreciated.

Store Demo On
http://demo22.online-ex.com

All is supported part for recurring payments, gift carts and stored procedures.

Orders:
Orders are being divided by stores. A shopping cart will be submitted as one and will be divided by stores.
An Order will be created to each store.

I have an error on One Page Checkout.
On confirm the JSON return success. for some reason, I am  being thrown to home page instead of CheckoutCompleted. please note that I am passing a new string to CheckoutCompleted  called successOrderList.

the thing is I dont get to OpcCompleteRedirectionPayment, The javascrip is throwing me to home page before and i can find where.

full solution http://demo22.online-ex.com/nop22MultiStore.rar


thank you
hezy
This post/answer is useful
1
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Posted: October 18, 2011 at 6:22 AM Quote #51973
for those who does not want to download the full solution following the problem calss:

public ActionResult OpcConfirmOrder()
        {
            try
            {
                //validation
                var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
                if (cart.Count == 0)
                    throw new Exception("Your cart is empty");

                if (!_orderSettings.OnePageCheckoutEnabled)
                    throw new Exception("One page checkout is disabled");

                if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed))
                    throw new Exception("Anonymous checkout is not allowed");

                //add by hz
                string successOrderslist = "";
                var storeOrders = _storeService.getStoreSoppingCartItems(cart);
                //end by hz

                //place order
                var processPaymentRequest = this.Session["OrderPaymentInfo"] as ProcessPaymentRequest;
                if (processPaymentRequest == null)
                {
                    //Check whether payment workflow is required
                    if (IsPaymentWorkflowRequired(cart))
                    {
                        throw new Exception("Payment information is not entered");
                    }
                    else
                        processPaymentRequest = new ProcessPaymentRequest();
                }

                processPaymentRequest.Customer = _workContext.CurrentCustomer;
                processPaymentRequest.PaymentMethodSystemName = _workContext.CurrentCustomer.SelectedPaymentMethodSystemName;

                //add by hz

                for (int i = 0; i < storeOrders.Count; i++)
                {
                    storeOrders[i].processPaymentRequest = processPaymentRequest;
                    storeOrders[i].placeOrderResult = _orderProcessingService.PlaceOrder(storeOrders[i]);
                    if (storeOrders[i].placeOrderResult.Success)
                    {
                        var postProcessPaymentRequest = new PostProcessPaymentRequest()
                        {
                            Order = storeOrders[i].placeOrderResult.PlacedOrder
                        };

                        var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(storeOrders[i].placeOrderResult.PlacedOrder.PaymentMethodSystemName);
                        if (paymentMethod == null)
                            throw new Exception("Payment method is not available"); //actually it's impossible
                        if (paymentMethod.PaymentMethodType == PaymentMethodType.Redirection)
                        {
                            //Redirection will not work because it's AJAX request.
                            //That's why we don't process it here (we redirect a user to another page where he'll be redirected)

                            //redirect
                            return Json(new { redirect = string.Format("{0}checkout/OpcCompleteRedirectionPayment", _webHelper.GetStoreLocation()) });
                        }
                        else
                        {
                            _paymentService.PostProcessPayment(postProcessPaymentRequest);
                            successOrderslist += storeOrders[i].placeOrderResult.PlacedOrder.Id.ToString();
                            if (i != storeOrders.Count - 1)
                                successOrderslist += ",";
                            else
                            {
                                //success
                                return Json(new { success = 1 });
                            }
                        }
                    }
                    else
                    {
                        //error
                        var confirmOrderModel = new CheckoutConfirmModel();
                        foreach (var error in storeOrders[i].placeOrderResult.Errors)
                            confirmOrderModel.Warnings.Add(error);

                        return Json(new
                        {
                            update_section = new UpdateSectionJsonModel()
                            {
                                name = "confirm-order",
                                html = RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
                            },
                            goto_section = "confirm_order"
                        });
                    }
                }
            }
            catch (Exception exc)
            {
                _logger.Warning(exc.Message, exc, _workContext.CurrentCustomer);
                return Json(new { error = 1, message = exc.Message });
            }
            return null;
        }

after the return JSON i am getting thrown to home page
This post/answer is useful
-1
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Posted: October 20, 2011 at 1:36 PM Quote #52222
Any one? Them members please
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Posted: October 21, 2011 at 12:33 AM Quote #52265
Just tested your solution. You create and init 'successOrderslist' variable in 'OpcConfirmOrder' method. But it's never used and returned as JSON. That's why 'successOrderslist' parameter is never passed to 'Completed' method.

Look at \Scripts\onepagecheckout.js which is used during one-page checkout and investigate how it works. Instead of returning "return Json(new { success = 1 });" from  'OpcConfirmOrder' method do the following:
return Json(new { redirect = string.Format("{0}checkout/Completed?successOrderList={1}", _webHelper.GetStoreLocation(), successOrderList) });

P.S. I haven't tested it.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: October 21, 2011 at 1:15 AM Quote #52266
Thank You, I will try that
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Posted: October 21, 2011 at 4:29 AM Quote #52276
Thanks again Andrei, its working perfect
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Posted: April 02, 2012 at 3:30 AM Quote #66212
Would you be able to share your Multi Store solution please?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: April 02, 2012 at 4:32 AM Quote #66216
all code on codeplex

http://nopms25.codeplex.com/SourceControl/list/changesets

download the last changeset
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Hezy Ziv

www.hz-dev.com
(free Nop Plugins)
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more