本文整理汇总了PHP中MS_Model_Membership::get_payment_types方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::get_payment_types方法的具体用法?PHP MS_Model_Membership::get_payment_types怎么用?PHP MS_Model_Membership::get_payment_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Membership
的用法示例。
在下文中一共展示了MS_Model_Membership::get_payment_types方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: supported_payment_types
/**
* Returns a list of supported payment types.
*
* @since 1.0.0
* @return array Payment types, index is the type-key / value the label.
*/
public function supported_payment_types()
{
static $Payment_Types = array();
if (!isset($Payment_Types[$this->id])) {
$Payment_Types[$this->id] = MS_Model_Membership::get_payment_types();
foreach ($this->unsupported_payment_types as $remove) {
unset($Payment_Types[$this->id][$remove]);
}
}
return $Payment_Types[$this->id];
}
示例2: prepare_fields
/**
* Prepare the HTML fields that can be displayed
*
* @since 1.0.0
*
* @return array
*/
protected function prepare_fields($data)
{
// List of known Membership types; used to display the nice-name
$ms_types = MS_Model_Membership::get_types();
$ms_paytypes = MS_Model_Membership::get_payment_types();
// Prepare the "Memberships" table
$memberships = array(array(__('Membership name', 'membership2'), __('Membership Type', 'membership2'), __('Payment Type', 'membership2'), __('Description', 'membership2')));
foreach ($data->memberships as $item) {
if (!isset($ms_types[$item->type])) {
$item->type = MS_Model_Membership::TYPE_STANDARD;
}
switch ($item->pay_type) {
case 'recurring':
$payment_type = MS_Model_Membership::PAYMENT_TYPE_RECURRING;
break;
case 'finite':
$payment_type = MS_Model_Membership::PAYMENT_TYPE_FINITE;
break;
case 'date':
$payment_type = MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE;
break;
default:
$payment_type = MS_Model_Membership::PAYMENT_TYPE_PERMANENT;
break;
}
$memberships[] = array($item->name, $ms_types[$item->type], $ms_paytypes[$payment_type], $item->description);
}
// Prepare the "Members" table
$members = array(array(__('Username', 'membership2'), __('Email', 'membership2'), __('Subscriptions', 'membership2'), __('Invoices', 'membership2')));
foreach ($data->members as $item) {
$inv_count = 0;
if (isset($item->subscriptions) && is_array($item->subscriptions)) {
foreach ($item->subscriptions as $registration) {
$inv_count += count($registration->invoices);
}
}
$members[] = array($item->username, $item->email, count($item->subscriptions), $inv_count);
}
$settings = array();
foreach ($data->settings as $setting => $value) {
switch ($setting) {
case 'addons':
$model = MS_Factory::load('MS_Model_Addon');
$list = $model->get_addon_list();
$code = '';
foreach ($value as $addon => $state) {
if ($state) {
$code .= __('Activate: ', 'membership2');
} else {
$code .= __('Dectivate: ', 'membership2');
}
$code .= $list[$addon]->name . '<br/>';
}
$settings[] = array(__('Add-Ons', 'membership2'), $code);
break;
}
}
if (empty($settings)) {
$settings[] = array('', __('(No settings are changed)', 'membership2'));
}
// Prepare the return value.
$fields = array();
// Export-Notes
$notes = '';
if (isset($data->notes)) {
if (is_scalar($data->notes)) {
$notes = array($data->notes);
}
$in_sub = false;
$notes = '<ul class="ms-import-notes">';
foreach ($data->notes as $line => $text) {
$is_sub = strpos($text, '- ') === 0;
if ($in_sub != $is_sub) {
$in_sub = $is_sub;
if ($is_sub) {
$notes .= '<ul>';
} else {
$notes .= '</ul>';
}
}
if ($in_sub) {
$text = substr($text, 2);
}
$notes .= '<li>' . $text;
}
$notes .= '</ul>';
}
$fields['details'] = array('type' => MS_Helper_Html::TYPE_HTML_TABLE, 'class' => 'ms-import-preview', 'value' => array(array(__('Data source', 'membership2'), $data->source . '   <small>' . sprintf(__('exported on %1$s', 'membership2'), $data->export_time) . '</small>'), array(__('Content', 'membership2'), sprintf(_n('%1$s Membership', '%1$s Memberships', count($data->memberships), 'membership2'), '<b>' . count($data->memberships) . '</b>') . ' / ' . sprintf(_n('%1$s Member', '%1$s Members', count($data->members), 'membership2'), '<b>' . count($data->members) . '</b>'))), 'field_options' => array('head_col' => true, 'head_row' => false, 'col_class' => array('preview-label', 'preview-data')));
if (!empty($notes)) {
$fields['details']['value'][] = array(__('Please note', 'membership2'), $notes);
}
$batchsizes = array(10 => __('Small (10 items)'), 30 => __('Normal (30 items)'), 100 => __('Big (100 items)'));
$fields['batchsize'] = array('id' => 'batchsize', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Batch size for import', 'membership2'), 'desc' => __('Big batches will be processed faster but may result in PHP Memory errors.', 'membership2'), 'value' => 30, 'field_options' => $batchsizes, 'class' => 'sel-batchsize');
//.........这里部分代码省略.........
示例3: get_fields
/**
* Returns field definitions to render the payment box for the specified
* membership.
*
* @since 1.0.0
*
* @return array An array containing all field definitions.
*/
private function get_fields()
{
global $wp_locale;
$membership = $this->data['membership'];
$action = MS_Controller_Membership::AJAX_ACTION_UPDATE_MEMBERSHIP;
$nonce = wp_create_nonce($action);
$fields = array();
$fields['price'] = array('id' => 'price', 'title' => __('Payment Amount', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'before' => MS_Plugin::instance()->settings->currency_symbol, 'value' => $membership->price, 'class' => 'ms-text-smallish', 'config' => array('step' => 'any', 'min' => 0), 'placeholder' => '0' . $wp_locale->number_format['decimal_point'] . '00', 'ajax_data' => array(1));
$fields['payment_type'] = array('id' => 'payment_type', 'title' => __('This Membership requires', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $membership->payment_type, 'field_options' => MS_Model_Membership::get_payment_types(), 'ajax_data' => array(1));
$fields['period_unit'] = array('id' => 'period_unit', 'title' => __('Grant access for', MS_TEXT_DOMAIN), 'name' => '[period][period_unit]', 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => $membership->period_unit, 'class' => 'ms-text-small', 'config' => array('step' => 1, 'min' => 1), 'placeholder' => '1', 'ajax_data' => array(1));
$fields['period_type'] = array('id' => 'period_type', 'name' => '[period][period_type]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $membership->period_type, 'field_options' => MS_Helper_Period::get_period_types('plural'), 'ajax_data' => array(1));
$fields['pay_cycle_period_unit'] = array('id' => 'pay_cycle_period_unit', 'title' => __('Payment Frequency', MS_TEXT_DOMAIN), 'name' => '[pay_cycle_period][period_unit]', 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => $membership->pay_cycle_period_unit, 'class' => 'ms-text-small', 'config' => array('step' => 1, 'min' => 1), 'placeholder' => '1', 'ajax_data' => array(1));
$fields['pay_cycle_period_type'] = array('id' => 'pay_cycle_period_type', 'name' => '[pay_cycle_period][period_type]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $membership->pay_cycle_period_type, 'field_options' => MS_Helper_Period::get_period_types('plural'), 'ajax_data' => array(1));
$fields['pay_cycle_repetitions'] = array('id' => 'pay_cycle_repetitions', 'title' => __('Total Payments', MS_TEXT_DOMAIN), 'name' => '[pay_cycle_repetitions]', 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'after' => __('payments (0 = unlimited)', MS_TEXT_DOMAIN), 'value' => $membership->pay_cycle_repetitions, 'class' => 'ms-text-small', 'config' => array('step' => '1', 'min' => 0), 'placeholder' => '0', 'ajax_data' => array(1));
$fields['period_date_start'] = array('id' => 'period_date_start', 'title' => __('Grant access from', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $membership->period_date_start, 'placeholder' => __('Start Date...', MS_TEXT_DOMAIN), 'ajax_data' => array(1));
$fields['period_date_end'] = array('id' => 'period_date_end', 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $membership->period_date_end, 'before' => _x('to', 'date range', MS_TEXT_DOMAIN), 'placeholder' => __('End Date...', MS_TEXT_DOMAIN), 'ajax_data' => array(1));
$fields['on_end_membership_id'] = array('id' => 'on_end_membership_id', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('After this membership ends', MS_TEXT_DOMAIN), 'value' => $membership->on_end_membership_id, 'field_options' => $membership->get_after_ms_ends_options(), 'ajax_data' => array(1));
$fields['enable_trial_addon'] = array('id' => 'enable_trial_addon', 'type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'value' => __('Yes, enable Trial Memberships!', MS_TEXT_DOMAIN), 'button_value' => 1, 'ajax_data' => array('action' => MS_Controller_Addon::AJAX_ACTION_TOGGLE_ADDON, '_wpnonce' => wp_create_nonce(MS_Controller_Addon::AJAX_ACTION_TOGGLE_ADDON), 'addon' => MS_Model_Addon::ADDON_TRIAL, 'field' => 'active'));
$fields['trial_period_enabled'] = array('id' => 'trial_period_enabled', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => '<strong>' . __('Trial Period', MS_TEXT_DOMAIN) . '</strong>', 'after' => __('Offer Free Trial', MS_TEXT_DOMAIN), 'value' => $membership->trial_period_enabled, 'ajax_data' => array(1));
$fields['trial_period_unit'] = array('id' => 'trial_period_unit', 'name' => '[trial_period][period_unit]', 'before' => __('The Trial is free and lasts for', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => $membership->trial_period_unit, 'class' => 'ms-text-small', 'config' => array('step' => 1, 'min' => 1), 'placeholder' => '1', 'ajax_data' => array(1));
$fields['trial_period_type'] = array('id' => 'trial_period_type', 'name' => '[trial_period][period_type]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $membership->trial_period_type, 'field_options' => MS_Helper_Period::get_period_types('plural'), 'ajax_data' => array(1));
$fields['membership_id'] = array('id' => 'membership_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->id);
$fields['action'] = array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $action);
// Get a list of all payment gateways.
$gateways = MS_Model_Gateway::get_gateways();
$fields['gateways'] = array();
foreach ($gateways as $gateway) {
if ('free' == $gateway->id) {
continue;
}
if (!$gateway->active) {
continue;
}
$payment_types = $gateway->supported_payment_types();
$wrapper_class = 'ms-payment-type-' . implode(' ms-payment-type-', array_keys($payment_types));
$fields['gateways'][$gateway->id] = array('id' => 'disabled-gateway-' . $gateway->id, 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => $gateway->name, 'before' => __('Available', MS_TEXT_DOMAIN), 'after' => __('Not available', MS_TEXT_DOMAIN), 'value' => !$membership->can_use_gateway($gateway->id), 'class' => 'reverse', 'wrapper_class' => 'ms-payment-type-wrapper ' . $wrapper_class, 'ajax_data' => array('field' => 'disabled_gateways[' . $gateway->id . ']', '_wpnonce' => $nonce, 'action' => $action, 'membership_id' => $membership->id));
}
// Modify some fields for free memberships.
if ($membership->is_free) {
$fields['price'] = '';
$fields['payment_type'] = array('id' => 'payment_type', 'title' => __('Access Structure:', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $membership->payment_type, 'field_options' => MS_Model_Membership::get_payment_types('free'), 'ajax_data' => array(1));
}
// Process the fields and add missing default attributes.
foreach ($fields as $key => $field) {
if (!empty($field['ajax_data'])) {
if (!empty($field['ajax_data']['action'])) {
continue;
}
if (!isset($fields[$key]['ajax_data']['field'])) {
$fields[$key]['ajax_data']['field'] = $fields[$key]['id'];
}
$fields[$key]['ajax_data']['_wpnonce'] = $nonce;
$fields[$key]['ajax_data']['action'] = $action;
$fields[$key]['ajax_data']['membership_id'] = $membership->id;
}
}
return apply_filters('ms_view_membership_tab_payment_fields', $fields);
}