Page 1 of 1

products links (orders.php)

Posted: Thu Aug 25, 2022 11:54 am
by Omar_one
Hello,
is there any way that orders products in orders page (admin) can be as link, I mean that orders products linked to product_info page or to product preview page (admin)

thank you in advance for your help
Omar

Re: products links (orders.php)

Posted: Thu Aug 25, 2022 12:04 pm
by ecartz
It would be a core edit, but change https://github.com/CE-PhoenixCart/Phoen ... s/edit.php to add the link.

Re: products links (orders.php)

Posted: Thu Aug 25, 2022 12:08 pm
by Omar_one
ecartz wrote: Thu Aug 25, 2022 12:04 pm It would be a core edit, but change https://github.com/CE-PhoenixCart/Phoen ... s/edit.php to add the link.
I meant without editing the core :( ..

Re: products links (orders.php)

Posted: Tue Sep 13, 2022 9:18 am
by Omar_one
I got working by change the line 95
ecartz wrote: Thu Aug 25, 2022 12:04 pm It would be a core edit, but change https://github.com/CE-PhoenixCart/Phoen ... s/edit.php to add the link.

Re: products links (orders.php)

Posted: Tue Sep 13, 2022 11:20 am
by raiwa
Enhance Orders has this and more without core changes
https://phoenixcart.org/forum/app.php/ ... nce_orders

Re: products links (orders.php)

Posted: Tue Sep 13, 2022 12:49 pm
by Omar_one
raiwa wrote: Tue Sep 13, 2022 11:20 am Enhance Orders has this and more without core changes
https://phoenixcart.org/forum/app.php/ ... nce_orders
Thank you @raiwa for your suggestions, but your module didn't say anything about the products link on the orders(admin)

Re: products links (orders.php)

Posted: Tue Sep 13, 2022 1:40 pm
by raiwa
Omar_one wrote: Tue Sep 13, 2022 12:49 pm Thank you @raiwa for your suggestions, but your module didn't say anything about the products link on the orders(admin)
Sorry, you are right. My confusion. I thought you were talking about the customers account order_history_info.php

Re: products links (orders.php)

Posted: Tue Sep 13, 2022 3:05 pm
by Omar_one
raiwa wrote: Tue Sep 13, 2022 1:40 pm Sorry, you are right. My confusion. I thought you were talking about the customers account order_history_info.php
No worries

Re: products links (orders.php)

Posted: Tue Feb 21, 2023 8:53 pm
by Kofod95
Maybe this could be helpful:

Code: Select all

<?php
  class hook_admin_orders_productLink {
    function listen_injectSiteEnd(){
      global $order;
      if(!empty($order)){
        $js = '';
        $counter = 0;
        foreach ($order->products as $product) {
          $text = '[' . str_pad($product['id'], 5, '0', STR_PAD_LEFT) . ']';
          $link = $GLOBALS['Admin']->catalog('product_info.php', ['products_id' => $product['id']]);

        $js .= <<<EOS
              <script>
              var productsTable = document.getElementById("section_products_content");
              var tableBody = productsTable.getElementsByTagName("tbody")[0];
              var products = tableBody.getElementsByTagName("tr");

	          products[{$counter}].getElementsByTagName("td")[0].innerHTML += " <a class='badge badge-primary badge-pill' target=blank href=" + "{$link}" + ">" + "{$text}" + "</a>";
              </script>
EOS;
          $counter ++;
        }
      return $js;
      }
    }

  }
Note:
-This is written quickly in my attempt to learn more JS
-There are things that are specific for our needs here and I will probably revise many things at some point
-instead of adding to the JS for every product, it may be worth creating the links as php-arrays and put them into JS-arrays and then make a JS-loop on the products that adds the link.

//Daniel