Using a invoice emailaddress

  • Posts: 52
  • Thank you received: 4
  • Hikashop Multisite
2 years 5 months ago #341910

-- HikaShop version -- : 4.5.1
-- Joomla version -- : 3.10.8
-- PHP version -- : 7.4.29
-- Browser(s) name and version -- : Edge

My customer has the following situation:
- An employee will order some products.
- The company of the customer can pay on account (pays after it).
- The invoice needs to be end to the invoice depertment of the company (other e-mailadress then the one of the user).

I have made a new address fiels called invoiceemailaddess.

Hoe can i set it up in a sich way that the invoice is send to the department and not to the e-mailadress of the user? I'm unsing PDF Invoice.
The notifications still needs to send also to the employee (also that he can few the order of cource).

How can i achive this. I can programm is nessesary.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #341912

Hi,

In the file plugins/hikashop/attachinvoice/attachinvoice.php you have this line:
$cc = $this->params->get('copy');
It takes the email address you can enter in the settings of the plugin to send a copy of the email with the invoice to it.
So change that line to:
$cc = $order->billing_address->invoiceemailaddess;
and it should use the email address entered in that custom address field.

Please Log in or Create an account to join the conversation.

  • Posts: 52
  • Thank you received: 4
  • Hikashop Multisite
2 years 5 months ago #341936

It is working. Although I changed the line to

        // check if there is an invoice-email of the customer
        $invoice_email =  $address->invoiceemailadres;

        if (!is_null($invoice_email)) {
            $mailer->addRecipient($invoice_email);
        }

        //We add an BCC in case of the parameters say so...
		$cc = $this->params->get('copy');
		if(!empty($cc)){
			$cc = explode(',', $cc);
			foreach($cc as $c) {
				if(!empty($c))
					$mailer->addBCC($c);
			}
		}
In this case it's added in the to list instead of cc-list.

In both cases it's not recorded in e-mail log. Shoud be nice for track records. IS that possible?

Last edit: 2 years 5 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #341937

Hi,

You can see that you added your code in the function onBeforeMailSend of the plugin. That function name is the event triggered by HikaShop whenever an email is sent.
And that same principle is used by the email history plugin which logs the emails.

So if you don't see the extra information you added in the email history what that means is that the email history plugin is probably triggered by the Joomla plugins system just before the PDF invoice plugin. The order of trigger of the plugins is based on their order you can configure in the plugins manager of Joomla. So I suppose just making sure that the order of the email history is greater than the order of the PDF invoice plugin in the Joomla plugins manager should make it log your modifications.

Last edit: 2 years 5 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 52
  • Thank you received: 4
  • Hikashop Multisite
2 years 5 months ago #341957

The suggestion you gave sound fair, but seems not be working.

I changed my code a little bit becuase I want to add it to de cc (instead to in the beginning),

The code is:

// check if there is an invoice-email of the customer
        $addressClass = hikashop_get('class.address');
        $address=$addressClass->get($data->data->old->order_billing_address_id);
        $invoice_email =  $address->invoiceemailadres;

        //We add an BCC in case of the parameters say so...
		$cc = $this->params->get('copy');
		if(!empty($cc)){
			$cc = explode(',', $cc);
			foreach($cc as $c) {
				if(!empty($c))
					$mailer->addBCC($c);
			}
		}

        if (!is_null($invoice_email)) {
            $mailer->addCC($invoice_email);
        }

This is working as i can see in mailtrap.io.


I I look in email-history I see:


As you ca see, the cc-address is missing.

The order of the plugin is as follow:


As last one the email history.

What did i wrong?

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #341961

Hi,

Can you confirm that you correctly set the "ordering" setting of both plugins ?
i.imgur.com/ypOWBld.png
Because the order on the listing is not necessarily correlated to the ordering of the plugins.

Please Log in or Create an account to join the conversation.

  • Posts: 52
  • Thank you received: 4
  • Hikashop Multisite
2 years 5 months ago #341975

Hi,

I don't see the Hiksshop action log. I only have Joomla Action log.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #341976

Hi,

No, I'm talking about the "ordering" option of the PDF invoice and the email history plugins. The action log plugin has nothing to do with this. I just openned the first plugin I saw on my plugins listing to make the screenshot of the "ordering" setting. Sorry if that was confusing.

Please Log in or Create an account to join the conversation.

Time to create page: 0.085 seconds
Powered by Kunena Forum