Add HTML in emails

Hello everybody,

Notifications emails from the plugins :
hivepress-requests - marketplace

/wp-content/plugins/hivepress-marketplace/includes/emails/class-order-dispute.php

Do not fully accepy html and spécial characters in subject.

Can can we make it so ?

This is the code of the file :

<?php
/**
 * Order dispute email.
 *
 * @package HivePress\Emails
 */

namespace HivePress\Emails;

use HivePress\Helpers as hp;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Order dispute email class.
 *
 * @class Order_Dispute
 */
class Order_Dispute extends Email {

	/**
	 * Class constructor.
	 *
	 * @param array $args Email arguments.
	 */
public function __construct( $args = [] ) {
    $args = hp\merge_arrays(
        [
            'subject' => esc_html__( 'MySmartisan - R&eacute;clamation ouverte', 'hivepress-marketplace' ), // Use actual character
            'body'    => hp\sanitize_html( __( 
                '<html>
                <head>
                </head>
                <body>
                <p>Bonjour,</p>
                <p>Une r&eacute;clamation a &eacute;t&eacute; ouverte sur la commande <strong>n&deg;%order_number%</strong>.</p>
                <p><strong>D&eacute;tails de la commande :</strong><br>
                <a href="%order_url%">Acc&eacute;der &agrave; la fiche de la commande</a></p>
                <p><strong>Motif d&eacute;clar&eacute; :</strong><br>%dispute_details%</p>
                <p>Merci de prendre connaissance de cette r&eacute;clamation et de proc&eacute;der &agrave; son traitement dans les plus brefs d&eacute;lais.</p>
                </body>
                </html>', 
                'hivepress-requests' 
            ) ),
        ],
        $args
    );
    parent::__construct( $args );
}
}

I’d like at least the

tags to work and i need accents in the subject.

Thanks in advance :slight_smile:

Hi,

Please note that you need to add code only using this documentation How to add custom code snippets - HivePress Help Center. If you edit the code directly, the update from our side will overwrite these changes and the ones that will be by default. As for emails, you need to overwrite them in HivePress > Emails using this documentation How to customize emails - HivePress Help Center. There, you can switch to the Code editor and add HTML.

I hope it helps

Hi Andrii,

Thank you for your reply but this is not helpfull at all.

The mail i am refering too do not exist in the
Hivepress->email template.

There is a template for “order reject”
but not for “order dispute”

It is hardcoded in that file :

/wp-content/plugins/hivepress-marketplace/includes/emails/class-order-dispute.php

This is the content of the original file :

<?php
/**
 * Order dispute email.
 *
 * @package HivePress\Emails
 */

namespace HivePress\Emails;

use HivePress\Helpers as hp;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
 * Order dispute email class.
 *
 * @class Order_Dispute
 */
class Order_Dispute extends Email {

	/**
	 * Class constructor.
	 *
	 * @param array $args Email arguments.
	 */
	public function __construct( $args = [] ) {
		$args = hp\merge_arrays(
			[
				'subject' => esc_html__( 'Order Disputed', 'hivepress-marketplace' ),
				'body'    => hp\sanitize_html( __( 'Order %order_number% %order_url% has been disputed with the following details: %dispute_details%', 'hivepress-marketplace' ) ),
			],
			$args
		);

		parent::__construct( $args );
	}
}

Hence my problem, that is why i tried to change the php file.

But if you can guide me on how to make that template available in the wordpress/hivepress admin i’d be delighted :slight_smile:

Thanks
lolo

Hi,

Thanks for the details. Admin emails are not available in HivePress/Emails for editing, but it’s still possible to override them using external code snippets without editing the email file directly, please try using this code snippet:

add_filter(
	'hivepress/v1/emails/order_dispute',
	function ( $email ) {
		$email['subject'] = 'custom text or HTML';
		$email['body']    = 'custom text or HTML';

		return $email;
	}
);

Hope this helps

Hi ihor,

Awesome thank you very much that is perfect ! :slight_smile:

And for :

\wp-content\plugins\hivepress-requests\includes\emails\class-offer-submit.php

Would it be :

add_filter(
	'hivepress/v1/emails/offer_submit',
	function ( $email ) {
		$email['subject'] = 'custom text or HTML';
		$email['body']    = 'custom text or HTML';

		return $email;
	}
);

?

Thank you :slight_smile:

lolo

No worries, I’m glad I could help. Yes, the same code snippet, but with the “offer_submit” email name should do the trick.

Thank you ! :slight_smile: