Avatar of Alicia St Rose
Alicia St Rose
Flag for United States of America asked on

Trying to append content to Short Description in WooCommerce

Hello!

I'm trying to add some content to the short description in the single product view. I've created a div that contains Post Objects from an Advanced Custom Fields Post Object field.

I've got the code below, but instead of appending, it's actually replacing. I can see why, but I can't figure out how to bring back the summary in the code.

<?php add_filter('woocommerce_short_description','ts_add_text_short_descr');
function ts_add_text_short_descr($description){
	$post_objects = get_field( 'juices_included_in_the_cleanse' );
			if ( $post_objects ): ?>
				<div class="cleanse-juices">
					<ul>
			
			 
				<?php foreach ( $post_objects as $post ):  ?>
					<?php setup_postdata( $post ); ?>
					<li>
						<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
					</li>
				<?php endforeach; ?>
				<?php wp_reset_postdata(); ?>
			 </ul>
			<?php endif; ?>
		</div>
	</div>
  
<?php }
?>

Open in new window

* woo commercePHPWordPress

Avatar of undefined
Last Comment
Alicia St Rose

8/22/2022 - Mon
SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Alicia St Rose

ASKER
Hi This is working, however, I'm only seeing the name of the actual post listed three times no matter how many or what juices I add in the Post Object custom field. Not sure what going wrong..

The-Rainbow---Juice-Ranch-2.jpg
ASKER CERTIFIED SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Alicia St Rose

ASKER
Here's a snapshot of my ACF settings

Edit-Field-Group---Juice-Ranch---Wor.jpg
Alicia St Rose

ASKER
I just added your new code, correctly and it worked.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Chris Stanyon

OK. That all looks OK. Now on a particular product page, make sure you've selected some Posts that have the correct titles you want to display. Then test the new code I've posted. The code should work, but it looks like you've just selected additional products that have the same title, which is why you're seeing the same title several times.
Chris Stanyon

Ah. Brilliant :)

Glad it's working
Alicia St Rose

ASKER
Actually, they were all different, but were somehow pulling in the current product/post title instead of the post objects I'd selected.

Now, I've got to remove the list from the Variation Description. Looks like the description hook works on both...

The-Caveman---Juice-Ranch.jpg
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Alicia St Rose

ASKER
I may just do a display: none; on that one!
Chris Stanyon

Hey Alicia,

I think you have too. Just done a quick search and it looks like a bug in WooCommerce. The solutions provided seem to suggest hiding it with CSS. Not ideal, but it should work fine.
Alicia St Rose

ASKER
Ah, good to know!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes