Created
December 28, 2019 07:35
-
-
Save imran-khan1/71ee6ac5fad8fd5fb63c60a93c9d5df2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
//Display custom fields on Woocommerce Product Details Page | |
add_action( 'woocommerce_single_product_summary', 'ci_woo_product_detail', 5 ); | |
function ci_woo_product_detail() { | |
global $product; | |
echo '<div>'; | |
echo '<span><strong> Text Field:</strong> ' . get_post_meta( $product->id, '_text_field', true ) . '</span>'; | |
echo '</div>'; | |
echo '<div>'; | |
echo '<span> <strong>Number Field:</strong> ' . get_post_meta( $product->id, '_number_field', true ) . '</span>'; | |
echo '</div>'; | |
echo '<div>'; | |
echo '<span> <strong>Text Area: </strong>' . get_post_meta( $product->id, '_textarea', true ) . '</span>'; | |
echo '</div>'; | |
echo '<div>'; | |
echo '<span> <strong>Select Field:</strong> ' . get_post_meta( $product->id, '_select', true ) . '</span>'; | |
echo '</div>'; | |
echo '<div>'; | |
echo '<span> <strong>Checkbox Field:</strong> ' . get_post_meta( $product->id, '_checkbox', true ) . '</span>'; | |
echo '</div>'; | |
echo '<div><span> <strong>Custom Field 1:</strong> </span>'; | |
echo get_post_meta( $product->id, '_custom_field_one', true ); | |
echo '</div>'; | |
echo '<div><span> <strong>Custom Field 2:</strong> </span>'; | |
echo get_post_meta( $product->id, '_custom_field_two', true ); | |
echo '</div>'; | |
echo '<div><span> <strong>Product Field:</strong> </span>'; | |
print_r(get_post_meta( $product->id, '_product_field_type_ids', true )); | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment