I need to remove the quantity from some product of my minicart.

But as the minicart is loaded in ajax, I need to deal with this with JS. Sometime of remove the input, sometime it doesn't. And if I remove a product, it seems that the minicart is fully reloaded, so my code is ignored.

I've added some timer that are checking if the cart contains product. If so, then go through the children and remove the input if the product options contains "Quantit" (quantité).

See my code :

let minicartLoaded  = setInterval(function(){
let miniCart = $("#mini-cart");
if(miniCart.length > 0){
    let intProduct = setInterval(function(){
        let minicartItems = miniCart.find("li");
        if(minicartItems.length > 0){
            $.each(minicartItems, function(){
                let item = $(this);
                let options = item.find("div.product.options");
                if(options.length > 0){
                    let optionsListe = options.find('.product.options.list').find("dt.label");
                    $.each(optionsListe, function(){
                        let value = $(this).text();
  • What is the logic to show qty input or not? – Sukumar Gorai Jun 7 '19 at 10:03
  • As I said, "if the product options contains "Quantit" (quantité)." – Morgan Tartreau Jun 7 '19 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.