Created
June 15, 2015 20:17
-
-
Save ameeker/746dbe2c46cd4d3978c3 to your computer and use it in GitHub Desktop.
Add WooCommerce Order ID column to Gravity Forms export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_export_fields', 'add_fields', 10, 1 ); | |
function add_fields( $form ) { | |
array_push( $form['fields'], array( 'id' => 'orderid', 'label' => __( 'Order ID', 'gravityforms' ) ) ); | |
return $form; | |
} | |
add_filter( 'gform_export_field_value', 'set_export_values', 10, 4 ); | |
function set_export_values( $value, $form_id, $field_id, $lead ) { | |
switch( $field_id ) { | |
case 'orderid' : | |
$value = 'echo $order->id;'; | |
break; | |
} | |
return $value; | |
} |
The first example returns the form id; the second returns a 0.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, depending on how that extension works you may be able to get the order number by using the
$form_id
. Something like this:If that doesn't work, if the form is submitted on the product's page you can retrieve that from the
$lead
parameter like this:I think that's about the best I can do with the given information and my understanding of the plugins you're using. It might work... or not... 😀