Post by emir28 » Sun Jun 02, 2024 2:40 pm

In Admin Panel;
When I click on the product on the order page, I want the product announcement page to open instead of the product editing page. How can I make the necessary arrangements? I'm a novice at coding.

I'm waiting for your help

Image


Image


Image

Newbie

Posts

Joined
Sun Jun 02, 2024 2:29 pm

Post by softmonke » Mon Jun 03, 2024 3:04 am

It's quite simple! Open up "order.php" in "admin/controller/sale" and look for the "info" function - it should look like the following:

Code: Select all

public function info() {
This function is where your order information gets retrieved from the database and formatted to be displayed on the frontend.

Under the "info" function, go look for "$data['products']" and you should see that it is simply an array of all the products in a specific order. You should also see that there is a for-loop that loops through all the products in the order and appends it into the "$data['products']" array. And in the for-loop, you should see something like the following:

Code: Select all

'href'     		   => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $product['product_id'], true)
That is the line that you should change. Currently, it is simply formatting a link that redirects to the product's settings page in admin. And what you want to do is to change the URL to redirect to the product's page on the frontend instead. However, since this is the admin portion of OpenCart, you can't use "$this->url->link" to format the URL, otherwise, it will generate an admin URL instead. What you can do, is use the HTTPS_CATALOG global constant to format the product page URL, like the following:

Code: Select all

HTTPS_CATALOG . "index.php?route=product/product&product_id=" . $product['product_id']
So all in all, you should change:

Code: Select all

'href'     		   => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $product['product_id'], true)
to:

Code: Select all

'href'     		   => HTTPS_CATALOG . "index.php?route=product/product&product_id=" . $product['product_id']
Hope this helps! :)

Check out our ever-growing list of extensions for OpenCart here.
Some useful extensions for a better admin experience: Image File Manager ProDrag & Drop Sort Order

Reach out to us at hello@softmonke.com for your OpenCart web development needs or feedback for our extensions.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am

Who is online

Users browsing this forum: No registered users and 23 guests