Jump to content

Removing ghost product from the cart summary page when clicking delete


Recommended Posts

Hello everyone,

Apologizing in advance for my english.

My shop is a B2B and it has products that are sold in sets of 2, 4, 10... depending of the product.

Let's take the product Blade sold by 10 as an example for my problem.

We used to manage those products with attributes but the price was the one of the complete set of 10 and 1 quantity = a set. People mistaked the quantity, they would take 10 sets thinking they are taking 10 blades even though it was written and they needed to have the unit price of the blade. So we are now managing the sets by the minimal quantity of a product and we erased the attributes of those products.

I'm not a pro in JS but I've managed to change the product, the category and the summary cart/one page checkout page templates and js for the quantities to go by multiple of the minimal quantity. So if the blade is sold by ten, you will see "10" prefilled on those pages instead of 1 and then clicking the plus or minus button would add or remove "10" quantities.

I also add warnings if the quantity filled is wrong (add to cart disabled and a sentence in red that tells people to correct the quantities by a multiple of 10).

On the cart summary, as there are several product, I created a function on the js file that checks if each quantity is filled correctly or not. The result is True if it's not filled correctly and False if it's filled correctly. I put those trues and falses on an array with the array.push() js function and then I say "if there is at least one true on that array, put a big warning and do not display the following blocks" which prevents the client from pursuing the order.

 

I have a bug with the last functionality:

  • Say that we have 6 different products in the cart and one has the wrong quantity : 16 instead of a multiple of 10. The warnings appear and the blocks after the summary table disappear so the client can't pursue the order. When this particular "wrong quantity" product is removed (clicking the delete button), my function checks the products of the summary cart list and creates its array of trues and falses. This array still contains the product that has been removed because it is still in the DOM of the page! I have to refresh the page for it to go.

Does someone know how to "remove" the product completly without refreshing so my function doesn't take it into account even though it's deleted? Or at least how to do an array.pop() on that product so it's removed from the array? Maybe it has a particular thing I can select to say those products deleted I want to pop them out of the array!

I hope I was clear in my explonation.

Prestashop 1.6.1.10 

MySQL 5.6.40

PHP 7.0.30-0ubuntu0.16.04.1

Edited by pranab13
Did not put the version of prestashop (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...