News:

Support the VirtueMart project and become a member

Main Menu

Load product data (child, next and previous) by AJAX (VM2.0.12)

Started by George@WisdomSoftware, October 22, 2012, 18:46:43 PM

Previous topic - Next topic

George@WisdomSoftware

Dear members of the Virtuemart community,

In VM1.1 when a shopper browses at a product details page and chooses a product child, then the product child data are loaded through AJAX without having to reload the whole page.
In VM2 this feature is not present. So we had to implement it and we would like to share this solution with the community, wishing that in the next versions of VM2, it could be incorporated into the main
virtuemart code line.

We have applied this solution to the site www.artweardimitriadis.com where one can see the results.

In order to use the solution you can follow the steps below:

1. If you already have the file "templates/my_template_folder/html/com_virtuemart/productdetails/default.php" into your template folder, then omit this step (go to step 2).
Else, copy the file "components/com_virtuemart/views/productdetails/tmpl/default.php" into the folder "templates/my_template_folder/html/com_virtuemart/productdetails/".
Take care: replace "my_template_folder" with your real template folder name

2. Modify the file "templates/my_template_folder/html/com_virtuemart/productdetails/default.php" adding after the line

defined('_JEXEC') or die('Restricted access');

the following code:

$js = '<script type="text/javascript" src="/templates/yoo_nano/html/com_virtuemart/productdetails/productDetailsUpdater.js"></script>';
$doc =& JFactory::getDocument();
$doc->addCustomTag($js);


3. Copy the file attached here "productDetailsUpdater.js" into the folder "templates/my_template_folder/html/com_virtuemart/productdetails/"
Take care: replace "my_template_folder" with your real template folder name

4. That's it. Now you just have to test your installation:
   4.a) Go to the Front-End, to the page of a product and click the previous (or next) product navigation buttons.
   4.b) Go to the page of a product having child products and choose one of its children.
In both cases the new product data should appear without a full page reload (using AJAX).

Please remember that this code is published under GPL and AS IS, without any kind of expressed or implied warranty of any kind.
It is not recommended for any particular application and can only be applied with your full responsibility for any implementation you may use it.

Kind regards to all.

Giorgos Kolomvos
Wisdom Software (www.wisdomsoftware.net)

P.D. Please note that this solution has been implemented by Maks (the author of Cherry Picker extension at www.galt.md) and sponsored by Wisdom Software.


[attachment cleanup by admin]

Steffi

 :) would be a realy nice feature ... but it doesn't work ... did every step  ???

George@WisdomSoftware

#2
Quote from: Steffi on October 26, 2012, 19:46:07 PM
:) would be a realy nice feature ... but it doesn't work ... did every step  ???

Please, give us more detailed information about your installation and we might help you.
What version of Joomla and Virtuemart do you have?
After you make the modification of  the file "templates/my_template_folder/html/com_virtuemart/productdetails/default.php" and upload the file "templates/my_template_folder/html/com_virtuemart/productdetails/productDetailsUpdater.js", what exactly happens when you choose a child product?
If the site you use is published, please post the url of one of your product pages so we can see what's wrong.
Note that, If you don't post enough info, nobody will be able to help you out.

abzamon

hello,
I'm trying to implement your code with a custom stockable variant (2 selects size and color) with VM2.012f .

I modified field0custom_value to match my custom field id (selectoptions2) but when I change the select I get a blank page.

Any ideas?

Thx

Sylvain

abzamon

I got it working.

I just need to fire    function processChangeChildProductEvent(changedSelect)  when the page loads.

Can you help me on this?

abzamon

hello,

With your code and small modification (eg: custom field id) everythings worked fine (Ajax refresh...) until I tried to add different variation of a product to my cart, it always add the same product.
I think this issue has something to do with the URL refresh but I wasn't able to fix it.

Can you help me please,

Sylvain

George@WisdomSoftware

#6
Quote from: abzamon on November 05, 2012, 11:49:19 AM
... until I tried to add different variation of a product to my cart, it always add the same product.
...

It might has nothing to do with our modifications.
Have you tried to do the same without the modifications suggested in this topic?
I have reasons to believe that the problem you have found might be a bug of  "custom stockable variants".

We have never  tried these modifications with "custom stockable variants". We have only tested them on "generic child variants".
(I have to note that in our last project with VM2, where we had to choose between "generic child variants" or  "custom stockable variants", we found many many problems and bugs at the "custom stockable variants" implementation, so we decided to go with the solution of the "generic child variants").


mhuebler

hello,

this hack is not working for my VM 2.0.24
i can see that the hole page is loading without ajax if i change the child variants in the frontend.

can you help me ?