function set_post_content($entry, $form)
{
    //$headers[] = "Content-type: text/html";
    $pending_meta_value = gform_get_meta($entry["id"], "is_pending");
    if ($pending_meta_value == "1") {
        // wp_mail('*****@*****.**', 'Form has been saved', print_r($entry, true), $headers);
        $entry["orderStatus"] = "incomplete";
        $output = GFAPI::update_entry($entry, $entry["id"]);
    } else {
        $entry["orderStatus"] = "complete";
        $entry["unique_id"] = guid();
        //wp_mail('*****@*****.**', 'Getting the Gravity Form Field IDs', print_r($entry, true), $headers);
        //wp_mail('*****@*****.**', 'Getting the Gravity Form Data', print_r($form, true), $headers);
        $output = GFAPI::update_entry($entry, $entry["id"]);
        global $wpdb;
        //look up row in lead table, update asic status and update with eCompanies order number.
        $update = $wpdb->query($wpdb->prepare("UPDATE wp_rg_lead SET unique_id='" . $entry["unique_id"] . "' WHERE id=" . $entry['id'] . " AND form_id=" . $entry['form_id']));
        // wp_mail('*****@*****.**', 'Getting the Gravity Form Field IDs', print_r($update, true), $headers);
    }
}
Esempio n. 2
0
 /**
  * Render entry info of the specified form and lead
  *
  * @param string $form_id
  * @param array $lead
  */
 public static function entry_info($form_id, $lead)
 {
     $payment_id = gform_get_meta($lead['id'], 'pronamic_payment_id');
     if ($payment_id) {
         printf('<a href="%s">%s</a>', esc_attr(get_edit_post_link($payment_id)), esc_html(get_the_title($payment_id)));
     }
 }
Esempio n. 3
0
function get_pronamic_gf_pay_feed_by_entry_id($entry_id)
{
    $feed_id = gform_get_meta($entry_id, 'ideal_feed_id');
    if (!empty($feed_id)) {
        return new Pronamic_WP_Pay_Extensions_GravityForms_PayFeed($feed_id);
    }
    return null;
}
Esempio n. 4
0
 function entry_info_link_to_salesforce($form_id, $lead)
 {
     $salesforce_id = gform_get_meta($lead['id'], 'salesforce_id');
     if (!empty($salesforce_id)) {
         echo sprintf(__('Salesforce ID: <a href="https://na9.salesforce.com/' . $salesforce_id . '">%s</a><br /><br />', 'gravity-forms-salesforce'), $salesforce_id);
     }
 }
Esempio n. 5
0
 public static function admin_update_payment($form, $lead_id)
 {
     check_admin_referer('gforms_save_entry', 'gforms_save_entry');
     //update payment information in admin, need to use this function so the lead data is updated before displayed in the sidebar info section
     //check meta to see if this entry is paypal
     $payment_gateway = gform_get_meta($lead_id, "payment_gateway");
     $form_action = strtolower(rgpost("save"));
     if ($payment_gateway != "paypal" || $form_action != "update") {
         return;
     }
     //get lead
     $lead = RGFormsModel::get_lead($lead_id);
     //get payment fields to update
     $payment_status = rgpost("payment_status");
     //when updating, payment status may not be editable, if no value in post, set to lead payment status
     if (empty($payment_status)) {
         $payment_status = $lead["payment_status"];
     }
     $payment_amount = rgpost("payment_amount");
     $payment_transaction = rgpost("paypal_transaction_id");
     $payment_date = rgpost("payment_date");
     if (empty($payment_date)) {
         $payment_date = gmdate("y-m-d H:i:s");
     } else {
         //format date entered by user
         $payment_date = date("Y-m-d H:i:s", strtotime($payment_date));
     }
     global $current_user;
     $user_id = 0;
     $user_name = "System";
     if ($current_user && ($user_data = get_userdata($current_user->ID))) {
         $user_id = $current_user->ID;
         $user_name = $user_data->display_name;
     }
     $lead["payment_status"] = $payment_status;
     $lead["payment_amount"] = $payment_amount;
     $lead["payment_date"] = $payment_date;
     $lead["transaction_id"] = $payment_transaction;
     // if payment status does not equal approved or the lead has already been fulfilled, do not continue with fulfillment
     if ($payment_status == 'Approved' && !$lead["is_fulfilled"]) {
         //call fulfill order, mark lead as fulfilled
         self::fulfill_order($lead, $payment_transaction, $payment_amount);
         $lead["is_fulfilled"] = true;
     }
     //update lead, add a note
     RGFormsModel::update_lead($lead);
     RGFormsModel::add_note($lead["id"], $user_id, $user_name, sprintf(__("Payment information was manually updated. Status: %s. Amount: %s. Transaction Id: %s. Date: %s", "gravityforms"), $lead["payment_status"], GFCommon::to_money($lead["payment_amount"], $lead["currency"]), $payment_transaction, $lead["payment_date"]));
 }
Esempio n. 6
0
 public static function get_active_config($form, $lead = false)
 {
     require_once self::get_base_path() . "/data.php";
     $config = false;
     // if lead is provided, attempt to retrieve config from lead meta
     if (isset($lead['id'])) {
         $config_id = gform_get_meta($lead['id'], 'user_registration_feed_id');
         $config = GFUserData::get_feed($config_id);
     }
     // if no lead is provided or if meta retrieval fails, get all feeds and find the first feed that matches
     if (!$config) {
         $configs = GFUserData::get_feeds_by_form($form["id"]);
         if (!$configs) {
             return false;
         }
         foreach ($configs as $cnfg) {
             if (self::registration_condition_met($form, $cnfg, $lead)) {
                 $config = $cnfg;
                 break;
             }
         }
     }
     // if lead is provided and a config is found, update lead meta with config ID
     if (isset($lead['id']) && $config && !$config_id) {
         gform_update_meta($lead['id'], 'user_registration_feed_id', $config['id']);
     }
     if ($config) {
         return $config;
     }
     return false;
 }
 protected function is_payment_gateway($entry_id)
 {
     if ($this->is_payment_gateway) {
         return true;
     }
     $gateway = gform_get_meta($entry_id, 'payment_gateway');
     return $gateway == $this->_slug;
 }
 /**
  * Handle the IPN response for pushing the event
  * 
  * @since 1.4.0
  * @param array $post_object global post array from the IPN
  * @param array $entry Gravity Forms entry object
  */
 public function paypal_track_form_post_ipn($post_object, $entry)
 {
     // Check if the payment was completed before continuing
     if (strtolower($entry['payment_status']) != 'paid') {
         return;
     }
     $form = GFFormsModel::get_form_meta($entry['form_id']);
     $ga_event_data = maybe_unserialize(gform_get_meta($entry['id'], 'ga_event_data'));
     // Override this coming from paypal IPN
     $_COOKIE['_ga'] = $ga_event_data['ga_cookie'];
     // Push the event to google
     $this->push_event($entry, $form, $ga_event_data);
 }
Esempio n. 9
0
 public static function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false)
 {
     $products = array();
     $product_info = null;
     // retrieve static copy of product info (only for "real" entries)
     if (!rgempty("id", $lead)) {
         $product_info = gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
     }
     // if no static copy, generate from form/lead info
     if (!$product_info) {
         foreach ($form["fields"] as $field) {
             $id = $field["id"];
             $lead_value = RGFormsModel::get_lead_field_value($lead, $field);
             $quantity_field = self::get_product_fields_by_type($form, array("quantity"), $id);
             $quantity = sizeof($quantity_field) > 0 && !RGFormsModel::is_field_hidden($form, $quantity_field[0], array(), $lead) ? RGFormsModel::get_lead_field_value($lead, $quantity_field[0]) : 1;
             switch ($field["type"]) {
                 case "product":
                     //ignore products that have been hidden by conditional logic
                     $is_hidden = RGFormsModel::is_field_hidden($form, $field, array(), $lead);
                     if ($is_hidden) {
                         continue;
                     }
                     //if single product, get values from the multiple inputs
                     if (is_array($lead_value)) {
                         $product_quantity = sizeof($quantity_field) == 0 && !rgar($field, "disableQuantity") ? rgget($id . ".3", $lead_value) : $quantity;
                         if (empty($product_quantity)) {
                             continue;
                         }
                         if (!rgget($id, $products)) {
                             $products[$id] = array();
                         }
                         $products[$id]["name"] = $use_admin_label && !rgempty("adminLabel", $field) ? $field["adminLabel"] : $lead_value[$id . ".1"];
                         $products[$id]["price"] = $lead_value[$id . ".2"];
                         $products[$id]["quantity"] = $product_quantity;
                     } else {
                         if (!empty($lead_value)) {
                             if (empty($quantity)) {
                                 continue;
                             }
                             if (!rgar($products, $id)) {
                                 $products[$id] = array();
                             }
                             if ($field["inputType"] == "price") {
                                 $name = $field["label"];
                                 $price = $lead_value;
                             } else {
                                 list($name, $price) = explode("|", $lead_value);
                             }
                             $products[$id]["name"] = !$use_choice_text ? $name : RGFormsModel::get_choice_text($field, $name);
                             $products[$id]["price"] = $price;
                             $products[$id]["quantity"] = $quantity;
                             $products[$id]["options"] = array();
                         }
                     }
                     if (isset($products[$id])) {
                         $options = self::get_product_fields_by_type($form, array("option"), $id);
                         foreach ($options as $option) {
                             $option_value = RGFormsModel::get_lead_field_value($lead, $option);
                             $option_label = empty($option["adminLabel"]) ? $option["label"] : $option["adminLabel"];
                             if (is_array($option_value)) {
                                 foreach ($option_value as $value) {
                                     $option_info = self::get_option_info($value, $option, $use_choice_text);
                                     if (!empty($option_info)) {
                                         $products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
                                     }
                                 }
                             } else {
                                 if (!empty($option_value)) {
                                     $option_info = self::get_option_info($option_value, $option, $use_choice_text);
                                     $products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
                                 }
                             }
                         }
                     }
                     break;
             }
         }
         $shipping_field = self::get_fields_by_type($form, array("shipping"));
         $shipping_price = $shipping_name = "";
         if (!empty($shipping_field) && !RGFormsModel::is_field_hidden($form, $shipping_field[0], array(), $lead)) {
             $shipping_price = RGFormsModel::get_lead_field_value($lead, $shipping_field[0]);
             $shipping_name = $shipping_field[0]["label"];
             if ($shipping_field[0]["inputType"] != "singleshipping") {
                 list($shipping_method, $shipping_price) = explode("|", $shipping_price);
                 $shipping_name = $shipping_field[0]["label"] . " ({$shipping_method})";
             }
         }
         $shipping_price = self::to_number($shipping_price);
         $product_info = array("products" => $products, "shipping" => array("name" => $shipping_name, "price" => $shipping_price));
         $product_info = apply_filters("gform_product_info_{$form["id"]}", apply_filters("gform_product_info", $product_info, $form, $lead), $form, $lead);
         // save static copy of product info (only for "real" entries)
         if (!rgempty("id", $lead) && !empty($product_info["products"])) {
             gform_update_meta($lead['id'], "gform_product_info_{$use_choice_text}_{$use_admin_label}", $product_info);
         }
     }
     return $product_info;
 }
 public static function add_entry_approved_hidden_input($form_id, $field_id, $value, $entry, $query_string)
 {
     if (!GVCommon::has_cap('gravityview_moderate_entries', $entry['id'])) {
         return;
     }
     if (empty($entry['id'])) {
         return;
     }
     if (gform_get_meta($entry['id'], 'is_approved')) {
         echo '<input type="hidden" class="entry_approved" id="entry_approved_' . $entry['id'] . '" value="true" />';
     }
 }
Esempio n. 11
0
function pdf_download_link($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format)
{
    $custom_merge_tag = '{pdf_download_link}';
    if (strpos($text, $custom_merge_tag) === false) {
        return $text;
    }
    $download_link = gform_get_meta($entry['id'], 'gf_pdf_url');
    $download_link = "<a href='{$download_link}'> Download PDF Here</a>";
    $text = str_replace($custom_merge_tag, $download_link, $text);
    return $text;
}
 /**
  * update payment status if it has changed
  * @param array $form
  * @param int $lead_id
  */
 public function gformAfterUpdateEntry($form, $lead_id)
 {
     // make sure we have permission
     check_admin_referer('gforms_save_entry', 'gforms_save_entry');
     // check that save action is for update
     if (strtolower(rgpost('save')) != 'update') {
         return;
     }
     // make sure payment is one of ours (probably)
     $payment_gateway = gform_get_meta($lead_id, 'payment_gateway');
     if (empty($payment_gateway) && GFEwayPlugin::isEwayForm($form['id'], $form['fields']) || $payment_gateway != 'gfeway') {
         return;
     }
     // make sure we have a new payment status
     $payment_status = rgpost('payment_status');
     if (empty($payment_status)) {
         return;
     }
     // update payment status
     $lead = GFFormsModel::get_lead($lead_id);
     $lead['payment_status'] = $payment_status;
     GFFormsModel::update_lead($lead);
 }
 /**
  * Populate meta field values when exporting entries
  * @param  string $value    Value of the field being exported
  * @param  int $form_id     ID of the current form.
  * @param  int $field_id    ID of the current field.
  * @param  object $lead     The current entry.
  * @return string
  */
 public static function export_entries_add_values($value, $form_id, $field_id, $lead)
 {
     switch ($field_id) {
         case 'salesforce_id':
             $value = gform_get_meta($lead['id'], 'salesforce_id');
             break;
         case 'salesforce_api_result':
             $value = gform_get_meta($lead['id'], 'salesforce_api_result');
             break;
     }
     return $value;
 }
 public static function paypal_fulfillment($entry, $config, $transaction_id, $amount)
 {
     //has this entry been already subscribed?
     $is_subscribed = gform_get_meta($entry["id"], "mailchimp_is_subscribed");
     if (!$is_subscribed) {
         $form = RGFormsModel::get_form_meta($entry['form_id']);
         self::export($entry, $form, true);
     }
 }
 private static function cancel_subscription($lead)
 {
     $lead["payment_status"] = "Canceled";
     RGFormsModel::update_lead($lead);
     //loading data class
     $feed_id = gform_get_meta($lead["id"], "authorize.net_feed_id");
     require_once self::get_base_path() . "/data.php";
     $config = GFAuthorizeNetData::get_feed($feed_id);
     if (!$config) {
         return;
     }
     //1- delete post or mark it as a draft based on configuration
     if (rgars($config, "meta/update_post_action") == "draft" && !rgempty("post_id", $lead)) {
         $post = get_post($lead["post_id"]);
         $post->post_status = 'draft';
         wp_update_post($post);
     } else {
         if (rgars($config, "meta/update_post_action") == "delete" && !rgempty("post_id", $lead)) {
             wp_delete_post($lead["post_id"]);
         }
     }
     //2- call subscription canceled hook
     do_action("gform_subscription_canceled", $lead, $config, $lead["transaction_id"], "authorize.net");
 }
Esempio n. 16
0
 private function is_valid_initial_payment_amount($entry_id, $amount_paid)
 {
     //get amount initially sent to paypal
     $amount_sent = gform_get_meta($entry_id, 'payment_amount');
     if (empty($amount_sent)) {
         return true;
     }
     $epsilon = 1.0E-5;
     $is_equal = abs(floatval($amount_paid) - floatval($amount_sent)) < $epsilon;
     $is_greater = floatval($amount_paid) > floatval($amount_sent);
     //initial payment is valid if it is equal to or greater than product/subscription amount
     if ($is_equal || $is_greater) {
         return true;
     }
     return false;
 }
Esempio n. 17
0
 /**
  * localize_script_prso_pluploader_entries
  * 
  * Called by $this->enqueue_scripts().
  * Localizes some variables for use in a js script that adds a file delete option
  * to the entry post edit page and warns users of file deletion when sending an entry to the trash
  * 
  * @access 	public
  * @author	Ben Moody
  */
 private function localize_script_prso_pluploader_entries()
 {
     //Init vars
     $input_field = NULL;
     $message = __("NOT deleting uploaded files. To delete any uploaded files, be sure to check Delete Uploads", "prso-gforms-plupload");
     $delete_files = NULL;
     $entry_id = NULL;
     //Set the checkbox input field html
     $input_field = '<div style="padding:10px 10px 10px 0;"><input id="prso_pluploader_delete_uploads" type="checkbox" onclick="" name="prso_pluploader_delete_uploads"><label for="prso_fineup_delete_uploads">&nbsp;' . __("Delete All Uploaded Files", "prso-gforms-plupload") . '</label></div>';
     //Get entry meta for delete files option
     if (isset($_GET['lid'])) {
         $entry_id = (int) $_GET['lid'];
     }
     $delete_files = gform_get_meta($entry_id, self::$delete_files_meta_key);
     wp_localize_script('prso-pluploader-entries', 'prso_gforms_pluploader', array('file_delete_message' => $message, 'file_delete_meta' => esc_attr($delete_files), 'input_field_html' => $input_field));
 }
Esempio n. 18
0
 /**
  * gform update meta
  *
  * @param $entry_id
  * @param $meta_key
  * @param $meta_value
  *
  * @since
  */
 public function gform_update_meta($entry_id, $meta_key, $meta_value)
 {
     global $wpdb, $_gform_lead_meta;
     $table_name = RGFormsModel::get_lead_meta_table_name();
     $meta_value = maybe_serialize($meta_value);
     $meta_exists = gform_get_meta($entry_id, $meta_key) !== false;
     if ($meta_exists) {
         $wpdb->update($table_name, array('meta_value' => $meta_value), array('lead_id' => $entry_id, 'meta_key' => $meta_key), array('%s'), array('%d', '%s'));
     } else {
         $wpdb->insert($table_name, array('lead_id' => $entry_id, 'meta_key' => $meta_key, 'meta_value' => $meta_value), array('%d', '%s', '%s'));
     }
     //updates cache
     $cache_key = $entry_id . '_' . $meta_key;
     if (array_key_exists($cache_key, $_gform_lead_meta)) {
         $_gform_lead_meta[$cache_key] = maybe_unserialize($meta_value);
     }
 }
Esempio n. 19
0
 public static function refresh_product_cache($form, $lead, $use_choice_text = false, $use_admin_label = false)
 {
     $cache_options = array(array(false, false), array(false, true), array(true, false), array(true, true));
     foreach ($form["fields"] as $field) {
         if (GFCommon::has_field_calculation($field)) {
             //deleting field value cache for calculated fields
             $cache_key = "GFFormsModel::get_lead_field_value_" . $lead["id"] . "_" . $field["id"];
             GFCache::delete($cache_key);
         }
     }
     foreach ($cache_options as $cache_option) {
         list($use_choice_text, $use_admin_label) = $cache_option;
         if (gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}")) {
             gform_delete_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
             GFCommon::get_product_fields($form, $lead, $use_choice_text, $use_admin_label);
         }
     }
 }
Esempio n. 20
0
 /**
  * Check if a certain entry is approved.
  *
  * If we pass the View settings ($args) it will check the 'show_only_approved' setting before
  *   checking the entry approved field, returning true if show_only_approved = false.
  *
  * @since 1.7
  *
  * @param array $entry  Entry object
  * @param array $args   View settings (optional)
  *
  * @return bool
  */
 public static function is_entry_approved($entry, $args = array())
 {
     if (empty($entry['id']) || array_key_exists('show_only_approved', $args) && !$args['show_only_approved']) {
         // is implicitly approved if entry is null or View settings doesn't require to check for approval
         return true;
     }
     $is_approved = gform_get_meta($entry['id'], 'is_approved');
     if ($is_approved) {
         return true;
     }
     return false;
 }
Esempio n. 21
0
 /**
  * Get the entry slug for the entry. By default, it is the entry ID.
  *
  *
  * @see gravityview_get_entry()
  * @uses GravityView_API::get_custom_entry_slug() If using custom slug, gets the custom slug value
  * @since 1.4
  * @param  int|string $id_or_string ID of the entry, or custom slug string
  * @param  array  $entry        Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter
  * @return string               Unique slug ID, passed through `sanitize_title()`
  */
 public static function get_entry_slug($id_or_string, $entry = array())
 {
     /**
      * Default: use the entry ID as the unique identifier
      */
     $slug = $id_or_string;
     /**
      * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
      * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
      */
     $custom = apply_filters('gravityview_custom_entry_slug', false);
     // If we're using custom slug...
     if ($custom) {
         // Get the entry hash
         $hash = self::get_custom_entry_slug($id_or_string, $entry);
         // See if the entry already has a hash set
         $value = gform_get_meta($id_or_string, 'gravityview_unique_id');
         // If it does have a hash set, and the hash is expected, use it.
         // This check allows users to change the hash structure using the
         // gravityview_entry_hash filter and have the old hashes expire.
         if (empty($value) || $value !== $hash) {
             gform_update_meta($id_or_string, 'gravityview_unique_id', $hash);
         }
         $slug = $hash;
         unset($value, $hash);
     }
     return sanitize_title($slug);
 }
 public function paypal_fulfillment($entry, $config, $transaction_id, $amount)
 {
     self::log_debug("Checking PayPal fulfillment for transaction {$transaction_id}");
     $is_fulfilled = gform_get_meta($entry['id'], "{$this->_slug}_is_fulfilled");
     if (!$is_fulfilled) {
         self::log_debug("Entry {$entry['id']} has not been fulfilled.");
         $form = RGFormsModel::get_form_meta($entry['form_id']);
         $this->maybe_process_feed($entry, $form, true);
         // updating meta to indicate this entry has been fulfilled for the current add-on
         self::log_debug("Marking entry {$entry['id']} as fulfilled");
         gform_update_meta($entry['id'], "{$this->_slug}_is_fulfilled", true);
     } else {
         self::log_debug("Entry {$entry['id']} is already fulfilled.");
     }
 }
Esempio n. 23
0
 public static function get_config_by_entry($entry)
 {
     $form_id = $entry["form_id"];
     if (!class_exists("GFPayPalData")) {
         require_once self::get_base_path() . "/data.php";
     }
     //Getting paypal settings associated with this transaction
     $paypal_config = GFPayPalData::get_feed_by_form($form_id);
     if (!is_array($paypal_config)) {
         return false;
     } else {
         //reading feed id from form meta
         $feed_id = gform_get_meta($entry["id"], "paypal_feed_id");
         foreach ($paypal_config as $config) {
             if ($config["id"] == $feed_id) {
                 return $config;
             }
         }
     }
     return false;
 }
Esempio n. 24
0
 public static function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false)
 {
     $products = array();
     $product_info = null;
     // retrieve static copy of product info (only for 'real' entries)
     if (!rgempty('id', $lead)) {
         $product_info = gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
     }
     // if no static copy, generate from form/lead info
     if (!$product_info) {
         foreach ($form['fields'] as $field) {
             $id = $field->id;
             $lead_value = RGFormsModel::get_lead_field_value($lead, $field);
             $quantity_field = self::get_product_fields_by_type($form, array('quantity'), $id);
             $quantity = sizeof($quantity_field) > 0 && !RGFormsModel::is_field_hidden($form, $quantity_field[0], array(), $lead) ? RGFormsModel::get_lead_field_value($lead, $quantity_field[0]) : 1;
             switch ($field->type) {
                 case 'product':
                     //ignore products that have been hidden by conditional logic
                     $is_hidden = RGFormsModel::is_field_hidden($form, $field, array(), $lead);
                     if ($is_hidden) {
                         continue;
                     }
                     //if single product, get values from the multiple inputs
                     if (is_array($lead_value)) {
                         $product_quantity = sizeof($quantity_field) == 0 && !$field->disableQuantity ? rgget($id . '.3', $lead_value) : $quantity;
                         if (empty($product_quantity)) {
                             continue;
                         }
                         if (!rgget($id, $products)) {
                             $products[$id] = array();
                         }
                         $products[$id]['name'] = $use_admin_label && !rgempty('adminLabel', $field) ? $field->adminLabel : $lead_value[$id . '.1'];
                         $products[$id]['price'] = rgar($lead_value, $id . '.2');
                         $products[$id]['quantity'] = $product_quantity;
                     } elseif (!empty($lead_value)) {
                         if (empty($quantity)) {
                             continue;
                         }
                         if (!rgar($products, $id)) {
                             $products[$id] = array();
                         }
                         if ($field->inputType == 'price') {
                             $name = $field->label;
                             $price = $lead_value;
                         } else {
                             list($name, $price) = explode('|', $lead_value);
                         }
                         $products[$id]['name'] = !$use_choice_text ? $name : RGFormsModel::get_choice_text($field, $name);
                         $include_field_label = apply_filters('gform_product_info_name_include_field_label', false);
                         if ($field->inputType == ('radio' || 'select') && $include_field_label) {
                             $products[$id]['name'] = $field->label . " ({$products[$id]['name']})";
                         }
                         $products[$id]['price'] = $price;
                         $products[$id]['quantity'] = $quantity;
                         $products[$id]['options'] = array();
                     }
                     if (isset($products[$id])) {
                         $options = self::get_product_fields_by_type($form, array('option'), $id);
                         foreach ($options as $option) {
                             $option_value = RGFormsModel::get_lead_field_value($lead, $option);
                             $option_label = empty($option['adminLabel']) ? $option['label'] : $option['adminLabel'];
                             if (is_array($option_value)) {
                                 foreach ($option_value as $value) {
                                     $option_info = self::get_option_info($value, $option, $use_choice_text);
                                     if (!empty($option_info)) {
                                         $products[$id]['options'][] = array('field_label' => rgar($option, 'label'), 'option_name' => rgar($option_info, 'name'), 'option_label' => $option_label . ': ' . rgar($option_info, 'name'), 'price' => rgar($option_info, 'price'));
                                     }
                                 }
                             } elseif (!empty($option_value)) {
                                 $option_info = self::get_option_info($option_value, $option, $use_choice_text);
                                 $products[$id]['options'][] = array('field_label' => rgar($option, 'label'), 'option_name' => rgar($option_info, 'name'), 'option_label' => $option_label . ': ' . rgar($option_info, 'name'), 'price' => rgar($option_info, 'price'));
                             }
                         }
                     }
                     break;
             }
         }
         $shipping_field = GFAPI::get_fields_by_type($form, array('shipping'));
         $shipping_price = $shipping_name = '';
         $shipping_field_id = '';
         if (!empty($shipping_field) && !RGFormsModel::is_field_hidden($form, $shipping_field[0], array(), $lead)) {
             $shipping_price = RGFormsModel::get_lead_field_value($lead, $shipping_field[0]);
             $shipping_name = $shipping_field[0]['label'];
             $shipping_field_id = $shipping_field[0]['id'];
             if ($shipping_field[0]['inputType'] != 'singleshipping') {
                 list($shipping_method, $shipping_price) = explode('|', $shipping_price);
                 $shipping_name = $shipping_field[0]['label'] . " ({$shipping_method})";
             }
         }
         $shipping_price = self::to_number($shipping_price);
         $product_info = array('products' => $products, 'shipping' => array('id' => $shipping_field_id, 'name' => $shipping_name, 'price' => $shipping_price));
         $product_info = gf_apply_filters('gform_product_info', $form['id'], $product_info, $form, $lead);
         // save static copy of product info (only for 'real' entries)
         if (!rgempty('id', $lead) && !empty($product_info['products'])) {
             gform_update_meta($lead['id'], "gform_product_info_{$use_choice_text}_{$use_admin_label}", $product_info);
         }
     }
     return $product_info;
 }
Esempio n. 25
0
 public static function refresh_product_cache($form, $lead, $use_choice_text = false, $use_admin_label = false)
 {
     $cache_options = array(array(false, false), array(false, true), array(true, false), array(true, true));
     foreach ($cache_options as $cache_option) {
         list($use_choice_text, $use_admin_label) = $cache_option;
         if (gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}")) {
             gform_delete_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
             GFCommon::get_product_fields($form, $lead, $use_choice_text, $use_admin_label);
         }
     }
 }
Esempio n. 26
0
 public function cancel($entry, $feed)
 {
     $this->include_stripe_api();
     try {
         $customer_id = gform_get_meta($entry['id'], 'stripe_customer_id');
         $customer = Stripe_Customer::retrieve($customer_id);
         $customer->cancelSubscription();
         return true;
     } catch (Stripe_Error $error) {
         return false;
     }
 }
 public function paypal_fulfillment($entry, $paypal_config, $transaction_id, $amount)
 {
     $this->log_debug('GFFeedAddOn::paypal_fulfillment(): Checking PayPal fulfillment for transaction ' . $transaction_id . ' for ' . $this->_slug);
     $is_fulfilled = gform_get_meta($entry['id'], "{$this->_slug}_is_fulfilled");
     if ($is_fulfilled) {
         $this->log_debug('GFFeedAddOn::paypal_fulfillment(): Entry ' . $entry['id'] . ' is already fulfilled for ' . $this->_slug . '. No action necessary.');
         return false;
     }
     $form = RGFormsModel::get_form_meta($entry['form_id']);
     $feed_to_process = '';
     $feeds = $this->get_feeds($entry['form_id']);
     foreach ($feeds as $feed) {
         if ($feed['is_active'] && $this->is_feed_condition_met($feed, $form, $entry)) {
             $feed_to_process = $feed;
             break;
         }
     }
     if (empty($feed_to_process)) {
         $this->log_debug('GFFeedAddOn::paypal_fulfillment(): No active feeds found or feeds did not meet conditional logic for ' . $this->_slug . '. No fulfillment necessary.');
         return false;
     }
     $this->process_feed($feed_to_process, $entry, $form);
     // updating meta to indicate this entry has been fulfilled for the current add-on
     $this->log_debug('GFFeedAddOn::paypal_fulfillment(): Marking entry ' . $entry['id'] . ' as fulfilled for ' . $this->_slug);
     gform_update_meta($entry['id'], "{$this->_slug}_is_fulfilled", true);
 }
 public function replace_merge_tags($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format)
 {
     if (strpos($text, '{personality_quiz_result}') !== false) {
         $quiz_result = gform_get_meta($entry['id'], 'personality_quiz_result');
         $text = str_replace('{personality_quiz_result}', $quiz_result, $text);
     }
     if (strpos($text, '{personality_quiz_result_percent}') !== false) {
         $quiz_result = (int) gform_get_meta($entry['id'], 'personality_quiz_result');
         $quiz_total = $this->get_quiz_total($form);
         $quiz_result = round($quiz_result / $quiz_total * 100);
         $text = str_replace('{personality_quiz_result_percent}', $quiz_result, $text);
     }
     return $text;
 }
 public static function get_encrypted_fields($entry_id)
 {
     $encrypted_fields = gform_get_meta($entry_id, '_encrypted_fields');
     if (empty($encrypted_fields)) {
         $encrypted_fields = array();
     }
     return $encrypted_fields;
 }
Esempio n. 30
0
 public static function paypal_fulfillment($entry, $config, $transaction_id, $amount)
 {
     self::log("Checking PayPal Fulfillment for transaction {$transaction_id}", "debug");
     //has this entry been already subscribed?
     $is_subscribed = gform_get_meta($entry["id"], "mailchimp_is_subscribed");
     if (!$is_subscribed) {
         self::log("Entry " . $entry["id"] . " has not been subscribed", "debug");
         $form = RGFormsModel::get_form_meta($entry['form_id']);
         self::export($entry, $form, true);
     } else {
         self::log("Entry " . $entry["id"] . " is already subscribed", "debug");
     }
 }