Bug with Cart products quantity and combine mechanism when add the same item.
How to make it so that it is displayed not in different line items, but one, provided that we select the same product option? And some strange behavior with quantity. Ps if you go to the next tab, select a customer, and go back, everything is displayed correctly.
Short video:
https://drive.google.com/file/d/1FHOoE07r02_64otuhmw3S7bhBI1TfNaZ/view?usp=sharing
any suggestion?
I believe we discussed this issue in one of the last Core Team meetings. I believe @kennyadsl was working on something that would fix this.
Yes, I'm working on a fix and unfortunately to make it work with the way Backbone is structured today, there's a lot to change.
@iLucker93 If you want to have a quick fix, you can force a page reload after adding items to the cart. If that's a viable solution for you and you need assistance implementing this, let me know and I can try to help.
@kennyadsl how I can force a page reload after adding items to the cart?
@iLucker93 here's a fix we came up with @kennyadsl that will patch Spree.Views.Cart.LineItemRow.prototype.onSave to make it reload the page whenever a new item is added. It's not pretty, but should be simple to install.
It should be enough to append it to vendor/assets/javascripts/spree/backend/all.js as shown below:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery3
//= require rails-ujs
//= require spree/backend
//= require_tree .
Spree.Views.Cart.LineItemRow.prototype.onSave = function(e) {
var wasNew = this.model.isNew(); // ADDED
e.preventDefault()
if(!this.validate()) {
return;
}
var attrs = {
quantity: parseInt(this.$('input.line_item_quantity').val())
}
if (this.model.isNew()) {
attrs['variant_id'] = this.$("[name=variant_id]").val()
}
var model = this.model;
this.model.save(attrs, {
patch: true,
success: function() {
model.order.advance()
if (wasNew) location.reload(); // ADDED
}
});
this.editing = false;
this.render();
}