Post by Nadalb » Mon Apr 22, 2024 10:34 am

Hello, I am trying to display "Product Option Image" in the customer's "Order Information" history.

I managed to display the Product Image in the customer's Order History by modifying the file
/catalog/view/theme/*/template/account/order_info.twig
I modified this line:
<td class="text-left">{{ product.name }}
By adding:
<td class="text-left">{{ product.name }}<img src="{{ product.image }}" class="img-thumbnail" />
It worked correctly. I then wanted to add "{{ option_value.image }}" in this way :
<small> - {{ option.name }}: {{ option.value }} {{ option_value.image }} </small> {% endfor %}</td>
so that the Product Option Image appears in case it exists but it doesn't work, could someone explain me what I am missing?

Thanks for helping me

New member

Posts

Joined
Tue Jan 04, 2022 2:12 am

Post by ADD Creative » Mon Apr 22, 2024 4:47 pm

It would be helpful to say which version of OpenCart you are using.

The images aren't stored with the orders. You would need to modify catalog/controller/account/order.php to use getProductOptions and then add the image to the option_data array.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Nadalb » Mon Apr 22, 2024 9:50 pm

ADD Creative wrote:
Mon Apr 22, 2024 4:47 pm
It would be helpful to say which version of OpenCart you are using.

The images aren't stored with the orders. You would need to modify catalog/controller/account/order.php to use getProductOptions and then add the image to the option_data array.

I'm sorry, i'm using 3.0.3.8

New member

Posts

Joined
Tue Jan 04, 2022 2:12 am

Post by robert2001b » Mon May 06, 2024 7:09 pm

Modify the controller file that corresponds to the order information page. This is usually located in /catalog/controller/account/. In the controller file, when fetching the order details, you’ll also need to fetch the option images for each product. Once you have the option images, you’ll need to add them to the array that’s being passed to the template file. In your template file, you can then check if the option image exists and display it accordingly.

Code: Select all

// After fetching the product options
foreach ($product_options as $product_option) {
    // Assuming you have a model method to get the option image
    $option_image = $this->model_catalog_product->getOptionImage($product_option['product_option_id']);
    if ($option_image) {
        $product_option['image'] = $this->model_tool_image->resize($option_image, 100, 100);
    } else {
        $product_option['image'] = ''; // No image available
    }
    // Add the option with the image to the array
    $order_info['products'][$product_id]['options'][] = $product_option;
}

Newbie

Posts

Joined
Mon May 06, 2024 6:40 pm
Who is online

Users browsing this forum: No registered users and 7 guests