没有收到用于自定义字段woocommerce的电子邮件 [英] not getting email for custom field woocommerce

查看:87
本文介绍了没有收到用于自定义字段woocommerce的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 woocommerce (免费插件)..我正试图在计费字段中添加一个自定义字段。.

I am using woocommerce (free plugin).. I am trying to add one custom field to the billing fields..

在这里:

// ADDED HOW YOU GOT TO KNOW ABOUT OUR SERVICE FIELD
add_filter( 'woocommerce_checkout_fields' , 'About_Our_Service' );

// Our hooked in function - $fields is passed via the filter!
function About_Our_Service( $fields ) {
     $fields['billing']['billing_meat'] = array(
    'label'       => __('How you Got to Know About Our Service?', 'woocommerce'),
    'placeholder' => _x('', 'placeholder', 'woocommerce'),
    'required'    => false,
    'clear'       => false,
    'type'        => 'select',
    'options'     => array(        
        'google-ads' => __('Google', 'woocommerce' ),
        'google-search' => __('Yahoo', 'woocommerce' ),
        'warrior-forum' => __('Bing', 'woocommerce' ),
        'facebook' => __('Facebook', 'woocommerce' ),
        'other' => __('Other', 'woocommerce' ),
        )
    );

     return $fields;
}

问题是:我在自定义邮件中没有得到值字段,该字段已添加到计费字段中。任何已经使用 woocommerce 的人都可以在此方面帮助我... ...

The problem is: I am not getting the value in my mail for the custom field which was added to the billing fields.. Anyone who already used woocommerce can help me on this... ?

我已经创建了一些自定义字段,这些字段已添加到结帐中(但这些字段未随核心字段一起添加),对于这些字段,我可以在邮件中获取值。

I already created some more custom fields which was added to the checkout (BUT these're not added along with the core fields), for these fields i'm able to get values in my mail..

通过,我检查了线程:但没有太多与邮件相关的信息。

By the ay, i checked this thread: but didn't much info related to mail..

请有人对此进行调查。

推荐答案

对于将来的读者,自定义计费/发货字段将另存为订单过账的过账元。因此,通常,您可以使用典型的WordPress get_post_meta()函数来检索它们。

For future readers, custom billing/shipping fields are saved as post meta for the order post. So in general, you can retrieve them with the typical WordPress get_post_meta() function.

但是在WooCommerce 2.2中,您不需要,因为您可以将字段名称直接传递给WC将在电子邮件中显示为列表的字段数组:

But in WooCommerce 2.2, you don't need to as you can pass the field name directly to an array of fields that WC will show as a list in the email:

// pre-WooCommerce 2.3
function kia_email_order_meta_keys( $keys ) {
    $keys['Some field'] = '_some_field';
    return $keys;
}
add_filter('woocommerce_email_order_meta_keys', 'kia_email_order_meta_keys');

此方法已在2.3版中弃用,可能是翻译效果更好。从2.3版本开始,您将需要针对其他过滤器并发送略有不同的数据。

This method has been deprecated in version 2.3, probably so translation can be better. As of 2.3 you will need to target a different filter and send slightly different data.

// WooCommerce 2.3+
function kia_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
    $fields['some_field'] = array(
                'label' => __( 'Some field', 'my-plugin-textdomain' ),
                'value' => get_post_meta( $order->id, '_some_field', true );
            );
    return $fields;
}
add_filter('woocommerce_email_order_meta_fields', 'kia_email_order_meta_keys', 10, 3 );

我在自定义WooCommerce结帐字段

这篇关于没有收到用于自定义字段woocommerce的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆