
Thanks to everyone for your input. I don’t think that the issue is being understood, so let me try to clarify. I have two categories: Ammo & Guns.
The first part of the code deals with fields related to Ammo, while the second part of the code is strictly for guns. The code below works well but it shows all the fields for both categories. So What I am looking to accomplish is as follows:
If category equals “Ammo” then
add_action( ‘woocommerce_single_product_summary’, ‘sbnai_display_acf_field_1’, 30 );
function sbnai_display_acf_field_1() {
echo ‘<b>Per Round Cost:</b> ‘ . get_field(‘per_round_cost’) . ‘<br />’;
echo ‘<b>UPC:</b> ‘ . get_field(‘upc’) . ‘<br />’;
echo ‘<b>Caliber:</b> ‘ . get_field(‘caliber’) . ‘<br />’;
echo ‘<b>Bullet Weight:</b> ‘ . get_field(‘bullet_weight’) . ‘<br />’;
echo ‘<b>Bullet Type:</b> ‘ . get_field(‘bullet_type’) . ‘<br />’;
echo ‘<b>Case Type:</b> ‘ . get_field(‘case_type’) . ‘<br />’;
echo ‘<b>Combined Reviews:</b> ‘ . get_field(‘combine_reviews’) . ‘<br />’;
}
Else if category equals “Guns” then
add_action( ‘woocommerce_single_product_summary’, ‘sbnai_display_acf_field_2’, 31 );
function sbnai_display_acf_field_2() {
echo ‘<b>Width:</b> ‘ . get_field(‘width’) . ‘<br />’;
echo ‘<b>Height:</b> ‘ . get_field(‘height’) . ‘<br />’;
echo ‘<b>Depth:</b> ‘ . get_field(‘depth’);
}
Hello,
Thank you for getting back to me. I’m not sure that I understand either of the two explanations or at least I would not know how to incorporate that into the code that I am using. Any clarifications?