Advertisement
Guest User

Display Gravity Form Selection in HTML Block

a guest
Aug 13th, 2012
1,289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. function mf_productSummary($atts) {
  2.      extract(shortcode_atts(array(
  3.         'formID' => '7'
  4.      ), $atts));
  5.      
  6.      $thisForm = RGFormsModel::get_form_meta($formID);
  7.      
  8.      $result .= "<h1>Purchase Summary</h1>";
  9.  
  10.      foreach($thisForm['fields'] as $index => $fieldInfo) {
  11.       if($fieldInfo['type'] == 'product') {
  12.         $subLabel = $fieldInfo['label'];
  13.        
  14.         $postName = 'input_'.$fieldInfo['id']; //build name to get $_POST value using rgpost function
  15.         $postedFieldValue = rgpost($postName);
  16.        
  17.         $choiceText = "(".RGFormsModel::get_choice_text($fieldInfo, $postedFieldValue, $fieldInfo['id']).")";
  18.        
  19.         $result .= "<h3>".formatProductPrice($postedFieldValue)." - $subLabel $choiceText</h3>";
  20.       }
  21.      }
  22.      
  23.      return $result;
  24. }
  25. add_shortcode('product_summary', 'mf_productSummary');
  26.  
  27. function formatProductPrice($rawVal) {
  28.   return "$".money_format('%6.2n',substr($rawVal,0,strpos($rawVal,'|')));  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement