Rank: Advanced Member
Groups: Authorized User, Registered, Developers, HelpDesk Joined: 11/30/2018(UTC) Posts: 86
Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
When Working with Discounts Scopes in a 9.0.5 Dev site we can add a category or product level to a setup. However, when trying to remove the category or product complete a pop up box forces something to be checked after the initial set-up. This is leaving us with no way to change back to having no category's or products selected for that Discount scope if we choose not to.
Maybe we are just missing something here.
|
|
|
|
Rank: Advanced Member
Groups: System, Administrators, Developers, Registered, HelpDesk Joined: 10/29/2018(UTC) Posts: 472
Thanks: 4 times Was thanked: 34 time(s) in 33 post(s)
|
Thanks for letting us know. It appears to be a bug. I will need to see if the dev team can provide a way to fix the issue. It's not working for me either. I can't remove a discount assigned to the category, but it does work when removing it from the product itself.
I'll have someone get back to you on Monday.
|
Thanks for your support!
Katie Secure eCommerce Software and Hosting |
|
|
|
Rank: Advanced Member
Groups: Authorized User, Registered, Developers, HelpDesk Joined: 11/30/2018(UTC) Posts: 86
Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Katie thank you for looking at this so quickly. We will wait to hear back from the Dev Team....
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
To fix the issue, you need to made the following code changes: 1- Open file \Website\Areas\Admin\Views\Discount\EditDiscountScopeCategory.cshtml 2- Search for Code:function submitMe(saveUrl) {
var checked_ids = [];
console.log($('#treeview').jstree("get_selected", true));
var selectedElms = $('#treeview').jstree("get_selected", true);
$.each(selectedElms, function () {
checked_ids.push(this.id);
});
if (checked_ids.length != 0)
{
$.ajax({
url: saveUrl + '&categoriesIds=' + checked_ids,
type: "POST",
success: function (data) {
if (data.status == "Redirect") {
window.location = data.Url;
}
else {
toastr.success("Categories added Successfully", "Success");
}
},
error: function (data) {
console.log("Failure " + data)
}
});
}
else
{
swal('Please Select at least one Category.')
}
}
3- Replace with Code:function submitMe(saveUrl) {
var checked_ids = [];
console.log($('#treeview').jstree("get_selected", true));
var selectedElms = $('#treeview').jstree("get_selected", true);
$.each(selectedElms, function () {
checked_ids.push(this.id);
});
$.ajax({
url: saveUrl + '&categoriesIds=' + checked_ids,
type: "POST",
success: function (data) {
if (data.status == "Redirect") {
window.location = data.Url;
}
else {
toastr.success("Categories added Successfully", "Success");
}
},
error: function (data) {
console.log("Failure " + data)
}
});
}
4- Open file \Website\Areas\Admin\Controllers\DiscountController.cs 5- Search for Code:public ActionResult SaveDiscountCategories(string categoriesIds, int DiscountId, bool SaveOnly)
{
var categoryRepo = AbleContext.Resolve<ICategoryRepository>();
VolumeDiscount discount = _discountRepo.Load(DiscountId);
List<int> categoriesIntIds = new List<int>();
foreach (var cId in categoriesIds.Split(',')) { categoriesIntIds.Add(AlwaysConvert.ToInt(cId)); }
if (categoriesIntIds.Count > 0)
{
//UPDATE CATEGORIES
discount.Categories.Clear();
foreach(int id in categoriesIntIds)
{
var category = categoryRepo.Load(id);
discount.Categories.Add(category);
}
discount.Categories.Save();
_discountRepo.Save(discount);
}
if (SaveOnly)
{
return Content("Success");
}
else
{
return Json(new { status = "Redirect", Url = Url.Action("EditDiscount", new { id = DiscountId}) });
}
}
6- Replace with Code:public ActionResult SaveDiscountCategories(string categoriesIds, int DiscountId, bool SaveOnly)
{
var categoryRepo = AbleContext.Resolve<ICategoryRepository>();
VolumeDiscount discount = _discountRepo.Load(DiscountId);
List<int> categoriesIntIds = new List<int>();
if (!string.IsNullOrEmpty(categoriesIds))
foreach (var cId in categoriesIds.Split(',')) { categoriesIntIds.Add(AlwaysConvert.ToInt(cId)); }
//CLEAR CATEGORY ASSIGNMENT
discount.Categories.Clear();
if (categoriesIntIds.Count > 0)
{
//UPDATE CATEGORIES
foreach(int id in categoriesIntIds)
{
var category = categoryRepo.Load(id);
discount.Categories.Add(category);
}
discount.Categories.Save();
_discountRepo.Save(discount);
}
if (SaveOnly)
{
return Content("Success");
}
else
{
return Json(new { status = "Redirect", Url = Url.Action("EditDiscount", new { id = DiscountId}) });
}
}
7- Compile the Ablecommerce project
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
The fix provided above by Shaharyar should work great and will be available in the upcoming release. If you can't compile the code, you can apply a workaround to this issue. That is, create a private empty category and assign the discount to this private category by removing from the original category.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Registered, Developers, HelpDesk Joined: 11/30/2018(UTC) Posts: 86
Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you all for the quick fix. We will make the change and if we have any issue's, we will let you know.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close