Jump to content

Store management off and product combinations


czita

Recommended Posts

Hi everyone,

 

I want to allow the user to add any number of product by clicking on the plus and minus buttons in the product details.

 

It is thus possible to set up prestashop?

 

I have disabled stock management.

 

Product without combinations work perfectly. Manual change number in input and then add to cart work.

 

I found yet another way - change code in product.js.

 

 

PS 1.6.0.9

 

Thank you for help

Link to comment
Share on other sites

Hi,

I am not totally sure what your question is about. You mean there is a bug, and combos are not added with the specified quantity, once you hit 'add to cart'?

Hi,

 

I don't know if it's bug.

I want to allow the user to change the quantity of the product before adding to cart using the buttons.

 

It works without the product combinations. For product combinations can't increase the number of pieces in the product detail page by using buttons.

Link to comment
Share on other sites

This is already possible in prestashop 1.6, by default. Are you using a custom template? Can you share your site's link?

 

Template is custom - modified default-bootstrap. For example test site and product with combinations http://prestashopeko.jipas.cz/kovove-obloucky-uchytky/1637-nabytkova-uchyka-kov-0364l.html. If clicking to plus button, number is still 1.

 

On localhost I tried switch template directory to original directory (default-bootstrap) and behaviour is same.

Link to comment
Share on other sites

I see. Try and debug the following, in product.js

    // The button to increment the product value
    $(document).on('click', '.product_quantity_up', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
		if (quantityAvailable > 0) {
				quantityAvailableT = quantityAvailable;
		} else {
				quantityAvailableT = 100000000;
		}
        if (!isNaN(currentVal) && currentVal < quantityAvailableT) {
            $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
        } else {
            $('input[name='+fieldName+']').val(quantityAvailableT);
        }
    });
	 // The button to decrement the product value
    $(document).on('click', '.product_quantity_down', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1) {
            $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
        } else {
            $('input[name='+fieldName+']').val(1);
        }
    });
Link to comment
Share on other sites

Thanks. I did it - added console.log to product.js script.

 

Problem probably is in variable quantityAvailable, because is set to 1 and then quantityAvailableT is set to 1 too.

 

 

I see. Try and debug the following, in product.js

    // The button to increment the product value
    $(document).on('click', '.product_quantity_up', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
		if (quantityAvailable > 0) {
				quantityAvailableT = quantityAvailable;
		} else {
				quantityAvailableT = 100000000;
		}
        if (!isNaN(currentVal) && currentVal < quantityAvailableT) {
            $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
        } else {
            $('input[name='+fieldName+']').val(quantityAvailableT);
        }
    });
	 // The button to decrement the product value
    $(document).on('click', '.product_quantity_down', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1) {
            $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
        } else {
            $('input[name='+fieldName+']').val(1);
        }
    });
Link to comment
Share on other sites

  • 1 month later...

Have anybody idea how to set or what to do?

 

Problem: Can't change number of products to cart by button "+" in detail product page. This problem is only at product with combinations. At product without combinations is possible add more pieces.

 

Stock management is disabled. Is this bug?

 

My workaround is edit product.js and comment code at line 227-229

// if (quantityAvailable > 0)
//			quantityAvailableT = quantityAvailable;
//		else

But this isn't real good solution.

 

Problem will be at generated variable combinations. There is set quantity = 1 at each combination.

 

Prestashop 1.6.0.9 and 1.6.0.8

Link to comment
Share on other sites

×
×
  • Create New...