示例#1
0
 public function feed_settings_fields()
 {
     $default_settings = parent::feed_settings_fields();
     //--add PayPal Email Address field
     $fields = array(array('name' => 'paypalEmail', 'label' => __('PayPal Email Address ', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => true, 'tooltip' => '<h6>' . __('PayPal Email Address', 'gravityformspaypal') . '</h6>' . __('Enter the PayPal email address where payment should be received.', 'gravityformspaypal')), array('name' => 'mode', 'label' => __('Mode', 'gravityformspaypal'), 'type' => 'radio', 'choices' => array(array('id' => 'gf_paypal_mode_production', 'label' => __('Production', 'gravityformspaypal'), 'value' => 'production'), array('id' => 'gf_paypal_mode_test', 'label' => __('Test', 'gravityformspaypal'), 'value' => 'test')), 'horizontal' => true, 'default_value' => 'production', 'tooltip' => '<h6>' . __('Mode', 'gravityformspaypal') . '</h6>' . __('Select Production to receive live payments. Select Test for testing purposes when using the PayPal development sandbox.', 'gravityformspaypal')));
     $default_settings = parent::add_field_after('feedName', $fields, $default_settings);
     //--------------------------------------------------------------------------------------
     //--add donation to transaction type drop down
     $transaction_type = parent::get_field('transactionType', $default_settings);
     $choices = $transaction_type['choices'];
     $add_donation = true;
     foreach ($choices as $choice) {
         //add donation option if it does not already exist
         if ($choice['value'] == 'donation') {
             $add_donation = false;
         }
     }
     if ($add_donation) {
         //add donation transaction type
         $choices[] = array('label' => __('Donations', 'gravityformspaypal'), 'value' => 'donation');
     }
     $transaction_type['choices'] = $choices;
     $default_settings = $this->replace_field('transactionType', $transaction_type, $default_settings);
     //-------------------------------------------------------------------------------------------------
     //--add Page Style, Continue Button Label, Cancel URL
     $fields = array(array('name' => 'pageStyle', 'label' => __('Page Style', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Page Style', 'gravityformspaypal') . '</h6>' . __('This option allows you to select which PayPal page style should be used if you have setup a custom payment page style with PayPal.', 'gravityformspaypal')), array('name' => 'continueText', 'label' => __('Continue Button Label', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Continue Button Label', 'gravityformspaypal') . '</h6>' . __('Enter the text that should appear on the continue button once payment has been completed via PayPal.', 'gravityformspaypal')), array('name' => 'cancelUrl', 'label' => __('Cancel URL', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Cancel URL', 'gravityformspaypal') . '</h6>' . __('Enter the URL the user should be sent to should they cancel before completing their PayPal payment.', 'gravityformspaypal')), array('name' => 'options', 'label' => __('Options', 'gravityformspaypal'), 'type' => 'options', 'tooltip' => '<h6>' . __('Options', 'gravityformspaypal') . '</h6>' . __('Turn on or off the available PayPal checkout options.', 'gravityformspaypal')), array('name' => 'notifications', 'label' => __('Notifications', 'gravityformspaypal'), 'type' => 'notifications', 'tooltip' => '<h6>' . __('Notifications', 'gravityformspaypal') . '</h6>' . __("Enable this option if you would like to only send out this form's notifications after payment has been received. Leaving this option disabled will send notifications immediately after the form is submitted.", 'gravityformspaypal')));
     //Add post fields if form has a post
     $form = $this->get_current_form();
     if (GFCommon::has_post_field($form['fields'])) {
         $post_settings = array('name' => 'post_checkboxes', 'label' => __('Posts', 'gravityformspaypal'), 'type' => 'checkbox', 'tooltip' => '<h6>' . __('Posts', 'gravityformspaypal') . '</h6>' . __('Enable this option if you would like to only create the post after payment has been received.', 'gravityformspaypal'), 'choices' => array(array('label' => __('Create post only when payment is received.', 'gravityformspaypal'), 'name' => 'delayPost')));
         if ($this->get_setting('transactionType') == 'subscription') {
             $post_settings['choices'][] = array('label' => __('Change post status when subscription is canceled.', 'gravityformspaypal'), 'name' => 'change_post_status', 'onChange' => 'var action = this.checked ? "draft" : ""; jQuery("#update_post_action").val(action);');
         }
         $fields[] = $post_settings;
     }
     //Adding custom settings for backwards compatibility with hook 'gform_paypal_add_option_group'
     $fields[] = array('name' => 'custom_options', 'label' => '', 'type' => 'custom');
     $default_settings = $this->add_field_after('billingInformation', $fields, $default_settings);
     //-----------------------------------------------------------------------------------------
     //--get billing info section and add customer first/last name
     $billing_info = parent::get_field('billingInformation', $default_settings);
     $billing_fields = $billing_info['field_map'];
     $add_first_name = true;
     $add_last_name = true;
     foreach ($billing_fields as $mapping) {
         //add first/last name if it does not already exist in billing fields
         if ($mapping['name'] == 'firstName') {
             $add_first_name = false;
         } else {
             if ($mapping['name'] == 'lastName') {
                 $add_last_name = false;
             }
         }
     }
     if ($add_last_name) {
         //add last name
         array_unshift($billing_info['field_map'], array('name' => 'lastName', 'label' => __('Last Name', 'gravityformspaypal'), 'required' => false));
     }
     if ($add_first_name) {
         array_unshift($billing_info['field_map'], array('name' => 'firstName', 'label' => __('First Name', 'gravityformspaypal'), 'required' => false));
     }
     $default_settings = parent::replace_field('billingInformation', $billing_info, $default_settings);
     //----------------------------------------------------------------------------------------------------
     //hide default display of setup fee, not used by PayPal Standard
     $default_settings = parent::remove_field('setupFee', $default_settings);
     //--add trial period
     $trial_period = array('name' => 'trialPeriod', 'label' => __('Trial Period', 'gravityformspaypal'), 'type' => 'trial_period', 'hidden' => !$this->get_setting('trial_enabled'), 'tooltip' => '<h6>' . __('Trial Period', 'gravityformspaypal') . '</h6>' . __('Select the trial period length.', 'gravityformspaypal'));
     $default_settings = parent::add_field_after('trial', $trial_period, $default_settings);
     //-----------------------------------------------------------------------------------------
     //--Add Try to bill again after failed attempt.
     $recurring_retry = array('name' => 'recurringRetry', 'label' => __('Recurring Retry', 'gravityformspaypal'), 'type' => 'checkbox', 'horizontal' => true, 'choices' => array(array('label' => __('Try to bill again after failed attempt.', 'gravityformspaypal'), 'name' => 'recurringRetry', 'value' => '1')), 'tooltip' => '<h6>' . __('Recurring Retry', 'gravityformspaypal') . '</h6>' . __('Turn on or off whether to try to bill again after failed attempt.', 'gravityformspaypal'));
     $default_settings = parent::add_field_after('recurringTimes', $recurring_retry, $default_settings);
     //-----------------------------------------------------------------------------------------------------
     return apply_filters('gform_paypal_feed_settings_fields', $default_settings, $form);
 }