installed plugin Easy Digital Downloads
version 3.1.0.3
This commit is contained in:
@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/**
|
||||
* Email Summary Blurb Class.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Emails
|
||||
* @copyright Copyright (c) 2022, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \EDD\Utils\EnvironmentChecker;
|
||||
|
||||
/**
|
||||
* EDD_Email_Summary_Blurb Class.
|
||||
*
|
||||
* Takes care of fetching the available blurbs and determines
|
||||
* which blurb meets the conditions and is next to be sent.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
class EDD_Email_Summary_Blurb {
|
||||
|
||||
/**
|
||||
* URL of the endpoint for the blurbs JSON.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const BLURBS_ENDPOINT_URL = 'https://plugin.easydigitaldownloads.com/wp-content/summaries.json';
|
||||
|
||||
/**
|
||||
* Environment Checker class.
|
||||
*
|
||||
* @var EnvironmentChecker
|
||||
*/
|
||||
protected $environment_checker;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Load plugin.php so that we can use is_plugin_active().
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
$this->environment_checker = new EnvironmentChecker();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all blurbs from remote endpoint.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_blurbs() {
|
||||
$blurbs = array();
|
||||
$request_body = false;
|
||||
|
||||
$request = wp_safe_remote_get( self::BLURBS_ENDPOINT_URL );
|
||||
|
||||
// @todo - Detect first response code, before redirect!
|
||||
if ( ! is_wp_error( $request ) && 200 === wp_remote_retrieve_response_code( $request ) ) {
|
||||
$request_body = wp_remote_retrieve_body( $request );
|
||||
$blurbs = json_decode( $request_body, true );
|
||||
}
|
||||
|
||||
if ( empty( $request_body ) ) {
|
||||
// HTTP Request for blurbs is empty, fallback to local .json file.
|
||||
$fallback_json = wp_json_file_decode( EDD_PLUGIN_DIR . 'includes/admin/promos/email-summary/blurbs.json', array( 'associative' => true ) );
|
||||
if ( ! empty( $fallback_json ) ) {
|
||||
$blurbs = $fallback_json;
|
||||
}
|
||||
}
|
||||
|
||||
return $blurbs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next blurb that can be sent.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_next() {
|
||||
$all_data = $this->fetch_blurbs();
|
||||
$blurbs = array();
|
||||
$blurbs_sent = get_option( 'email_summary_blurbs_sent', array() );
|
||||
$next_blurb = false;
|
||||
|
||||
if ( empty( $all_data['blurbs'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop through the fetched blurbs and filter out all that meet the conditions.
|
||||
foreach ( $all_data['blurbs'] as $key => $blurb ) {
|
||||
if ( $this->does_blurb_meet_conditions( $blurb ) ) {
|
||||
$blurbs[] = $blurb;
|
||||
}
|
||||
}
|
||||
|
||||
// Find first blurb that was not yet sent.
|
||||
foreach ( $blurbs as $blurb ) {
|
||||
$blurb_hash = $this->get_blurb_hash( $blurb );
|
||||
if ( is_array( $blurbs_sent ) && ! in_array( $blurb_hash, $blurbs_sent, true ) ) {
|
||||
$next_blurb = $blurb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If all of the available blurbs were already sent out, choose random blurb.
|
||||
if ( ! $next_blurb && ! empty( $blurbs ) ) {
|
||||
$next_blurb = $blurbs[ array_rand( $blurbs ) ];
|
||||
}
|
||||
|
||||
return $next_blurb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save blurb as sent to the options.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $blurb Blurb data.
|
||||
* @return void
|
||||
*/
|
||||
public function mark_blurb_sent( $blurb ) {
|
||||
$blurbs_sent = get_option( 'email_summary_blurbs_sent', array() );
|
||||
if ( ! empty( $blurb ) ) {
|
||||
$blurb_hash = $this->get_blurb_hash( $blurb );
|
||||
if ( ! in_array( $blurb_hash, $blurbs_sent, true ) ) {
|
||||
$blurbs_sent[] = $blurb_hash;
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'email_summary_blurbs_sent', $blurbs_sent );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hash blurb array
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $blurb Blurb data.
|
||||
* @return string MD5 hashed blurb.
|
||||
*/
|
||||
public function get_blurb_hash( $blurb ) {
|
||||
if ( empty( $blurb ) ) {
|
||||
return false;
|
||||
}
|
||||
// We want to sort the array, so that we can get reliable hash everytime even if array properties order changed.
|
||||
array_multisort( $blurb );
|
||||
return md5( wp_json_encode( $blurb ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if store pass matches the condition from the blurb.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param string $condition Pass details.
|
||||
* @return bool
|
||||
*/
|
||||
public function check_blurb_current_pass( $condition ) {
|
||||
return $this->environment_checker->meetsCondition( $condition );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if store has all requested plugins active.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $active_plugins An array of plugins that all need to be active.
|
||||
* @return bool
|
||||
*/
|
||||
public function check_blurb_active_plugins( $active_plugins ) {
|
||||
foreach ( $active_plugins as $plugin_name ) {
|
||||
if ( ! is_plugin_active( $plugin_name ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if store has certain plugins inactive.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $inactive_plugins An array of plugins that needs to be inactive.
|
||||
* @return bool
|
||||
*/
|
||||
public function check_blurb_inactive_plugins( $inactive_plugins ) {
|
||||
foreach ( $inactive_plugins as $plugin_name ) {
|
||||
if ( is_plugin_active( $plugin_name ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if store has specific products/downloads active.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $conditions An array of predefined conditions.
|
||||
* @return bool
|
||||
*/
|
||||
public function check_blurb_has_downloads( $conditions ) {
|
||||
foreach ( $conditions as $condition_name ) {
|
||||
// Check if store has any products that are free.
|
||||
if ( 'free' === $condition_name ) {
|
||||
$args = array(
|
||||
'post_type' => 'download',
|
||||
'posts_per_page' => 1,
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'edd_price',
|
||||
'value' => '0.00',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$downloads = new WP_Query( $args );
|
||||
if ( 0 === $downloads->post_count ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if blurb meets conditions.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $blurb Blurb data.
|
||||
* @return bool
|
||||
*/
|
||||
public function does_blurb_meet_conditions( $blurb ) {
|
||||
if ( isset( $blurb['conditions'] ) && ! empty( $blurb['conditions'] ) ) {
|
||||
foreach ( $blurb['conditions'] as $condition_name => $condition ) {
|
||||
if ( empty( $condition ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pass check.
|
||||
if ( 'current_pass' === $condition_name ) {
|
||||
if ( ! $this->check_blurb_current_pass( $condition ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Active plugins check.
|
||||
if ( 'active_plugins' === $condition_name ) {
|
||||
if ( ! $this->check_blurb_active_plugins( $condition ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Inactive plugins check.
|
||||
if ( 'inactive_plugins' === $condition_name ) {
|
||||
if ( ! $this->check_blurb_inactive_plugins( $condition ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for specific product/downloads.
|
||||
if ( 'has_downloads' === $condition_name ) {
|
||||
if ( ! $this->check_blurb_has_downloads( $condition ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Email Summary Cron Class.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Emails
|
||||
* @copyright Copyright (c) 2022, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Email_Summary_Cron Class.
|
||||
*
|
||||
* Takes care of scheduling and sending Email Summaries.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
class EDD_Email_Summary_Cron {
|
||||
|
||||
/**
|
||||
* Name of the Email Summary cron hook.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const CRON_EVENT_NAME = 'edd_email_summary_cron';
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Register daily check.
|
||||
add_action( 'edd_daily_scheduled_events', array( $this, 'schedule_cron_events' ) );
|
||||
|
||||
// User settings changed.
|
||||
add_action( 'updated_option', array( $this, 'settings_changed' ), 10, 3 );
|
||||
|
||||
// Prepare and run cron.
|
||||
add_action( self::CRON_EVENT_NAME, array( $this, 'run_cron' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current status of email summary.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return bool True if email summary is enabled, false if disabled.
|
||||
*/
|
||||
public function is_enabled() {
|
||||
return (bool) ! edd_get_option( 'disable_email_summary', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine when the next cron event
|
||||
* should be and schedule it.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function schedule_cron_events() {
|
||||
// Exit if email summary is disabled or event is already scheduled.
|
||||
if ( ! $this->is_enabled() || wp_next_scheduled( self::CRON_EVENT_NAME ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the event date based on user settings.
|
||||
$days = EDD()->utils->date()->getDays();
|
||||
$email_frequency = edd_get_option( 'email_summary_frequency', 'weekly' );
|
||||
$week_start_day = $days[ (int) get_option( 'start_of_week' ) ];
|
||||
|
||||
if ( 'monthly' === $email_frequency ) {
|
||||
$next_time_string = 'first day of next month 8am';
|
||||
} else {
|
||||
$next_time_string = "next {$week_start_day} 8am";
|
||||
}
|
||||
|
||||
$date = new \DateTime( $next_time_string, new DateTimeZone( edd_get_timezone_id() ) );
|
||||
wp_schedule_single_event( $date->getTimestamp(), self::CRON_EVENT_NAME );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all cron events related to email summary.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear_cron_events() {
|
||||
wp_clear_scheduled_hook( self::CRON_EVENT_NAME );
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect when settings that affect the
|
||||
* schedule of email summaries are updated.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param string $option_name WordPress option that was changed.
|
||||
* @param string $old_value Old option value.
|
||||
* @param string $new_value New option value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function settings_changed( $option_name, $old_value, $new_value ) {
|
||||
if ( ! in_array( $option_name, array( 'edd_settings', 'start_of_week', 'timezone_string', 'gmt_offset' ), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If `edd_settings` were changed, listen
|
||||
// only to changes in specific fields.
|
||||
if ( 'edd_settings' === $option_name ) {
|
||||
$change_detected = false;
|
||||
$field_listeners = array( 'email_summary_frequency', 'disable_email_summary' );
|
||||
foreach ( $field_listeners as $field ) {
|
||||
if ( ( empty( $old_value[ $field ] ) || empty( $new_value[ $field ] ) ) || ( $old_value[ $field ] !== $new_value[ $field ] ) ) {
|
||||
$change_detected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $change_detected ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reload EDD options so that we have the newest values in class methods.
|
||||
global $edd_options;
|
||||
$edd_options = get_option( 'edd_settings' );
|
||||
}
|
||||
|
||||
$this->clear_cron_events();
|
||||
$this->schedule_cron_events();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the cron with all the proper checks.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run_cron() {
|
||||
// This is not cron, abort!
|
||||
if ( ! wp_doing_cron() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$email = new EDD_Email_Summary();
|
||||
$email->send_email();
|
||||
|
||||
// Schedule the next event.
|
||||
$this->schedule_cron_events();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/**
|
||||
* Email Summary Class.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Emails
|
||||
* @copyright Copyright (c) 2022, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Email_Summary Class.
|
||||
*
|
||||
* Takes care of preparing the necessary dataset, building the
|
||||
* email template and sending the Email Summary.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
class EDD_Email_Summary {
|
||||
|
||||
/**
|
||||
* Are we in a test mode.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $test_mode;
|
||||
|
||||
/**
|
||||
* Email options.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $email_options;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function __construct( $test_mode = false ) {
|
||||
$this->test_mode = $test_mode;
|
||||
$this->email_options = array(
|
||||
'email_summary_frequency' => edd_get_option( 'email_summary_frequency', 'weekly' ),
|
||||
'email_summary_start_of_week' => jddayofweek( (int) get_option( 'start_of_week' ) - 1, 1 ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get site URL.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return string Host of the site url.
|
||||
*/
|
||||
public function get_site_url() {
|
||||
$site_url = get_site_url();
|
||||
$site_url_parsed = wp_parse_url( $site_url );
|
||||
$site_url = isset( $site_url_parsed['host'] ) ? $site_url_parsed['host'] : $site_url;
|
||||
|
||||
return $site_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return string Email subject.
|
||||
*/
|
||||
public function get_email_subject() {
|
||||
/* Translators: Site domain name */
|
||||
$email_subject = sprintf( __( 'Easy Digital Downloads Summary - %s', 'easy-digital-downloads' ), $this->get_site_url() );
|
||||
|
||||
if ( $this->test_mode ) {
|
||||
$email_subject = '[TEST] ' . $email_subject;
|
||||
}
|
||||
|
||||
return $email_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email recipients.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array Recipients to receive the email.
|
||||
*/
|
||||
public function get_email_recipients() {
|
||||
$recipients = array();
|
||||
|
||||
if ( 'admin' === edd_get_option( 'email_summary_recipient', 'admin' ) ) {
|
||||
$recipients[] = get_option( 'admin_email' );
|
||||
} else {
|
||||
$emails = edd_get_option( 'email_summary_custom_recipients', '' );
|
||||
$emails = array_map( 'trim', explode( "\n", $emails ) );
|
||||
foreach ( $emails as $email ) {
|
||||
if ( is_email( $email ) ) {
|
||||
$recipients[] = $email;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $recipients ) ) {
|
||||
edd_debug_log( __( 'Missing email recipients for Email Summary', 'easy-digital-downloads' ), true );
|
||||
}
|
||||
|
||||
return apply_filters( 'edd_email_summary_recipients', $recipients );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report start date.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return EDD\Utils\Date An array of start date and its relative counterpart as the EDD date object set at the UTC equivalent time.
|
||||
*/
|
||||
public function get_report_start_date() {
|
||||
$date = EDD()->utils->date( 'now', edd_get_timezone_id(), false );
|
||||
|
||||
if ( 'monthly' === $this->email_options['email_summary_frequency'] ) {
|
||||
$start_date = $date->copy()->subMonth( 1 )->startOfMonth();
|
||||
$relative_start_date = $date->copy()->subMonth( 2 )->startOfMonth();
|
||||
} else {
|
||||
$start_date = $date->copy()->subDay( 7 )->startOfDay();
|
||||
$relative_start_date = $date->copy()->subDay( 14 )->startOfDay();
|
||||
}
|
||||
|
||||
return array(
|
||||
'start_date' => $start_date,
|
||||
'relative_start_date' => $relative_start_date,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report end date.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return EDD\Utils\Date An array of end date and its relative counterpart as the EDD date object set at the UTC equivalent time.
|
||||
*/
|
||||
public function get_report_end_date() {
|
||||
$date = EDD()->utils->date( 'now', edd_get_timezone_id(), false );
|
||||
|
||||
if ( 'monthly' === $this->email_options['email_summary_frequency'] ) {
|
||||
$end_date = $date->copy()->subMonth( 1 )->endOfMonth();
|
||||
$relative_end_date = $date->copy()->subMonth( 2 )->endOfMonth();
|
||||
} else {
|
||||
$end_date = $date->copy()->endOfDay();
|
||||
$relative_end_date = $date->copy()->subDay( 7 )->endOfDay();
|
||||
}
|
||||
|
||||
return array(
|
||||
'end_date' => $end_date,
|
||||
'relative_end_date' => $relative_end_date,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report date range.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array Array of start and end date objects in \EDD\Utils\Date[] format.
|
||||
*/
|
||||
public function get_report_date_range() {
|
||||
// @todo - Check if we have to convert this to UTC because of DB?
|
||||
return array_merge(
|
||||
$this->get_report_start_date(),
|
||||
$this->get_report_end_date()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Retrieve ! TEST ! dataset for email content.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array Data and statistics for the period.
|
||||
*/
|
||||
public function get_test_report_dataset() {
|
||||
$stats = new EDD\Stats();
|
||||
$args = array(
|
||||
'post_type' => 'download',
|
||||
'posts_per_page' => 5,
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
);
|
||||
|
||||
$downloads = new WP_Query( $args );
|
||||
$top_selling_products = array();
|
||||
|
||||
foreach ( $downloads->posts as $post ) {
|
||||
$download = new EDD_Download( $post );
|
||||
|
||||
$product = new stdClass();
|
||||
$product->object = $download;
|
||||
$product->total = 100;
|
||||
|
||||
$top_selling_products[] = $product;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'earnings_gross' => array(
|
||||
'value' => 5000,
|
||||
'relative_data' => $stats->generate_relative_data( 5000, 4000 ),
|
||||
),
|
||||
'earnings_net' => array(
|
||||
'value' => 4500,
|
||||
'relative_data' => $stats->generate_relative_data( 4500, 3500 ),
|
||||
),
|
||||
'average_order_value' => array(
|
||||
'value' => 29,
|
||||
'relative_data' => $stats->generate_relative_data( 20, 35 ),
|
||||
),
|
||||
'new_customers' => array(
|
||||
'value' => 25,
|
||||
'relative_data' => $stats->generate_relative_data( 25, 20 ),
|
||||
),
|
||||
'top_selling_products' => $top_selling_products,
|
||||
'order_count' => array( 'value' => 172 ),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve dataset for email content.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array Data and statistics for the period.
|
||||
*/
|
||||
public function get_report_dataset() {
|
||||
if ( $this->test_mode ) {
|
||||
return $this->get_test_report_dataset();
|
||||
}
|
||||
|
||||
$date_range = $this->get_report_date_range();
|
||||
$start_date = $date_range['start_date']->format( 'Y-m-d H:i:s' );
|
||||
$end_date = $date_range['end_date']->format( 'Y-m-d H:i:s' );
|
||||
$relative_start_date = $date_range['relative_start_date']->format( 'Y-m-d H:i:s' );
|
||||
$relative_end_date = $date_range['relative_end_date']->format( 'Y-m-d H:i:s' );
|
||||
$stats = new EDD\Stats(
|
||||
array(
|
||||
'output' => 'array',
|
||||
'start' => $start_date,
|
||||
'end' => $end_date,
|
||||
'relative' => true,
|
||||
'relative_start' => $relative_start_date,
|
||||
'relative_end' => $relative_end_date,
|
||||
)
|
||||
);
|
||||
|
||||
$earnings_gross = $stats->get_order_earnings(
|
||||
array(
|
||||
'function' => 'SUM',
|
||||
'exclude_taxes' => false,
|
||||
'revenue_type' => 'gross',
|
||||
)
|
||||
);
|
||||
|
||||
$earnings_net = $stats->get_order_earnings(
|
||||
array(
|
||||
'function' => 'SUM',
|
||||
'exclude_taxes' => true,
|
||||
'revenue_type' => 'net',
|
||||
)
|
||||
);
|
||||
|
||||
$average_order_value = $stats->get_order_earnings(
|
||||
array(
|
||||
'function' => 'AVG',
|
||||
'exclude_taxes' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$new_customers = $stats->get_customer_count();
|
||||
|
||||
$top_selling_products = $stats->get_most_valuable_order_items(
|
||||
array(
|
||||
'number' => 5,
|
||||
)
|
||||
);
|
||||
|
||||
$order_count = $stats->get_order_count();
|
||||
|
||||
return compact(
|
||||
'earnings_gross',
|
||||
'earnings_net',
|
||||
'average_order_value',
|
||||
'new_customers',
|
||||
'top_selling_products',
|
||||
'order_count'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate HTML for relative markup.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array $relative_data Calculated relative data.
|
||||
*
|
||||
* @return string HTML for relative markup.
|
||||
*/
|
||||
private function build_relative_markup( $relative_data ) {
|
||||
$arrow = $relative_data['positive_change'] ? 'icon-arrow-up.png' : 'icon-arrow-down.png';
|
||||
$output = __( 'No data to compare', 'easy-digital-downloads' );
|
||||
if ( $relative_data['no_change'] ) {
|
||||
$output = __( 'No Change', 'easy-digital-downloads' );
|
||||
} elseif ( $relative_data['comparable'] ) {
|
||||
$output = $relative_data['formatted_percentage_change'] . '%';
|
||||
}
|
||||
ob_start();
|
||||
?>
|
||||
<?php if ( $relative_data['comparable'] ) : ?>
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/' . $arrow ); ?>" width="12" height="10" style="outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: 12px; height: 10px; max-width: 100%; clear: both; vertical-align: text-top;">
|
||||
<?php endif; ?>
|
||||
<span style="padding-left: 1px;">
|
||||
<?php echo esc_html( $output ); ?>
|
||||
</span>
|
||||
<?php
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build email template.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param array|bool $blurb Structured blurb data.
|
||||
*
|
||||
* @return string|bool The string of the email template or false if the email template couldn't be built.
|
||||
*/
|
||||
public function build_email_template( $blurb = false ) {
|
||||
$dataset = $this->get_report_dataset();
|
||||
// If there were no sales, do not build an email template.
|
||||
if ( empty( $dataset['order_count'] ) || 0 === $dataset['order_count'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$date_range = $this->get_report_date_range();
|
||||
$site_url = get_site_url();
|
||||
$view_more_url = edd_get_admin_url(
|
||||
array(
|
||||
'page' => 'edd-reports',
|
||||
'range' => ( 'monthly' === $this->email_options['email_summary_frequency'] ) ? 'last_month' : 'last_week',
|
||||
'relative_range' => 'previous_period',
|
||||
)
|
||||
);
|
||||
$wp_date_format = get_option( 'date_format' );
|
||||
$period_name = ( 'monthly' === $this->email_options['email_summary_frequency'] ) ? __( 'month', 'easy-digital-downloads' ) : __( 'week', 'easy-digital-downloads' );
|
||||
/* Translators: period name (e.g. week) */
|
||||
$relative_text = sprintf( __( 'vs previous %s', 'easy-digital-downloads' ), $period_name );
|
||||
|
||||
ob_start();
|
||||
include EDD_PLUGIN_DIR . 'includes/emails/email-summary/edd-email-summary-template.php';
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and send email.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return bool True if email was sent, false if there was an error.
|
||||
*/
|
||||
public function send_email() {
|
||||
// Get next blurb.
|
||||
$email_blurbs = new EDD_Email_Summary_Blurb();
|
||||
$next_blurb = false;
|
||||
|
||||
if ( ! $this->test_mode ) {
|
||||
$next_blurb = $email_blurbs->get_next();
|
||||
}
|
||||
|
||||
// Prepare email.
|
||||
$email_body = $this->build_email_template( $next_blurb );
|
||||
// If there is no email body, we cannot continue.
|
||||
if ( ! $email_body ) {
|
||||
edd_debug_log( __( 'Email body for Email Summary was empty.', 'easy-digital-downloads' ), true );
|
||||
return false;
|
||||
}
|
||||
|
||||
$email_subject = $this->get_email_subject();
|
||||
$email_recipients = $this->get_email_recipients();
|
||||
$email_headers = array( 'Content-Type: text/html; charset=UTF-8' );
|
||||
|
||||
// Everything is ok, send email.
|
||||
$email_sent = wp_mail( $email_recipients, $email_subject, $email_body, $email_headers );
|
||||
if ( $email_sent ) {
|
||||
$email_blurbs->mark_blurb_sent( $next_blurb );
|
||||
}
|
||||
|
||||
return $email_sent;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,418 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo esc_html( $this->get_email_subject() ); ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!--[if !mso]><!-->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<!--<![endif]-->
|
||||
|
||||
<style>
|
||||
@media only screen and (max-width: 480px) {
|
||||
body {
|
||||
max-width: 320px;
|
||||
}
|
||||
.push-down-25 {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.pull-down-8 {
|
||||
margin-top: 8px !important;
|
||||
}
|
||||
.pull-down-5 {
|
||||
margin-top: 5px !important;
|
||||
}
|
||||
h1 {
|
||||
font-size: 20px !important;
|
||||
line-height: 26px !important;
|
||||
}
|
||||
h2 {
|
||||
font-size: 16px !important;
|
||||
line-height: 22px !important;
|
||||
}
|
||||
p {
|
||||
font-size: 12px !important;
|
||||
line-height: 17px !important;
|
||||
}
|
||||
p.bigger {
|
||||
font-size: 12px !important;
|
||||
line-height: 16px !important;
|
||||
}
|
||||
.email-header-holder {
|
||||
max-height: 50px !important;
|
||||
height: 50px !important;
|
||||
}
|
||||
.logo-holder {
|
||||
padding: 10px 22px 5px 22px !important;
|
||||
}
|
||||
.logo-holder .edd-logo {
|
||||
max-width: 175px !important;
|
||||
max-height: 28px !important;
|
||||
}
|
||||
.content-holder {
|
||||
padding: 22px 22px 0px 22px !important;
|
||||
}
|
||||
.content-holder.pro-tip-section {
|
||||
padding: 0px 22px 27px 22px !important;
|
||||
}
|
||||
.period-date {
|
||||
font-size: 12px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
.link-style {
|
||||
font-size: 12px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
.link-style.bigger {
|
||||
font-size: 12px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
.stats-totals-wrapper {
|
||||
margin-top: 38px !important;
|
||||
}
|
||||
.stats-totals-wrapper td {
|
||||
font-size: 12px !important;
|
||||
border-collapse: collapse !important;
|
||||
}
|
||||
.stats-total-item {
|
||||
width: 145px;
|
||||
display: inline-table;
|
||||
min-width: 145px;
|
||||
}
|
||||
.stats-total-item-inner {
|
||||
font-size: 12px !important;
|
||||
border-collapse: collapse !important;
|
||||
}
|
||||
.stats-total-item-title {
|
||||
font-size: 16px !important;
|
||||
line-height: 19px !important;
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
.stats-total-item-value {
|
||||
line-height: 18px !important;
|
||||
font-size: 16px !important;
|
||||
margin: 0 0 11px 0px !important;
|
||||
}
|
||||
.stats-total-item-percent {
|
||||
line-height: 11px !important;
|
||||
font-size: 11px !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.stats-total-item-percent span.comparison {
|
||||
font-style: normal;
|
||||
font-weight: lighter;
|
||||
font-size: 11px !important;
|
||||
line-height: 15px !important;
|
||||
margin-top: 5px !important;
|
||||
}
|
||||
.stats-total-item-percent img {
|
||||
width: 8px !important;
|
||||
height: 6px !important;
|
||||
vertical-align: baseline !important;
|
||||
}
|
||||
.table-top-title {
|
||||
font-size: 12px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
table.top-products tr th {
|
||||
padding: 8px 0px !important;
|
||||
font-size: 12px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
table.top-products tr td {
|
||||
font-size: 12px !important;
|
||||
padding: 10px 0px !important;
|
||||
border-bottom: 1px solid #F0F1F4;
|
||||
}
|
||||
table.top-products tr td:nth-child(2) {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
.pro-tip-holder {
|
||||
background: #F3F8FE;
|
||||
border-radius: 8px !important;
|
||||
padding: 24px 24px !important;
|
||||
}
|
||||
.pro-tip-section-title {
|
||||
font-size: 14px !important;
|
||||
line-height: 15px !important;
|
||||
}
|
||||
.pro-tip-section-title img {
|
||||
margin-right: 3px !important;
|
||||
}
|
||||
.pro-tip-title {
|
||||
font-size: 14px !important;
|
||||
line-height: 18px !important;
|
||||
}
|
||||
.cta-btn {
|
||||
padding: 6px 15px;
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
background: #2794DA;
|
||||
display: inline-block;
|
||||
color: #FFFFFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body style="margin: 0px auto; max-width: 450px;">
|
||||
<!-- PREVIEW TEXT -->
|
||||
<div style="display: none; max-height: 0px; overflow: hidden;">
|
||||
<?php echo esc_html( __( 'Store performance summary', 'easy-digital-downloads' ) ); ?> <?php echo esc_html( $date_range['start_date']->format( $wp_date_format ) ); ?> - <?php echo esc_html( $date_range['end_date']->format( $wp_date_format ) ); ?>
|
||||
</div>
|
||||
|
||||
<!-- HEADER HOLDER -->
|
||||
<div class="email-header-holder" style="background: #343A40; max-height: 60px; height: 60px;">
|
||||
|
||||
<div class="email-container" style="max-width: 450px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; color: #1F2937;">
|
||||
|
||||
<div class="logo-holder" style="padding: 12px 31px 7px 31px; display: inline-block;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/edd-logo-white-2x.png' ); ?>" class="edd-logo" width="216" height="35" style="width: 100%; max-width: 100%; height: auto; max-width: 216px; max-height: 35px;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="email-container" style="max-width: 450px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; color: #1F2937;">
|
||||
|
||||
|
||||
<!-- MAIN EMAIL CONTENT HOLDER -->
|
||||
|
||||
<div class="content-box" style="background: #FFF;">
|
||||
|
||||
<div class="content-holder" style="padding: 22px 31px 0px 31px;">
|
||||
|
||||
<h1 style="margin: 0px; color: #1F2937;font-weight: 700;font-size: 24px;line-height: 24px;"><?php echo esc_html( __( 'Your eCommerce Summary', 'easy-digital-downloads' ) ); ?></h1>
|
||||
|
||||
<div class="period-date pull-down-8" style="margin-top: 8px; font-weight: 400; font-size: 14px; line-height: 18px; color: #4B5563;">
|
||||
<?php echo esc_html( $date_range['start_date']->format( $wp_date_format ) ); ?> - <?php echo esc_html( $date_range['end_date']->format( $wp_date_format ) ); ?>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $site_url ); ?>" class="link-style pull-down-8" style="margin-top: 8px; font-weight: 400; font-size: 14px; text-decoration-line: underline; display: inline-block; color: inherit; text-decoration: none;">
|
||||
<?php echo esc_url( $site_url ); ?>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="pull-down-20" style="margin-top: 20px;">
|
||||
<h2 style="margin: 0px; font-weight: 700; font-size: 18px; line-height: 23px; letter-spacing: -0.02em; color: #1F2937;"><?php echo esc_html( __( 'Hey there!', 'easy-digital-downloads' ) ); ?></h2>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="pull-down-5" style="margin: 0px; font-weight: 400; font-size: 14px; line-height: 18px; color: #4B5563; margin-top: 5px;">
|
||||
<?php
|
||||
/* Translators: period name (e.g. week) */
|
||||
echo esc_html( sprintf( __( 'Below is a look at how your store performed in the last %s.', 'easy-digital-downloads' ), $period_name ) );
|
||||
?>
|
||||
</p>
|
||||
|
||||
|
||||
<!-- DATA LISTING -->
|
||||
<table class="stats-totals-wrapper" style="border-collapse: collapse; border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 100%; margin-top: 48px;" width="100%" valign="top" align="left">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-totals-item-wrapper" style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" valign="top" align="center">
|
||||
<table class="stats-total-item" width="145" style="border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 145px; display: inline-table; min-width: 145px;" valign="top" align="center">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-total-item-inner" style="width: 100%; min-width: 100%; word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" width="100%" valign="top" align="center">
|
||||
<p class="stats-total-item-icon-wrapper" style="font-weight: 400; font-size: 14px; line-height: 18px; margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #809EB0; padding: 0; text-align: center; mso-line-height-rule: exactly; margin-bottom: 1px; height: 32px;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-gross.png' ); ?>" alt="#" title="#" width="28" height="28">
|
||||
</p>
|
||||
<p class="stats-total-item-title" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #1F2937; padding: 0; text-align: center; mso-line-height-rule: exactly; font-weight: 600; font-size: 14px; line-height: 18px; font-style: normal; margin-bottom: 5px; white-space: nowrap;">
|
||||
<?php echo esc_html( __( 'Gross Revenue', 'easy-digital-downloads' ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-value dark-white-color" style="margin: 0 0 6px 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: bold; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 32px; font-size: 32px;">
|
||||
<?php echo esc_html( edd_currency_filter( edd_format_amount( $dataset['earnings_gross']['value'] ) ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-percent" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #777777; font-weight: normal; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 14px; font-size: 10px; white-space: nowrap;">
|
||||
<?php echo $this->build_relative_markup( $dataset['earnings_gross']['relative_data'] ); ?>
|
||||
<span class="comparison" style="font-style: normal; font-weight: lighter; font-size: 12px; line-height: 14px; text-align: center; color: #6B7280; display: block; margin-top: 6px;">
|
||||
<?php echo esc_html( $relative_text ); ?>
|
||||
</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="stats-totals-item-wrapper" style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" valign="top" align="center">
|
||||
<table class="stats-total-item" width="145" style="border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 145px; display: inline-table; min-width: 145px;" valign="top" align="center">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-total-item-inner" style="width: 100%; min-width: 100%; word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" width="100%" valign="top" align="center">
|
||||
<p class="stats-total-item-icon-wrapper" style="font-weight: 400; font-size: 14px; line-height: 18px; margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #809EB0; padding: 0; text-align: center; mso-line-height-rule: exactly; margin-bottom: 1px; height: 32px;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-net.png' ); ?>" alt="#" title="#" width="28" height="28">
|
||||
</p>
|
||||
<p class="stats-total-item-title" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #1F2937; padding: 0; text-align: center; mso-line-height-rule: exactly; font-weight: 600; font-size: 14px; line-height: 18px; font-style: normal; margin-bottom: 5px; white-space: nowrap;">
|
||||
<?php echo esc_html( __( 'Net Revenue', 'easy-digital-downloads' ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-value dark-white-color" style="margin: 0 0 6px 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: bold; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 32px; font-size: 32px;">
|
||||
<?php echo esc_html( edd_currency_filter( edd_format_amount( $dataset['earnings_net']['value'] ) ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-percent" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #777777; font-weight: normal; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 14px; font-size: 10px; white-space: nowrap;">
|
||||
<?php echo $this->build_relative_markup( $dataset['earnings_net']['relative_data'] ); ?>
|
||||
<span class="comparison" style="font-style: normal; font-weight: lighter; font-size: 12px; line-height: 14px; text-align: center; color: #6B7280; display: block; margin-top: 6px;">
|
||||
<?php echo esc_html( $relative_text ); ?>
|
||||
</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="stats-totals-wrapper pull-down-40" style="border-collapse: collapse; border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 100%; margin-top: 48px; margin-bottom: 48px !important;" width="100%" valign="top" align="left">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-totals-item-wrapper" style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" valign="top" align="center">
|
||||
<table class="stats-total-item" width="145" style="border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 145px; display: inline-table; min-width: 145px;" valign="top" align="center">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-total-item-inner" style="width: 100%; min-width: 100%; word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" width="100%" valign="top" align="center">
|
||||
<p class="stats-total-item-icon-wrapper" style="font-weight: 400; font-size: 14px; line-height: 18px; margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #809EB0; padding: 0; text-align: center; mso-line-height-rule: exactly; margin-bottom: 1px; height: 32px;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-new-customers.png' ); ?>" alt="#" title="#" width="28" height="28">
|
||||
</p>
|
||||
<p class="stats-total-item-title" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #1F2937; padding: 0; text-align: center; mso-line-height-rule: exactly; font-weight: 600; font-size: 14px; line-height: 18px; font-style: normal; margin-bottom: 5px; white-space: nowrap;">
|
||||
<?php echo esc_html( __( 'New Customers', 'easy-digital-downloads' ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-value dark-white-color" style="margin: 0 0 6px 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: bold; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 32px; font-size: 32px;">
|
||||
<?php echo esc_html( $dataset['new_customers']['value'] ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-percent" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #777777; font-weight: normal; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 14px; font-size: 10px; white-space: nowrap;">
|
||||
<?php echo $this->build_relative_markup( $dataset['new_customers']['relative_data'] ); ?>
|
||||
<span class="comparison" style="font-style: normal; font-weight: lighter; font-size: 12px; line-height: 14px; text-align: center; color: #6B7280; display: block; margin-top: 6px;">
|
||||
<?php echo esc_html( $relative_text ); ?>
|
||||
</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="stats-totals-item-wrapper" style="word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" valign="top" align="center">
|
||||
<table class="stats-total-item" width="145" style="border-spacing: 0; padding: 0; vertical-align: top; text-align: left; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; width: 145px; display: inline-table; min-width: 145px;" valign="top" align="center">
|
||||
<tr style="padding: 0; vertical-align: top; text-align: left;" valign="top" align="left">
|
||||
<td class="stats-total-item-inner" style="width: 100%; min-width: 100%; word-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; padding: 0px; vertical-align: top; text-align: center; mso-table-lspace: 0pt; mso-table-rspace: 0pt; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: normal; margin: 0; mso-line-height-rule: exactly; line-height: 140%; font-size: 14px; border-collapse: collapse;" width="100%" valign="top" align="center">
|
||||
<p class="stats-total-item-icon-wrapper" style="font-weight: 400; font-size: 14px; line-height: 18px; margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #809EB0; padding: 0; text-align: center; mso-line-height-rule: exactly; margin-bottom: 1px; height: 32px;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-average.png' ); ?>" alt="#" title="#" width="28" height="28">
|
||||
</p>
|
||||
<p class="stats-total-item-title" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #1F2937; padding: 0; text-align: center; mso-line-height-rule: exactly; font-weight: 600; font-size: 14px; line-height: 18px; font-style: normal; margin-bottom: 5px; white-space: nowrap;">
|
||||
<?php echo esc_html( __( 'Average Order', 'easy-digital-downloads' ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-value dark-white-color" style="margin: 0 0 6px 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #444444; font-weight: bold; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 32px; font-size: 32px;">
|
||||
<?php echo esc_html( edd_currency_filter( edd_format_amount( $dataset['average_order_value']['value'] ) ) ); ?>
|
||||
</p>
|
||||
<p class="stats-total-item-percent" style="margin: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #777777; font-weight: normal; padding: 0; text-align: center; mso-line-height-rule: exactly; line-height: 14px; font-size: 10px; white-space: nowrap;">
|
||||
<?php echo $this->build_relative_markup( $dataset['average_order_value']['relative_data'] ); ?>
|
||||
<span class="comparison" style="font-style: normal; font-weight: lighter; font-size: 12px; line-height: 14px; text-align: center; color: #6B7280; display: block; margin-top: 6px;">
|
||||
<?php echo esc_html( $relative_text ); ?>
|
||||
</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<hr style="border: 0.2px solid #E5E7EB; display: block;">
|
||||
|
||||
|
||||
<!-- TABLE DATA -->
|
||||
<div class="table-data-holder pull-down-25 " style="margin-top: 25px; ">
|
||||
<div class="table-top-icon align-c" style="text-align: center;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-top-products.png' ); ?>" alt="#" title="#" width="28" height="28">
|
||||
</div>
|
||||
|
||||
<div class="table-top-title align-c" style="text-align: center; font-size: 14px; line-height: 18px; font-weight: 600; color: #1F2937; display: block; margin-top: 0px; margin-bottom: 12px;">
|
||||
<?php echo esc_html( __( 'Top 5 Products by Revenue', 'easy-digital-downloads' ) ); ?>
|
||||
</div>
|
||||
|
||||
<table class="top-products" style="border-collapse: collapse; width: 100%; font-size: 12px; line-height: 15px; color: #4B5563;" width="100%">
|
||||
<tr>
|
||||
<th style="font-weight: 600; border-bottom: 1px solid #E5E7EB; text-align: left; border-right: none; padding: 10px 0px; font-size: 12px; line-height: 15px;" align="left"><?php echo esc_html( __( 'Product', 'easy-digital-downloads' ) ); ?></th>
|
||||
<th style="font-weight: 600; border-bottom: 1px solid #E5E7EB; border-right: none; padding: 10px 0px; font-size: 12px; line-height: 15px; text-align: right;" align="right"><?php echo esc_html( __( 'Gross Revenue', 'easy-digital-downloads' ) ); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$counter = 1;
|
||||
foreach ( $dataset['top_selling_products'] as $product ) :
|
||||
if ( ! $product->object instanceof \EDD_Download ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $product->object->post_title;
|
||||
$revenue = edd_currency_filter( edd_format_amount( $product->total ) );
|
||||
?>
|
||||
<tr>
|
||||
<td style="font-size: 12px; color: #4B5563; font-weight: 400; text-align: left; padding: 9px 0px; border-bottom: 1px solid #F0F1F4;" align="left"><?php echo esc_html( $counter ); ?>. <?php echo esc_html( $title ); ?></td>
|
||||
<td style="font-size: 12px; color: #4B5563; font-weight: 400; padding: 9px 0px; border-bottom: 1px solid #F0F1F4; text-align: right;" align="right"><?php echo esc_html( $revenue ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$counter++;
|
||||
endforeach;
|
||||
?>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_attr( $view_more_url ); ?>" style="color: #2794DA; margin-top: 15px; margin-bottom: 15px; font-weight: 400; font-size: 14px; text-decoration-line: underline; display: inline-block; text-decoration: none;">
|
||||
<?php echo esc_html( __( 'View Full Report', 'easy-digital-downloads' ) ); ?>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.content-box -->
|
||||
|
||||
|
||||
</div>
|
||||
<!-- /.email-container -->
|
||||
|
||||
|
||||
<?php if ( ! empty( $blurb ) ) : ?>
|
||||
<!-- PRO-TIP SECTION -->
|
||||
<div class="email-container pro-tip-blurb" style="max-width: 450px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; color: #1F2937;">
|
||||
<div class="content-box pro-tip-section" style="background: #FFF;">
|
||||
|
||||
<div class="content-holder pro-tip-section" style="padding: 0px 31px 27px 31px;">
|
||||
|
||||
<div class="pro-tip-holder" style="background: #F3F8FE; border-radius: 10px; padding: 32px 40px;">
|
||||
|
||||
<div class="pro-tip-section-title" style="font-weight: 600; font-size: 18px; line-height: 23px; color: #2794DA;">
|
||||
<img src="<?php echo esc_url( EDD_PLUGIN_URL . '/assets/images/icons/icon-megaphone.png' ); ?>" alt="#" title="#" width="24" height="24" style="vertical-align: bottom; display: inline-block; margin-right: 4px;">
|
||||
<?php echo esc_html( __( 'Pro-tip from our expert', 'easy-digital-downloads' ) ); ?>
|
||||
</div>
|
||||
|
||||
<div class="pro-tip-title pull-down-12" style="margin-top: 12px; font-weight: 600; font-size: 20px; line-height: 26px; color: #1F2937;">
|
||||
<?php echo esc_html( $blurb['headline'] ); ?>
|
||||
</div>
|
||||
|
||||
<p class="bigger pull-down-8" style="margin: 0px; font-weight: 400; color: #4B5563; margin-top: 8px; font-size: 16px; line-height: 22px;">
|
||||
<?php echo esc_html( $blurb['content'] ); ?>
|
||||
</p>
|
||||
|
||||
<div class="pull-down-15" style="margin-top: 15px;">
|
||||
<a href="<?php echo esc_attr( $blurb['button_link'] ); ?>" class="cta-btn" style="padding: 6px 15px; font-weight: 600; font-size: 14px; line-height: 20px; background: #2794DA; display: inline-block; text-decoration: none; color: white;">
|
||||
<?php echo esc_html( $blurb['button_text'] ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.pro-tip-blurb -->
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user