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

products attribute and ajax request

Started by lbar, December 17, 2012, 19:26:57 PM

Previous topic - Next topic

lbar

Hi guys,

i have a trouble with a ajx request on product attributed.
Basically when an user click on a form on a (custom) product page, that i have created for a specific product,
the system make an ajax request on an external script passing them the id of the product.
Well....
On this external script (where i know only the product id), what kind of script, and what kind of class i need to include
in order to grab all the information of the product?

Hope that my question it's clear enough.
Thank you. 

bytelord

http://forum.virtuemart.net/index.php?topic=79799.0

Also please any live url and explain your issue better ... what are you trying to do?
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

lbar

You are right bytelord, yesterday i have posted with too much harryup and i didn't report all the needed details.
Sorry about that, i will do right now:

vmart version: 2.0.10f
joomla: 2.5.8

unlucky i canno't provide any live url, as i'm in develop enviroment with no public access.

Btw, what i'm trying to archive basically is:

- i have a products with an attribute (textual attribute);
- before to insert this product on the cart, system must do an ajax request to an external script passing the id of the
product and some data of the attribute;
- if some conditions are satisfied the ajax response must create a add to cart button;
- when i click add to cart the product must be inserted on the cart;

Well, all this process works pretty fine, the only problem that i have it's to grab the products data (that i need in order to create the corret add to cart button)
starting with only the product id, on the external (i mean external to virtuemart) script.
In other words: what kind of library i need to insert (or what kind of class i need to use) in order to create a product object starting from the id?

Hope that in this way it's more clear.
Thank you.

bytelord

Hello,

I think you mean 2.0.12f. You could create a plugin for that, just if you are using ajax i think you can done it fine inside your template also. Why you are not using some json with ajax over there to grab the product data?
$.getJSON(window.vmSiteurl + 'index.php?option=com_virtuemart&nosef=1&view=productdetails&task=recalculate&virtuemart_product_id='+id+'&format=json'

you could study the vmsite.js and vmprices.js, also use the format=json to your links from ajax requests

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

markqtty

Quote from: bytelord on December 22, 2012, 19:39:48 PM
Hello,

I think you mean 2.0.12f. You could create a plugin for that, just if you are using ajax i think you can done it fine inside your template also. Why you are not using some json with ajax over there to grab the product data?
$.getJSON(window.vmSiteurl + 'index.php?option=com_virtuemart&nosef=1&view=productdetails&task=recalculate&virtuemart_product_id='+id+'&format=json'

you could study the vmsite.js and vmprices.js, also use the format=json to your links from ajax requests

Regards

Yes, now i had followed your advice. Thank you for your collaboration, greatly appreciate.