1

This is a cross-post from stackoverflow, where nobody has been able to help so far.

I'm trying to add a minimal, manual "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 (e.g. 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.

2

I would recommend to use the build in Magento order status functions. If you create the 3 different status types you can select them at the order detail page in the order history box. This way you also have a history when the status changed.

Also the solution you used is not recommended, best is to create an extension and use an observer or rewrite to add your changes.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.