No that didn’t work either. I’ll just use the CSS option for now. Like I said, PHP is new to me so it could be that I have implemented the code wrong. My entire code is:
// ACF SPECIFICATION FIELDS
add_action('woocommerce_short_description', 'speaker_specification_fields', 4 );
function speaker_specification_fields() { ?>
<ul>
<li><?php
$field = get_field_object('field_6155c03d20d5c');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<li><?php
$field = get_field_object('field_61715110d855c');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<li><?php
$field = get_field_object('field_6155bf1660b3c');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<li><?php
$field = get_field_object('field_60d47fd0711ca');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<li><?php
$field = get_field_object('field_60d47ffb711cb');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<li><?php
$field = get_field_object('field_6155bed832b78');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
</ul>
<?php
if( is_product_category() ):
return $description;
else:
return $description.$text;
endif; ?>
<?php } ?>
Hi @jarvis thanks for this. Unfortunately it didn’t seem to work. However, (and this probably isn’t the best solution) I was able to hide it on the product overview page using this css:
/*-- HIDE HEADER PRODUCT OVERVIEW --*/
header.woocommerce-products-header {
display: none;
}
So for now it is hidden and appears correctly on the product page when in and out of stock.
Thanks.
@jarvis Worked perfectly! Thank you 🙂 However, it also displays the fields on the product overview page now also.
Thank you, I really appreciate it. An issue I have come across is that if the product is marked as out of stock, it hides all the fields. Any idea how I can prevent this from happening?
Thanks
Hi @kipmyk I was able to get the values to display with that command so thank you! it’s not pretty and I am sure there are better ways to do it but it works:
add_action('woocommerce_before_add_to_cart_form', 'speaker_specification_fields', 4 );
function speaker_specification_fields() { ?>
<?php
$field = get_field_object('field_6155c03d20d5c');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?>
<?php
$field = get_field_object('field_61712d2256ff2');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?>
<?php
$field = get_field_object('field_6155bf1660b3c');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?>
<?php
$field = get_field_object('field_60d47fd0711ca');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?>
<?php
$field = get_field_object('field_60d47ffb711cb');
?>
<?php echo $field['label']; ?>: <?php echo $field['value']; ?>
<?php
$field = get_field_object('field_6155bed832b78');
?>
<?php echo $field['label']; ?>: <?php echo $field['value'];
}
?>
I just call on every field individually.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.