• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP give_has_variable_prices函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中give_has_variable_prices函数的典型用法代码示例。如果您正苦于以下问题:PHP give_has_variable_prices函数的具体用法?PHP give_has_variable_prices怎么用?PHP give_has_variable_prices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了give_has_variable_prices函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: give_single_forms_cmb2_metaboxes

/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 *
 * @return array
 */
function give_single_forms_cmb2_metaboxes(array $meta_boxes)
{
    $post_id = give_get_admin_post_id();
    $price = give_get_form_price($post_id);
    $goal = give_get_form_goal($post_id);
    $variable_pricing = give_has_variable_prices($post_id);
    $prices = give_get_variable_prices($post_id);
    //No empty prices - min. 1.00 for new forms
    if (empty($price)) {
        $price = esc_attr(give_format_amount('1.00'));
    }
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_give_';
    /**
     * Repeatable Field Groups
     */
    $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array('id' => 'form_field_options', 'title' => __('Donation Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(array('name' => __('Donation Option', 'give'), 'description' => __('Would you like this form to have one set donation price or multiple levels (for example, $10 silver, $20 gold, $50 platinum)?', 'give'), 'id' => $prefix . 'price_option', 'type' => 'radio_inline', 'default' => 'set', 'options' => apply_filters('give_forms_price_options', array('set' => __('Set Donation', 'give'), 'multi' => __('Multi-level Donation', 'give')))), array('name' => __('Set Donation', 'give'), 'description' => __('This is the set donation amount for this form.', 'give'), 'id' => $prefix . 'set_price', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'value' => $price, 'class' => 'cmb-type-text-small give-money-field')), array('id' => $prefix . 'levels_header', 'type' => 'levels_repeater_header'), array('id' => $prefix . 'donation_levels', 'type' => 'group', 'row_classes' => 'give-subfield', 'options' => array('add_button' => __('Add Level', 'give'), 'remove_button' => __('<span class="dashicons dashicons-no"></span>', 'give'), 'sortable' => true), 'fields' => apply_filters('give_donation_levels_table_row', array(array('name' => __('ID', 'give'), 'id' => $prefix . 'id', 'type' => 'levels_id'), array('name' => __('Amount', 'give'), 'id' => $prefix . 'amount', 'type' => 'text_small', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'class' => 'cmb-type-text-small give-money-field'), 'before' => 'give_format_admin_multilevel_amount'), array('name' => __('Text', 'give'), 'id' => $prefix . 'text', 'type' => 'text', 'attributes' => array('placeholder' => __('Donation Level', 'give'), 'rows' => 3)), array('name' => __('Default', 'give'), 'id' => $prefix . 'default', 'type' => 'give_default_radio_inline')))), array('name' => __('Display Style', 'give'), 'description' => __('Set how the donations levels will display on the form.', 'give'), 'id' => $prefix . 'display_style', 'type' => 'radio_inline', 'default' => 'buttons', 'options' => array('buttons' => __('Buttons', 'give'), 'radios' => __('Radios', 'give'), 'dropdown' => __('Dropdown', 'give'))), array('name' => __('Custom Amount', 'give'), 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), 'id' => $prefix . 'custom_amount', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Custom Amount Text', 'give'), 'description' => __('This text appears as a label next to the custom amount field for single level forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option). Add your own message or leave this field blank to prevent it from displaying within your form.', 'give'), 'id' => $prefix . 'custom_amount_text', 'type' => 'text', 'row_classes' => 'give-subfield', 'attributes' => array('rows' => 3, 'placeholder' => __('Give a Custom Amount', 'give'))), array('name' => __('Set Goal?', 'give'), 'description' => __('Do you want to set a donation goal for this form?', 'give'), 'id' => $prefix . 'goal_option', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Set Goal', 'give'), 'description' => __('This is the goal you want to achieve for this form.', 'give'), 'id' => $prefix . 'set_goal', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('0.00'), 'value' => isset($goal) ? esc_attr(give_format_amount($goal)) : '', 'class' => 'cmb-type-text-small give-money-field')), array('name' => __('Goal Progress Bar Color', 'give'), 'id' => $prefix . 'goal_color', 'type' => 'colorpicker', 'row_classes' => 'give-subfield', 'default' => '#2bc253')))));
    /**
     * Content Field
     */
    $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array('id' => 'form_content_options', 'title' => __('Form Content', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(array('name' => __('Display Content', 'give'), 'description' => __('Do you want to display content? If you select "Yes" a WYSIWYG editor will appear which you will be able to enter content to display above or below the form.', 'give'), 'id' => $prefix . 'content_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No content', 'give'), 'give_pre_form' => __('Yes, display content ABOVE the form fields', 'give'), 'give_post_form' => __('Yes, display content BELOW the form fields', 'give'))), 'default' => 'none'), array('name' => __('Content', 'give'), 'description' => __('This content will display on the single give form page.', 'give'), 'id' => $prefix . 'form_content', 'row_classes' => 'give-subfield', 'type' => 'wysiwyg')))));
    /**
     * Display Options
     */
    $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array('id' => 'form_display_options', 'title' => __('Form Display Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(array('name' => __('Payment Fields', 'give'), 'desc' => __('How would you like to display payment information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon clicks slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'), 'id' => $prefix . 'payment_display', 'type' => 'select', 'options' => array('onpage' => __('Show on Page', 'give'), 'reveal' => __('Reveal Upon Click', 'give'), 'modal' => __('Modal Window Upon Click', 'give')), 'default' => 'onpage'), array('id' => $prefix . 'reveal_label', 'name' => __('Reveal / Modal Open Text', 'give'), 'desc' => __('The button label for completing the donation.', 'give'), 'type' => 'text_small', 'row_classes' => 'give-subfield', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('id' => $prefix . 'checkout_label', 'name' => __('Complete Donation Text', 'give'), 'desc' => __('The button label for completing a donation.', 'give'), 'type' => 'text_small', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('name' => __('Default Gateway', 'give'), 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), 'id' => $prefix . 'default_gateway', 'type' => 'default_gateway'), array('name' => __('Disable Guest Donations', 'give'), 'desc' => __('Do you want to require users be logged-in to make donations?', 'give'), 'id' => $prefix . 'logged_in_only', 'type' => 'checkbox'), array('name' => __('Register / Login Form', 'give'), 'desc' => __('Display the registration and login forms in the checkout section for non-logged-in users. Note: this option will not require users to register or log in prior to completing a donation. It simply determines whether the login and/or registration form are displayed on the checkout page.', 'give'), 'id' => $prefix . 'show_register_form', 'type' => 'select', 'options' => array('both' => __('Registration and Login Forms', 'give'), 'registration' => __('Registration Form Only', 'give'), 'login' => __('Login Form Only', 'give'), 'none' => __('None', 'give')), 'default' => 'none'), array('name' => __('Floating Labels', 'give'), 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")), 'id' => $prefix . 'form_floating_labels', 'type' => 'select', 'options' => array('' => __('Use the global setting', 'give'), 'enabled' => __('Enabled', 'give'), 'disabled' => __('Disabled', 'give')), 'default' => 'none')))));
    /**
     * Terms & Conditions
     */
    $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array('id' => 'form_terms_options', 'title' => __('Terms and Conditions', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(array('name' => __('Terms and Conditions', 'give'), 'description' => __('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'), 'id' => $prefix . 'terms_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No', 'give'), 'yes' => __('Yes', 'give'))), 'default' => 'none'), array('id' => $prefix . 'agree_label', 'name' => __('Agree to Terms Label', 'give'), 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), 'type' => 'text', 'row_classes' => 'give-subfield', 'size' => 'regular', 'attributes' => array('placeholder' => __('Agree to Terms?', 'give'))), array('id' => $prefix . 'agree_text', 'row_classes' => 'give-subfield', 'name' => __('Agreement Text', 'give'), 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), 'type' => 'wysiwyg')))));
    return $meta_boxes;
}
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:38,代码来源:metabox.php


示例2: give_get_default_form_amount

/**
 * Get Default Form Amount
 *
 * @description: Grabs the default amount for set and level forms
 *
 * @param int $form_id
 *
 * @return string $default_price
 * @since      1.0
 */
function give_get_default_form_amount($form_id)
{
    if (give_has_variable_prices($form_id)) {
        $default_amount = give_get_default_multilevel_amount($form_id);
    } else {
        $default_amount = get_post_meta($form_id, '_give_set_price', true);
    }
    return $default_amount;
}
开发者ID:helgatheviking,项目名称:Give,代码行数:19,代码来源:price-functions.php


示例3: give_render_form_columns

/**
 * Render Give Form Columns
 *
 * @since 1.0
 *
 * @param string $column_name Column name
 * @param int    $post_id     Give Form (Post) ID
 *
 * @return void
 */
function give_render_form_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'give_forms') {
        global $give_options;
        $style = isset($give_options['button_style']) ? $give_options['button_style'] : 'button';
        $color = isset($give_options['checkout_color']) ? $give_options['checkout_color'] : 'blue';
        $color = $color == 'inherit' ? '' : $color;
        $purchase_text = !empty($give_options['add_to_cart_text']) ? $give_options['add_to_cart_text'] : __('Purchase', 'give');
        switch ($column_name) {
            case 'form_category':
                echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
                break;
            case 'form_tag':
                echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
                break;
            case 'price':
                if (give_has_variable_prices($post_id)) {
                    echo give_price_range($post_id);
                } else {
                    echo give_price($post_id, false);
                    echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price($post_id) . '" />';
                }
                break;
            case 'goal':
                $goal_option = get_post_meta($post_id, '_give_goal_option', true);
                if (!empty($goal_option) && $goal_option === 'yes') {
                    echo give_goal($post_id, false);
                } else {
                    echo __('No Goal Set', 'give');
                }
                echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal($post_id) . '" />';
                break;
            case 'donations':
                if (current_user_can('view_give_forms_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id)) . '">';
                    echo give_get_form_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_give_forms_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id)) . '">';
                    echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'shortcode':
                echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint($post_id) . '&#34;]">';
                break;
        }
    }
}
开发者ID:lots0logs,项目名称:Give,代码行数:66,代码来源:dashboard-columns.php


示例4: give_process_paypal_purchase

/**
 * Process PayPal Purchase
 *
 * @since 1.0
 *
 * @param array $purchase_data Purchase Data
 *
 * @return void
 */
function give_process_paypal_purchase($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
        wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403));
    }
    // Collect payment data
    $payment_data = array('price' => $purchase_data['price'], 'give_form_title' => $purchase_data['post_data']['give-form-title'], 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => give_get_currency(), 'user_info' => $purchase_data['user_info'], 'status' => 'pending', 'gateway' => 'paypal');
    // Record the pending payment
    $payment = give_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment);
        // Problems? send back
        give_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['give-gateway']);
    } else {
        // Only send to PayPal if the pending payment is created successfully
        $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
        // Get the success url
        $return_url = add_query_arg(array('payment-confirmation' => 'paypal', 'payment-id' => $payment), get_permalink(give_get_option('success_page')));
        // Get the PayPal redirect uri
        $paypal_redirect = trailingslashit(give_get_paypal_redirect()) . '?';
        //Item name - pass level name if variable priced
        $item_name = $purchase_data['post_data']['give-form-title'];
        if (give_has_variable_prices($purchase_data['post_data']['give-form-id']) && isset($purchase_data['post_data']['give-price-id'])) {
            $item_price_level_text = give_get_price_option_name($purchase_data['post_data']['give-form-id'], $purchase_data['post_data']['give-price-id']);
            //Is there any donation level text?
            if (!empty($item_price_level_text)) {
                $item_name .= ' - ' . $item_price_level_text;
            }
        }
        // Setup PayPal arguments
        $paypal_args = array('business' => give_get_option('paypal_email', false), 'email' => $purchase_data['user_email'], 'invoice' => $purchase_data['purchase_key'], 'amount' => $purchase_data['price'], 'item_name' => $item_name, 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => give_get_currency(), 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => give_get_failed_transaction_uri('?payment-id=' . $payment), 'notify_url' => $listener_url, 'page_style' => give_get_paypal_page_style(), 'cbt' => get_bloginfo('name'), 'bn' => 'WordImpress_Donate_Give_US');
        if (!empty($purchase_data['user_info']['address'])) {
            $paypal_args['address1'] = $purchase_data['user_info']['address']['line1'];
            $paypal_args['address2'] = $purchase_data['user_info']['address']['line2'];
            $paypal_args['city'] = $purchase_data['user_info']['address']['city'];
            $paypal_args['country'] = $purchase_data['user_info']['address']['country'];
        }
        if (give_get_option('paypal_button_type') === 'standard') {
            $paypal_extra_args = array('cmd' => '_xclick');
        } else {
            $paypal_extra_args = array('cmd' => '_donations');
        }
        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
        $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data);
        // Build query
        $paypal_redirect .= http_build_query($paypal_args);
        // Fix for some sites that encode the entities
        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
        // Redirect to PayPal
        wp_redirect($paypal_redirect);
        exit;
    }
}
开发者ID:helgatheviking,项目名称:Give,代码行数:64,代码来源:paypal-standard.php


示例5: give_verify_minimum_price

/**
 * Donation Form Validate Minimum Donation Amount
 *
 * @access      private
 * @since       1.3.6
 * @return      bool
 */
function give_verify_minimum_price()
{
    $amount = give_sanitize_amount($_REQUEST['give-amount']);
    $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
    $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
    $variable_prices = give_has_variable_prices($form_id);
    if ($variable_prices && !empty($price_id)) {
        $price_level_amount = give_get_price_option_amount($form_id, $price_id);
        if ($price_level_amount == $amount) {
            return true;
        }
    }
    $minimum = give_get_form_minimum_price($form_id);
    if ($minimum > $amount) {
        return false;
    }
    return true;
}
开发者ID:wordimpress,项目名称:give,代码行数:25,代码来源:process-purchase.php


示例6: give_check_for_form_price_variations_html

/**
 * Check for Variation Prices HTML  (Multi-level donation forms)
 *
 * @since  1.6
 *
 * @return void
 */
function give_check_for_form_price_variations_html()
{
    if (!current_user_can('edit_give_payments', get_current_user_id())) {
        wp_die();
    }
    $form_id = intval($_POST['form_id']);
    $payment_id = intval($_POST['payment_id']);
    $form = get_post($form_id);
    if ('give_forms' != $form->post_type) {
        wp_die();
    }
    if (!give_has_variable_prices($form_id)) {
        esc_html_e('n/a', 'give');
    } else {
        // Payment object.
        $payment = new Give_Payment($payment_id);
        // Payment meta.
        $payment_meta = $payment->get_meta();
        // Variable price dropdown options.
        $variable_price_dropdown_option = array('id' => $form_id, 'name' => 'give-variable-price', 'chosen' => true, 'show_option_all' => '', 'selected' => $payment_meta['price_id']);
        // Render variable prices select tag html.
        give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
    }
    give_die();
}
开发者ID:wordimpress,项目名称:give,代码行数:32,代码来源:ajax-functions.php


示例7: give_get_form_variable_price_dropdown

/**
 * Get/Print give form variable price dropdown html
 *
 * @since 1.6
 *
 * @param array $args Arguments for form dropdown
 * @param bool  $echo This parameter decide if print form dropdown html output or not
 *
 * @return string/void
 */
function give_get_form_variable_price_dropdown($args = array(), $echo = false)
{
    // Check for give form id.
    if (empty($args['id'])) {
        return false;
    }
    // Check if form has variable prices or not.
    if (!($variable_prices = give_has_variable_prices($args['id']))) {
        return false;
    }
    $variable_prices = give_get_variable_prices(absint($args['id']));
    $variable_price_options = array();
    // Check if multi donation form support custom donation or not.
    if (give_is_custom_price_mode(absint($args['id']))) {
        $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
    }
    // Get variable price and ID from variable price array.
    foreach ($variable_prices as $variable_price) {
        $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text'];
    }
    // Update options.
    $args = array_merge($args, array('options' => $variable_price_options));
    // Generate select html.
    $form_dropdown_html = Give()->html->select($args);
    if (!$echo) {
        return $form_dropdown_html;
    }
    echo $form_dropdown_html;
}
开发者ID:wordimpress,项目名称:give,代码行数:39,代码来源:functions.php


示例8: give_update_payment_details


//.........这里部分代码省略.........
            $customer->increase_value($new_total);
        }
        $payment->customer_id = $customer->id;
    } else {
        if ('publish' === $status) {
            // Update user donation stat.
            $customer->update_donation_value($curr_total, $new_total);
        }
    }
    // Set new meta values
    $payment->user_id = $customer->user_id;
    $payment->email = $customer->email;
    $payment->first_name = $first_name;
    $payment->last_name = $last_name;
    $payment->address = $address;
    $payment->total = $new_total;
    // Check for payment notes
    if (!empty($data['give-payment-note'])) {
        $note = wp_kses($data['give-payment-note'], array());
        give_insert_payment_note($payment_id, $note);
    }
    // Set new status
    $payment->status = $status;
    // Adjust total store earnings if the payment total has been changed
    if ($new_total !== $curr_total && 'publish' == $status) {
        if ($new_total > $curr_total) {
            // Increase if our new total is higher
            $difference = $new_total - $curr_total;
            give_increase_total_earnings($difference);
        } elseif ($curr_total > $new_total) {
            // Decrease if our new total is lower
            $difference = $curr_total - $new_total;
            give_decrease_total_earnings($difference);
        }
    }
    $payment->save();
    // Get new give form ID.
    $new_form_id = absint($data['forms']);
    $current_form_id = absint($payment->get_meta('_give_payment_form_id'));
    // We are adding payment transfer code in last to remove any conflict with above functionality.
    // For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
    /* Check if user want to transfer current payment to new give form id. */
    if ($new_form_id != $current_form_id) {
        // Get new give form title.
        $new_form_title = get_the_title($new_form_id);
        // Update new give form data in payment data.
        $payment_meta = $payment->get_meta();
        $payment_meta['form_title'] = $new_form_title;
        $payment_meta['form_id'] = $new_form_id;
        // Update price id post meta data for set donation form.
        if (!give_has_variable_prices($new_form_id)) {
            $payment_meta['price_id'] = '';
        }
        // Update payment give form meta data.
        $payment->update_meta('_give_payment_form_id', $new_form_id);
        $payment->update_meta('_give_payment_form_title', $new_form_title);
        $payment->update_meta('_give_payment_meta', $payment_meta);
        // Update price id payment metadata.
        if (!give_has_variable_prices($new_form_id)) {
            $payment->update_meta('_give_payment_price_id', '');
        }
        // If purchase was completed, adjust stats of forms
        if ('publish' == $status) {
            // Decrease sale of old give form. For other payment status
            $current_form = new Give_Donate_Form($current_form_id);
            $current_form->decrease_sales();
            $current_form->decrease_earnings($curr_total);
            // Increase sale of new give form.
            $new_form = new Give_Donate_Form($new_form_id);
            $new_form->increase_sales();
            $new_form->increase_earnings($new_total);
        }
        // Re setup payment to update new meta value in object.
        $payment->update_payment_setup($payment->ID);
    }
    // Update price id if current form is variable form.
    if (!empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) {
        // Get payment meta data.
        $payment_meta = $payment->get_meta();
        // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ).
        $data['give-variable-price'] = 'custom' === $data['give-variable-price'] ? 'custom' : 0 < $data['give-variable-price'] ? $data['give-variable-price'] : '';
        // Update payment meta data.
        $payment_meta['price_id'] = $data['give-variable-price'];
        // Update payment give form meta data.
        $payment->update_meta('_give_payment_price_id', $data['give-variable-price']);
        $payment->update_meta('_give_payment_meta', $payment_meta);
        // Re setup payment to update new meta value in object.
        $payment->update_payment_setup($payment->ID);
    }
    /**
     * Fires after updating edited purchase.
     *
     * @since 1.0
     *
     * @param int $payment_id The ID of the payment.
     */
    do_action('give_updated_edited_purchase', $payment_id);
    wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id));
    exit;
}
开发者ID:wordimpress,项目名称:give,代码行数:101,代码来源:actions.php


示例9: get_recent_donations

 /**
  * Retrieves Recent Sales
  *
  * @access public
  * @since  1.1
  * @return array
  */
 public function get_recent_donations()
 {
     global $wp_query;
     $sales = array();
     if (!user_can($this->user_id, 'view_give_reports') && !$this->override) {
         return $sales;
     }
     if (isset($wp_query->query_vars['id'])) {
         $query = array();
         $query[] = give_get_payment_by('id', $wp_query->query_vars['id']);
     } elseif (isset($wp_query->query_vars['purchasekey'])) {
         $query = array();
         $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
     } elseif (isset($wp_query->query_vars['email'])) {
         $query = give_get_payments(array('meta_key' => '_give_payment_user_email', 'meta_value' => $wp_query->query_vars['email'], 'number' => $this->per_page(), 'page' => $this->get_paged(), 'status' => 'publish'));
     } else {
         $query = give_get_payments(array('number' => $this->per_page(), 'page' => $this->get_paged(), 'status' => 'publish'));
     }
     if ($query) {
         $i = 0;
         foreach ($query as $payment) {
             $payment_meta = give_get_payment_meta($payment->ID);
             $user_info = give_get_payment_meta_user_info($payment->ID);
             $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
             $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : '';
             $sales['donations'][$i]['ID'] = give_get_payment_number($payment->ID);
             $sales['donations'][$i]['transaction_id'] = give_get_payment_transaction_id($payment->ID);
             $sales['donations'][$i]['key'] = give_get_payment_key($payment->ID);
             $sales['donations'][$i]['total'] = give_get_payment_amount($payment->ID);
             $sales['donations'][$i]['gateway'] = give_get_payment_gateway($payment->ID);
             $sales['donations'][$i]['name'] = $first_name . ' ' . $last_name;
             $sales['donations'][$i]['fname'] = $first_name;
             $sales['donations'][$i]['lname'] = $last_name;
             $sales['donations'][$i]['email'] = give_get_payment_user_email($payment->ID);
             $sales['donations'][$i]['date'] = $payment->post_date;
             $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
             $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
             $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
             $sales['donations'][$i]['form']['id'] = $form_id;
             $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']);
             $sales['donations'][$i]['form']['price'] = $price;
             if (give_has_variable_prices($form_id)) {
                 if (isset($payment_meta['price_id'])) {
                     $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
                     $sales['donations'][$i]['form']['price_name'] = $price_name;
                     $sales['donations'][$i]['form']['price_id'] = $price_id;
                     $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id);
                 }
             }
             //Add custom meta to API
             foreach ($payment_meta as $meta_key => $meta_value) {
                 $exceptions = array('form_title', 'form_id', 'price_id', 'user_info', 'key', 'email', 'date');
                 //Don't clutter up results with dupes
                 if (in_array($meta_key, $exceptions)) {
                     continue;
                 }
                 $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
             }
             $i++;
         }
     }
     return apply_filters('give_api_donations_endpoint', $sales);
 }
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:70,代码来源:class-give-api.php


示例10: give_price

/**
 * Displays a formatted price for a donation form
 *
 * @since 1.0
 *
 * @param int  $form_id  ID of the form price to show
 * @param bool $echo     Whether to echo or return the results
 * @param int  $price_id Optional price id for variable pricing
 *
 * @return void
 */
function give_price($form_id = 0, $echo = true, $price_id = false)
{
    if (empty($form_id)) {
        $form_id = get_the_ID();
    }
    if (give_has_variable_prices($form_id)) {
        $prices = give_get_variable_prices($form_id);
        if (false !== $price_id) {
            //loop through multi-prices to see which is default
            foreach ($prices as $price) {
                //this is the default price
                if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
                    $price = (double) $price['_give_amount'];
                }
            }
        } else {
            $price = give_get_lowest_price_option($form_id);
        }
        $price = give_sanitize_amount($price);
    } else {
        $price = give_get_form_price($form_id);
    }
    $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id);
    $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
    $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
    if ($echo) {
        echo $formatted_price;
    } else {
        return $formatted_price;
    }
}
开发者ID:helgatheviking,项目名称:Give,代码行数:42,代码来源:functions.php


示例11: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 1.5
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     $data = array();
     $meta = array('give_price', '_thumbnail_id', 'give_sku', 'give_product_notes', '_give_form_sales', '_give_download_earnings');
     $args = array('post_type' => 'download', 'posts_per_page' => 30, 'paged' => $this->step);
     $downloads = new WP_Query($args);
     if ($downloads->posts) {
         foreach ($downloads->posts as $download) {
             $row = array();
             foreach ($this->csv_cols() as $key => $value) {
                 // Setup default value
                 $row[$key] = '';
                 if (in_array($key, $meta)) {
                     switch ($key) {
                         case '_thumbnail_id':
                             $image_id = get_post_thumbnail_id($download->ID);
                             $row[$key] = wp_get_attachment_url($image_id);
                             break;
                         case 'give_price':
                             if (give_has_variable_prices($download->ID)) {
                                 $prices = array();
                                 foreach (give_get_variable_prices($download->ID) as $price) {
                                     $prices[] = $price['name'] . ': ' . $price['amount'];
                                 }
                                 $row[$key] = implode(' | ', $prices);
                             } else {
                                 $row[$key] = give_get_download_price($download->ID);
                             }
                             break;
                         case '_give_files':
                             $files = array();
                             foreach (give_get_download_files($download->ID) as $file) {
                                 $files[] = $file['file'];
                             }
                             $row[$key] = implode(' | ', $files);
                             break;
                         default:
                             $row[$key] = get_post_meta($download->ID, $key, true);
                             break;
                     }
                 } elseif (isset($download->{$key})) {
                     switch ($key) {
                         case 'post_author':
                             $row[$key] = get_the_author_meta('user_login', $download->post_author);
                             break;
                         default:
                             $row[$key] = $download->{$key};
                             break;
                     }
                 } elseif ('tags' == $key) {
                     $terms = get_the_terms($download->ID, 'download_tag');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 } elseif ('categories' == $key) {
                     $terms = get_the_terms($download->ID, 'download_category');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 }
             }
             $data[] = $row;
         }
         $data = apply_filters('give_export_get_data', $data);
         $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
开发者ID:wordimpress,项目名称:give,代码行数:78,代码来源:class-batch-export-forms.php


示例12: give_output_donation_amount_top

/**
 * Donation Amount Field
 *
 * Outputs the donation amount field that appears at the top of the donation forms. If the user has custom amount enabled the field will output as a customizable input
 *
 * @since  1.0
 *
 * @param  int   $form_id Give Form ID
 * @param  array $args
 *
 * @return void
 */
function give_output_donation_amount_top($form_id = 0, $args = array())
{
    global $give_options;
    $variable_pricing = give_has_variable_prices($form_id);
    $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true);
    $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before';
    $symbol = give_currency_symbol(give_get_currency());
    $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>';
    $default_amount = give_format_amount(give_get_default_form_amount($form_id));
    $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
    do_action('give_before_donation_levels', $form_id, $args);
    //Set Price, No Custom Amount Allowed means hidden price field
    if ($allow_custom_amount == 'no') {
        ?>

		<label class="give-hidden" for="give-amount-hidden"><?php 
        echo esc_html__('Donation Amount:', 'give');
        ?>
</label>
		<input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount"
		       value="<?php 
        echo $default_amount;
        ?>
" required>
		<div class="set-price give-donation-amount form-row-wide">
			<?php 
        if ($currency_position == 'before') {
            echo $currency_output;
        }
        ?>
			<span id="give-amount-text" class="give-text-input give-amount-top"><?php 
        echo $default_amount;
        ?>
</span>
			<?php 
        if ($currency_position == 'after') {
            echo $currency_output;
        }
        ?>
		</div>
		<?php 
    } else {
        //Custom Amount Allowed
        ?>
		<div class="give-total-wrap">
			<div class="give-donation-amount form-row-wide">
				<?php 
        if ($currency_position == 'before') {
            echo $currency_output;
        }
        ?>
				<label class="give-hidden" for="give-amount"><?php 
        echo esc_html__('Donation Amount:', 'give');
        ?>
</label>
				<input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php 
        echo $default_amount;
        ?>
" autocomplete="off">
				<?php 
        if ($currency_position == 'after') {
            echo $currency_output;
        }
        ?>
			</div>
		</div>
	<?php 
    }
    do_action('give_after_donation_amount', $form_id, $args);
    //Custom Amount Text
    if (!$variable_pricing && $allow_custom_amount == 'yes' && !empty($custom_amount_text)) {
        ?>
		<p class="give-custom-amount-text"><?php 
        echo $custom_amount_text;
        ?>
</p>
	<?php 
    }
    //Output Variable Pricing Levels
    if ($variable_pricing) {
        give_output_levels($form_id);
    }
    do_action('give_after_donation_levels', $form_id, $args);
}
开发者ID:wordimpress,项目名称:give,代码行数:96,代码来源:template.php


示例13: is_free

 /**
  * Determine if the donation is free or if the given price ID is free
  *
  * @since  1.0
  * @access public
  *
  * @param  int    $price_id Price ID. Default is false.
  *
  * @return bool
  */
 public function is_free($price_id = false)
 {
     $is_free = false;
     $variable_pricing = give_has_variable_prices($this->ID);
     if ($variable_pricing && !is_null($price_id) && $price_id !== false) {
         $price = give_get_price_option_amount($this->ID, $price_id);
     } elseif (!$variable_pricing) {
         $price = get_post_meta($this->ID, '_give_set_price', true);
     }
     if (isset($price) && (double) $price == 0) {
         $is_free = true;
     }
     return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
 }
开发者ID:wordimpress,项目名称:give,代码行数:24,代码来源:class-give-donate-form.php


示例14: give_process_paypal_purchase

/**
 * Process PayPal Purchase.
 *
 * @since 1.0
 *
 * @param array $purchase_data Purchase Data
 *
 * @return void
 */
function give_process_paypal_purchase($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
        wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    $form_id = intval($purchase_data['post_data']['give-form-id']);
    $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '';
    // Collect payment data.
    $payment_data = array('price' => $purchase_data['price'], 'give_form_title' => $purchase_data['post_data']['give-form-title'], 'give_form_id' => $form_id, 'give_price_id' => $price_id, 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => give_get_currency(), 'user_info' => $purchase_data['user_info'], 'status' => 'pending', 'gateway' => 'paypal');
    // Record the pending payment.
    $payment_id = give_insert_payment($payment_data);
    // Check payment.
    if (!$payment_id) {
        // Record the error.
        give_record_gateway_error(esc_html__('Payment Error', 'give'), sprintf(esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment_id);
        // Problems? Send back.
        give_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['give-gateway']);
    } else {
        // Only send to PayPal if the pending payment is created successfully.
        $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
        // Get the success url.
        $return_url = add_query_arg(array('payment-confirmation' => 'paypal', 'payment-id' => $payment_id), get_permalink(give_get_option('success_page')));
        

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP give_is_test_mode函数代码示例发布时间:2022-05-15
下一篇:
PHP give_get_variable_prices函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap