Last active
April 23, 2021 18:19
-
-
Save luiseduardobraschi/6153f24a247e52d0dd8805ee8662bc4d to your computer and use it in GitHub Desktop.
Exibir dados do Extra Checkout Fields/Brazilian Market na página de pedido do Dokan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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