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 } }
/** * 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; } } }
/** * This function renders most of the columns in the list table. * * @access public * @since 1.4 * * @param array $item Contains all the data of the log item * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($item, $column_name) { $return = ''; switch ($column_name) { case 'download': $return = '<a href="' . add_query_arg('download', $item[$column_name]) . '" >' . get_the_title($item[$column_name]) . '</a>'; break; case 'user_id': $user = !empty($item['user_id']) ? $item['user_id'] : edd_get_payment_user_email($item['payment_id']); $return = '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'">' . $item['user_name'] . '</a>'; break; case 'item_price': $return = edd_currency_filter(edd_format_amount($item['item_price'])); break; case 'amount': $return = edd_currency_filter(edd_format_amount($item['amount'] / $item['quantity'])); break; case 'payment_id': $return = '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment_id']) . '">' . edd_get_payment_number($item['payment_id']) . '</a>'; break; default: $return = $item[$column_name]; break; } return $return; }
/** * 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; } } }
/** * Adds item to the cart from the wish list via AJAX. Based off edd_ajax_add_to_cart() * * @since 1.0 * @return void */ function edd_ajax_add_to_cart_from_wish_list() { if (isset($_POST['download_id'])) { global $post; $to_add = array(); if (isset($_POST['price_ids']) && is_array($_POST['price_ids'])) { foreach ($_POST['price_ids'] as $price) { $to_add[] = array('price_id' => $price); } } foreach ($to_add as $options) { if ($_POST['download_id'] == $options['price_id']) { $options = array(); } parse_str($_POST['post_data'], $post_data); if (isset($options['price_id']) && isset($post_data['edd_download_quantity_' . $options['price_id']])) { $options['quantity'] = absint($post_data['edd_download_quantity_' . $options['price_id']]); } else { $options['quantity'] = isset($post_data['edd_download_quantity']) ? absint($post_data['edd_download_quantity']) : 1; } // call EDD's edd_add_to_cart function $key = edd_add_to_cart($_POST['download_id'], $options); $item = array('id' => $_POST['download_id'], 'options' => $options); $item = apply_filters('edd_wl_ajax_pre_cart_item_template', $item); $return = array('add_to_cart' => 'Added to Cart', 'subtotal' => html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_cart_subtotal())), ENT_COMPAT, 'UTF-8'), 'cart_item' => html_entity_decode(edd_get_cart_item_template($key, $item, true), ENT_COMPAT, 'UTF-8')); echo json_encode($return); } } edd_die(); }
/** * Get the allowed deposit levels * * @since 1.0.0 * @return array $levels The allowed deposit levels */ function edd_wallet_get_deposit_levels() { $levels = array(); $initial_levels = apply_filters('edd_wallet_deposit_levels', array('10', '20', '30', '40', '50', '60', '70', '80', '90', '100', '200', '300', '400', '500')); foreach ($initial_levels as $level) { $levels[$level] = edd_currency_filter(edd_format_amount($level)); } return $levels; }
function download_lowest_price_function($atts) { $atts = shortcode_atts(array('limit' => -1, 'id' => ''), $atts, 'download_price_lowest'); if ($atts['id'] != '') { $id = $atts['id']; } else { $id = get_the_id(); } return edd_currency_filter(edd_format_amount(edd_get_download_price($id, false))); }
/** * Display column contents * * @since 1.0.0 * @param string $value The default value for the column * @param int $item_id The ID of the row item * @return string $value The updated value for the column */ function edd_wallet_column_data($value, $item_id) { $customer = new EDD_Customer($item_id); if ($customer->user_id < 1) { return ''; } $value = edd_wallet()->wallet->balance($customer->user_id); $value = edd_currency_filter(edd_format_amount((double) $value)); // Build the wallet link $value = '<a href="' . admin_url('edit.php?post_type=download&page=edd-customers&view=wallet&id=' . $item_id) . '" title="' . __('View user wallet', 'edd-wallet') . '">' . $value . '</a>'; return $value; }
/** * Email Download Purchase Receipt * * Email the download link(s) and payment confirmation to the buyer. * * @access private * @since 1.0 * @return void */ function edd_email_purchase_receipt($payment_id, $admin_notice = true) { global $edd_options; $payment_data = edd_get_payment_meta($payment_id); $user_info = maybe_unserialize($payment_data['user_info']); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $message = edd_get_email_body_header(); $message .= edd_get_email_body_content($payment_id, $payment_data); $message .= edd_get_email_body_footer(); $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name'); $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email'); $subject = isset($edd_options['purchase_subject']) && strlen(trim($edd_options['purchase_subject'])) > 0 ? edd_email_template_tags($edd_options['purchase_subject'], $payment_data, $payment_id) : __('Purchase Receipt', 'edd'); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; // allow add-ons to add file attachments $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); wp_mail($payment_data['email'], $subject, $message, $headers, $attachments); if ($admin_notice) { /* send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data); $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $download_list .= html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $admin_message .= __('Thank you', 'edd'); $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data); $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data); $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments); } }
/** * Get the data being exported * * @return array $data */ public function get_data() { global $wpdb; $data = array(); $campaign = $this->campaign; $campaign = atcf_get_campaign($campaign); $backers = $campaign->backers(); if (empty($backers)) { return $data; } foreach ($backers as $log) { $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true); $payment = get_post($payment_id); $payment_meta = edd_get_payment_meta($payment_id); $user_info = edd_get_payment_meta_user_info($payment_id); $downloads = edd_get_payment_meta_cart_details($payment_id); $total = edd_get_payment_amount($payment_id); $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; $products = ''; if ($downloads) { foreach ($downloads as $key => $download) { // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); // Display the Downoad Name $products .= get_the_title($id) . ' - '; if (isset($downloads[$key]['item_number'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - '; } } $products .= html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { $products .= ' / '; } } } if (is_numeric($user_id)) { $user = get_userdata($user_id); } else { $user = false; } $shipping = isset($payment_meta['shipping']) ? $payment_meta['shipping'] : null; $data[] = apply_filters('atcf_csv_cols_values', array('id' => $payment_id, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'shipping' => isset($shipping) ? implode("\n", $shipping) : '', 'products' => $products, 'amount' => html_entity_decode(edd_currency_filter(edd_format_amount($total))), 'tax' => html_entity_decode(edd_payment_tax($payment_id, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'atcf'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => date_i18n(get_option('date_format'), strtotime($payment->post_date)), 'user' => $user ? $user->display_name : __('guest', 'atcf'), 'status' => edd_get_payment_status($payment, true)), $payment_id); } $data = apply_filters('edd_export_get_data', $data); $data = apply_filters('edd_export_get_data_' . $this->export_type, $data); return $data; }
/** * Output column data * * @access private * @since 1.3 * @return string */ function column_default($item, $column_name) { switch ($column_name) { case 'earnings': return edd_currency_filter(edd_format_amount($item[$column_name])); case 'average_sales': return round($item[$column_name]); case 'average_earnings': return edd_currency_filter(edd_format_amount($item[$column_name])); default: return $item[$column_name]; } }
/** * Render most columns * * @access private * @since 1.4 * @return string */ function column_default($item, $column_name) { switch ($column_name) { case 'name': return '<a href="' . admin_url('/edit.php?post_type=download&page=edd-payment-history&user='******'email'])) . '">' . esc_html($item[$column_name]) . '</a>'; case 'amount_spent': return edd_currency_filter(edd_format_amount($item[$column_name])); case 'file_downloads': return '<a href="' . admin_url('/edit.php?post_type=download&page=edd-reports&tab=logs&user='******'ID']) ? $item['ID'] : $item['email'])) . '" target="_blank">' . $item['file_downloads'] . '</a>'; default: return $item[$column_name]; } }
/** * This function renders most of the columns in the list table. * * @access public * @since 1.4 * * @param array $item Contains all the data of the discount code * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($item, $column_name) { switch ($column_name) { case 'download': return '<a href="' . add_query_arg('download', $item[$column_name]) . '" >' . get_the_title($item[$column_name]) . '</a>'; case 'user_id': return '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&user='******'user_id'])) . '">' . $item['user_name'] . '</a>'; case 'amount': return edd_currency_filter(edd_format_amount($item['amount'])); default: return $item[$column_name]; } }
function download_checkout_item_total_function($atts) { $atts = shortcode_atts(array('id' => ''), $atts, 'download_checkout_item_total'); global $x, $cart_array; if ($atts['id'] != '') { $id = $atts['id']; } else { $id = get_the_id(); } $options = $cart_array[get_the_ID()][$x - 1]['options']; $price = edd_get_cart_item_price($id, $options); $price += edd_get_cart_item_tax($id, $options, $price); $price = edd_currency_filter(edd_format_amount($price)); return $price; }
/** * This function renders most of the columns in the list table. * * @access public * @since 1.5 * * @param array $item Contains all the data of the downloads * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($item, $column_name) { switch ($column_name) { case 'earnings': return edd_currency_filter(edd_format_amount($item[$column_name])); case 'average_sales': return round($item[$column_name]); case 'average_earnings': return edd_currency_filter(edd_format_amount($item[$column_name])); case 'details': return '<a href="' . admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $item['ID']) . '">' . __('View Detailed Report', 'easy-digital-downloads') . '</a>'; default: return $item[$column_name]; } }
/** * Get Cart Item Template * * @access public * @since 1.0 * @return string */ 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, $post, $ajax); $title = get_the_title($id); $options = !empty($item['options']) ? $item['options'] : array(); if (!empty($options)) { $title .= ' <span class="edd-cart-item-separator">-</span> ' . edd_get_price_name($id, $item['options']); } $remove = '<a href="' . esc_url($remove_url) . '" data-cart-item="' . absint($cart_key) . '" data-download-id="' . absint($id) . '" data-action="edd_remove_from_cart" class="edd-remove-from-cart">' . __('remove', 'edd') . '</a>'; $item = '<li class="edd-cart-item"><span class="edd-cart-item-title">' . $title . '</span> '; $item .= '<span class="edd-cart-item-separator">-</span> ' . edd_currency_filter(edd_get_cart_item_price($id, $options)) . ' '; $item .= '<span class="edd-cart-item-separator">-</span> ' . $remove . '</li>'; return apply_filters('edd_cart_item', $item, $id); }
/** * 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; } } }
/** * Add Custom Points Conversion Rate Settings * * Handle to add custom points conversion rate settings * * @package Easy Digital Downloads - Points and Rewards * @since 1.0.0 * */ function edd_pointsrate_callback($args) { global $edd_options; if (isset($edd_options[$args['id']])) { $value = $edd_options[$args['id']]; } else { $value = isset($args['std']) ? $args['std'] : ''; } $points = isset($value['points']) ? $value['points'] : ''; $rate = isset($value['rate']) ? $value['rate'] : ''; $val = edd_currency_filter(' '); $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; $html = '<input type="text" class="' . $args['size'] . '-text" id="edd_settings[' . $args['id'] . ']" name="edd_settings[' . $args['id'] . '][points]" value="' . esc_attr($points) . '"/> '; $html .= __('Points =', 'eddpoints') . ' ' . $val . ' <input type="text" class="' . $args['size'] . '-text" id="edd_settings[' . $args['id'] . ']" name="edd_settings[' . $args['id'] . '][rate]" value="' . esc_attr($rate) . '"/>'; $html .= '<label for="edd_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>'; echo $html; }
/** * Set the CSV columns * * @access public * @since 1.4.4 * @return array $cols All the columns */ public function csv_cols() { if (!empty($_POST['edd_export_download'])) { $cols = array('name' => __('Name', 'edd'), 'email' => __('Email', 'edd'), 'date' => __('Date Purchased', 'edd')); } else { $cols = array(); if ('emails' != $_POST['edd_export_option']) { $cols['name'] = __('Name', 'edd'); } $cols['email'] = __('Email', 'edd'); if ('full' == $_POST['edd_export_option']) { $cols['purchases'] = __('Total Purchases', 'edd'); $cols['amount'] = __('Total Purchased', 'edd') . ' (' . html_entity_decode(edd_currency_filter('')) . ')'; } } return $cols; }
/** * This function renders most of the columns in the list table. * * @access public * @since 1.2.6 * * @param array $item Contains all the data of the discount code * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($item, $column_name) { switch ($column_name) { case 'id': return $item['id']; case 'download': return '<a href="' . add_query_arg(array('download' => $item['download']), $this->base) . '">' . get_the_title($item['download']) . '</a>'; case 'source': return '<a href="' . add_query_arg(array('source' => $item['source']), $this->base) . '">' . get_the_title($item['source']) . '</a>'; case 'payment': return '<a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $item['payment']) . '">' . $item['payment'] . '</a>'; case 'amount': return edd_currency_filter(edd_format_amount($item['amount'])); default: return $item[$column_name]; } }
function sd_edd_commissions_email_alert($user_id, $commission_amount, $rate, $download_id, $commission_id) { global $edd_options; $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name'); $from_name = apply_filters('eddc_email_from_name', $from_name, $user_id, $commission_amount, $rate, $download_id); $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email'); $from_email = apply_filters('eddc_email_from_email', $from_email, $user_id, $commission_amount, $rate, $download_id); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; /* send an email alert of the sale */ $user = get_userdata($user_id); $email = $user->user_email; // set address here $message = __('Hello', 'eddc') . "\n\n" . sprintf(__('You have made a new sale on %s!', 'eddc'), stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))) . ".\n\n"; $variation = get_post_meta($commission_id, '_edd_commission_download_variation', true); $message .= __('Item sold: ', 'eddc') . get_the_title($download_id) . (!empty($variation) ? ' - ' . $variation : '') . "\n\n"; $message .= __('Amount: ', 'eddc') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($commission_amount))) . "\n\n"; $message .= __('Commission Rate: ', 'eddc') . $rate . "%\n\n"; $message .= __('Thank you', 'eddc'); $message = apply_filters('eddc_sale_alert_email', $message, $user_id, $commission_amount, $rate, $download_id); wp_mail($email, __('New Sale!', 'eddc'), $message, $headers); }
/** * Tie into the heartbeat and append our stats * * @access public * @since 1.8 * @return array */ public static function heartbeat_received($response, $data) { if (!current_user_can('view_shop_reports')) { return $response; // Only modify heartbeat if current user can view show reports } // Make sure we only run our query if the edd_heartbeat key is present if (isset($data['edd_heartbeat']) && $data['edd_heartbeat'] == 'dashboard_summary') { // Instantiate the stats class $stats = new EDD_Payment_Stats(); $earnings = edd_get_total_earnings(); // Send back the number of complete payments $response['edd-total-payments'] = edd_format_amount(edd_get_total_sales(), false); $response['edd-total-earnings'] = html_entity_decode(edd_currency_filter(edd_format_amount($earnings)), ENT_COMPAT, 'UTF-8'); $response['edd-payments-month'] = edd_format_amount($stats->get_sales(0, 'this_month', false, array('publish', 'revoked')), false); $response['edd-earnings-month'] = html_entity_decode(edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'this_month'))), ENT_COMPAT, 'UTF-8'); $response['edd-payments-today'] = edd_format_amount($stats->get_sales(0, 'today', false, array('publish', 'revoked')), false); $response['edd-earnings-today'] = html_entity_decode(edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'today'))), ENT_COMPAT, 'UTF-8'); } return $response; }
/** * Display widget * * @access public * @since 1.1.0 * @param array $args Arguements for the widget * @param array $instance This widget instance * @return void */ public function widget($args, $instance) { // Bail if user isn't logged in if (!is_user_logged_in()) { return; } $args['id'] = isset($args['id']) ? $args['id'] : 'edd_wallet_widget'; $instance['title'] = isset($instance['title']) ? $instance['title'] : ''; $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']); echo $args['before_widget']; if ($title) { echo $args['before_title'] . $title . $args['after_title']; } do_action('edd_before_wallet_widget'); $current_user = wp_get_current_user(); $value = edd_wallet()->wallet->balance($current_user->ID); $value = edd_currency_filter(edd_format_amount($value)); $value = '<span class="edd-wallet-value">' . $value . '</span>'; echo $value; do_action('edd_after_wallet_widget'); echo $args['after_widget']; }
function shoestrap_edd_purchase_variable_pricing($download_id) { $variable_pricing = edd_has_variable_prices($download_id); if (!$variable_pricing) { return; } $prices = apply_filters('edd_purchase_variable_prices', edd_get_variable_prices($download_id), $download_id); $type = edd_single_price_option_mode($download_id) ? 'checkbox' : 'radio'; do_action('edd_before_price_options', $download_id); echo '<div class="edd_price_options">'; if ($prices) { echo '<select name="edd_options[price_id][]">'; foreach ($prices as $key => $price) { printf('<option for="%3$s" name="edd_options[price_id][]" id="%3$s" class="%4$s" value="%5$s" %7$s> %6$s</option>', checked(0, $key, false), $type, esc_attr('edd_price_option_' . $download_id . '_' . $key), esc_attr('edd_price_option_' . $download_id), esc_attr($key), esc_html($price['name'] . ' - ' . edd_currency_filter(edd_format_amount($price['amount']))), selected(isset($_GET['price_option']), $key, false)); do_action('edd_after_price_option', $key, $price, $download_id); } echo '</select>'; } do_action('edd_after_price_options_list', $download_id, $prices, $type); echo '</div><!--end .edd_price_options-->'; do_action('edd_after_price_options', $download_id); }
/** * 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') { 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; } } }
/** * Process deposit * * @since 1.0.0 * @return void */ function edd_wallet_process_deposit() { // Verify the nonce if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'edd-wallet-deposit-nonce')) { wp_die(__('Nonce verification failed', 'edd-wallet'), __('Error', 'edd-wallet'), array('response' => 403)); } // Make sure the cart is empty edd_empty_cart(); $value = $_POST['edd_wallet_deposit_amount']; if ($value == 'custom') { $value = $_POST['edd_wallet_custom_deposit']; } // Setup the fee label $label = edd_get_option('edd_wallet_deposit_description', __('Deposit to wallet', 'edd-wallet')); $label = str_replace('{val}', edd_currency_filter(edd_format_amount($value)), $label); // Setup the fee (product) for the deposit $fee = array('amount' => $value, 'label' => $label, 'type' => 'item', 'no_tax' => true, 'id' => 'edd-wallet-deposit'); EDD()->fees->add_fee($fee); // Redirect to checkout wp_redirect(edd_get_checkout_uri(), 303); edd_die(); }
<?php foreach ($fees as $fee) { ?> <tr> <td class="edd_fee_label"><?php echo esc_html($fee['label']); ?> </td> <?php if (edd_item_quantities_enabled()) { ?> <td></td> <?php } ?> <td class="edd_fee_amount"><?php echo edd_currency_filter(edd_format_amount($fee['amount'])); ?> </td> </tr> <?php } ?> <?php } ?> </tbody> </table> <?php }
/** * Register Settings * * Handels to add settings in settings page * * @package Easy Digital Downloads - Points and Rewards * @since 1.0.0 */ public function edd_points_settings($settings) { $success_message = ''; // Display success message when click Apply Points extensions settings if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'apply_points' && isset($_GET['success_count'])) { $success_count = $_GET['success_count']; $success_message = '<div class="updated" id="message"><p><strong>' . sprintf(__('%d order(s) updated.', 'eddpoints'), $success_count) . '</strong></p></div>'; } $edd_points_settings = array(array('id' => 'edd_points_settings', 'name' => $success_message . '<strong>' . __('Points And Rewards Options', 'eddpoints') . '</strong>', 'desc' => __('Configure Points And Rewards Settings', 'eddpoints'), 'type' => 'header'), array('id' => 'edd_points_general_settings', 'name' => '<strong>' . __('Points Settings', 'eddpoints') . '</strong>', 'desc' => __('Configure Points Settings', 'eddpoints'), 'type' => 'header'), array('id' => 'edd_points_earn_conversion', 'name' => __('Earn Points Conversion Rate:', 'eddpoints'), 'desc' => '<p class="description">' . __('Set the number of points awarded based on the product price.', 'eddpoints') . '</p>', 'type' => 'pointsrate', 'size' => 'small'), array('id' => 'edd_points_redeem_conversion', 'name' => __('Redeem Points Conversion Rate:', 'eddpoints'), 'desc' => '<p class="description">' . __('Set the value of points redeemed for a discount.', 'eddpoints') . '</p>', 'type' => 'pointsrate', 'size' => 'small'), array('id' => 'edd_points_buy_conversion', 'name' => __('Buy Points Conversion Rate:', 'eddpoints'), 'desc' => '<p class="description">' . __('Set the value for buy points.', 'eddpoints') . '</p>', 'type' => 'pointsrate', 'size' => 'small'), array('id' => 'edd_points_selling_conversion', 'name' => __('Selling Points Conversion Rate:', 'eddpoints'), 'desc' => '<p class="description">' . __('Set the value for selling points.', 'eddpoints') . '</p>', 'type' => 'pointsrate', 'size' => 'small'), array('id' => 'edd_points_cart_max_discount', 'name' => __('Maximum Cart Discount:', 'eddpoints'), 'desc' => edd_currency_filter('') . '<p class="description">' . __('Set the maximum discount allowed for the cart when redeeming points. Leave blank to disable.', 'eddpoints') . '</p>', 'type' => 'text', 'size' => 'medium'), array('id' => 'edd_points_max_discount', 'name' => __('Maximum Per-Product Points Discount:', 'eddpoints'), 'desc' => edd_currency_filter('') . '<p class="description">' . __('Set the maximum per-product discount allowed for the cart when redeeming points. Leave blank to disable.', 'eddpoints') . '</p>', 'type' => 'text', 'size' => 'medium'), array('id' => 'edd_points_label', 'name' => __('Points Label:', 'eddpoints'), 'desc' => '<p class="description">' . __('The label used to refer the points on the frontend, singular and plural.', 'eddpoints') . '</p>', 'type' => 'singularplural', 'size' => 'small'), array('id' => 'edd_points_product_messages', 'name' => '<strong>' . __('Product / Cart / Checkout Messages', 'eddpoints') . '</strong>', 'desc' => __('Configure Message Settings', 'eddpoints'), 'type' => 'header'), array('id' => 'edd_points_single_product_messages', 'name' => __('Single Product Page Message:', 'eddpoints'), 'desc' => '<p class="description">' . sprintf(__('Add an optional message to the single product page below the price. Customize the message using %s and %s.Limited HTML is allowed.Leave blank to disable.', 'eddpoints'), '{points}', '{points_label}') . '</p>', 'type' => 'textarea'), array('id' => 'edd_points_cart_messages', 'name' => __('Earn Points Cart / Checkout Page Message:', 'eddpoints'), 'desc' => '<p class="description">' . sprintf(__('Displayed on the cart and checkout page when points are earned. Customize the message using %s and %s.Limited HTML is allowed.', 'eddpoints'), '{points}', '{points_label}') . '</p>', 'type' => 'textarea'), array('id' => 'edd_points_reedem_cart_messages', 'name' => __('Reedem Points Cart / Checkout Page Message:', 'eddpoints'), 'desc' => '<p class="description">' . sprintf(__('Displayed on the cart and checkout page when points are available for redemption. Customize the message using %s, %s, and %s.Limited HTML is allowed.', 'eddpoints'), '{points}', '{points_value}', '{points_label}') . '</p>', 'type' => 'textarea'), array('id' => 'edd_points_earn_guest_messages', 'name' => __('Guest User Cart/Chekout Page Message:', 'eddpoints'), 'desc' => '<p class="description">' . sprintf(__('Displayed on the cart and checkout page for guest users to indicate to create an account for earn the points. Customize the message using %s, %s and %s. Limited HTML is allowed. Leave blank to disable.', 'eddpoints'), '{points}', '{points_label}', '{signup_points}') . '</p>', 'type' => 'textarea'), array('id' => 'edd_points_bought_guest_messages', 'name' => __('Guest User Cart/Chekout Page Buy Message:', 'eddpoints'), 'desc' => '<p class="description">' . sprintf(__('Displayed on the cart and checkout page for guest users to indicate to create an account to get points into their account. Customize the message using %s and %s. Limited HTML is allowed. Leave blank to disable.', 'eddpoints'), '{points}', '{points_label}') . '</p>', 'type' => 'textarea'), array('id' => 'edd_points_earned_action', 'name' => '<strong>' . __('Points Earned For Actions', 'eddpoints') . '</strong>', 'desc' => __('Configure Points Settings', 'eddpoints'), 'type' => 'header'), array('id' => 'edd_points_earned_account_signup', 'name' => __('Points earned for account signup:', 'eddpoints'), 'desc' => '<p class="description">' . __('Enter the amount of points earned when a customer signs up for a new account.', 'eddpoints') . '</p>', 'type' => 'text', 'size' => 'regular'), array('id' => 'edd_points_apply_points', 'name' => __('Apply Points to Previous Orders:', 'eddpoints'), 'desc' => '<p class="description">' . __('This will apply points to all previous orders and cannot be reversed.', 'eddpoints') . '</p>', 'type' => 'apply_points', 'size' => 'button', 'button' => __('Apply Points', 'eddpoints'))); return array_merge($settings, $edd_points_settings); }
/** * This function renders most of the columns in the list table. * * @access public * @since 1.4 * * @param array $payment Contains all the data of the payment * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($payment, $column_name) { switch ($column_name) { case 'amount': $amount = $payment->total; $amount = !empty($amount) ? $amount : 0; $value = edd_currency_filter(edd_format_amount($amount), edd_get_payment_currency_code($payment->ID)); break; case 'date': $date = strtotime($payment->date); $value = date_i18n(get_option('date_format'), $date); break; case 'status': $payment = get_post($payment->ID); $value = edd_get_payment_status($payment, true); break; case 'details': $value = '<a href="' . add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')) . '">' . __('View Order Details', 'easy-digital-downloads') . '</a>'; break; default: $value = isset($payment->{$column_name}) ? $payment->{$column_name} : ''; break; } return apply_filters('edd_payments_table_column', $value, $payment->ID, $column_name); }
/** * Parse email template tags * * @since 3.0 * @param string $message The email body * @param int $download_id The ID for a given download * @param int $commission_id The ID of this commission * @param int $commission_amount The amount of the commission * @param int $rate The commission rate of the user * @return string $message The email body */ function eddc_parse_template_tags($message, $download_id, $commission_id, $commission_amount, $rate) { $meta = get_post_meta($commission_id, '_edd_commission_info', true); $variation = get_post_meta($commission_id, '_edd_commission_download_variation', true); $download = get_the_title($download_id) . (!empty($variation) ? ' - ' . $variation : ''); $amount = html_entity_decode(edd_currency_filter(edd_format_amount($commission_amount))); $date = date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $commission_id))); $user = get_userdata($meta['user_id']); if (!empty($user->first_name)) { $name = $user->first_name; if (!empty($user->last_name)) { $fullname = $name . ' ' . $user->last_name; } else { $fullname = $name; } } else { $name = $user->display_name; $fullname = $name; } $message = str_replace('{download}', $download, $message); $message = str_replace('{amount}', $amount, $message); $message = str_replace('{date}', $date, $message); $message = str_replace('{rate}', $rate, $message); $message = str_replace('{name}', $name, $message); $message = str_replace('{fullname}', $fullname, $message); return $message; }