Billing Email

Discussion in 'Templates customization' started by thm43608, Oct 31, 2017.

  1. thm43608

    thm43608 aMember Pro Customer

    Joined:
    Jun 25, 2013
    Messages:
    4
    We often have members that need the invoice to be emailed to someone else. Is it possible to define a "Billing Email" field and have the invoice automatically emailed to that address in the event it is not empty?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    Hello,

    I am afraid there is not such feature by default.

    It is possible to implement custom solution to achieve it.

    You can add additional user field for billing email at
    aMember CP -> Configuration -> Add User Field

    add-user-field.png

    Then use the following code in site.php file to add this address as CC to email with payment receipt
    http://www.amember.com/docs/Site.php_file

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::MAIL_TEMPLATE_BEFORE_PARSE, function(Am_Event $e) {
       
        
    $t $e->getTemplate();
        
    $c $t->getConfig();
        if (
    $c['name'] == 'send_payment_mail' && $t['user']->billing_email) {
            
    $e->getMail()->addCc($t['user']->billing_email);
        }

    });
    You can billing email field to either signup or profile form in drag & drop forms editor at
    aMember CP -> Configurations -> Forms Editor

    Best Regards.
  3. thm43608

    thm43608 aMember Pro Customer

    Joined:
    Jun 25, 2013
    Messages:
    4
    I don't have my payment receipts setup through Configuration >> Setup/Configuration >> E-Mail. Does this code only work for that? Is it possible to add a checkbox to the E-mail Messages to CC the billing email address?
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    Yes, it works only for 'E-Mail Payment Receipt to User' in current implementation.
    Do you use Payment Emails from?
    aMember CP -> Protect Content -> E-Mails

    In this case you just need to replace name of template in my code above from 'send_payment_mail' to 'payment'.

    Best Regards.
    thm43608 likes this.
  5. thm43608

    thm43608 aMember Pro Customer

    Joined:
    Jun 25, 2013
    Messages:
    4
    That works perfectly, thank you!
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    It is great. You are welcome!

Share This Page