cf_si_process_form_estimate

Function runs on form process to create an estimate.

Description

cf_si_process_form_estimate( $config, $form ); 

This will create the Estimate and Client and Return the Estimate ID which is then a magic tag.

Parameters (2)

0. $config
The config.
1. $form
The form.

Usage

  1. if ( !function_exists( 'cf_si_process_form_estimate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-forms-sprout-invoices-integration/cf-sprout-invoice.php'; 
  3.  
  4. // The config. 
  5. $config = null; 
  6.  
  7. // The form. 
  8. $form = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = cf_si_process_form_estimate($config, $form); 
  12.  

Defined (1)

The function is defined in the following location(s).

/cf-sprout-invoice.php  
  1. function cf_si_process_form_estimate($config, $form) { 
  2. global $transdata; 
  3.  
  4. foreach ($config as $key => &$value) { 
  5. $value = Caldera_Forms::do_magic_tags($value); 
  6. // Set Values 
  7. $subject = $config['subject']; 
  8. $requirements = $config['requirements']; 
  9. $email = $config['email']; 
  10. $client_name = $config['client_name']; 
  11. $full_name = $config['first_name'] . ' ' . $config['first_name']; 
  12. $website = $config['website']; 
  13. $contact_street = $config['street_address']; 
  14. $contact_city = $config['city']; 
  15. $contact_zone = $config['state']; 
  16. $contact_postal_code = $config['postal_code']; 
  17. $contact_country = $config['country']; 
  18.  
  19. // build arguments for estimate 
  20. $estimate_args = array( 
  21. 'subject' => $subject,  
  22. 'requirements' => $requirements,  
  23. 'fields' => array(),  
  24. 'history_link' => Caldera_Forms::do_magic_tags( $config['history_text'] ),  
  25. ); 
  26.  
  27. // Maybe create the estimate? 
  28. $estimate = @cf_si_maybe_create_estimate( $estimate_args, $config['processor_id'] ); 
  29.  
  30. if ( is_a( $estimate, 'SI_Estimate' ) ) { 
  31. // build the client arguments if it is an estimate 
  32. $client_args = array( 
  33. 'email' => $email,  
  34. 'client_name' => $client_name,  
  35. 'full_name' => $full_name,  
  36. 'website' => $website,  
  37. 'contact_street' => $contact_street,  
  38. 'contact_city' => $contact_city,  
  39. 'contact_zone' => $contact_zone,  
  40. 'contact_postal_code' => $contact_postal_code,  
  41. 'contact_country' => $contact_country 
  42. ); 
  43. // maybe create a client? 
  44. $client = cf_si_maybe_create_client( $estimate, $client_args ); 
  45.  
  46. // return meta data for entry and magic tag values for the rest of the process 
  47. return array('estimate_id' => $transdata['estimate'][$config['processor_id']]); 
  48.