Skip to content

Instantly share code, notes, and snippets.

@CasperBraske
Last active Apr 23, 2021
Embed
What would you like to do?
Exibir dados do Extra Checkout Fields/Brazilian Market na página de pedido do Dokan
<?php
add_filter( 'woocommerce_order_formatted_shipping_address', function( $address, $order ){
if( $parent_order_id = $order->get_parent_id() ){
$order = wc_get_order( $parent_order_id );
}
$address['number'] = $order->get_meta( '_shipping_number' );
$address['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
return $address;
}, 10, 2 );
add_filter( 'woocommerce_order_formatted_billing_address', function( $address, $order ){
if( $parent_order_id = $order->get_parent_id() ){
$order = wc_get_order( $parent_order_id );
}
$address['number'] = $order->get_meta( '_billing_number' );
$address['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
return $address;
}, 10, 2 );
add_action( 'dokan_order_details_after_customer_info', function( $order ){
if( $parent_order_id = $order->get_parent_id() ){
$order = wc_get_order( $parent_order_id );
}
$cpf = $order->get_meta( '_billing_cpf' );
$cnpj = $order->get_meta( '_billing_cnpj' );
$birthdate = $order->get_meta( '_billing_birthdate' );
$sex = $order->get_meta( '_billing_sex' );
$cellphone = $order->get_meta( '_billing_cellphone' );
if( !empty( $cpf ) ):
?>
<li><span>CPF:</span> <?php echo esc_html( $cpf ); ?></li>
<?php
endif;
if( !empty( $cnpj ) ):
?>
<li><span>CNPJ:</span> <?php echo esc_html( $cnpj ); ?></li>
<?php
endif;
if( !empty( $birthdate ) ):
?>
<li><span>Aniversário:</span> <?php echo esc_html( $birthdate ); ?></li>
<?php
endif;
if( !empty( $sex ) ):
?>
<li><span>Sexo:</span> <?php echo esc_html( $sex ); ?></li>
<?php
endif;
if( !empty( $cellphone ) ):
?>
<li><span>Celular:</span> <?php echo esc_html( $cellphone ); ?></li>
<?php
endif;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment