Support

Account

Forum Replies Created

  • 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.

  • @kipmyk Yes that’s correct. The fields show fine while the product is in stock but disappear when they are out of stock.


    @jarvis
    It displayed while in stock but not when it was out of stock.

    Thanks for your help on this, I really appreciate it.

  • 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.

Viewing 6 posts - 1 through 6 (of 6 total)