Пример #1
0
/**
 * Shows the acquisition method on the payment details in admin
 *
 * @since  1.0
 * @param  int $payment_id The Payment ID
 * @return void
 */
function edd_acq_method_payment_details($payment_id)
{
    $acquisition_method = edd_get_payment_meta($payment_id, '_edd_payment_acquisition_method', true);
    if (!empty($acquisition_method)) {
        $current_methods = edd_acq_get_methods();
        foreach ($current_methods as $method) {
            if ($method['value'] === $acquisition_method) {
                $acquisition_name = $method['name'];
                break;
            }
        }
        if (empty($acquisition_name)) {
            $acquisition_name = $acquisition_method . ' - ' . __('inactive', 'edd-acquisition-survey');
        }
        ?>
		<div class="edd-order-acquisition-method edd-admin-box-inside">
			<p>
				<span class="label"><?php 
        _e('Acquisition:', 'edd-acquisition-survey');
        ?>
</span>&nbsp;
				<span><?php 
        echo $acquisition_name;
        ?>
</span>
			</p>
		</div>
		<?php 
    }
}
Пример #2
0
/**
 * Validates the survey results on checkout
 *
 * @since  1.0
 * @param  array $valid_data The array of valid data
 * @param  array $data       The data submitted
 * @return void
 */
function edd_acq_validate_custom_fields($valid_data, $data)
{
    $methods = edd_acq_get_methods();
    if (empty($methods)) {
        return;
    }
    $required = edd_get_option('acq_require_response', false);
    if ($required && (empty($data['edd_acquisition_method']) || $data['edd_acquisition_method'] == '-1')) {
        // check for a phone number
        edd_set_error('invalid_acquisition_method', __('Please tell us how you found us.', 'edd-acquisition-survey'));
    }
}
Пример #3
0
/**
 * Acquisition Methods Callback
 *
 * Renders Acquisition Methods table
 *
 * @since 1.0
 * @param array $args Arguments passed by the setting
 * @global $edd_options Array of all the EDD Options
 * @return void
 */
function edd_acquisition_methods_callback($args)
{
    global $edd_options;
    $methods = edd_acq_get_methods();
    ob_start();
    ?>
	<p><?php 
    echo $args['desc'];
    ?>
</p>
	<table id="edd-acquisition-methods" class="wp-list-table widefat fixed posts">
		<thead>
			<tr>
				<th scope="col" class="edd-acq-drag"></th>
				<th scope="col" class="edd-acq-name"><?php 
    _e('Method Name', 'edd-acquisition-survey');
    ?>
</th>
				<th scope="col" class="edd-acq-value"><?php 
    _e('Unique ID', 'edd-acquisition-survey');
    ?>
</th>
				<th scope="col" class="edd-acq-remove"></th>
			</tr>
		</thead>
		<?php 
    if (!empty($methods)) {
        ?>
			<?php 
        foreach ($methods as $key => $method) {
            ?>
			<tr class="edd-acq-method-row">
				<td>
					<span class="edd_draghandle"></span>
				</td>
				<td class="edd-acq-name">
					<?php 
            echo EDD()->html->text(array('name' => 'edd_acq_methods[' . $key . '][name]', 'value' => $method['name'], 'placeholder' => __('Name visible to Customers', 'edd-acquisition-survey')));
            ?>
				</td>
				<td class="edd-acq-value">
					<?php 
            echo EDD()->html->text(array('name' => 'edd_acq_methods[' . $key . '][value]', 'value' => $method['value'], 'placeholder' => __('name-identifier', 'edd-acquisition-survey')));
            ?>
				</td>
				<td><span class="edd-acq-remove-method button-secondary"><?php 
            _e('Remove', 'edd-acquisition-survey');
            ?>
</span></td>
			</tr>
			<?php 
        }
        ?>
		<?php 
    } else {
        ?>
			<tr class="edd-acq-method-row">
				<td>
					<span class="edd_draghandle"></span>
				</td>
				<td class="edd-acq-name">
					<?php 
        echo EDD()->html->text(array('name' => 'edd_acq_methods[0][name]', 'placeholder' => __('Name visible to Customers', 'edd-acquisition-survey')));
        ?>
				</td>
				<td class="edd-acq-value">
					<?php 
        echo EDD()->html->text(array('name' => 'edd_acq_methods[0][value]', 'placeholder' => __('name-identifier', 'edd-acquisition-survey')));
        ?>
				</td>
				<td><span class="edd-acq-remove-method button-secondary"><?php 
        _e('Remove', 'edd-acquisition-survey');
        ?>
</span></td>
			</tr>
		<?php 
    }
    ?>
	</table>
	<p>
		<span class="button-secondary" id="edd-acq-add-method"><?php 
    _e('Add Method', 'edd');
    ?>
</span>
	</p>
	<?php 
    echo ob_get_clean();
}
 /**
  * Build all the reports data
  *
  * @access public
  * @since 1.0
  * @return array $reports_data All the data for customer reports
  */
 public function reports_data()
 {
     global $wpdb;
     $reports_data = array();
     $methods = edd_acq_get_methods();
     $sql = "SELECT DISTINCT( meta_value ) as value FROM {$wpdb->postmeta} WHERE meta_key = '_edd_payment_acquisition_method'";
     $methods = $wpdb->get_results($sql);
     $current_method_data = edd_acq_get_methods();
     foreach ($methods as $method) {
         $acquisition_name = false;
         foreach ($current_method_data as $current_method) {
             if ($current_method['value'] === $method->value) {
                 $acquisition_name = $current_method['name'];
                 break;
             }
         }
         if (empty($acquisition_name)) {
             $acquisition_name = $method->value . ' - ' . __('inactive', 'edd-acquisition-survey');
         }
         $sales = edd_acq_count_sales_by_method($method->value);
         $earnings = edd_acq_count_earnings_by_method($method->value);
         $reports_data[] = array('name' => $acquisition_name, 'sales' => edd_format_amount($sales, false), 'earnings' => edd_currency_filter(edd_format_amount($earnings)));
     }
     return $reports_data;
 }