简体   繁体   中英

Editing Magento Admin and User order detail page

I'm trying to add a minimal "track shipment" system in Magento. Here's what I'm trying to do:

I'd like to have radio buttons on the admin order detail page to select where the shipment is (eg not yet shipped, on its way, arrived). When I select one and press submit, I'd like for the customer to see the information on his/her order detail page.

I've managed to add radio buttons on the admin side by editing this file-- app/design/adminhtml/default/default/template/sales/order/view/tab/info.phtml --but I believe that it will be overwritten if Magento is updated. The same is true for edits on the customer side file-- app/design/frontend/base/default/template/sales/order/info/buttons.phtml

Also, the buttons don't actually do anything yet. I think what I need to do might be to add a column to Sales_Flat_Order (for the order to have a shipping state) and Sales_Flat_Order_Grid (for the admin to be able to see its current state). Then, the radio buttons could somehow change the state in this table, and when the customer page is loaded, it could retrieve the state and display it.

Summary of questions:

  1. How can I edit the order detail pages (admin's and customer's) in a sustainable way?
  2. Should I just make a new table column in phpMyAdmin, or must it somehow be done through Magento?
  3. Can I somehow use radio buttons to change a table?
  4. Can I then retrieve that information and display it on the customer order detail page?

Any guidance, however partial, would be greatly appreciated. I've been beating my head against google to get this far, but I don't feel that much closer to actually solving the problem.

So, I (mostly) solved my problem. Here's what I did:

I created a new column in the sales_flat_order table in phpMyAdmin called shipping_status. Then, in the page I mentioned for the admin side, I added the radio buttons, which are using the get method. I then updated the shipping_status of the order using this code:

<?php @$a = $_GET['shipping_status'] ?>
<?php $b = $_order->getId() ?>
<?php $con = mysql_connect("localhost",login,password); ?>
<?php mysql_select_db("magentodb", $con); ?>
<?php $sql_statement = "UPDATE sales_flat_order ".
    "SET shipping_status = '$a' ".
    "WHERE entity_id = $b" ; ?>
<?php mysql_query($sql_statement); ?>

where login and password are my actual database username and password. So it takes the submitted value from the radio buttons and puts it into the sales_flat_order table in the row for the order with the given order id (entity_id).

Then, on the user side, I edited the page at app/design/frontend/base/default/template/sales/order/info.phtml by adding this code:

<?php $b = $_order->getId() ?>
<?php $con = mysql_connect("localhost",login,password); ?>
<?php mysql_select_db("magentodb", $con); ?>
<?php $sql_statement = "SELECT shipping_status ".
    "FROM sales_flat_order ".
    "WHERE entity_id = $b" ; ?>
<?php $result1 = mysql_query($sql_statement); ?>
<?php $result2 = mysql_fetch_assoc($result1); ?>
<?php if ($result2[shipping_status] == '0'): ?>
    <strong><?php echo 'Preparing to Ship'; ?></strong>
<?php elseif ($result2[shipping_status] == "1"): ?>
    <strong><?php echo 'Departed the United Kingdom'; ?></strong>
<?php elseif ($result2[shipping_status] == '2'): ?>
    <strong><?php echo 'Arrived in your country'; ?></strong>
<?php elseif ($result2[shipping_status] == '3'): ?>
    <strong><?php echo 'Out for Local Delivery'; ?></strong>
<?php else: ?>
    <strong><?php echo 'Delivered'; ?></strong>
<?php endif; ?>

This gets the current value of shipping_status and prints the associated status. For good measure, I went back and put this code in the other file as well, so that the admin could see the state before/after changing it.

Here's the remaining problem: this is not a sustainable solution. Whenever Magento is updated, I believe these files will be replaced by new ones without this code. So if you're looking for a solution to a similar problem, this is only a temporary fix.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM