Automatically Send Emails With Export of Totals

Hello

I want to know if there is a way to automatically send an email with the current totals for the day.

I know it is possible to manually create an csv file of the totals to your specification.

Can this be done automatically so that a csv file are sent out with some specified parameters?

I know this would take some coding and that is not a problem. I do have experience with php coding and there is already a lot of custom code on the site so adding more would not be difficult. I just do not know if this is possible so I would like some guidance.


Comments

3 responses to “Automatically Send Emails With Export of Totals”

  1. That’s great, good luck with your implementation!
    Btw, if you decide to share it publicly on GitHub for instance, please let me know!

    Cheers

  2. Thank you this is perfect and exactly what I was looking for. You have been a big help.

  3. Hi Felix,

    The main function for generating a report for totals is Affiliates_Totals::get_mass_payment_file( $service, $params, get_option( 'blog_charset' ) );

    $service string parameter can be either paypal or export.
    $params is an array that must contain at least a ‘tables’ entry. Other options can be ‘from_date’, ‘thru_date’, ‘minimum_total’, ‘affiliate_status’, ‘referral_status’, ‘currency_id’, ‘affiliate_id’, ‘affiliate_name’, ‘affiliate_user_login’, ‘orderby’, ‘order’

    For example

    global $wpdb, $affiliates_db;
    $service = 'export';
    $params = array();
    $params['tables'] = array(
    'affiliates' => $affiliates_db->get_tablename( 'affiliates' ),
    'affiliates_users' => $affiliates_db->get_tablename( 'affiliates_users' ),
    'referrals' => $affiliates_db->get_tablename( 'referrals' ),
    'users' => $wpdb->users
    );
    ob_start();
    Affiliates_Totals::get_mass_payment_file( $service, $params, get_option( 'blog_charset' ) );
    $report = ob_get_contents();
    ob_end_clean();
    wp_mail(...);

    the above will export a totals file and $report has the file contents to string which can be used with wp_mail().

    Hope it helps.

    Kind regards,
    George

Share