I am going to be phasing out Drupal Commerce on our website in favor of a new custom built application that is hosted at another URL. Without completely rebuilding everything I am trying to override the Add to Cart form to redirect with POST data to the new app.
Using $form['#action'] I can redirect properly and dumping out shows something like this:
array(7) {
["quantity"]=>
string(1) "2"
["product_id"]=>
string(4) "8566"
["form_build_id"]=>
string(48) "form--90fc5Yp9qgp4CVFJlq03jfEZyYBkAhDX-j7E5g9oBQ"
["form_token"]=>
string(43) "T08Fl1dNHuI4BCZ4JuLNwxbw6gUTOfnodbc1zcQMR4E"
["form_id"]=>
string(35) "commerce_cart_add_to_cart_form_8566"
["field_are_you_a_product"]=>
array(1) {
[0]=>
array(1) {
["field_are_you_a_"]=>
array(1) {
["und"]=>
string(3) "yes"
}
}
}
["op"]=>
string(11) "Add to cart"
This is helpful but the product_id is useless as I need more info, like the SKU or a custom ID field I have on the product level. I can't seem to get this to provide me with the product info I need.
I initially tried using a custom submit handler instead but that didn't work. drupal_http_request isn't right as it just sends post data, does actually redirect with post data like action does.
So since setting the action works great, how would I alter this form to send more information during that step within hook_form_alter?
commerce_product_load($product_id)
to load product object, than you can retrieve any info see the fuction api.drupalhelp.net/api/commerce/…hook_form_alter
for example SKU$form['sky'] = array( '#type' => 'hidden', '#value' => YOUR_VALUE, );
as hidden fields and they will submitted with the form