• Resolved deeeesign

    (@designnewdaymediacom)


    I would like to display the image of the product a customer is purchasing on the checkout page. I found some code online to do this, however, it does not display the variation of the product that the person has selected, just the main product image. I’m using WooCommerce for a client that builds custom travel trailers, so I would like to display the image of the customized trailer on the checkout page (the customizations are set using variations). Is there a function that would accomplish this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Stef

    (@serafinnyc)

    By default WC displays the variation image. Do you not have images on the actual variation? If not then the featured image will display only. Maybe there’s a problem with your theme too.

    Thread Starter deeeesign

    (@designnewdaymediacom)

    Yes, I have images for every variation. The variation image does indeed display on both the PRODUCT page once it has been selected, and also on the CART page, but it does not show up on the CHECKOUT page, where they fill in their billing information. By default, the product image doesn’t display on the Checkout page, but I would like for it to load at the top and be the variation the customer selected.

    I found a function that pulls in the image for the product in someone’s cart onto the CHECKOUT page, and I added it to my Child Theme’s Functions.php, but that code only pulls in the featured image.

    Here’s what that code looks like:
    /*
    * Showing Product Image on Checkout Page — By Darshan Gada
    */
    add_action(‘woocommerce_before_checkout_form’, ‘displays_cart_products_feature_image’);
    function displays_cart_products_feature_image() {
    foreach ( WC()->cart->get_cart() as $cart_item ) {
    $item = $cart_item[‘data’];
    //print_r($item);
    if(!empty($item)){
    $product = new WC_product($item->id);
    // $image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->ID ), ‘single-post-thumbnail’ );
    echo $product->get_image();
    echo $product->name;
    echo $product->price;
    // to display only the first product image uncomment the line bellow
    // break;
    }
    }
    }

    What I need is for it to pull in the variation image of the product the customer selected.

    I’m using the latest version of the DIVI Theme, if that’s relevant.

    Hi @designnewdaymediacom,

    I found some code online to do this, however, it does not display the variation of the product that the person has selected, just the main product image.

    What I need is for it to pull in the variation image of the product the customer selected. I’m using the latest version of the DIVI Theme, if that’s relevant.

    DIVI does have a lot of theme overrides, in particular to the Product, the Cart, and Checkout pages. It is very possible the theme is overriding your function to not work correctly. Take the function to your theme provider and see if they can fine tune it in the template override for the Cart/Checkout pages, as there is most likely a template override happening here (which is why it is not showing correctly).

    I will go ahead and mark this as Resolved, but if you continue to have issues please come back and open a new thread to let us know!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Variable Product Image on Checkout Page’ is closed to new replies.