Remove vendor address from email

  • Posts: 171
  • Thank you received: 9
7 years 11 months ago #242296

-- HikaMarket version -- : 2.3.5

Hi,

I've a really specialized problem and I would be really glad for a small help code snippet Jerome. In email (market.order_status_notification) I'm able to add a custom email address like below:

if($data->order->order_status == 'shipped'){
	 $this->mailer->addBCC('email@address.com');
}

But I have to solve somehow to send status notification email in shipped status just to that specified custom email address. Neither for vendor, nor for customer, just to This email address is being protected from spambots. You need JavaScript enabled to view it.. Can I solve it somehow?

Thanks for your help in advance!

Regards,
PePe

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

  • Posts: 26032
  • Thank you received: 4006
  • MODERATOR
7 years 11 months ago #242298

Hi,

The vendor order notification in HikaMarket is send to the vendor email (and his notified users).
Even if you can access to the mailer in the "preload" part of the email, the "dest email" is set after that in another function.
Which mean that you cannot replace the destination email unless you're doing the job just before the HikaShop job.

So if you want to override that, you'll need to use a plugin to catch (and modify) the email before it is sent by HikaShop.
www.hikashop.com/support/documentation/6...tml#onBeforeMailSend

Regards,

PS : Please note that HikaMarket 2.3.5 does not exists.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
7 years 11 months ago #242389

Thanks for the advice Jerome.

I've created a hikashop plugin, installed and activated it with the following content, but with no luck:

function onBeforeMailSend(&$mail,&$mailer){		
	$app =JFactory::getApplication();
	$orderid = $app->getUserState('com_hikashop.order_id');
	$orderClass = hikashop_get('class.order');
	$order = $orderClass->loadFullOrder($orderid);		
	
	if($order->order_status == 'shipped'){		
		unset($mail->dst_email);
	}
}

Any ideas what am I failed on?

Last edit: 7 years 11 months ago by pepecortez.

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

  • Posts: 26032
  • Thank you received: 4006
  • MODERATOR
7 years 11 months ago #242394

Hi,

Please note that the "$mail" object contains a lot of useful information ; like the mail name which is currently send and also his data (like the "order" when it's an order notification).
And your goal is to replace the destination email with another element.
If you want to refuse the expedition of an email the best would be to use the trigger "onBeforeMailPrepare" which have a "$do" parameter to cancel the mail.

You can see an example of mail handling in HikaMarket ; in the class "mail" you will see the function "beforeMailPrepare" which call different sub functions depending the mail name ; like "processContactMail" to change the destination email to the vendor while the contact request is regarding a vendor product.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
7 years 11 months ago #242542

Hi Jerome!

Thanks, it seems the problem was that the order status was not loaded correctly. Also I added a BCC address to the dst_email, I modified to code this way, and it seems working ok:

function onBeforeMailPrepare(&$mail,&$mailer,&$do){
	if($mail->data->order->order_status == 'shipped'){	
		$mail->dst_email = 'email@address.com';
	}
}
Thanks for your help again!

Last edit: 7 years 11 months ago by pepecortez.

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

  • Posts: 26032
  • Thank you received: 4006
  • MODERATOR
7 years 11 months ago #242554

Hi,

Please do not use that code in your website ; You can potentially affect every emails which have an "order" data ; not only the HikaMarket email but also the HikaShop one.
You will find the right tips in my previous message and information where you can see some code to base your code on.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
7 years 11 months ago #242693

Oooh... jeeez... you're right.

I was playing all day to somehow fix that problem, this looks ok now, as any other ideas I had was not working:

function onBeforeMailPrepare(&$mail,&$mailer,&$do){
	if((($mail->data->order->order_status == 'shipped') || ($mail->data->order->order_status == 'confirmed'))){	
			$vendorClass = hikamarket::get('class.vendor');
			$vendor = $vendorClass->get($mail->data->order->koltseghely);
			//koltseghely field was an already created field for vendor_id
			if ($vendor->vendor_email == $mail->dst_email){
				$mail->dst_email = 'address@email.com';
				}
	}
}

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

  • Posts: 26032
  • Thank you received: 4006
  • MODERATOR
7 years 11 months ago #242696

Hi,

I have the impression that my tips are not read.

Please note that the "$mail" object contains a lot of useful information ; like the mail name which is currently send

And I also told you to read the HikaMarket code in order to have a working base.

It will be the only submission of code in that thread ; please understand that custom development are not part of the support we are providing with our components.
public function onBeforeMailPrepare(&$mail, &$mailer, &$do) {
	$mail_name = $mail->mail_name;
	if(isset($mail->hikamarket) && !empty($mail->hikamarket))
		$mail_name = 'market.' . $mail_name;

	if($mail_name != 'market.order_status_notification' || empty($mail->data->order_vendor_id))
		return;

	$mail->dst_email = 'address@email.com';
	$mail->dst_name = 'destination name";
}

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: pepecortez

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

  • Posts: 171
  • Thank you received: 9
7 years 11 months ago #242743

Jerome, understood, I really appreciate your patience and help!
I've tried a lot ways you referenced in your earlier posts, but with no luck, so I had to try something that worked with my noob PHP skills.

Thank you again!

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

Moderators: Obsidev
Time to create page: 0.067 seconds
Powered by Kunena Forum