VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: melingmeier on March 03, 2015, 10:37:42 AM

Title: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: melingmeier on March 03, 2015, 10:37:42 AM
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?
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: prokops on March 03, 2015, 12:04:00 PM
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,
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: GJC Web Design on March 03, 2015, 14:34:00 PM
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
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: melingmeier on March 03, 2015, 18:04:39 PM
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!
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: AH on March 03, 2015, 18:46:22 PM
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.

Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: jenkinhill on March 03, 2015, 19:45:38 PM
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. 
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: patbe60 on March 06, 2015, 10:30:18 AM
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
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Milbo on March 09, 2015, 15:32:14 PM
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
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: prokops on March 12, 2015, 14:15:18 PM
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
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: raffys88 on March 19, 2015, 13:02:34 PM
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
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Studio 42 on March 19, 2015, 14:15:34 PM
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.
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: JacoboPS on April 10, 2015, 12:02:20 PM
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!)
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Studio 42 on April 10, 2015, 16:20:55 PM
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.
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Milbo on April 10, 2015, 20:41:02 PM
ehrm Patrick, it was originally your code, as far as I know.
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Studio 42 on April 11, 2015, 00:31:03 AM
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 ?
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Milbo on April 11, 2015, 17:50:21 PM
yeh Patrick and whoever wrote it. In doubt it was you, because you did most of the js in vm2.0. All I did was to notice that it does not work and to adjust it that it works. One part of the work was to create a proper function for it. I just placed the function in the Virtuemart variable. To remove the inline stuff, but the function is mainly a copy of the old stuff with a bit enhancements making it more robust. But the idea for vm3 was to stay BC as best as possible regarding the templates/layouts and there are often more important things todo, so I left it. Btw j3 is even using inline js for all toolbars.

I had to rework a lot js, due the ajax reloading. So I was happy if someone directly worked.
None of my new js is inline. All the js, which I overhauled myself is using the .on .off construction. But actually, inline scripts are shitty to modify ( I know it very well, because I just overhauled the js for j2.5 and j3.4 and then came j3.4.1), but work very well. And you know the rules of this projects, they are still the same.
If you want to modify it and want to remove the inline js, then just create a patch using the jQuery on. off. pattern and it will be implemented at least for vm3.2
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Studio 42 on April 12, 2015, 15:46:13 PM
Max,
Many problem come from step checking. This was not existing when i was in team.
The button was working before, because the value was always 1, nothing to check.
A developer has added the step feature(for more then 1 year), from this moment the script have bugs.
You can check yourself the commits, i never wrote one line of the broken code.

I Never said, you have add the "bad" code, but you (the current team) continue to use it so. If you don't understand, i cannot help you.
The ajax loading is a nice feature, but i think it was not mature and was not the moment to add it.

I don't migrate to Virtuemart 3 only because, migration does not full work, all little bugs in vm3 and i cannot re implement my own javascript with the method you use currently. Of course if you don't use any plugins, modules with javascript, all work correctly but for custom shops you can't migrate when you have Zoom script for eg., customfields with javascripts Or you have to rewrite all the Core javascript.
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Studio 42 on April 12, 2015, 16:11:30 PM
For the inline javascript in joomla, this was a main problem seens year :

You can read this page : https://docs.joomla.org/JavaScript_Working_Group#J.21_and_Beyond_2012 reporting the same problems

you can read in this page:
QuoteStop writing JavaScript in PHP!
Stop
writing inline JavaScript! (causes "flashes") (although Geraint disagrees (and so does Peter (and Danielle)))
Don't code onClick events directly into markup! Use stopPropagation.

But as you can see the Joomla javascript coder do the same, but this not mean they do it right

PS: I was at this meeting and all the people making javascript said the same thing
Title: Re: 3.0.6(.2): Quantity Not incrementing on Product Details page
Post by: Milbo on April 13, 2015, 09:34:22 AM
Seems you still do not understand. There are always wishes and the reality. If you want that your wishes become reality, you must priorise. If no one has problems with the code, no one want to change it => no one will change it. Very simple. It has nothing todo if the code could be written better or not. The project has the still the same rules as years before. If you or your customers have a problem with the code, enhance it. Dont come in here and just bitch around.

The ajax stuff is working very great and also with 3rd party plugins, you must just use the correct way. So why the gentle you come in here, not being able to adjust your js to the ajax, which is according to your own words basic knowledge. On the other hand you want that I change a function which works for most people that way and also with the ajax. Just because it is not following the last standard.

The thread is solved. Anyone is happy, even we know it could be better, but you come in here and mainly just bitch around.

Btw you can solve the problem of dynamically loaded js on different ways. So my priority was not to provide a perfect quantity step script. My priority was to get a js working dynamically reloaded by ajax.