News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

No price update in product details on page load [VM 3.4.3]

Started by balai, June 14, 2019, 13:52:38 PM

Previous topic - Next topic

balai

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):
/*/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):
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

Which version is this? We are currently testing VM3.6.0.10075 - it is still commented out in this version.
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

StefanSTS

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

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

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

QuoteYou are still not giving version numbers.
Look the topic's title

QuoteWhat 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

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

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

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

balai

QuoteJust 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?

Quoteit 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

My answer was for product details only, of course as requested in the title.