Skip to content

Commit

Permalink
Extend section json model & ShoppingCartController update
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykPorabik committed Dec 7, 2020
1 parent 8e88092 commit 9815de1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 23 deletions.
11 changes: 8 additions & 3 deletions Grand.Web/Controllers/ActionCartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public virtual async Task<IActionResult> AddProductToCart_Catalog(string product
message = string.Format(_localizationService.GetResource("Products.ProductHasBeenAddedToTheWishlist.Link"), Url.RouteUrl("Wishlist")),
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel),
updatetopwishlistsectionhtml = updatetopwishlistsectionhtml,
model = addtoCartModel
});
}
case ShoppingCartType.ShoppingCart:
Expand Down Expand Up @@ -257,7 +258,8 @@ public virtual async Task<IActionResult> AddProductToCart_Catalog(string product
message = string.Format(_localizationService.GetResource("Products.ProductHasBeenAddedToTheCart.Link"), Url.RouteUrl("ShoppingCart")),
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel),
updatetopcartsectionhtml = updatetopcartsectionhtml,
updateflyoutcartsectionhtml = updateflyoutcartsectionhtml
updateflyoutcartsectionhtml = updateflyoutcartsectionhtml,
model = addtoCartModel
});
}
}
Expand Down Expand Up @@ -555,6 +557,7 @@ public virtual async Task<IActionResult> AddProductToCart_Details(string product
message = string.Format(_localizationService.GetResource("Products.ProductHasBeenAddedToTheWishlist.Link"), Url.RouteUrl("Wishlist")),
updatetopwishlistsectionhtml = updatetopwishlistsectionhtml,
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel),
model = addtoCartModel
});
}
case ShoppingCartType.ShoppingCart:
Expand Down Expand Up @@ -594,7 +597,8 @@ public virtual async Task<IActionResult> AddProductToCart_Details(string product
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel),
updatetopcartsectionhtml = updatetopcartsectionhtml,
updateflyoutcartsectionhtml = updateflyoutcartsectionhtml,
refreshreservation = product.ProductType == ProductType.Reservation && product.IntervalUnitType != IntervalUnit.Day
refreshreservation = product.ProductType == ProductType.Reservation && product.IntervalUnitType != IntervalUnit.Day,
model = addtoCartModel
});
}
}
Expand Down Expand Up @@ -703,7 +707,8 @@ public virtual async Task<IActionResult> AddBid(string productId, int shoppingCa
{
success = true,
message = _localizationService.GetResource("ShoppingCart.Yourbidhasbeenplaced"),
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel)
html = await RenderPartialViewToString("_PopupAddToCart", addtoCartModel),
model = addtoCartModel
});
}

Expand Down
36 changes: 24 additions & 12 deletions Grand.Web/Controllers/CheckoutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ await _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
{
update_section = new UpdateSectionJsonModel {
name = "shipping-method",
html = await RenderPartialViewToString("OpcShippingMethods", shippingMethodModel)
html = await RenderPartialViewToString("OpcShippingMethods", shippingMethodModel),
model = shippingMethodModel
},
goto_section = "shipping_method"
});
Expand Down Expand Up @@ -1060,7 +1061,8 @@ await _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
{
update_section = new UpdateSectionJsonModel {
name = "payment-method",
html = await RenderPartialViewToString("OpcPaymentMethods", paymentMethodModel)
html = await RenderPartialViewToString("OpcPaymentMethods", paymentMethodModel),
model = paymentMethodModel
},
goto_section = "payment_method"
});
Expand All @@ -1075,7 +1077,8 @@ await _genericAttributeService.SaveAttribute<string>(_workContext.CurrentCustome
{
update_section = new UpdateSectionJsonModel {
name = "confirm-order",
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel),
model = confirmOrderModel
},
goto_section = "confirm_order"
});
Expand All @@ -1098,7 +1101,8 @@ protected async Task<JsonResult> OpcLoadStepAfterPaymentMethod(IPaymentMethod pa
{
update_section = new UpdateSectionJsonModel {
name = "confirm-order",
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel),
model = confirmOrderModel
},
goto_section = "confirm_order"
});
Expand All @@ -1110,7 +1114,8 @@ protected async Task<JsonResult> OpcLoadStepAfterPaymentMethod(IPaymentMethod pa
{
update_section = new UpdateSectionJsonModel {
name = "payment-info",
html = await RenderPartialViewToString("OpcPaymentInfo", paymenInfoModel)
html = await RenderPartialViewToString("OpcPaymentInfo", paymenInfoModel),
model = paymenInfoModel
},
goto_section = "payment_info"
});
Expand Down Expand Up @@ -1203,7 +1208,8 @@ public virtual async Task<IActionResult> OpcSaveBilling(IFormCollection form)
{
update_section = new UpdateSectionJsonModel {
name = "billing",
html = await RenderPartialViewToString("OpcBillingAddress", billingAddressModel)
html = await RenderPartialViewToString("OpcBillingAddress", billingAddressModel),
model = billingAddressModel
},
wrong_billing_address = true,
});
Expand Down Expand Up @@ -1265,7 +1271,8 @@ public virtual async Task<IActionResult> OpcSaveBilling(IFormCollection form)
{
update_section = new UpdateSectionJsonModel {
name = "shipping",
html = await RenderPartialViewToString("OpcShippingAddress", shippingAddressModel)
html = await RenderPartialViewToString("OpcShippingAddress", shippingAddressModel),
model = shippingAddressModel
},
goto_section = "shipping"
});
Expand Down Expand Up @@ -1397,7 +1404,8 @@ await _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer,
{
update_section = new UpdateSectionJsonModel {
name = "shipping",
html = await RenderPartialViewToString("OpcShippingAddress", shippingAddressModel)
html = await RenderPartialViewToString("OpcShippingAddress", shippingAddressModel),
model = shippingAddressModel
}
});
}
Expand Down Expand Up @@ -1545,7 +1553,8 @@ await _genericAttributeService.SaveAttribute<string>(_workContext.CurrentCustome
{
update_section = new UpdateSectionJsonModel {
name = "confirm-order",
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel),
model = confirmOrderModel
},
goto_section = "confirm_order"
});
Expand Down Expand Up @@ -1600,7 +1609,8 @@ public virtual async Task<IActionResult> OpcSavePaymentInfo(IFormCollection form
{
update_section = new UpdateSectionJsonModel {
name = "confirm-order",
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel),
model = confirmOrderModel
},
goto_section = "confirm_order"
});
Expand All @@ -1612,7 +1622,8 @@ public virtual async Task<IActionResult> OpcSavePaymentInfo(IFormCollection form
{
update_section = new UpdateSectionJsonModel {
name = "payment-info",
html = await RenderPartialViewToString("OpcPaymentInfo", paymenInfoModel)
html = await RenderPartialViewToString("OpcPaymentInfo", paymenInfoModel),
model = paymenInfoModel
}
});
}
Expand Down Expand Up @@ -1700,7 +1711,8 @@ public virtual async Task<IActionResult> OpcConfirmOrder(
{
update_section = new UpdateSectionJsonModel {
name = "confirm-order",
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
html = await RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel),
model = confirmOrderModel
},
goto_section = "confirm_order"
});
Expand Down
26 changes: 18 additions & 8 deletions Grand.Web/Controllers/ShoppingCartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public virtual async Task<IActionResult> CheckoutAttributeChange(IFormCollection
enabledattributeids = enabledAttributeIds.ToArray(),
disabledattributeids = disabledAttributeIds.ToArray(),
htmlordertotal = await RenderPartialViewToString("Components/OrderTotals/Default", model),
model = model,
checkoutattributeinfo = await checkoutAttributeFormatter.FormatAttributes(attributeXml, _workContext.CurrentCustomer),
});
}
Expand Down Expand Up @@ -305,7 +306,8 @@ public virtual async Task<IActionResult> UpdateCart(IFormCollection form)
return Json(new
{
totalproducts = string.Format(_localizationService.GetResource("ShoppingCart.HeaderQuantity"), model.Items.Sum(x => x.Quantity)),
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model }),
model = model
});
}

Expand Down Expand Up @@ -356,7 +358,8 @@ public virtual async Task<IActionResult> DeleteCartItem(string id, bool shopping
return Json(new
{
totalproducts = string.Format(_localizationService.GetResource("ShoppingCart.HeaderQuantity"), model.TotalProducts),
flyoutshoppingcart = this.RenderViewComponentToString("FlyoutShoppingCart", model)
flyoutshoppingcart = this.RenderViewComponentToString("FlyoutShoppingCart", model),
model = model
});
}
else
Expand All @@ -375,7 +378,9 @@ public virtual async Task<IActionResult> DeleteCartItem(string id, bool shopping
{
totalproducts = string.Format(_localizationService.GetResource("ShoppingCart.HeaderQuantity"), model.TotalProducts),
flyoutshoppingcart = RenderViewComponentToString("FlyoutShoppingCart", model),
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = shoppingcartmodel })
flyoutshoppingcartmodel = model,
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = shoppingcartmodel }),
model = shoppingcartmodel,
});
}
}
Expand Down Expand Up @@ -423,7 +428,8 @@ public virtual async Task<IActionResult> ChangeTypeCartItem(string id, bool stat

return Json(new
{
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = shoppingcartmodel })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = shoppingcartmodel }),
model = shoppingcartmodel
});

}
Expand Down Expand Up @@ -572,7 +578,8 @@ public virtual async Task<IActionResult> ApplyDiscountCoupon(string discountcoup

return Json(new
{
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model }),
model = model
});
}

Expand Down Expand Up @@ -636,7 +643,8 @@ public virtual async Task<IActionResult> ApplyGiftCard(string giftcardcouponcode

return Json(new
{
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model }),
model = model
});
}

Expand Down Expand Up @@ -691,7 +699,8 @@ public virtual async Task<IActionResult> RemoveDiscountCoupon(string discountId)

return Json(new
{
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model }),
model = model
});
}

Expand Down Expand Up @@ -722,7 +731,8 @@ public virtual async Task<IActionResult> RemoveGiftCardCode(string giftCardId, [

return Json(new
{
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model })
cart = RenderViewComponentToString("OrderSummary", new { overriddenModel = model }),
model = model
});

}
Expand Down
1 change: 1 addition & 0 deletions Grand.Web/Models/Checkout/UpdateSectionJsonModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class UpdateSectionJsonModel
{
public string name { get; set; }
public string html { get; set; }
public object model { get; set; }
}
}

0 comments on commit 9815de1

Please sign in to comment.