Programmatically Update Product Price From Add Cart Form
My client has a huge number of product prices based on customer id and product which often change. The vendor hosts the pricing table on an external server.
I have been trying to modify commerce_cart_add_to_cart_form with my own hook module to
1. Grab the pricing from the external server with drupal_http_request
2. Update the unit price of the line item so that when the using hits the Add To Cart (submit) button, the new price goes into the cart.
I have #1 working fine... I can get the price and assign it to a variable. What I -can't- figure out is #2: how to assign that to the line_item object.
I thought there might be a way to add PHP directly to a pricing rule, but I can't figure -that- out. And when I looked for help on hook_commerce_cart_product_add ... which seems to be the hook I need, I can find no examples.