Author Topic: No price update in product details on page load [VM 3.4.3]  (Read 660 times)

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1384
No price update in product details on page load [VM 3.4.3]
« on: June 14, 2019, 13:52:38 pm »
Seems like the price update script is not called on page load of the product details page.
Looking further i found out that the part of the script that calls the price update in the com_virtuemart/assets/js/vmprices.js is commented.

As is now (No update):
Code: [Select]
/*/jQuery(document).ready(function($) {
Virtuemart.product(jQuery("form.product"));

/*$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find('input[name="virtuemart_product_id[]"]').val();
Virtuemart.setproducttype($(this),id);

}
});*/
//});

Without the comment (Functional):
Code: [Select]
jQuery.noConflict();
jQuery(document).ready(function($) {
Virtuemart.product(jQuery("form.product"));

$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find('input[name="virtuemart_product_id[]"]').val();
Virtuemart.setproducttype($(this),id);

}
});
});

Not sure if this should be called always but now the product price is not correct if the product contains custom fields with price.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27570
  • Always on vacation
    • Jenkin Hill Internet
Re: No price update in product details on page load [VM 3.4.3]
« Reply #1 on: June 14, 2019, 15:27:44 pm »
Which version is this? We are currently testing VM3.6.0.10075 - it is still commented out in this version.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.6.8.10197 on Joomla 3.9.13 PHP 7.0.33

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 516
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: No price update in product details on page load [VM 3.4.3]
« Reply #2 on: June 18, 2019, 11:10:23 am »
It is commented out in 10075, but the price calculation works.

It is probably a template issue or a jQuery conflict with a third party extension.

Regards
Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1384
Re: No price update in product details on page load [VM 3.4.3]
« Reply #3 on: June 18, 2019, 11:49:12 am »
No the price update does not work on page load.

Tested in a clean installation with the Joomla native templates. No js errors in my browser's console.

On page load:
https://drive.google.com/file/d/1INkiPDF3-PKmQo_UbaHin2shdY2-WYr-/view?usp=drivesdk

After selecting/clicking the custom field value:
https://drive.google.com/file/d/15N1bOU3v-eND9iMyrxsBQWl79QGdpyvf/view?usp=drivesdk

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 516
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: No price update in product details on page load [VM 3.4.3]
« Reply #4 on: June 18, 2019, 12:13:26 pm »
You are still not giving version numbers.
A screenshot does not help to find problems in this case.

Your reply:
"No the price update does not work on page load."

What does that mean? The price is loaded on page load, it is not updating on page load.
The price updates on changing the custom field value via the drop down with an ajax request which is not loading the page again.

In my case the price change works fine, so either you have a different version, or something else is different. But since you don't give your version, it's hard to say.



--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1384
Re: No price update in product details on page load [VM 3.4.3]
« Reply #5 on: June 18, 2019, 12:17:39 pm »
Quote
You are still not giving version numbers.
Look the topic's title

Quote
What does that mean? The price is loaded on page load, it is not updating on page load.
I am referring to custom fields which have price, they are selected by default and and their price is not added to the product's price (on page load).

Steps to reproducce
1. Create a string custom field.
Cart Input>Yes, Cart Attribute > Yes

2. Go to a product, assign that custom field and give a value.
Also set a price for that value.

3. Repeat step 2 for another value.

4. Visit the product details page in the front-end.
Check it's final price.
Also notice that the custom field's 1st value is selected by default.

5. Select the 2nd value and then the 1st.
You will notice that the final price is now different, although the 1st value is selected (as when you visited the product).
Now the custom field value's price is calculated.

Conclusion
Although the custom field's value is pre-selected when the user visits the product's page, it's price is added (calculated) only after the user selects that.
I.e. If the user adds the product to the cart as is, accepting the default selection, the product price in the cart will be different to the product price in the details page.

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 516
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: No price update in product details on page load [VM 3.4.3]
« Reply #6 on: June 18, 2019, 12:28:05 pm »
3.4.3 is not a precise version number.
3.4.3.10075 kind of is, because there are even different 10075s out.
Betwenn 3.4.3. first version and 10075, are more than hundred versions I guess. You can find that out in the SVN.

I could reproduce your problem though.
If your first custom field value has an added price, it will not load on page load, that is right.
It did not show up in my test because my first custom field price was 0.00.

With a nice test description everything is so easy, thanks.

So this is a confirmed bug.

Thanks for reporting.
Stefan

PS. The vmprices.js has not changed in a long time, maybe the price was loaded with the right value before (I would expect that) and didn't need the recalculation after load. So something might have changed on the initial load, so that the custom field is not taken into account.
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4044
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: No price update in product details on page load [VM 3.4.3]
« Reply #7 on: June 18, 2019, 13:12:04 pm »
If you want price update then trigger a click or change in any field in the form should work and is easy to implement.
Of course it's better to verify if you have some cart fields to not call for nothing price update.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9972
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: No price update in product details on page load [VM 3.4.3]
« Reply #8 on: June 18, 2019, 13:30:03 pm »
The price update was removed loong, loong time ago. I think for vm3.0.0, the reason is simple! Just imagine you browse 50 products which need a price update to show the correct price, would mean 50 ajax calls in the FE. So since vm3.0.x times it is mandatory to setup the prices so, that the price loaded by the product is directly the correct price.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1384
Re: No price update in product details on page load [VM 3.4.3]
« Reply #9 on: June 18, 2019, 14:08:56 pm »
Quote
Just imagine you browse 50 products which need a price update to show the correct price, would mean 50 ajax calls in the FE.
What about calling that only to the details page and only when cart attribute custom fields exist?

Quote
it is mandatory to setup the prices so, that the price loaded by the product is directly the correct price.
How this can be done for a product with price variant custom fields.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4044
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: No price update in product details on page load [VM 3.4.3]
« Reply #10 on: June 18, 2019, 15:27:29 pm »
My answer was for product details only, of course as requested in the title.