/**
  * Prepare the NOD email content.
  * 
  * @param	arr		$nod			Required: The NOD offer data
  * @param	int		$discount_id	Required: The NOD offer discount ID
  *
  * @return	arr		Array of prepared email data
  */
 public function prepare_email($nod, $discount_id)
 {
     $payment_data = edd_get_payment_meta($nod['payment_id']);
     $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
     $from_name = apply_filters('nod_offer_from_name', $from_name, $nod['payment_id'], $payment_data);
     $from_email = edd_get_option('from_email', get_bloginfo('admin_email'));
     $from_email = apply_filters('nod_offer_from_address', $from_email, $nod['payment_id'], $payment_data);
     $to_email = edd_get_payment_user_email($nod['payment_id']);
     $subject = EDD_NOD()->settings->email_subject;
     $subject = apply_filters('nod_offer_subject', wp_strip_all_tags($subject), $nod['payment_id']);
     $subject = edd_do_email_tags($subject, $nod['payment_id']);
     $subject = edd_nod_do_email_tags($subject, $discount_id);
     $heading = EDD_NOD()->settings->email_heading;
     $heading = edd_do_email_tags($heading, $nod['payment_id']);
     $heading = edd_nod_do_email_tags($heading, $discount_id);
     $heading = apply_filters('nod_offer_heading', $heading, $nod['payment_id'], $payment_data);
     $attachments = apply_filters('nod_offer_attachments', array(), $nod['payment_id'], $payment_data);
     $message = edd_nod_do_email_tags(edd_nod_get_email_body_content($discount_id, $nod['payment_id'], $payment_data), $discount_id);
     $message = edd_do_email_tags($message, $nod['payment_id']);
     return array('from_name' => $from_name, 'from_email' => $from_email, 'to_email' => $to_email, 'subject' => $subject, 'heading' => $heading, 'attachments' => $attachments, 'message' => $message);
 }
Esempio n. 2
0
/**
 * Check if the users purchase qualifies for a NOD offer.
 *
 * @param	int			$purchase_count		Purchase count of customer.
 * @return	bool		true if this the customer is eligible, false if not.
 *
 * @since 0.0.4
 * @return
 */
function edd_nod_purchase_qualifies($purchase_count)
{
    // First offer
    if ($purchase_count < EDD_NOD()->settings->first) {
        return false;
    }
    if ($purchase_count == EDD_NOD()->settings->first) {
        return true;
    }
    // Second offer
    if (empty(EDD_NOD()->settings->repeat)) {
        return false;
    }
    if ($purchase_count == EDD_NOD()->settings->repeat) {
        return true;
    }
    // Repeat offers
    if ($purchase_count % EDD_NOD()->settings->repeat == 0 && edd_get_option('nod_continue', false)) {
        return true;
    }
    return false;
}
Esempio n. 3
0
/**
 * Add NOD email settings to the EDD emails settings tab
 *
 * @since	    0.0.1
 * @global		
 * @param       arr		$settings		Existing EDD Settings
 * @return      arr		$settings		Filtered EDD Settings
 */
function edd_nod_email_settings($settings)
{
    $nod_settings = array('next_order_discount' => array('nod_email_settings_header' => array('id' => 'nod_email_settings_header', 'name' => '<h3>' . __('NOD Offers', 'edd-next-order-discount') . '</h3>', 'type' => 'header'), 'nod_email_subject' => array('id' => 'nod_email_subject', 'name' => __('Offer Email Subject', 'edd-next-order-discount'), 'desc' => __('Enter the subject line for the NOD email.', 'edd-next-order-discount'), 'type' => 'text', 'size' => 'regular', 'std' => EDD_NOD()->settings->email_subject), 'nod_email_heading' => array('id' => 'nod_email_heading', 'name' => __('Offer Email Heading', 'edd-next-order-discount'), 'desc' => __('Enter the heading for the NOD email.', 'edd-next-order-discount'), 'type' => 'text', 'size' => 'regular', 'std' => EDD_NOD()->settings->email_heading), 'nod_offer_content' => array('id' => 'nod_offer_content', 'name' => __('Offer Content', 'edd-next-order-discount'), 'desc' => __('Enter the text that is sent as next order discount offer email. HTML is accepted. Available template tags:', 'easy-digital-downloads') . '<br/>' . edd_nod_get_email_tags_list(), 'type' => 'rich_editor', 'std' => edd_nod_get_default_offer_email()), 'nod_admin_emails' => array('id' => 'nod_admin_emails', 'name' => __('NOD Notification Emails', 'edd-next-order-discount'), 'desc' => __('Enter the email address(es) that should receive a notification anytime a NOD offer is made, one per line.', 'edd-next-order-discount'), 'type' => 'textarea', 'std' => EDD_NOD()->settings->admin_emails), 'nod_no_admin_emails' => array('id' => 'nod_no_admin_emails', 'name' => __('Disable Admin Notifications', 'edd-next-order-discount'), 'desc' => __('Check this box if you do not want NOD offers to be blind copied to admins. Will overide NOD Notification Emails.', 'edd-next-order-discount'), 'type' => 'checkbox', 'std' => EDD_NOD()->settings->disable_admin)));
    return array_merge($settings, $nod_settings);
}
Esempio n. 4
0
function EDD_NOD_Load()
{
    if (!class_exists('Easy_Digital_Downloads')) {
        if (!class_exists('EDD_Extension_Activation')) {
            require_once 'includes/class.extension-activation.php';
        }
        $activation = new EDD_Extension_Activation(plugin_dir_path(__FILE__), basename(__FILE__));
        $activation = $activation->run();
    } else {
        EDD_NOD();
    }
}
Esempio n. 5
0
 /**
  * Create the unique NOD discount code.
  *
  * This function generates a new discount code to be used when creating the discount.
  * 
  * @params
  *
  * @return	str		The newly generated code
  */
 public function generate_code()
 {
     // Generate a new code using the defined prefix and random numbers/letters.
     $code = EDD_NOD()->settings->prefix . substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), 0, 4);
     return apply_filters('nod_generate_code', $code, EDD_NOD()->settings->prefix);
 }