Jump to content

Sort Column in Orders


Claudia M

Recommended Posts

I know I am missing something pretty obvious but here I am.  I have added sold_site to my order summary database and added it to the places I want it to show in the order and that works well.  It shows on the Orders page in admin but I can't get it to sort. I added the following to the admin/sources/order.index.inc and I know I'm missing something but can't figure it out.  Also added sold_site to the orders portion of the language file.

 

  $thead_sort = array(

 'sold_site'   => $GLOBALS['db']->column_sort('sold_site', $lang['orders']['sold_site'], 'sort', $current_page, $_GET['sort']),

 'cart_order_id' => $GLOBALS['db']->column_sort('cart_order_id', $lang['orders']['order_number'], 'sort', $current_page, $_GET['sort']),

 

Also, If I wanted to make the Sold Site editable in the Orders page in Admin how would I add a Save button?

 

Thanks for any and all help
Link to comment
Share on other sites

Told you it was something stupid I did.  I had it at <td>Sold Site</td>. When I changed it to, it works <td>{$THEAD.sold_site}</td>

What about this:

"Also, If I wanted to make the Sold Site editable in the Orders page in Admin how would I add a Save button?"

Link to comment
Share on other sites

There is a Save button in the template code (at the bottom). The reason why we don't see it is because it is within a <div> block that only appears when the Add/Edit Order $DISPLAY_FORM is true.

So, we will need to move a modified <div class="form_control"> block below that final {/if}, then find and copy the means of making "inline edits" possible.

 

 

Link to comment
Share on other sites

The span class "editable" makes a textbox 300px wide (too much), and "editable number" makes a textbox 100px wide (good enough).

We need to create a new element name for the array of input elements newly created on this page - a page that never had inputs before - which is then identified by the actual order's cart_order_id that is about to be changed, then followed by the actual piece of data that will be changed.

Try this line:

<td><span class="editable number" name="update_overview_table[{$order.cart_order_id}][sold_site]">{$order.sold_site}</span></td>

Next is to make a specific submit button for this specific tab, because other tabs also have a submit button that will submit any data entered there. The Search Orders tab has a specific submit button titled "Search" (this submit input element does not have a name). The GDPR tab has a specific submit button titled "Go" (and this submit input element also does not have a name). (We really should give them names.)

So, we will name this new submit button "overview_table_submit".

Near line 90, find:

      <p align="center"><strong>{$LANG.orders.notify_orders_none}</strong></p>
      {/if}

Add after:

      <div class="form_control">
         <input name="overview_table_submit" type="submit" value="{$LANG.common.save}">
      </div>

Let's fix this:

Some lines later, find:

      </fieldset>
      <input type="submit" value="{$LANG.common.search}">
   </div>
   <div id="gdpr" class="tab_content">
   <h3>{$LANG.search.gdpr_tools}</h3>

Change the <input> to have a name:

      <input name="search_submit" type="submit" value="{$LANG.common.search}">

If needed, we can also fix the GDPR submit button to have a name.

Now that we are submitting data back to CubeCart that it was never expecting, we need to create the code in orders.index.inc.php to handle that submitted data.

Near line 27, find:

if (isset($_POST['month_purge']) && ctype_digit($_POST['month_purge'])) {

We will be adding the new code ABOVE this.

if (isset($_POST['update_overview']) && is_array($_POST['update_overview'])) {
    foreach($_POST['update_overview'] as $update_cart_order_id => $update_details) {
        // Update the database record
        $GLOBALS['db']->update('CubeCart_order_summary', $update_details, array('cart_order_id' => $update_cart_order_id));
    }
    // Bounce back to the Orders Overview page
    httpredir(currentPage());
}

Let's see what happens.

Be very, very, very careful about what else you decide to make "editable". Some data has been massaged to be more presentable: Total is a data item 'prod_total' - seen as $400.00 - which has been converted from the database value of 400.00, or Date is a data item 'date' - seen as 17 Jan 2021, 17:07 - which has been converted from the database value of 1610932036.

Having said this, you need to know exactly what you are doing when updating 'massaged' data.

Your 'sold_site' seems to be very straight-forward.

Link to comment
Share on other sites

Hmm. We need to return to the same "page" of orders after processing the form.

I also see that I failed to update the name of the form element from a previous experiment.

From:

if (isset($_POST['update_overview']) && is_array($_POST['update_overview'])) {
    foreach($_POST['update_overview'] as $update_cart_order_id => $update_details) {

To:

if (isset($_POST['update_overview_table']) && is_array($_POST['update_overview_table'])) {
    foreach($_POST['update_overview_table'] as $update_cart_order_id => $update_details) {

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...