Update cart problem

Posted: July 09, 2019 at 7:00 AM Quote #242299
Cart is not update after adding products.When i refresh page added products appear.


My code is


@model IList<ProductOverviewModel>
@using Nop.Core.Infrastructure
@using Nop.Services.Catalog
@using Nop.Services.Media
@using Nop.Core.Domain.Orders

@inject IProductService c
@inject IPictureService picService

@{
    var pictureService = EngineContext.Current.Resolve<IPictureService>();
    var media = new Nop.Core.Domain.Media.MediaSettings();
    var addtocartlink = "";
    var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
    addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.FirstOrDefault().Id, shoppingCartTypeId = shoppingCartTypeId, quantity = 1 });
}


addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.FirstOrDefault().Id, shoppingCartTypeId = shoppingCartTypeId, quantity = 1 });

<input type="button" value="ekle" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;" />
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: July 09, 2019 at 2:33 PM Quote #242319
Hello kazmirci,
Please go to "Presentation\Nop.Web\Controllers\ShoppingCartController" and debug "AddProductToCart_Catalog" action.
I think "updateflyoutcartsectionhtml" not returning the expected html.

Hope it will help.
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)
Posted: July 09, 2019 at 3:14 PM Quote #242320
ferdous0905 wrote:
Hello kazmirci,
Please go to "Presentation\Nop.Web\Controllers\ShoppingCartController" and debug "AddProductToCart_Catalog" action.
I think "updateflyoutcartsectionhtml" not returning the expected html.

Hope it will help.


Thank you.You are right i debuged and it returns below code.But my product dont have any attributes.
How can i fix it?

//allow a product to be added to the cart when all attributes are with "read-only checkboxes" type
            var productAttributes = _productAttributeService.GetProductAttributeMappingsByProductId(product.Id);
            if (productAttributes.Any(pam => pam.AttributeControlType != AttributeControlType.ReadonlyCheckboxes))
            {
                //product has some attributes. let a customer see them
                return Json(new
                {
                    redirect = Url.RouteUrl("Product", new { SeName = _urlRecordService.GetSeName(product) })
                });
            }
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: July 10, 2019 at 12:38 PM Quote #242366
Hello kazmirci,
Its good to know you found your problem. that specific loop won't work if the product doesn't have any attribute.
so please go to product edit page and check for product attribute.
You can take this product as an example "http://admin-demo.nopcommerce.com/Admin/Product/Edit/1".

There is a another action in "ShoppingCartController" called "AddProductToCart_Details" you may also want to study that. it normally use in product details page.

i hope you will solve your problem.Thanks.
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)
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