当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_has_variable_prices函数代码示例

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


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

示例1: edd_render_download_columns

/**
 * Render Donwload Columns
 *
 * Render the custom columns content.
 *
 * @access      private
 * @since       1.0 
 * @return      void
*/
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        $sales = edd_get_download_sales_stats($post_id);
        $earnings = edd_get_download_earnings_stats($post_id);
        $color = get_post_meta($post_id, '_edd_purchase_color', true);
        $color = $color ? $color : 'blue';
        $purchase_text = get_post_meta($post_id, '_edd_purchase_text', true);
        $purchase_text = $purchase_text && '' !== $purchase_text ? $purchase_text : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                echo edd_price($post_id, false);
                if (!edd_has_variable_prices($post_id)) {
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                echo $sales;
                break;
            case 'earnings':
                echo edd_currency_filter($earnings);
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="button" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:43,代码来源:dashboard-columns.php

示例2: edd_get_cart_item_template

/**
 * Get Cart Item Template
 *
 * @since 1.0
 * @param int $cart_key Cart key
 * @param array $item Cart item
 * @param bool $ajax AJAX?
 * @return string Cart item
*/
function edd_get_cart_item_template($cart_key, $item, $ajax = false)
{
    global $post;
    $id = is_array($item) ? $item['id'] : $item;
    $remove_url = edd_remove_item_url($cart_key);
    $title = get_the_title($id);
    $options = !empty($item['options']) ? $item['options'] : array();
    $quantity = edd_get_cart_item_quantity($id, $options);
    $price = edd_get_cart_item_price($id, $options);
    if (!empty($options)) {
        $title .= edd_has_variable_prices($item['id']) ? ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']) : edd_get_price_name($id, $item['options']);
    }
    ob_start();
    edd_get_template_part('widget', 'cart-item');
    $item = ob_get_clean();
    $item = str_replace('{item_title}', $title, $item);
    $item = str_replace('{item_amount}', edd_currency_filter(edd_format_amount($price)), $item);
    $item = str_replace('{cart_item_id}', absint($cart_key), $item);
    $item = str_replace('{item_id}', absint($id), $item);
    $item = str_replace('{item_quantity}', absint($quantity), $item);
    $item = str_replace('{remove_url}', $remove_url, $item);
    $subtotal = '';
    if ($ajax) {
        $subtotal = edd_currency_filter(edd_format_amount(edd_get_cart_subtotal()));
    }
    $item = str_replace('{subtotal}', $subtotal, $item);
    return apply_filters('edd_cart_item', $item, $id);
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:template.php

示例3: edd_add_to_cart

/**
 * Add To Cart
 *
 * Adds a download ID to the shopping cart.
 * Uses edd_get_cart_contents().
 *
 * @access      public
 * @since       1.0
 * @param       $download_id - INT the ID number of the download to add to the cart
 * @param       $options - array an array of options, such as variable price
 * @return      string - cart key of the new item
*/
function edd_add_to_cart($download_id, $options = array())
{
    $cart = edd_get_cart_contents();
    if (!edd_item_in_cart($download_id)) {
        if ('download' != get_post_type($download_id)) {
            return;
        }
        // not a download product
        do_action('edd_pre_add_to_cart', $download_id, $options);
        if (edd_has_variable_prices($download_id) && !isset($options['price_id'])) {
            // forces to the first price ID if none is specified and download has variable prices
            $options['price_id'] = 0;
        }
        $cart_item = apply_filters('edd_add_to_cart_item', array('id' => $download_id, 'options' => $options));
        if (is_array($cart)) {
            $cart[] = $cart_item;
        } else {
            $cart = array($cart_item);
        }
        $_SESSION['edd_cart'] = $cart;
        do_action('edd_post_add_to_cart', $download_id, $options);
        // clear all the checkout errors, if any
        edd_clear_errors();
        return count($cart) - 1;
    }
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:38,代码来源:functions.php

示例4: simple_sale_price_field

    /**
     * Sale price field.
     *
     * Display the simple sale price field below the normal price field.
     *
     * @since 1.0.0
     *
     * @param int $post_id ID of the current download being edited.
     */
    public function simple_sale_price_field($post_id)
    {
        $price = edd_get_download_price($post_id);
        $sale_price = get_post_meta($post_id, 'edd_sale_price', true);
        $variable_pricing = edd_has_variable_prices($post_id);
        $prices = edd_get_variable_prices($post_id);
        $single_option_mode = edd_single_price_option_mode($post_id);
        $price_display = $variable_pricing ? ' style="display:none;"' : '';
        $variable_display = $variable_pricing ? '' : ' style="display:none;"';
        ?>
<div id="edd_regular_sale_price_field" class="edd_pricing_fields" <?php 
        echo $price_display;
        ?>
><?php 
        $price_args = array('name' => 'edd_sale_price', 'value' => !empty($sale_price) ? esc_attr(edd_format_amount($sale_price)) : '', 'class' => 'edd-price-field edd-sale-price-field');
        $currency_position = edd_get_option('currency_position');
        if (empty($currency_position) || $currency_position == 'before') {
            echo edd_currency_filter('') . ' ' . EDD()->html->text($price_args) . ' ';
        } else {
            echo EDD()->html->text($price_args) . ' ' . edd_currency_filter('') . ' ';
        }
        ?>
<label class="edd-label" for="edd_sale_price"><?php 
        _e('Sale price', 'edd-sale-price');
        ?>
</label>&nbsp;<?php 
        ?>
</div><?php 
    }
开发者ID:gelther,项目名称:EDD-Sale-Price,代码行数:38,代码来源:class-eddsp-admin-product.php

示例5: edd_render_download_columns

/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                echo edd_get_download_sales_stats($post_id);
                break;
            case 'earnings':
                echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:42,代码来源:dashboard-columns.php

示例6: edd_cr_check_for_download_price_variations

/**
 * Check for download price variations
 *
 * @since       2.0
 * @return      void
 */
function edd_cr_check_for_download_price_variations()
{
    if (!current_user_can('edit_products')) {
        die('-1');
    }
    $download_id = absint($_POST['download_id']);
    $key = isset($_POST['key']) ? absint($_POST['key']) : 0;
    $download = get_post($download_id);
    if ('download' != $download->post_type) {
        die('-2');
    }
    if (edd_has_variable_prices($download_id)) {
        $variable_prices = edd_get_variable_prices($download_id);
        if ($variable_prices) {
            $ajax_response = '<select class="edd_price_options_select edd-select edd-select edd_cr_download" name="edd_cr_download[' . $key . '][price_id]">';
            $ajax_response .= '<option value="all">' . esc_html(__('All prices', 'edd-cr')) . '</option>';
            foreach ($variable_prices as $price_id => $price) {
                $ajax_response .= '<option value="' . esc_attr($price_id) . '">' . esc_html($price['name']) . '</option>';
            }
            $ajax_response .= '</select>';
            echo $ajax_response;
        }
    }
    edd_die();
}
开发者ID:rohmann,项目名称:EDD-Content-Restriction,代码行数:31,代码来源:ajax-functions.php

示例7: if_download_price_function

function if_download_price_function($atts, $content)
{
    $atts = shortcode_atts(array('not' => 'no', 'id' => '', 'equals' => '', 'greater' => '', 'less' => ''), $atts, 'if_download_price');
    if ($atts['id'] != '') {
        $id = $atts['id'];
    } else {
        $id = get_the_id();
    }
    ob_start();
    $price = '';
    if (edd_has_variable_prices($id)) {
        $get_default_price = edd_get_default_variable_price($id);
        $prices = edd_get_variable_prices($id);
        $price = $prices[$get_default_price]['amount'];
    } else {
        $price = edd_get_download_price($id);
    }
    if ($atts['not'] == 'yes' || $atts['not'] == '1') {
        if (!eval_condition($price, $atts['equals'], $atts['greater'], $atts['less'])) {
            echo do_shortcode($content);
        } else {
            echo '';
        }
    } else {
        if (eval_condition($price, $atts['equals'], $atts['greater'], $atts['less'])) {
            echo do_shortcode($content);
        } else {
            echo '';
        }
    }
    return ob_get_clean();
}
开发者ID:Bento4Extend,项目名称:EDD-Download-Shortcodes,代码行数:32,代码来源:if_download_price.php

示例8: edd_price

/**
 * Price
 *
 * Displays a formatted price for a download.
 *
 * @access      public
 * @since       1.0
 * @param       int $download_id the ID of the download price to show
 * @param		bool whether to echo or return the results
* @return       void
*/
function edd_price($download_id, $echo = true)
{
    if (edd_has_variable_prices($download_id)) {
        $prices = edd_get_variable_prices($download_id);
        // return the lowest price
        $price_float = 0;
        foreach ($prices as $key => $value) {
            if ((double) $prices[$key]['amount'] < $price_float or $price_float == 0) {
                $price_float = (double) $prices[$key]['amount'];
            }
        }
        $price = edd_sanitize_amount($price_float);
    } else {
        $price = edd_get_download_price($download_id);
    }
    if (edd_use_taxes() && edd_taxes_on_prices()) {
        $price += edd_calculate_tax($price);
    }
    $price = apply_filters('edd_download_price', $price, $download_id);
    $price = '<span class="edd_price" id="edd_price_' . $download_id . '">' . $price . '</span>';
    if ($echo) {
        echo $price;
    } else {
        return $price;
    }
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:download-functions.php

示例9: set_price

 /**
  * Setup the variable and prices properties
  *
  * @since 0.0.9
  *
  * @access protected
  */
 protected function set_price()
 {
     if (edd_has_variable_prices($this->product->ID)) {
         $this->variable = true;
         $this->prices = edd_get_variable_prices($this->product->ID);
     } else {
         $this->variable = false;
         $this->prices = edd_get_download_price($this->product->ID);
     }
 }
开发者ID:Ramoonus,项目名称:ingot,代码行数:17,代码来源:edd.php

示例10: atcf_purchase_variable_pricing

function atcf_purchase_variable_pricing($download_id)
{
    $variable_pricing = edd_has_variable_prices($download_id);
    if (!$variable_pricing) {
        return;
    }
    $prices = edd_get_variable_prices($download_id);
    $type = edd_single_price_option_mode($download_id) ? 'checkbox' : 'radio';
    do_action('edd_before_price_options', $download_id);
    do_action('atcf_campaign_contribute_options', $prices, $type, $download_id);
    do_action('edd_after_price_options', $download_id);
}
开发者ID:unclebrain,项目名称:appthemer-crowdfunding,代码行数:12,代码来源:deprecated.php

示例11: download_price_function

function download_price_function($atts)
{
    $atts = shortcode_atts(array('limit' => -1, 'id' => ''), $atts, 'download_price');
    if ($atts['id'] != '') {
        $id = $atts['id'];
    } else {
        $id = get_the_id();
    }
    if (edd_has_variable_prices($id)) {
        $get_default_price = edd_get_default_variable_price($id);
        return edd_price($id, false, $get_default_price);
    } else {
        return edd_price($id, false);
    }
}
开发者ID:Bento4Extend,项目名称:EDD-Download-Shortcodes,代码行数:15,代码来源:download_price.php

示例12: edd_wp_downloads_text_args

/**
 * Change the button text of a free download. Default is "Free - Add to Cart"
 *
 * @since 1.0.0
 */
function edd_wp_downloads_text_args($args)
{
    $free_download_text = edd_get_option('edd_wp_downloads_button_text', __('Free Download', 'edd-wp-downloads'));
    $variable_pricing = edd_has_variable_prices($args['download_id']);
    if ($args['price'] && $args['price'] !== 'no' && !$variable_pricing) {
        $price = edd_get_download_price($args['download_id']);
        if (0 == $price) {
            $wp_downloads_url = get_post_meta($args['download_id'], '_edd_wp_downloads_url', true);
            if ($wp_downloads_url) {
                $args['text'] = $free_download_text;
            }
        }
    }
    return $args;
}
开发者ID:expandedfronts,项目名称:edd-wp-downloads,代码行数:20,代码来源:functions.php

示例13: edd_rp_generate_stats

/**
 * edd_rp_generate_stats
 *
 * Generates the full relational data array for all downloads
 * *
 * @since       1.0
*/
function edd_rp_generate_stats()
{
    $defaults = array('number' => 250);
    // Data is acquired from the most recent 250 purchase logs to protect performance. If you need to increase or decrease this, use the following filter
    $log_query = apply_filters('edd_rp_log_query_args', $defaults);
    $edd_payments_query = new EDD_Payments_Query($log_query);
    $edd_payments = $edd_payments_query->get_payments();
    // Determine what users have purchased what products
    if (!empty($edd_payments)) {
        foreach ($edd_payments as $payment) {
            $user_email = strtolower($payment->user_info['email']);
            $cart_items = $payment->cart_details;
            if (is_array($cart_items)) {
                foreach ($cart_items as $item) {
                    $logs_data[md5($user_email)][] = $item['id'];
                }
            }
        }
        foreach ($logs_data as &$log) {
            $log = array_unique($log);
        }
        // Itterate through each download and find users who have purchased it, then if they have purhcased any other downloads
        // add those to the count.
        $downloads = get_posts(array('post_type' => 'download', 'posts_per_page' => '-1', 'fields' => 'ids'));
        $relation_array = array();
        $display_free = edd_get_option('edd_rp_show_free', 1);
        foreach ($downloads as $download) {
            $relation_array[$download] = array();
            foreach ($logs_data as $log) {
                if (in_array($download, $log)) {
                    foreach ($log as $item) {
                        if ($display_free && !edd_has_variable_prices($item) && absint(edd_get_download_price($item)) === 0) {
                            continue;
                        }
                        if (!isset($relation_array[$download][$item])) {
                            $relation_array[$download][$item] = 0;
                        }
                        $relation_array[$download][$item]++;
                    }
                }
            }
            // Since the data inherintly includes itself in it's own array, just unset it.
            unset($relation_array[$download][$download]);
            arsort($relation_array[$download]);
        }
        update_option('_edd_rp_master_array', $relation_array);
    }
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:55,代码来源:recommendation-functions.php

示例14: edd_render_download_columns

/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $color = $color == 'inherit' ? '' : $color;
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&tab=logs&view=sales&download=' . $post_id)) . '">';
                    echo edd_get_download_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post_id)) . '">';
                    echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:55,代码来源:dashboard-columns.php

示例15: edd_customerio_connect_register_user

/**
 * Track new users
 *
 * @since       1.0.0
 * @param       int $payment_id The ID of a given payment
 * @return      void
 */
function edd_customerio_connect_register_user($payment_id)
{
    // Bail if API isn't setup
    if (!edd_customerio_connect()->api) {
        return;
    }
    // Setup the request body
    $user_info = edd_get_payment_meta_user_info($payment_id);
    $payment_meta = edd_get_payment_meta($payment_id);
    $cart_items = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false;
    $user_name = false;
    if ($payment_meta['user_info']['first_name']) {
        $user_name = $payment_meta['user_info']['first_name'];
        if ($payment_meta['user_info']['last_name']) {
            $user_name .= ' ' . $payment_meta['user_info']['last_name'];
        }
    }
    $body = array('email' => $payment_meta['user_info']['email'], 'created_at' => $payment_meta['date']);
    if ($user_name) {
        $body['name'] = $user_name;
    }
    $response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body);
    // Track the purchases
    if (empty($cart_items) || !$cart_items) {
        $cart_items = maybe_unserialize($payment_meta['downloads']);
    }
    if ($cart_items) {
        $body = array('name' => 'purchased', 'data' => array('discount' => $payment_meta['user_info']['discount']));
        foreach ($cart_items as $key => $cart_item) {
            $item_id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item;
            $price = $cart_item['price'];
            $body['data']['items'][$cart_item['id']] = array('price' => $price, 'product_id' => $cart_item['id'], 'product_name' => esc_attr($cart_item['name']));
            if (edd_has_variable_prices($cart_item['id'])) {
                $body['data']['items'][$cart_item['id']]['price_id'] = $cart_item['item_number']['options']['price_id'];
                $body['data']['items'][$cart_item['id']]['price_name'] = edd_get_price_option_name($cart_item['id'], $cart_item['item_number']['options']['price_id']);
                $body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['item_number']['quantity'];
            } else {
                $body['data']['items'][$cart_item['id']]['quantity'] = $cart_item['quantity'];
            }
            if (edd_use_taxes()) {
                $body['data']['items'][$cart_item['id']]['tax'] = $cart_item['tax'];
            }
        }
        $response = edd_customerio_connect()->api->call($payment_meta['user_info']['id'], $body, 'POST', 'events');
    }
}
开发者ID:easydigitaldownloads,项目名称:EDD-Customerio-Connect,代码行数:53,代码来源:actions.php


注:本文中的edd_has_variable_prices函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。