Skip to content

Instantly share code, notes, and snippets.

@Yame-
Created June 16, 2015 21:24
Show Gist options
  • Save Yame-/6cd1133b24bfc6a1f20a to your computer and use it in GitHub Desktop.
Save Yame-/6cd1133b24bfc6a1f20a to your computer and use it in GitHub Desktop.
Add WooCommerce product with Contact Form 7
<?php
/* Capture CF7 data */
add_action( 'wpcf7_mail_sent', 'wpcf7_capture_data' );
function wpcf7_capture_data( $contact_form ) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
// The 999 represents our CF7 form ID
if( $posted_data['_wpcf7'] == 999 ) {
// Add WooCommerce product
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment