3.0.6(.2): Quantity Not incrementing on Product Details page

Started by melingmeier, March 03, 2015, 10:37:42 AM

Previous topic - Next topic

melingmeier

I just updated to 3.0.6.2 because the "+" an "-" for the product quantity doesnt work in the Product Details view since 3.0.6 but the bug is still there...
If I click on "+" there is a "NaN" shown in the quantity box and I get the following error message "Sie können dieses Produkt nur in Vielfachen von 1 Stück kaufen!" which means I'm only able to buy a multiple of 1 piece.

Does someone else have this problem?
Virtuemart Version: 3.0.16 on Joomla 3.5.1; php 7

prokops

Hi,

I have the same problem. It seems that the problem is with my template and VM itself. Try to contact your template provider ?

Cheers,

GJC Web Design

Indeed - std. answer..

try with the default template (obviously it works)

not with your template? Then the problem is in your template

compare the two and correct or if commercial get on to the seller
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

melingmeier

You're right. It's the template.
One thing I don't understand is why you change such elementary things from one revisionnumber to another, so it is not enough for template designer to create compatibility to VM3 only, no they have to check compatiblity every single revison from 3.0 to 3.0.4 to 3.0.6...

Anyway, thanks for your fast reply!
Virtuemart Version: 3.0.16 on Joomla 3.5.1; php 7

AH

VM3 is not a fixed set of functionality but a major version change.  With revisions that continue to enhance functionality.

There are revisions and they are called that because things have changed.

Quoteso it is not enough for template designer to create compatibility to VM3 only,

Correct, every revision requires templaters to review the changes and impact on their templates and users

The devs could have called each revision 3.1, 3.2, 3.3, 3.4 etc but the numbering is irrelevant.  What matters is that when the version number changes so does the code.

And consequently templates need to be checked.

Regards
A

Joomla 3.10.11
php 8.0

jenkinhill

Many commercial templaters are not happy just to change layouts & style, but also add their own changes to functionality. It is these changes that so often cause problems with updates when VM code changes to improve or enhance the default functions. 
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

patbe60

QuoteMany commercial templaters are not happy just to change layouts & style, but also add their own changes to functionality. It is these changes that so often cause problems with updates when VM code changes to improve or enhance the default functions. 

Not in this case: the file com_virtuemart/sublayouts/addtocart.php has got some changes. Maybe in your overrides folder (yourtemplate/html) there is an older version of this file. In this case you need to delete or replace it with the new version and to make the overrides in the html parts.

Regards
Patrik

Milbo

This change should be backward compatible, the old addtocart.php is just calling the addtocartbar.php which is almost the same code as before.

So if someone used and override for addtocart.php, anything should still work. The problem is the fix for the quantity update.

The input

<input type="text" class="quantity-input js-recalculate" name="quantity[]"


has 3 new attributes

value="<?php echo $init?>" init="<?php echo $init?>" step="<?php echo $step?>" <?php echo $maxOrder?> />


which is for example

value="2" init="2" step="2>" max="20" />


So to keep the BC, the JS is missing a fallback.

Please try the attached js, upload it to components\com_virtuemart\assets\js and remove the .txt
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

prokops

Thanks for the response. I applied your fix.

It works great as long as the quantity is in the positive. As soon as the counter goes below 1, it goes NaN :)

Cheers,
prokop

raffys88

i have the same problem...i use you fix but i have a small problem.
when i increment more 1 pcs and after i return to 1 product...if press again i revise NAN.
Sorry for my english

Studio 42

Quotefor Milbo :

ANd why not using html data attributes ?
I don't understand that you have permit so a bad change in 2015 and not follow html5 rules.

Or you use HTML5 number input type : http://www.w3schools.com/tags/att_input_max.asp
<input type="number" name="quantity" min="1" max="5" data-step="2">
or input text html4/5
<input type="text" name="quantity" data-min="1" data-max="5" data-step="2">

Especialy this was wrote this year, then why not using right html semantic.

JacoboPS

Thank you Milbo for the solution!, The + button is working now!!

And what about the "-"?  ;) I have the same problem than some people here. Anyone solved it already?

Don't make me beg!! (I will do it if need it!)
Learning, pulling hair out, learning...

Studio 42

Sorry, i don't give the fix for a already bad way to do.

The function have change more then 3 times in 6 months, only for quantity cheking & the solution is not perfect.

when i only see this code in vm 3.0.6
<input type="text" class="quantity-input js-recalculate" name="quantity[]"
   onblur="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
   onclick="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
   onchange="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
   onsubmit="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
   value="<?php echo $init?>" init="<?php echo $init?>" step="<?php echo $step?>" <?php echo $maxOrder?> />


If a javacript PRO see the code, he laughs all day :)

Wait for milbo.

Milbo

ehrm Patrick, it was originally your code, as far as I know.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

Hi max,
Virtuemart.checkQuantity(
was not existing when i was in the team this was added in vm 2.6.X

right html
Quote<input class="quantity-input" type="text" name="quantity" data-min="2" data-max="10" data-step="2" data-msg="<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>">

The poorest javascript, is inline javascript. This is explained in many basic tutorials.
right way in jquery :
$( body ).on( "click blur change submit", ".quantity-input", function() {
  var $this= $(this), min = $this.data('min'), max=$this.data('max'), step=$this.data('step');
  Virtuemart.checkQuantity(this,step,$string);

}


Your atribute : step, init are not valid html4,html5 and xhtml!
You have now html5 data (not xhtml valid , but we are in 2015 now)

but why click ? and submit ?
but why adding the message in all inputs ?

You don't think, your code is bad ?