Ajax add to cart

I am trying to update the price of an item dynamically. I can update the page just fine, but it appears that a class=“cm-ajax” form is read at load time for the values (for ajax add to cart). Hence, it’s not really dynamic at all, but based on the form input fields at page load time. I do NOT want to reload the page to get it to work properly.

Does anyone know how to tell the ajax.js to re-read the form to get the current values from the DOM?

Example, a normal price for a product is $49.99. Based on a counter (javascript setTimer()), I update the price with a new value at a certain frequency. Unfortunately, no matter what I set the price to (displays just fine), the value, when added to the cart, is $49.99.

So if there’s a javascript junky out there who can help me out, I’d appreciate it. I think the easiest thing is to tell it to re-read the whole form after I update, but if I can tell it the field and value, that would be fine too.

So here’s what I learned…

The Ajax add to cart does not send the price to the cart. It simply reports the price of the item after it has been added to the cart. So the problem changed from to figuring out how to add a specific (calculated) price to the cart.

I chose to do this with a hook. I used the add_to_cart hook where I force the cart product price to what I want. It is important to set the $cart[‘stored_cart’]=‘Y’, otherwise it will retrieve the price from the db and overwrite the changes.

Hence this was all done in PHP versus javascript (though I did have to rewrite some elments of the product_detail page to set some form fields to work with.