Support » Plugin: WooCommerce » Displaying Product Variation Description using a shortcode

  • Resolved elemtech

    (@elemtech)


    I’m trying to build a shortcode for Woocommerce that will contain the variation description for a selected product variation and update its contents on selecting another variation. This is necessary to be able to position the variation description freely on the page.

    According to this topic, the following two pieces of code can get the job done, but this is only a part of the solution.

    The first piece:
    <?php echo $value[‘variation_description’];?>

    The second one:

    function woocommerce_variable_add_to_cart() {
     global $product, $post;
     $variations = $product->get_available_variations();
     ?>
    			
     <?php 
     foreach ($variations as $key => $value) {
     ?>
     
    <div id="varianty">
     <h3><?php echo implode('/', $value['attributes']);?></h3>
     <img src = "<?php echo $value['image']['full_src'];?>" width='250'>
    	<br />
    	<?php echo $value['price_html'];?>

    How can I tie these two pieces together? Any help is appreciated.

    As far as I know, using “echo” is not the way for the result output, but

    $result = [...];
    return $result;

    is. Am I correct in assuming this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Displaying Product Variation Description using a shortcode’ is closed to new replies.