Jump to content
Latest News: (loading..)
jhilgeman

NEW! Complete Order Editing Tool!

Recommended Posts

I made some kind of 'modularization' of this addon time ago and I'm currently using it.

When I found several errors I split the module into templates, actions and common functions because I found many patches were being applied on the ajax page or in the standard one over time and both codes made different things, so I made both to run under the same code - that way any fix will affect both versions and code is much more readable and workable.

As dr_lucas I also use some custom fields and mods and I didn't find the time to make a version for download that doesn't have all of those mods. Also, I use QTPro. One of the big flaws on this addon is that it messes the stock quantities when adding or substracting units for a product with attributes. This is because oscommerce doesn't save database id for attributes in the database but instead saves attribute localized names. I've fixed it by adding a new field on the database that contains product attribute id that is saved on checkout - so later can be used with this addon to fix stock when you add or substract quantities of an order.

Anyway I can share it if some of you want to work on it. Just let me know.

 

 

Share this post


Link to post
Share on other sites

@BrockleyJohn just downloaded your files to test them on a blank oscommerce and found that it searches for images under /order_editor/images directory while in the zip file those are stored under /images

Share this post


Link to post
Share on other sites
1 hour ago, piernas said:

@BrockleyJohn just downloaded your files to test them on a blank oscommerce and found that it searches for images under /order_editor/images directory while in the zip file those are stored under /images

It explains why my test site doesn't have the pretty icons in Pierre's screenshot! I was commissioned to make a light-touch install of it so didn't go deeply into the actual editor itself, just plugged a lot of obvious holes and made sure that it stood up and appeared to work.

That said I'm quite happy to apply bug fixes, test and put them to the apps area, so keep them coming.

I can confirm that moving the images folder from where it was in the previous package does make them appear.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

...but it turns out the javascript expects the images to be where they were in the package.

Time to start making a list! Perhaps your version of the editor might make a better starting point @piernas. Is it on github?


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

I don't think to add code for compatibility with other add-ons is the right way to go.
Order Editor should should be simple and clean as possible and work with stock osC features. Any required support or modification should be written down inside a install manual as OPTIONAL.
Not everyone is using QTPro or SPPC or SSPP or whatever all those add-ons are called.

Right now there is code to support; shipping label pdf, google maps + direction, pdf invoice admin 1.6.2, Send Html Email and I think QTPro.

That all should be stripped out and make Order Editor as simple as possible. People can modify their own Order Editor version later to support the add-ons they need.

Just my 2 cents.
 

 


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@Tsimi I've no argument with that. A modularised approach with common code between the edit and ajax files is a very good idea too, and if well structured could readily support additional addons which would typically only hit one of the functional areas (eg. add/remove products for QTPro, SPPC, probably SSPP).


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

If we could get a clean Order Editor together that actually works with all the basic osC functions then that would be a huge step forward. :smile:

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Hi,

I have installed the order-editor on my OSC 2.3.4.1 and i have next error.

 

Not Found

The requested URL /admin/edit_orders.phpoID=2 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

What could be my mistake?

 

Many thanks,

Share this post


Link to post
Share on other sites

@Frekey80

The generated URL you posted is incomplete. It *should* be:

/admin/edit_orders.php?oID=2

(note the missing question mark)

Now, why the generated URL is wrong, I don't know ...

HTH

Malcolm

Edited by ArtcoInc
typo correction

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Edge" release here

Share this post


Link to post
Share on other sites
1 hour ago, Frekey80 said:

Hi,

I have installed the order-editor on my OSC 2.3.4.1 and i have next error.

 

Not Found

The requested URL /admin/edit_orders.phpoID=2 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

What could be my mistake?

 

Many thanks,

That doesn't look like your mistake, it looks more like the code didn't work properly.

  1. Did you get that on the single order view (ie. while looking at admin/orders.php?oID=2&action=edit) or the list of orders view (admin/orders.php?oID=7) ?
  2. If you refresh that page and try again, do you still get the error?

 


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

 

On 23/2/2018 at 12:12 AM, BrockleyJohn said:

...but it turns out the javascript expects the images to be where they were in the package.

Time to start making a list! Perhaps your version of the editor might make a better starting point @piernas. Is it on github?

My pc has broken this weekend. I've managed to reinstall an old one but don't have the files here. I'll get them from FTP once I have this pc completely up and running and send them to you.

Having separate templates allowed me to understand more of the addon. There's still a lot of work to do, for example in the cart recreation - that's the most tricky part where are loops inside loops and more loops up to 8 or 9 levels - and there's where the addon mostly fails to recognize and calculate totals.

 

Share this post


Link to post
Share on other sites
On 23/2/2018 at 9:40 PM, BrockleyJohn said:

That doesn't look like your mistake, it looks more like the code didn't work properly.

  1. Did you get that on the single order view (ie. while looking at admin/orders.php?oID=2&action=edit) or the list of orders view (admin/orders.php?oID=7) ?
  2. If you refresh that page and try again, do you still get the error?

 

It happened to me the first time I run the page. This error dissapears on reload.

Edited by piernas

Share this post


Link to post
Share on other sites
5 minutes ago, piernas said:

 

My pc has broken this weekend. I've managed to reinstall an old one but don't have the files here. I'll get them from FTP once I have this pc completely up and running and send them to you.

Having separate templates allowed me to understand more of the addon. There's still a lot of work to do, for example in the cart recreation - that's the most tricky part where are loops inside loops and more loops up to 8 or 9 levels - and there's where the addon mostly fails to recognize and calculate totals.

 

OK - no rush, it's not going to be a quick project!


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
10 minutes ago, piernas said:

It happened to me the first time I run the page. This error dissapears on reload.

Only the first time after installation, or the first time you view an order?


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

someone familiar with this add-on knows how to manipulate the ot_tax/ order tax on update.

I would like to update the tax when the shipping amount is changed, but didn't found a way to do it.

By default it is not supported, only updates order total.

Share this post


Link to post
Share on other sites

I use prices including tax in my live site so I can't test (don't see a tax row in the order total). Let me install and check it offline.

Share this post


Link to post
Share on other sites

I''ve been doing a quick test and that's what I found:

Tax rate for shipping is calculated only if you choose a shipping method on the left. If you change manually the shipping method the shipping tax vanishes.

You can test it doing these steps:

  • create two different taxes with different names and percentages.
  • apply one tax to products and the another to shipping mehod.
  • place an order

The order is placed and you obtain two different tax rate totals, one for products and another for shipping.

Then you edit the order: if you change the shipping cost or add products, the line for the shipping tax vanishes.

Trick: if you re-add the shipping method it will recalculate. But in my test the line was added in the wrong place (before shipping) even when the calculation was right.

The trick won't work if you change the shipping price itself.

 

 

 

 

Share this post


Link to post
Share on other sites

This is the logic for recalculating totals (at least on my order editor). I took it apart of the rest of the code and cleanded up a bit to make more readable (there were two versions that were slightly different in edit_order and in edit_order_ajax. I also applied some of the patches seen here in the forum while other didn't work).

As you'll see it's complex because there are up to 8 levels of nested checks.

There is also another difficulty: while in products you save the gross price and the tax class in the db, shipping is saved as a net price only. Calculation gets even more complex :(

<?php
      $shipping = array();
      if (is_array($_POST['update_totals'])) {
        foreach($_POST['update_totals'] as $total_index => $total_details) {
          extract($total_details, EXTR_PREFIX_ALL, "ot");
          if ($ot_class == "ot_shipping") {
            $shipping['cost'] = $ot_value;
            $shipping['title'] = $ot_title;
            $shipping['id'] = $ot_id;
          } // end if ($ot_class == "ot_shipping")
        } //end foreach
      } //end if is_array

      if (tep_not_null($shipping['id'])) { // Asignamos al pedido ot_shipping
        tep_db_query("UPDATE orders SET shipping_module = '" . $shipping['id'] . "' WHERE orders_id = '" . $oID . "'");
      }

//////////////////////////////////////////////////////////////////////////////////////////////////
// Get the shipping quotes- if we don't have shipping quotes shipping tax calculation can't happen
//////////////////////////////////////////////////////////////////////////////////////////////////

      $shipping_quotes = $shipping_modules->quote();

      if (DISPLAY_PRICE_WITH_TAX == 'true') {
        //extract the base shipping cost or the ot_shipping module will add tax to it again
        $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
        $tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        $order->info['total'] -= ( $order->info['shipping_cost'] - ($order->info['shipping_cost'] / (1 + ($tax /100))) );
        $order->info['shipping_cost'] = ($order->info['shipping_cost'] / (1 + ($tax /100)));
      }

      //this is where we call the order total modules
      require( 'order_editor/classes/order_total.php');
      $payment = $order->info['payment_module'];
      $order_total_modules = new order_total();
      $order_totals = $order_total_modules->process();
      $current_ot_totals_array = array();
      $current_ot_titles_array = array();
      $written_ot_totals_array = array();
      $written_ot_titles_array = array();
        //how many weird arrays can I make today?
      $current_ot_totals_query = tep_db_query("select class, title from orders_total where orders_id = '" . $oID . "' order by sort_order");
      while ($current_ot_totals = tep_db_fetch_array($current_ot_totals_query)) {
        $current_ot_totals_array[] = $current_ot_totals['class'];
        $current_ot_titles_array[] = $current_ot_totals['title'];
      }

      tep_db_query("DELETE FROM orders_total WHERE orders_id = '" . $oID . "'");

      $j=1; //giving something a sort order of 0 ain't my bag baby
      $new_order_totals = array();

      if (is_array($_POST['update_totals'])) { //1
        foreach($_POST['update_totals'] as $total_index => $total_details) { //2
// print_R ($ot_class);
          extract($total_details, EXTR_PREFIX_ALL, "ot");
          if (!strstr($ot_class, 'ot_custom')) { //3
            for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { //4
// echo $order_totals[$i]['title'] . "**" . $order_totals[$i]['code'] . $i .  "<br>";
              if ($order_totals[$i]['code'] == 'ot_tax') { //5
                $new_ot_total = ((in_array($order_totals[$i]['title'], $current_ot_titles_array)) ? false : true);
              } else { //within 5
                $new_ot_total = ((in_array($order_totals[$i]['code'], $current_ot_totals_array)) ? false : true);
              }  //end 5 if ($order_totals[$i]['code'] == 'ot_tax')

              if ( ( ($order_totals[$i]['code'] == 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) && ($order_totals[$i]['title'] == $ot_title) ) || ( ($order_totals[$i]['code'] != 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) ) ) { //6
              //only good for components that show up in the $order_totals array
                if ($ot_title != '') { //7
                  $new_order_totals[] = array('title' => $ot_title,
                                              'text' => (($ot_class != 'ot_total') ? $order_totals[$i]['text'] : '<b>' . $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']) . '</b>'),
                                              'value' => (($order_totals[$i]['code'] != 'ot_total') ? $order_totals[$i]['value'] : $order->info['total']),
                                              'code' => $order_totals[$i]['code'],
                                              'sort_order' => $j);
                  $written_ot_totals_array[] = $ot_class;
                  $written_ot_titles_array[] = $ot_title;
                  $j++;
                } else { //within 7
                  $order->info['total'] += ($ot_value*(-1));
                  $written_ot_totals_array[] = $ot_class;
                  $written_ot_titles_array[] = $ot_title;
                } //end 7

              } elseif ( ($new_ot_total) && (!in_array($order_totals[$i]['title'], $current_ot_titles_array)) ) { //within 6
                $new_order_totals[] = array('title' => $order_totals[$i]['title'],
                                            'text' => $order_totals[$i]['text'],
                                            'value' => $order_totals[$i]['value'],
                                            'code' => $order_totals[$i]['code'],
                                            'sort_order' => $j);
                $current_ot_totals_array[] = $order_totals[$i]['code'];
                $current_ot_titles_array[] = $order_totals[$i]['title'];
                $written_ot_totals_array[] = $ot_class;
                $written_ot_titles_array[] = $ot_title;
                $j++;
                echo $order_totals[$i]['code'] . "<br>"; //for debugging- use of this results in errors
              } elseif ($new_ot_total) { //also within 6
                $order->info['total'] += ($order_totals[$i]['value']*(-1));
                $current_ot_totals_array[] = $order_totals[$i]['code'];
                $written_ot_totals_array[] = $ot_class;
                $written_ot_titles_array[] = $ot_title;
              }//end 6
            }//end 4
          } elseif ( (tep_not_null($ot_value)) && (tep_not_null($ot_title)) ) { // this modifies if (!strstr($ot_class, 'ot_custom')) { //3
            $new_order_totals[] = array('title' => $ot_title,
                                        'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
                                        'code' => 'ot_custom_' . $j,
                                        'sort_order' => $j);
            $order->info['total'] += $ot_value;

            $written_ot_totals_array[] = $ot_class;
            $written_ot_titles_array[] = $ot_title;
            $j++;
          } //end 3

          //save ot_skippy from certain annihilation
          if ( (!in_array($ot_class, $written_ot_totals_array)) && (!in_array($ot_title, $written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7
          //this is supposed to catch the oddball components that don't show up in $order_totals
            $new_order_totals[] = array('title' => $ot_title,
                                        'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
                                        'code' => $ot_class,
                                        'sort_order' => $j);
            //$current_ot_totals_array[] = $order_totals[$i]['code'];
            //$current_ot_titles_array[] = $order_totals[$i]['title'];
            $written_ot_totals_array[] = $ot_class;
            $written_ot_titles_array[] = $ot_title;
            $j++;

          } //end 7
        } //end 2
      } else {//within 1
        // $_POST['update_totals'] is not an array => write in all order total components that have been generated by the sundry modules
        for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { //8
          $new_order_totals[] = array('title' => $order_totals[$i]['title'],
                                      'text' => $order_totals[$i]['text'],
                                      'value' => $order_totals[$i]['value'],
                                      'code' => $order_totals[$i]['code'],
                                      'sort_order' => $j);
          $j++;

        } //end 8

      } //end if (is_array($_POST['update_totals'])) { //1

      for ($i=0, $n=sizeof($new_order_totals); $i<$n; $i++) {
        $sql_data_array = array('orders_id' => $oID,
                                'title' => oe_iconv($new_order_totals[$i]['title']),
                                'text' => $new_order_totals[$i]['text'],
                                'value' => $new_order_totals[$i]['value'],
                                'class' => $new_order_totals[$i]['code'],
                                'sort_order' => $new_order_totals[$i]['sort_order']);
        tep_db_perform('orders_total', $sql_data_array);
      }

// reload_totals.php end

 

Share this post


Link to post
Share on other sites

I'm maintaining a heavily customized OSC 2.3.4 (non BS).

I had severe problems in order editor related to multiple tax rates, shipping cost and discount coupons.
One of the problems was also, how to tackle free shipping, if the order total changes.

Our tax rates are VAT 24% and VAT 10%. Shipping, if not free, is always VAT 24%.

I realized that all those are correctly calculated on the catalog side.

I customised edit_orders.php and cloned some code from the catalog side into:
/admin/order_editor/cart.php
/admin/order_editor/order.php

I had some "custom tax fix" lines in edit_orders.php, which actually  never worked properly.
I removed these lines also, as well as ot_custom total handling.

I have the addon "Discount Coupon Codes 3.34 for osc 2.31 " to handle discounts coupons.
I also put a modified version of  discount_coupon.php to /admin/order_editor.

Now the admin can add/remove products with different tax rates  and everyting is correclty calculated.

My code is so customized for my needs, that I doubt if it can help anybody.
If you think it may help, I can upload it.

Maybe just the idea will help: if it works on the catalog side, do the same on the admin side.
Do not try to "fix" it in the edit_orders.php.

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

Hello @vmn,

Thank you for your time an explanations.

I got a way to do all what you mentioned.

The only point left is the possibility to change the shipping fee directly in the order editior's ot shipping field and get the shipping tax part recalculated.

My work around for now is to use a shipping module which shows only in the shipping editor and to select this one, changing before the fee to what I need in the shipping module configuration.

If your version does what I need or you think it will give a hint how to do it, I would apreciate if you could upload it here.

Thanks a lot

Rainer

Edited by raiwa

Share this post


Link to post
Share on other sites
Posted (edited)

We only use flat shipping with minimum shipping fee. The shipping fee can be changed in the order editor, if needed.

The discount coupon cannot be changed, only removed, in the order editor. In case of other discounts, we simply change the product price in the order editor.

I have also added order language. Admin interface language is automatically changed based on the order. Our shop supports Finnish and English.

See my attached modifications. The files belong to folders admin and admin/order_editor.

I hope this helps somebody to develop the order editor NG.

vmn.order.editor.zip

Edited by vmn

Share this post


Link to post
Share on other sites

I believe all the problems of this contrib are caused by the compatibility with custom modules. As @vmn says, if you remove support for them then you can use a custom checkout from catalog intehrated in the file I posted above. Ideal thing would be replicating the checkout proccess but having the ability to add those custom modules.

Share this post


Link to post
Share on other sites
Posted (edited)

(I have run into a bug, but I am using a *very* old version of this add-on, and do not know if this has been addressed already or not)

What happened to me was: a customer placed an order. One item was out of stock, and we put it on backorder. The customer turned around and placed a second order for the same item. When the product was back in stock, and it came time to ship these, I put both orders together. I entered the order as two line items ... one line for the original (backordered) purchase order, and the second line for the new purchase order.

Because both line items were for the same product, the order editor did not add the weight of the item(s) correctly. Can someone test this for me with the current code:

1) Create an order. You can either enter a new customer, or use an existing customer ... it doesn't matter

2) Add a line item for a product, any product ... Note the shipping weight

3) Add another line item for the same product ... Note the shipping weight again

TIA

Malcolm

PS: These orders were over the telephone ... the customer did not place the order(s) through the store. I manually entered the order through Admin and this add-on.

Edited by ArtcoInc
additional explaination

If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Edge" release here

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×