Send "E-Mail Payment Receipt to user" on second+ payments

Discussion in 'Customization & add-ons' started by gogoseo, Jan 10, 2013.

  1. gogoseo

    gogoseo Member

    Joined:
    Nov 17, 2012
    Messages:
    36
    I would like to send the "E-Mail Payment Receipt to user" email only on second and every following payment. But not after 1. payment because at this time i send the payment details in the "singup email".

    ...so maybe i could check if the user has some previous purchases...how could i code this?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You need to modify /amember/application/default/models/EmailTemplate.php :
    PHP:
        static function onPaymentWithAccessAfterInsert(Am_Event_PaymentWithAccessAfterInsert $event)
        {
            
    /**
             * This e-mail is sent for first payment in invoice only
             * another template must be used for the following payments
             */
            // if ($event->getInvoice()->getPaymentsCount() != 1) return;
            
    if ($event->getDi()->config->get('send_payment_mail') && $event->getInvoice()->getPaymentsCount()>1)

  3. gogoseo

    gogoseo Member

    Joined:
    Nov 17, 2012
    Messages:
    36
    Ok. I think this will work for every next payment for the same product/invoice. What if I have multiple products (all are just one time paments) and i want to send out the payment confirmation emails only on second+ product purchases?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    if you want to check all payments for user:
    PHP:
    if ($event->getDi()->config->get('send_payment_mail'
    && (
    $event->getDi()->db->selectCell('select count(*) from ?_invoice_payment where user_id=?'$event->getInvoice()->user_id)>1))

Share This Page