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


PHP edd_sanitize_amount函数代码示例

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


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

示例1: column_default

 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'rate':
             $download = get_post_meta($item['ID'], '_download_id', true);
             $type = eddc_get_commission_type($download);
             if ('percentage' == $type) {
                 return $item[$column_name] . '%';
             } else {
                 return edd_currency_filter(edd_sanitize_amount($item[$column_name]));
             }
         case 'status':
             return $item[$column_name];
         case 'amount':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'date':
             return date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $item['ID'])));
         case 'download':
             $download = !empty($item['download']) ? $item['download'] : false;
             return $download ? '<a href="' . esc_url(add_query_arg('download', $download)) . '" title="' . __('View all commissions for this item', 'eddc') . '">' . get_the_title($download) . '</a>' . (!empty($item['variation']) ? ' - ' . $item['variation'] : '') : '';
         case 'payment':
             $payment = get_post_meta($item['ID'], '_edd_commission_payment_id', true);
             return $payment ? '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '" title="' . __('View payment details', 'eddc') . '">#' . $payment . '</a> - ' . edd_get_payment_status(get_post($payment), true) : '';
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
开发者ID:chriscct7,项目名称:EDD-Commissions-1,代码行数:28,代码来源:EDD_C_List_Table.php

示例2: 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

示例3: output_data

 public function output_data($data, $query_mode, $api_object)
 {
     if ('commissions' != $query_mode) {
         return $data;
     }
     $user_id = $api_object->get_user();
     $data['unpaid'] = array();
     $data['paid'] = array();
     $unpaid = eddc_get_unpaid_commissions(array('user_id' => $user_id, 'number' => 30, 'paged' => $api_object->get_paged()));
     if (!empty($unpaid)) {
         foreach ($unpaid as $commission) {
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $data['unpaid'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title(get_post_meta($commission->ID, '_download_id', true)), 'date' => $commission->post_date);
         }
     }
     $paid = eddc_get_paid_commissions(array('user_id' => $user_id, 'number' => 30, 'paged' => $api_object->get_paged()));
     if (!empty($paid)) {
         foreach ($paid as $commission) {
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $data['paid'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title(get_post_meta($commission->ID, '_download_id', true)), 'date' => $commission->post_date);
         }
     }
     $data['totals'] = array('unpaid' => eddc_get_unpaid_totals($user_id), 'paid' => eddc_get_paid_totals($user_id));
     return $data;
 }
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:25,代码来源:rest-api.php

示例4: vp_edd_fd_get_calculated_price

/**
 * Get final price of a download after discount
 * 
 * Modified From:
 * includes/download-functions.php -> edd_price()
 * Modified Parts:
 * Remove the price as a number, without the html formatting.
 * 
 * @param  int   $download_id ID of the download
 * @return float              Download price
 */
function vp_edd_fd_get_calculated_price($download_id)
{
    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);
    }
    return $price;
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:31,代码来源:edd-functions.php

示例5: edd_get_cart_tax

/**
 * Gets the total tax amount for the cart contents
 *
 * @since 1.2.3
 *
 * @return mixed|void Total tax amount
 */
function edd_get_cart_tax()
{
    $cart_tax = 0;
    $items = edd_get_cart_content_details();
    if ($items) {
        $taxes = wp_list_pluck($items, 'tax');
        if (is_array($taxes)) {
            $cart_tax = array_sum($taxes);
        }
    }
    $cart_tax += edd_get_cart_fee_tax();
    return apply_filters('edd_get_cart_tax', edd_sanitize_amount($cart_tax));
}
开发者ID:ankitpokhrel,项目名称:Easy-Digital-Downloads,代码行数:20,代码来源:functions.php

示例6: edd_sanitize_variable_prices_save

/**
 * Sanitize the variable prices
 *
 * Ensures prices are correctly mapped to an array starting with an index of 0
 *
 * @since 1.4.2
 * @param array $prices Variable prices
 * @return array $prices Array of the remapped variable prices
 */
function edd_sanitize_variable_prices_save($prices)
{
    foreach ($prices as $id => $price) {
        if (empty($price['amount']) && empty($price['name'])) {
            unset($prices[$id]);
            continue;
        } elseif (empty($price['amount'])) {
            $price['amount'] = 0;
        }
        $prices[$id]['amount'] = edd_sanitize_amount($price['amount']);
    }
    return $prices;
}
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:22,代码来源:metabox.php

示例7: edd_wallet_cart_items_renewal_row

/**
 * Displays the incentive discount row on the cart
 *
 * @since		1.0.1
 * @return		void
 */
function edd_wallet_cart_items_renewal_row()
{
    $incentive_type = edd_get_option('edd_wallet_incentive_type', 'flatrate');
    $incentive_amount = edd_get_option('edd_wallet_incentive_amount', 0);
    $incentive_description = edd_get_option('edd_wallet_incentive_description', __('Wallet Discount', 'edd-wallet'));
    if ($incentive_amount <= 0) {
        return;
    }
    if (!EDD()->session->get('wallet_has_incentives')) {
        return;
    }
    if ($incentive_type == 'percent') {
        $discount = $incentive_amount . '%';
    } else {
        $discount = edd_currency_filter(edd_sanitize_amount($incentive_amount * edd_get_cart_quantity()));
    }
    ?>
	<tr class="edd_cart_footer_row edd_wallet_incentive_row">
		<td colspan="3"><?php 
    printf(__('%1$s: %2$s', 'edd-wallet'), $incentive_description, $discount);
    ?>
</td>
	</tr>
<?php 
}
开发者ID:easydigitaldownloads,项目名称:edd-wallet,代码行数:31,代码来源:incentive-functions.php

示例8: payments

 /**
  * Create sample purchase data for your EDD site
  *
  * ## OPTIONS
  *
  * --number: The number of purchases to create
  * --status=<status>: The status to create purchases as
  * --id=<product_id>: A specific product to create purchase data for
  * --price_id=<price_id>: A price ID of the specified product
  *
  * ## EXAMPLES
  *
  * wp edd payments create --number=10 --status=completed
  * wp edd payments create --number=10 --id=103
  */
 public function payments($args, $assoc_args)
 {
     $error = false;
     // At some point we'll likely add another action for payments
     if (!isset($args) || count($args) == 0) {
         $error = __('No action specified, did you mean', 'easy-digital-downloads');
     } elseif (isset($args) && !in_array('create', $args)) {
         $error = __('Invalid action specified, did you mean', 'easy-digital-downloads');
     }
     if ($error) {
         foreach ($assoc_args as $key => $value) {
             $query .= ' --' . $key . '=' . $value;
         }
         WP_CLI::error(sprintf($error . ' %s?', 'wp edd payments create' . $query));
         return;
     }
     // Setup some defaults
     $number = 1;
     $status = 'complete';
     $id = false;
     $price_id = false;
     if (count($assoc_args) > 0) {
         $number = array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : $number;
         $id = array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : $id;
         $price_id = array_key_exists('price_id', $assoc_args) ? absint($assoc_args['id']) : false;
         $tax = array_key_exists('tax', $assoc_args) ? floatval($assoc_args['tax']) : 0;
         $email = array_key_exists('email', $assoc_args) ? sanitize_email($assoc_args['email']) : 'guest@local.dev';
         $fname = array_key_exists('fname', $assoc_args) ? sanitize_text_field($assoc_args['fname']) : 'Pippin';
         $lname = array_key_exists('lname', $assoc_args) ? sanitize_text_field($assoc_args['lname']) : 'Williamson';
         // Status requires a bit more validation
         if (array_key_exists('status', $assoc_args)) {
             $stati = array('publish', 'complete', 'pending', 'refunded', 'revoked', 'failed', 'abandoned', 'preapproval', 'cancelled');
             if (in_array($assoc_args['status'], $stati)) {
                 $status = $assoc_args['status'] == 'complete' ? 'publish' : $assoc_args['status'];
             } else {
                 WP_CLI::warning(sprintf(__("Invalid status '%s', defaulting to 'complete'", 'easy-digital-downloads'), $assoc_args['status']));
             }
         }
     }
     // Build the user info array
     $user_info = array('id' => 0, 'email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'discount' => 'none');
     for ($i = 0; $i < $number; $i++) {
         $products = array();
         $total = 0;
         // No specified product
         if (!$id) {
             $products = get_posts(array('post_type' => 'download', 'orderby' => 'rand', 'order' => 'ASC', 'posts_per_page' => 1));
         } else {
             $product = get_post($id);
             if ($product->post_type != 'download') {
                 WP_CLI::error(__('Specified ID is not a product', 'easy-digital-downloads'));
                 return;
             }
             $products[] = $product;
         }
         $cart_details = array();
         // Create the purchases
         foreach ($products as $key => $download) {
             if (!is_a($download, 'WP_Post')) {
                 continue;
             }
             $options = array();
             $final_downloads = array();
             // Deal with variable pricing
             if (edd_has_variable_prices($download->ID)) {
                 $prices = edd_get_variable_prices($download->ID);
                 if (false === $price_id || !array_key_exists($price_id, (array) $prices)) {
                     $price_id = rand(0, count($prices) - 1);
                 }
                 $item_price = $prices[$price_id]['amount'];
                 $options['price_id'] = $price_id;
             } else {
                 $item_price = edd_get_download_price($download->ID);
             }
             $item_number = array('id' => $download->ID, 'quantity' => 1, 'options' => $options);
             $cart_details[$key] = array('name' => $download->post_title, 'id' => $download->ID, 'item_number' => $item_number, 'item_price' => edd_sanitize_amount($item_price), 'subtotal' => edd_sanitize_amount($item_price), 'price' => edd_sanitize_amount($item_price), 'quantity' => 1, 'discount' => 0, 'tax' => $tax);
             $final_downloads[$key] = $item_number;
             $total += $item_price;
         }
         $purchase_data = array('price' => edd_sanitize_amount($total), 'tax' => 0, 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $email, 'user_info' => $user_info, 'currency' => edd_get_currency(), 'downloads' => $final_downloads, 'cart_details' => $cart_details, 'status' => 'pending');
         $payment_id = edd_insert_payment($purchase_data);
         remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999);
         if ($status != 'pending') {
             edd_update_payment_status($payment_id, $status);
         }
//.........这里部分代码省略.........
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:class-edd-cli.php

示例9: edd_save_bulk_edit

/**
 * Process bulk edit actions via AJAX
 *
 * @since 1.4.4
 * @return void
 */
function edd_save_bulk_edit()
{
    $post_ids = isset($_POST['post_ids']) && !empty($_POST['post_ids']) ? $_POST['post_ids'] : array();
    if (!empty($post_ids) && is_array($post_ids)) {
        $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
        foreach ($post_ids as $post_id) {
            if (!empty($price)) {
                update_post_meta($post_id, 'edd_price', edd_sanitize_amount($price));
            }
        }
    }
    die;
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:19,代码来源:dashboard-columns.php

示例10: get_price

 /**
  * Retrieve the price
  *
  * @since 2.2
  * @return float
  */
 public function get_price()
 {
     if (!isset($this->price)) {
         $this->price = get_post_meta($this->ID, 'edd_price', true);
         if ($this->price) {
             $this->price = edd_sanitize_amount($this->price);
         } else {
             $this->price = 0;
         }
     }
     /**
      * Override the download price.
      *
      * @since 2.2
      *
      * @param string $price The download price(s).
      * @param string|int $id The downloads ID.
      */
     return apply_filters('edd_get_download_price', $this->price, $this->ID);
 }
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:26,代码来源:class-edd-download.php

示例11: edd_update_payment_details

/**
 * Process the payment details edit
 *
 * @access      private
 * @since       1.9
 * @return      void
*/
function edd_update_payment_details($data)
{
    if (!current_user_can('edit_shop_payments', $data['edd_payment_id'])) {
        wp_die(__('You do not have permission to edit this payment record', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    check_admin_referer('edd_update_payment_details_nonce');
    // Retrieve the payment ID
    $payment_id = absint($data['edd_payment_id']);
    // Retrieve existing payment meta
    $meta = edd_get_payment_meta($payment_id);
    $user_info = edd_get_payment_meta_user_info($payment_id);
    $status = $data['edd-payment-status'];
    $unlimited = isset($data['edd-unlimited-downloads']) ? '1' : '';
    $date = sanitize_text_field($data['edd-payment-date']);
    $hour = sanitize_text_field($data['edd-payment-time-hour']);
    // Restrict to our high and low
    if ($hour > 23) {
        $hour = 23;
    } elseif ($hour < 0) {
        $hour = 00;
    }
    $minute = sanitize_text_field($data['edd-payment-time-min']);
    // Restrict to our high and low
    if ($minute > 59) {
        $minute = 59;
    } elseif ($minute < 0) {
        $minute = 00;
    }
    $address = array_map('trim', $data['edd-payment-address'][0]);
    $curr_total = edd_sanitize_amount(edd_get_payment_amount($payment_id));
    $new_total = edd_sanitize_amount($_POST['edd-payment-total']);
    $tax = isset($_POST['edd-payment-tax']) ? edd_sanitize_amount($_POST['edd-payment-tax']) : 0;
    $date = date('Y-m-d', strtotime($date)) . ' ' . $hour . ':' . $minute . ':00';
    $curr_customer_id = sanitize_text_field($data['edd-current-customer']);
    $new_customer_id = sanitize_text_field($data['customer-id']);
    // Setup purchased Downloads and price options
    $updated_downloads = isset($_POST['edd-payment-details-downloads']) ? $_POST['edd-payment-details-downloads'] : false;
    if ($updated_downloads && !empty($_POST['edd-payment-downloads-changed'])) {
        $downloads = array();
        $cart_details = array();
        $i = 0;
        foreach ($updated_downloads as $download) {
            if (empty($download['amount'])) {
                $download['amount'] = '0.00';
            }
            $item = array();
            $item['id'] = absint($download['id']);
            $item['quantity'] = absint($download['quantity']) > 0 ? absint($download['quantity']) : 1;
            $price_id = (int) $download['price_id'];
            $has_log = absint($download['has_log']);
            if ($price_id !== false && edd_has_variable_prices($item['id'])) {
                $item['options'] = array('price_id' => $price_id);
            }
            $downloads[] = $item;
            $cart_item = array();
            $cart_item['item_number'] = $item;
            $item_price = round($download['amount'] / $item['quantity'], edd_currency_decimal_filter());
            $cart_details[$i] = array('name' => get_the_title($download['id']), 'id' => $download['id'], 'item_number' => $item, 'price' => $download['amount'], 'item_price' => $item_price, 'subtotal' => $download['amount'], 'quantity' => $download['quantity'], 'discount' => 0, 'tax' => 0);
            // If this item doesn't have a log yet, add one for each quantity count
            if (empty($has_log)) {
                $log_date = date('Y-m-d G:i:s', current_time('timestamp', true));
                $price_id = $price_id !== false ? $price_id : 0;
                $y = 0;
                while ($y < $download['quantity']) {
                    edd_record_sale_in_log($download['id'], $payment_id, $price_id, $log_date);
                    $y++;
                }
                edd_increase_purchase_count($download['id'], $download['quantity']);
                edd_increase_earnings($download['id'], $download['amount']);
            }
            $i++;
        }
        $meta['downloads'] = $downloads;
        $meta['cart_details'] = $cart_details;
        $deleted_downloads = json_decode(stripcslashes($data['edd-payment-removed']), true);
        foreach ($deleted_downloads as $deleted_download) {
            $deleted_download = $deleted_download[0];
            if (empty($deleted_download['id'])) {
                continue;
            }
            $price_id = empty($deleted_download['price_id']) ? 0 : (int) $deleted_download['price_id'];
            $log_args = array('post_type' => 'edd_log', 'post_parent' => $deleted_download['id'], 'numberposts' => $deleted_download['quantity'], 'meta_query' => array(array('key' => '_edd_log_payment_id', 'value' => $payment_id, 'compare' => '='), array('key' => '_edd_log_price_id', 'value' => $price_id, 'compare' => '=')));
            $found_logs = get_posts($log_args);
            foreach ($found_logs as $log) {
                wp_delete_post($log->ID, true);
            }
            edd_decrease_purchase_count($deleted_download['id'], $deleted_download['quantity']);
            edd_decrease_earnings($deleted_download['id'], $deleted_download['amount']);
            do_action('edd_remove_download_from_payment', $payment_id, $deleted_download['id']);
        }
    }
    do_action('edd_update_edited_purchase', $payment_id);
    // Update main payment record
//.........这里部分代码省略.........
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:actions.php

示例12: edd_update_edited_purchase

/**
 * Update Edited Purchase
 *
 * Updates the purchase data for a payment.
 * Used primarily for adding new downloads to a purchase.
 *
 * @since 1.0
 * @param $data Arguments passed
 * @return void
 */
function edd_update_edited_purchase($data)
{
    if (wp_verify_nonce($data['edd-payment-nonce'], 'edd_payment_nonce')) {
        $payment_id = $_POST['payment-id'];
        $payment_data = edd_get_payment_meta($payment_id);
        if (isset($_POST['edd-purchased-downloads'])) {
            $download_list = array();
            foreach ($_POST['edd-purchased-downloads'] as $key => $download) {
                if (isset($download['options']['price_id'])) {
                    $download_list[] = array('id' => $key, 'options' => array('price_id' => $download['options']['price_id']));
                } else {
                    $download_list[] = array('id' => $download);
                }
            }
            $payment_data['downloads'] = serialize($download_list);
        }
        $user_info = maybe_unserialize($payment_data['user_info']);
        $user_info['email'] = strip_tags($_POST['edd-buyer-email']);
        $user_info['user_id'] = strip_tags(intval($_POST['edd-buyer-user-id']));
        $payment_data['user_info'] = serialize($user_info);
        update_post_meta($payment_id, '_edd_payment_meta', $payment_data);
        update_post_meta($payment_id, '_edd_payment_user_email', strip_tags($_POST['edd-buyer-email']));
        update_post_meta($payment_id, '_edd_payment_user_id', strip_tags(intval($_POST['edd-buyer-user-id'])));
        if (!empty($_POST['edd-payment-note'])) {
            $note = wp_kses($_POST['edd-payment-note'], array());
            $note_id = edd_insert_payment_note($payment_id, $note);
        }
        if (!empty($_POST['edd-payment-amount'])) {
            update_post_meta($payment_id, '_edd_payment_total', sanitize_text_field(edd_sanitize_amount($_POST['edd-payment-amount'])));
        }
        if (!empty($_POST['edd-unlimited-downloads'])) {
            add_post_meta($payment_id, '_unlimited_file_downloads', '1');
        } else {
            delete_post_meta($payment_id, '_unlimited_file_downloads');
        }
        if ($_POST['edd-old-status'] != $_POST['edd-payment-status']) {
            edd_update_payment_status($payment_id, $_POST['edd-payment-status']);
        }
        if ($_POST['edd-payment-status'] == 'publish' && isset($_POST['edd-payment-send-email'])) {
            // Send the purchase receipt
            edd_email_purchase_receipt($payment_id, false);
        }
        do_action('edd_update_edited_purchase', $payment_id);
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:55,代码来源:actions.php

示例13: atcf_edd_add_to_cart_item

/**
 * Custom pledge level fix.
 *
 * If there is a custom price, figure out the difference
 * between that, and the price level they have chosen. Store
 * the differene in the cart item meta, so it can be added to
 * the total in the future.
 *
 * @since Astoundify Crowdfunding 1.6
 *
 * @param array $cart_item The current cart item to be added.
 * @return array $cart_item The modified cart item.
 */
function atcf_edd_add_to_cart_item($cart_item)
{
    if (isset($_POST['post_data'])) {
        $post_data = array();
        parse_str($_POST['post_data'], $post_data);
        $custom_price = $post_data['atcf_custom_price'];
    } else {
        $custom_price = $_POST['atcf_custom_price'];
    }
    $custom_price = edd_sanitize_amount($custom_price);
    $price = edd_get_cart_item_price($cart_item['id'], $cart_item['options'], edd_prices_include_tax());
    if ($custom_price > $price) {
        $cart_item['options']['atcf_extra_price'] = $custom_price - $price;
    }
    return $cart_item;
}
开发者ID:unclebrain,项目名称:appthemer-crowdfunding,代码行数:29,代码来源:checkout.php

示例14: eddc_generate_payout_file

function eddc_generate_payout_file($data)
{
    if (wp_verify_nonce($data['eddc-payout-nonce'], 'eddc-payout-nonce')) {
        $from = !empty($data['from']) ? sanitize_text_field($data['from']) : date('m/d/Y', strtotime('-1 month'));
        $to = !empty($data['to']) ? sanitize_text_field($data['to']) : date('m/d/Y');
        $from = explode('/', $from);
        $to = explode('/', $to);
        $args = array('number' => -1, 'query_args' => array('date_query' => array('after' => array('year' => $from[2], 'month' => $from[0], 'day' => $from[1]), 'before' => array('year' => $to[2], 'month' => $to[0], 'day' => $to[1]), 'inclusive' => true)));
        $commissions = eddc_get_unpaid_commissions($args);
        if ($commissions) {
            header('Content-Type: text/csv; charset=utf-8');
            header('Content-Disposition: attachment; filename=edd-commission-payout-' . date('m-d-Y') . '.csv');
            header("Pragma: no-cache");
            header("Expires: 0");
            $payouts = array();
            foreach ($commissions as $commission) {
                $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
                $user_id = $commission_meta['user_id'];
                $user = get_userdata($user_id);
                $custom_paypal = get_user_meta($user_id, 'eddc_user_paypal', true);
                $email = is_email($custom_paypal) ? $custom_paypal : $user->user_email;
                if (array_key_exists($email, $payouts)) {
                    $payouts[$email]['amount'] += $commission_meta['amount'];
                } else {
                    $payouts[$email] = array('amount' => $commission_meta['amount'], 'currency' => $commission_meta['currency']);
                }
                eddc_set_commission_status($commission->ID, 'paid');
            }
            if ($payouts) {
                foreach ($payouts as $key => $payout) {
                    echo $key . ",";
                    echo edd_sanitize_amount(number_format($payout['amount'], 2)) . ",";
                    echo $payout['currency'];
                    echo "\r\n";
                }
            }
        } else {
            wp_die(__('No commissions to be paid', 'eddc'), __('Error'));
        }
        die;
    }
}
开发者ID:chriscct7,项目名称:EDD-Commissions-1,代码行数:42,代码来源:commission-functions.php

示例15: widget

    /**
     * Display the widget content.
     *
     * @since 1.0
     *
     * @param array $args Display arguments including before_widget and after_widget.
     * @param array $instance The settings for the particular instance of the widget
     */
    function widget($args, $instance)
    {
        // Merge with defaults
        $instance = wp_parse_args((array) $instance, $this->defaults);
        // Return early if we have no download ID or no variable prices
        if (!isset($instance['download']) || !edd_has_variable_prices(absint($instance['download']))) {
            return;
        }
        // Set the download ID
        $download_id = absint($instance['download']);
        // Get the variable price options
        $prices = edd_get_variable_prices($download_id);
        // Get the featured price option
        $featured = isset($instance['price_variation']) && !empty($instance['price_variation']) ? absint($instance['price_variation']) : false;
        echo $args['before_widget'];
        ?>

		<section class="pricing-section <?php 
        if ($featured) {
            echo 'featured-price';
        }
        ?>
">
			<div class="pricing-table-wrap">
				<?php 
        foreach ($prices as $key => $price) {
            ?>
					<div itemscope class="pricing-table <?php 
            if ($key == $featured) {
                echo 'featured';
            }
            ?>
">
						<div class="pricing-table-top">
							<div class="pricing-table-price"><?php 
            echo apply_filters('edd_download_price', edd_sanitize_amount($price['amount']), $download_id, $key);
            ?>
</div>
							<div class="pricing-table-price-desc"><?php 
            echo $price['name'];
            ?>
</div>
						</div>
						<div class="pricing-table-features">
							<div class="download-details download-aside">
								<div class="download-features" itemprop="itemCondition">
									<ul>
									<?php 
            $list_items = checkout_edd_download_details_list_items($download_id, $key);
            if ($list_items) {
                foreach ($list_items as $item) {
                    echo '<li class="price-feature">' . $item . '</li>';
                }
            }
            $list_item_all_prices = checkout_edd_download_details_list_items($download_id, 'all');
            if ($list_item_all_prices) {
                foreach ($list_item_all_prices as $list_item) {
                    echo '<li class="all-prices-feature">' . $list_item . '</li>';
                }
            }
            ?>
										</ul>
									</div>
								</div>
							<a class="button" href="<?php 
            echo edd_get_checkout_uri();
            ?>
?edd_action=add_to_cart&amp;download_id=<?php 
            echo absint($download_id);
            ?>
&amp;edd_options%5Bprice_id%5D=<?php 
            echo absint($key);
            ?>
" title="<?php 
            echo esc_attr($price['name']);
            ?>
">
								<?php 
            _e('Buy Now', 'checkout');
            ?>
							</a>
						</div>
					</div>
				<?php 
        }
        ?>
			</div>

			<?php 
        if ($instance['footnotes']) {
            ?>
				<div class="pricing-table-footnotes">
//.........这里部分代码省略.........
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:101,代码来源:widget-pricing-table-variable.php


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