【发布时间】:2020-09-29 17:50:44
【问题描述】:
我添加了以下 sn-p 以显示一个自定义字段(如果产品有字段,则不显示分类字段)和预计交货时间。这是有效的。
<?php add_action( 'woocommerce_before_add_to_cart_form', 'geschatte_levertijd', 10 );
function geschatte_levertijd (){
if( get_field('plevertijd') ): ?>
<span class="product_melding_kleur"><i class="fa fa-truck"></i>Levertijd: <a href="/verzending-en-levertijd/" alt="Verzending en levertijd" ><?php the_field( 'plevertijd' ); ?></a></span>
<?php else: ?>
<? $terms = get_the_terms( $post->ID, 'product_cat' );
if ( !empty($terms)):
$term = array_pop($terms);
$text= get_field('levertijd', $term);
if (!empty($levertijd))?>
<span class="product_melding_kleur"><i class="fa fa-truck"></i>Levertijd: <a href="/verzending-en-levertijd/" alt="Verzending en levertijd" ><?php the_field( 'levertijd', $term ); ?></a></span>
<?php endif; ?>
<?php endif;
}
?>
但现在我正在尝试在订单通知邮件中显示该字段。在产品标题下方。 有人可以为我指出正确的方向吗?
【问题讨论】:
标签: php wordpress woocommerce advanced-custom-fields email-notifications