针对woocommerce电子邮件的不同电子邮件标题图像

时间:2017-01-25 19:39:29

标签: php wordpress email woocommerce

我正在尝试为发送给客户的每封电子邮件显示不同的标题图像,例如。处理订单。

我在email-header.php中尝试了一个if语句,并像这样调用了电子邮件模板

<?php if ('class-wc-email-customer-processing-order') :?>
    <img src="#">
<?php else: ?>
    <?php
         if ( $img = get_option( 'woocommerce_email_header_image' ) ) {
             echo '<p style="margin-top:0;"><img src="' . esc_url( $img ) . '" alt="' . get_bloginfo( 'name', 'display' ) . '" /></p>';
         }
    ?>

我还尝试为每封电子邮件制作一个单独的电子邮件标题,但我没有运气。我知道我必须亲近所以我希望有人能指出我正确的方向。

感谢。

1 个答案:

答案 0 :(得分:0)

我已成功完成此操作,方法是从email-header.php获取HTML并将其添加到模板中并更改图像路径,如下所示: 第1步:在您的孩子主题中创建一个名为woocommerce的文件夹,在其中创建另一个名为emails的文件夹。 第2步:从wp-content&gt;复制所有电子邮件插件&gt; woocommerce&gt;模板&gt;电子邮件 第3步:删除do_action('woocommerce_email_header',$ email_heading,$ email);但离开?&gt;在您的电子邮件模板中关闭php up top 第4步:然后从email-header.php添加HTML并添加图像的路径

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
		<title><?php echo get_bloginfo( 'name', 'display' ); ?></title>
	</head>
	<body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
		<div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>">
			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
				<tr>
					<td align="center" valign="top">
						<div id="template_header_image">
							<?php
								if ( $img = get_option( 'woocommerce_email_header_image' ) ) {
									echo '<p style="margin-top:0;"><img src="ADD IMAGE PATH HERE" /></p>';
								}
							?>
						</div>
						<table border="0" cellpadding="0" cellspacing="0" width="800" id="template_container">
							<tr>
								<td align="center" valign="top">
									<!-- Header -->
									<table border="0" cellpadding="0" cellspacing="0" width="800" id="template_header">
										<tr>
											<td id="header_wrapper">
												<h1><?php echo $email_heading; ?></h1>
											</td>
										</tr>
									</table>
									<!-- End Header -->
								</td>
							</tr>
							<tr>
								<td align="center" valign="top">
									<!-- Body -->
									<table border="0" cellpadding="0" cellspacing="0" width="800" id="template_body">
										<tr>
											<td valign="top" id="body_content">
												<!-- Content -->
												<table border="0" cellpadding="20" cellspacing="0" width="100%">
													<tr>
														<td valign="top">
															<div id="body_content_inner">

将图片添加到此处添加图像路径的位置。 步骤5:对每个不同的模板执行此操作,以在每个模板上都有自定义图像。

相关问题