• Resolved jiswebsite

    (@jiswebsite)


    Hello, I’m trying to add the chosen variations as in the cart, but on the thank you page. I managed to activate the images via a small code, but I don’t know how to show the selected variations on the last page. Do you have an idea? Thanks to you

    Here is my code

    Hello, I'm trying to add the chosen variations as in the cart, but on the thank you page. I managed to activate the images via a small code, but I don't know how to show the selected variations on the last page. Do you have an idea? Thanks to you
    
    Here is my code
    
    add_filter( 'woocommerce_order_item_name', 'ts_product_image_on_order_pay', 'cart_variation_description', 10, 3 );
     
    function ts_product_image_on_order_pay( $name, $item, $extra ) {
     
    /* Return if not checkout page */
     
    if (! is_checkout() ) {
     
    return $name;
     
    }
     
    $product_id = $item->get_product_id();
     
    /* Get product object */
     
    $_product = wc_get_product( $product_id );
     
    /* Get product thumbnail */
     
    $thumbnail = $_product->get_image();
     
    /* Add wrapper to image and add some css */
     
    image = '<div class="ts-product-image" style="width: 52px; height: 45px; display: inline-block; padding-right: 7px; vertical-align: middle;">''.
     
    . $thumbnail .
     
    </div>';
     
    /* Prepend image to name and return it */
     
    return $image . $name ;
     
    }
    

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @jiswebsite ,

    That’s an interesting idea.

    I can see that you already have the product object so from there you can get variations and then loop through the available variations on that product object.

    Here is an example –

    //$product is my product object. Replace with your one.
    
    	$variations = $product->get_available_variations();
    
    	foreach ( $variations as $variation ) {
    
    		print_r(get_the_post_thumbnail( $variation['variation_id'] ));
    
    	}

    I have used get_the_post_thumbnail() to show the images. You can also get the URL of the thumbnails for $variation in the foreach loop –

    print_r($variation['image']['thumb_src']);

    I hope the information helps.

    Thank you ??

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @jiswebsite

    I hope this information was helpful! Since we haven’t heard back from you, and this thread has been inactive for a bit, I’m going to mark it as Resolved now for the overall health of the forums. Please feel free to open a new one if you have any further questions.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘thank you page variation’ is closed to new replies.