php Mostrarmaisinformaçõesnos电子邮件做WooCommerce

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Mostrarmaisinformaçõesnos电子邮件做WooCommerce相关的知识,希望对你有一定的参考价值。

<?php
/**
 * @author Luiz Paulo Bills <luizpbills@gmail.com>
 * @version 1.0.0
*/
add_filter( 'woocommerce_email_customer_details_fields', 'lpb_email_with_extra_fields', 10, 3 );
function lpb_email_with_extra_fields ( $fields, $sent_to_admin, $order ) {
	$order_id = $order->get_id();
	$extra_fields = array(
		'Celular' => 'billing_cellphone',
		'CPF' => 'billing_cpf',
		'RG' => 'billing_rg',
		'CNPJ' => 'billing_cnpj',
		'Razão Social' => 'billing_company',
		'Inscrição Estadual' => 'billing_ie',
		'Data de Nascimento' => 'billing_birthdate',
		'Sexo' => 'billing_sex',
	);

	$person_type = intval( get_post_meta( $order_id, '_billing_persontype', true ) );

	foreach( $extra_fields as $label => $id ) {
		if ( $person_type === 1 ) {
			if ( $id === 'billing_cnpj') continue;
			if ( $id === 'billing_company' ) continue;
			if ( $id === 'billing_ie' ) continue;
		} elseif ( $person_type === 2 ) {
			if ( $id === 'billing_cpf') continue;
			if ( $id === 'billing_rg') continue;
		}

		$value = get_post_meta( $order_id, '_' . $id, true );
		
		if ( ! empty( $value ) ) {
			$fields[] = array(
				'label' => $label,
				'value' => esc_html( $value )
			);
		}
	}
	
	return $fields;
}

以上是关于php Mostrarmaisinformaçõesnos电子邮件做WooCommerce的主要内容,如果未能解决你的问题,请参考以下文章

php编译安装

php-------2.php启动 .php文件

php学习有啥要求

php常用扩展安装

PHP基础加固2——语法

[PHP7.0-PHP7.2]的新特性和新变更