Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

NEW! Complete Order Editing Tool!


jhilgeman

Recommended Posts

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?

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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.

 

Link to comment
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
Link to comment
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!

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
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?

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
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.

 

 

 

 

Link to comment
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

 

Link to comment
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.

 

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

(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
Link to comment
Share on other sites

  • 2 months later...

Tax problems with the shipping cost in the order editor 1.2.5 - my findings sofar. 

In admin\edit_orders.php, I added 4 echoes at the bottom of this:

    // Edit Order
      case 'edit':
        if (!isset($_GET['oID'])) {
        $messageStack->add(ERROR_NO_ORDER_SELECTED, 'error');
        break;
    }
        $oID = tep_db_prepare_input($_GET['oID']);
        $orders_query = tep_db_query("select orders_id from orders where orders_id = '" . (int)$oID . "'");
        $order_exists = true;
        if (!tep_db_num_rows($orders_query)) {
        $order_exists = false;
          $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
          break;
        }
       
        $order = new manualOrder($oID);
        $shippingKey = $order->adjust_totals($oID);
        $order->adjust_zones();
       
        $cart = new manualCart();
        $cart->restore_contents($oID);
        $total_count = $cart->count_contents();
        $total_weight = $cart->show_weight();

        // Get the shipping quotes
        $shipping_modules = new shipping;
        $shipping_quotes = $shipping_modules->quote();

echo $order->delivery['country']['id'] . ' country id<br>';
echo $order->delivery['zone_id'] . ' zone id<br>';
echo $shipping_quotes[0]['tax'] . ' %tax ' . $shipping_quotes[0]['module'] . ' first quote<br>';
echo $shipping_quotes[1]['tax'] . ' %tax ' . $shipping_quotes[0]['module'] . ' second quote<br>';

        break;

 

That tells me that the first shipping quote (table shipping) on the left, in the order editor use 0% tax (should be 21). The second quote (flat rate) is fine, 21% indeed.

if I hard code 22 in both shipping cost modules, the first quote stubbornly shows 0, the second quote 22.

That is weird. I don't understand that at all.

Any ideas?

 

Link to comment
Share on other sites

@franktechniek have you checked that orders placed in the checkout do what you expect?

The problem might lie in the shipping module, not the order editor

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

11 hours ago, BrockleyJohn said:

@franktechniek have you checked that orders placed in the checkout do what you expect?

The problem might lie in the shipping module, not the order editor

Well, the shop runs fine, all orders have everything in the right place, with correct taxes. As soon as I use the order editor, things go wrong. The shipping quotes that I see on the left, the top one (coming from table rate) has no tax, and the second one (coning from flat rate) has 21% tax (high level tax). Both shipping methods are configured for 21% tax.

That's why I added the echo lines to check if the right country data was applied, and to check what percentage was set in the quotes. It goes wrong at fetching the quotes. Table rate give 0%.

Even when I hard coded the qoute method to return a fixed number, 22 to distinguish from the configured 21, it still shows 0% for table rate, but 22 for flat rate.

Have to check that again, still can't believe it.. so weird.

 

Link to comment
Share on other sites

18 minutes ago, franktechniek said:

Well, the shop runs fine, all orders have everything in the right place, with correct taxes. As soon as I use the order editor, things go wrong. The shipping quotes that I see on the left, the top one (coming from table rate) has no tax, and the second one (coning from flat rate) has 21% tax (high level tax). Both shipping methods are configured for 21% tax.

That's why I added the echo lines to check if the right country data was applied, and to check what percentage was set in the quotes. It goes wrong at fetching the quotes. Table rate give 0%.

Even when I hard coded the qoute method to return a fixed number, 22 to distinguish from the configured 21, it still shows 0% for table rate, but 22 for flat rate.

Have to check that again, still can't believe it.. so weird.

 

Hmm, forget that, I was messing with the wrong file.. Sorry folks ;-)

 

Link to comment
Share on other sites

And now I modified \includes\modules\order_total\ot_tax so that I can enter negative quantities for products without loosing the total for tax completely.

I want it to work that way, because occasionally I need to create a credit invoice for customers that return product(s).  

In function process() it is just a simple change:

      foreach($order->info['tax_groups'] as $key => $value) {
//        if ($value > 0) {
        if ($value != 0) { // also allow negative tax for negative quantities of products that are returned and have to be credited on the (credit) invoice
          $this->output[] = array('title' => $key . ':',
                                  'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
                                  'value' => $value);
        }

Next step is to figure out why the order editor looses the tax that is part of the shipping cost. A new order that is placed has the correct total for tax, for products and shipping combined, but as soon as I hit update even without changing any fields, the total tax is changed to products only.

Once the order editor behaves correctly, I guess I would like a button to create a blank order for a particular customer and then fill/modify it as desired. That should not be too difficult.

But that shipping tax......

 

Link to comment
Share on other sites

@franktechniek in edit_orders.php (at around line 990 in version 2.5.1) there is

        $order = new manualOrder($oID);
        $shippingKey = $order->adjust_totals($oID);
        $order->adjust_zones();
        

The shipping module is going to use $order->delivery['country']['id'] and $order->delivery['zone_id'] to work out the tax on the shipping so check the values of these after the first and third lines above.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

17 hours ago, BrockleyJohn said:

@franktechniek in edit_orders.php (at around line 990 in version 2.5.1) there is


        $order = new manualOrder($oID);
        $shippingKey = $order->adjust_totals($oID);
        $order->adjust_zones();
        

The shipping module is going to use $order->delivery['country']['id'] and $order->delivery['zone_id'] to work out the tax on the shipping so check the values of these after the first and third lines above.

Thanks John, after some time I figured out there was an ommission in my own modfications I made to facilitate intracommute orders (b2b) inside the EU that don't have tax added. I decided to turn off the ajax functions also. They are nice to have, but since the code is too complicated for my own level of understanding, I decided it is better to do without - for now anyway..

Nice when things start to work ;-)

Edited by franktechniek
Link to comment
Share on other sites

  • 1 month later...

Hi I have installed this addon on my Frozen CE version.. Order Editor BS

https://apps.oscommerce.com/wwEZ9&amp;order-editor-for2-3-v1-0

Works good but when I create the Order the shipping is not calculating correctly..

I am using MPW which works with every addon but does not seem to work with the shipping of this addon.. Please Help

The attribute weights are not been taken into account by it, It only calculates the base weight of the item..

Help on it will be deeply appreciated..

Warm Regds./

radhavallabh

Edited by radhavallabh
Link to comment
Share on other sites

  • 3 months later...
3 minutes ago, joe122joe said:

Hi  @BrockleyJohn  
when I create order and after  adding  products to order I get blank page .. so I have to press back on the browser and it show the order ,
so the oder are created and the product also add it, but why the blank page ?.

oscommerce BS updated to Frozen
php 7.2

Br
Joe

 

The blank page is likely a php error, presumably after the order is created. My guess is that it's due to something not compatible with php7.2

If you make sure that errors are being displayed you should find out what it is, eg by having in admin/includes/application_top.php

  error_reporting(E_ALL & ~E_NOTICE);

  ini_set("display_errors", 1);

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...