Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

NEW! Complete Order Editing Tool!


jhilgeman

Recommended Posts

@@Dan Cole

 

The Order Editor is just plain clunky (and you can't enter discounts, or charge credit cards!) whereas our front end is beautifully crafted and functional. Kind of a no brainer for us :)

@@frankl @@Tsimi

 

Yeah...it's not ideal but as Lambros points out...it is the only one available.   I added the ability to enter products by scanning the UPCs a few years ago and for us it works better then our front end or at least quicker.   Now to sort out that coupon issue.  Under the hood I go...

 

Dan 

Link to comment
Share on other sites

Could someone please let me know whether Order Editor does actually handle Discount Coupons correctly. As I said maybe our install is a bit messed up.

 

Dan

 

I have installed "Discount Codes BS" (http://addons.oscommerce.com/info/9460) and I'm searching to get compatibility too with "Order Editor" when I use Discount Coupon.

Thanks.

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@Dan Cole

 

About compatibility with "Discount Codes BS" and Order Editor, the simplest way to get the data "ot_discount" into account in the "order_total" calculation would be to associate it or to substitute it to the "ot_custom" data generated by "Order Editor" (when adding a new field with + symbol).

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@Dan Cole

 

It works but I need help to add the consideration of the tax from "ot_discount" to the total tax calculation.

My current version : edit_orders.php v5.0.5

 

1. In admin/edit_orders.php, replace all "ot_custom" occurences like this :

 

At line 374 :

// Add ot_discount
//            if (!strstr($ot_class, 'ot_custom')) { //3
            if (!strstr($ot_class, 'ot_discount')) { //3
// Add ot_discount

At line 430 :

// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount

2. In admin/order_editor/order.php, replace "ot_custom" occurence like this :

// Add ot_discount
//                                'class' => 'ot_custom',
                                'class' => 'ot_discount',
// Add ot_discount

Now you can add or edit "ot_discount" value with a fair calculation of the total amount but wrong calculation of total tax if you have (DISPLAY_PRICE_WITH_TAX == 'true') set from your admin.

 

Considering that "ot_discount" is added or subtracted from" ot_subtotal" with the same taxes rate.

 

Would anyone know how to proceed to have fair calculation of total tax too ?

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan Hi Gwenn. 

 

It works but I need help to add the consideration of the tax from "ot_discount" to the total tax calculation.

 

Thanks for confirming the tax calculation problem. I think if we can fix that it should solve a long outstanding issue with Order Editor.   I had a quick look at the code and I don't think it matters whether the class is set to ot_discount or ot_custom.  It seems to deal with the regular order class items (shipping, total, sub-total and tax) in one manner and skips all others no matter what they are called.  I suppose you could try treating ot_discount as one of those regular order classes and see if that solves the problem, for the coupons at least.   I haven't really looked much deeper into the code but I will.  It is a problem I intend to fix one way or the other.  

 

Maybe we can work together on this or at least bounce ideas off each other.  I assume from the changes to the code you posted that you're not using the ajax version?

 

Dan

Link to comment
Share on other sites

Maybe we can work together on this or at least bounce ideas off each other.  I assume from the changes to the code you posted that you're not using the ajax version?

 

Dan

 

My version has got ajax option but I don't use it.

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

The "ot_discount" class is not taken into account by order_editor because all the parameters related to the coupon calculated from the catalog are not attached to the ot_shipping class itself :

 

Applies to:    Order Sub-Total    Shipping  Products:    Categories:    Manufacturers:

 

Normally it would require a different class depending parameter.

 

% or number, "Shipping" or "Order Sub-Total/Product/Categories/Manufacturer" option...

 

The registered class name from "orders_total" TABLE must be unique depending on the crossing of options.

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan

 

@@Dan Cole

 

Which version do you use ?

 

The version I'm using is marked...

 

$Id: edit_orders_ajax.php v5.0.5 08/27/2007 djmonkey1 Exp $

 

and as you'll see I'm using AJAX.

 

Dan

Link to comment
Share on other sites

The "ot_discount" class is not taken into account by order_editor because all the parameters related to the coupon calculated from the catalog are not attached to the ot_shipping class itself :

 

Applies to:    Order Sub-Total    Shipping  Products:    Categories:    Manufacturers:

 

Normally it would require a different class depending parameter.

 

% or number, "Shipping" or "Order Sub-Total/Product/Categories/Manufacturer" option...

 

The registered class name from "orders_total" TABLE must be unique depending on the crossing of options.

 

I'm not sure what this means at this point but maybe I'll understand more when I have a chance to pop the hood....I'm off tomorrow so I hope to have a closer look then.

 

Dan

Link to comment
Share on other sites

The "ot_discount" class is not taken into account by order_editor because all the parameters related to the coupon calculated from the catalog are not attached to the ot_shipping class itself :

 

Applies to:    Order Sub-Total    Shipping  Products:    Categories:    Manufacturers:

 

Normally it would require a different class depending parameter.

 

% or number, "Shipping" or "Order Sub-Total/Product/Categories/Manufacturer" option...

 

The registered class name from "orders_total" TABLE must be unique depending on the crossing of options.

 

A lot of this is still lost on me (my eyes glaze over when I start looking at classes) but I think you are correct in that the order_total class is not picking up or recognizing anything other than the ot_shipping, ot_total, ot_subtotal and ot_tax classes.   So I guess the question is....how do we change, add or register the coupon class so it is picked up in the order_totals_array?   Anyone have any ideas on this?

 

I guess the other option is to try and work around that and see if we can just determine what the tax is on the coupon (this is simple to do) and then try to simply deduct that from the ot_tax valve (haven't tried this yet).   The feels like a dirty hack so I would favor the first option if possible.

 

Dan

Link to comment
Share on other sites

@Dan Cole

 

It works but I need help to add the consideration of the tax from "ot_discount" to the total tax calculation.

 

My current version : edit_orders.php v5.0.5

 

1. In admin/edit_orders.php, replace all "ot_custom" occurences like this :

 

At line 374 :

// Add ot_discount
//            if (!strstr($ot_class, 'ot_custom')) { //3
            if (!strstr($ot_class, 'ot_discount')) { //3
// Add ot_discount

At line 430 :

// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount

2. In admin/order_editor/order.php, replace "ot_custom" occurence like this :

// Add ot_discount
//                                'class' => 'ot_custom',
                                'class' => 'ot_discount',
// Add ot_discount

Now you can add or edit "ot_discount" value with a fair calculation of the total amount but wrong calculation of total tax if you have (DISPLAY_PRICE_WITH_TAX == 'true') set from your admin.

 

Considering that "ot_discount" is added or subtracted from" ot_subtotal" with the same taxes rate.

 

Would anyone know how to proceed to have fair calculation of total tax too ?

 

To add tax to "ot_custom" class (or "ot_discount" if replace by it), you have to edit "admin/edit_orders.php" and modify like this :

 

 

1. Line 499 :

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

        $j=1; //giving something a sort order of 0 ain't my bag baby
		$new_order_totals = array();
	  // Add tax to ot_custom bof
        $tax_to_add=0;
	  // Add tax to ot_custom eof

	    if (is_array($_POST['update_totals'])) { //1
          foreach($_POST['update_totals'] as $total_index => $total_details) { //2

2. Line 517 :

			  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

			  // Add tax to ot_custom bof
                if ($order_totals[$i]['code'] == 'ot_tax') {
                  $order_totals[$i]['value'] += $tax_to_add;
                  $order_totals[$i]['text'] = $currencies->format($order_totals[$i]['value'], true, $order->info['currency'], $order->info['currency_value']);
                }
			  // Add tax to ot_custom eof

				if ($ot_title != '') { //7

3. Line 562 :

          } elseif ( (tep_not_null($ot_value)) && (tep_not_null($ot_title)) ) { // this modifies if (!strstr($ot_class, 'ot_custom')) { //3
		  // Add tax to ot_custom bof
            //This calculates tax on ot_custom
            $tax_to_add += $ot_value * $tax / (100 + $tax);
		  // Add tax to ot_custom eof

            $new_order_totals[] = array('title' => $ot_title,
                     'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),

4. Line 577 :

		    //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;

			  // Add tax to ot_custom bof
                //This calculates tax on non-standard
                $tax_to_add += $ot_value * $tax / (100 + $tax);
                $order->info['total'] += $ot_value;
			  // Add tax to ot_custom eof
                $j++;
				 
				 } //end 7
        } //end 2

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan  Wow, you have this working already?  Thanks Gwenn.  I'll give it a go and see how it works out....I'd still love to know how to register a new order_total module though.   Any ideas on that?  I'm thinking that you should just be able to drop in the module and related language file in the appropriate directories and install it but that doesn't seem to work with the ot_discount_coupon module.  Anyone know if my thinking is correct?

 

Now that I think about this, I think I'll just rework one of the exiting modules, that I know works, and see if my thinking is sound but if anyone wants to chime in, I'd welcome the input.

 

Dan

Link to comment
Share on other sites

@@milerwan Nice job Gwenn....works a treat....I added the changes you posted to the edit_orders_ajax.php file instead of to edit_orders.php as you did.   The only problem I had is that $tax wasn't defined in that file so I added these two lines....

 

$tax_class = 3;
$tax = tep_get_tax_rate($tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

 

just before the two instances of...

 

$tax_to_add += $ot_value * $tax / (100 + $tax);

 

in your code so they now look like...

 

$tax_class = 3;
$tax = tep_get_tax_rate($tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
$tax_to_add += $ot_value * $tax / (100 + $tax);

 

$tax_class = 3 is my Taxable class.

 

Well done! :thumbsup:

 

Dan

Edited by Dan Cole
Link to comment
Share on other sites

@@milerwan Nice job Gwenn....works a treat....I added the changes you posted to the edit_orders_ajax.php file instead of to edit_orders.php as you did.   The only problem I had is that $tax wasn't defined in that file so I added these two lines....

 

 

just before the two instances of...

 

 

in your code so they now look like...

 

 

$tax_class = 3 is my Taxable class.

 

Well done! :thumbsup:

 

Dan

 

Thank you. :)

 

 

Maybe another approch for better association with "Discount Codes" module.

 

 

1. Edit "function keys" and "function install" of includes/modules/order_total/ot_discount.php and modify it to add tax_class (when editing order from Order Editor) :

    function keys() {
      return array('MODULE_ORDER_TOTAL_DISCOUNT_VERSION',
				   'MODULE_ORDER_TOTAL_DISCOUNT_STATUS',
				   'MODULE_ORDER_TOTAL_DISCOUNT_SORT_ORDER',
				   'MODULE_ORDER_TOTAL_DISCOUNT_TAX_CLASS',
				   'MODULE_ORDER_TOTAL_DISCOUNT_DELETE_TABLES');
    }

    function install() {
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Module Version', 'MODULE_ORDER_TOTAL_DISCOUNT_VERSION', '" . $this->version . "', 'The version of this module that you are running', '6', '0', 'tep_version_readonly(', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Discount', 'MODULE_ORDER_TOTAL_DISCOUNT_STATUS', 'true', 'Do you want to display the discount value?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_DISCOUNT_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())");
	// Add tax to ot_custom bof
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_DISCOUNT_TAX_CLASS', '0', 'Use the following tax class when editing order (Order Editor).', '6', '7', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
	// Add tax to ot_custom eof
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Delete auto created tables when uninstalling', 'MODULE_ORDER_TOTAL_DISCOUNT_DELETE_TABLES', 'False', 'Do you want to remove the tables that were created during installing this module?<br><i>Note: all the created discount codes will be deleted</i>.', '6', '13', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      // CREATE NEEDED TABLES INTO DB
      tep_db_query("
        CREATE TABLE IF NOT EXISTS `customers_to_discount_codes` (
          `customers_id` int(11) NOT NULL default '0',
          `discount_codes_id` int(11) NOT NULL default '0',
          KEY `customers_id` (`customers_id`),
          KEY `discount_codes_id` (`discount_codes_id`)
          ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
        ");
      tep_db_query("
        CREATE TABLE IF NOT EXISTS `discount_codes` (
          `discount_codes_id` int(11) NOT NULL auto_increment,
          `products_id` text,
          `categories_id` text,
          `manufacturers_id` text,
          `excluded_products_id` text,
          `customers_id` text,
          `orders_total` tinyint(1) NOT NULL default '0',
          `shipping` tinyint(1) NOT NULL default '0',
          `order_info` tinyint(1) NOT NULL default '0',
          `exclude_specials` tinyint(1) NOT NULL default '0',
          `discount_codes` varchar(8) NOT NULL default '',
          `discount_values` varchar(8) NOT NULL default '',
          `minimum_order_amount` decimal(15,4) NOT NULL default '0.0000',
          `expires_date` date NOT NULL default '0000-00-00',
          `number_of_orders` int(4) NOT NULL default '0',
          `number_of_use` int(4) NOT NULL default '0',
          `number_of_products` int(4) NOT NULL default '0',
          `status` tinyint(1) NOT NULL default '1',
          PRIMARY KEY  (`discount_codes_id`)
          ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
        ");
      // check if new field exist if not create
      $check = tep_db_query("SHOW COLUMNS FROM `discount_codes` LIKE 'shipping'");
      $exists = (tep_db_num_rows($check))?TRUE:FALSE;
      if(!$exists) {
        tep_db_query("ALTER TABLE `discount_codes` ADD `shipping` tinyint(1) NOT NULL default '0'");
      }
      $check = tep_db_query("SHOW COLUMNS FROM `discount_codes` LIKE 'newsletter'");
      $exists = (tep_db_num_rows($check))?TRUE:FALSE;
      if(!$exists) {
        tep_db_query("ALTER TABLE `discount_codes` ADD `newsletter` tinyint(1) NOT NULL default '0'");
      }
      $check = tep_db_query("SHOW COLUMNS FROM `discount_codes` LIKE 'order_number'");
      $exists = (tep_db_num_rows($check))?TRUE:FALSE;
      if(!$exists) {
        tep_db_query("ALTER TABLE `discount_codes` ADD `order_number` tinyint(1) NOT NULL default '0'");
      }
    }

2. In admin/edit_order.php replace calculation of "ot_custom/discount" by this :

		  // Add tax to ot_custom bof
            //This calculates tax on ot_custom
			if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') {
			  $tax_class = MODULE_ORDER_TOTAL_DISCOUNT_TAX_CLASS;
			} else {
			  $tax_class = 3;
			}
			$tax = tep_get_tax_rate($tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
			$tax_to_add += $ot_value * $tax / (100 + $tax);
		  // Add tax to ot_custom eof

3. Repeat operation in admin/edit_order_ajax.php :

		  // Add tax to ot_custom bof
            //This calculates tax on ot_custom
			if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') {
			  $tax_class = MODULE_ORDER_TOTAL_DISCOUNT_TAX_CLASS;
			} else {
			  $tax_class = 3;
			}
			$tax = tep_get_tax_rate($tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
			$tax_to_add += $ot_value * $tax / (100 + $tax);
		  // Add tax to ot_custom eof
Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

I have added new order_total module that shows "Total Excl. Tax", 100% work from catalog but, from Order Editor, when editing order, Discount amount is not applied to this new field.
 
From Order Editor, currently I have :
 
Sub-total TTC:                       24.00 €       
Discount (INF10):                 -10.00 €      
Shipping cost (0.07kg):            5.40 €     
Total Incl. Tax:                        19.40 €       
VAT 20%:                                 3.23 €        
Total Excl. Tax:                    24.50 €        
 
 
But the expected result must be :
 
Sub-total TTC:                       24.00 €       
Discount (INF10):                 -10.00 €      
Shipping cost (0.07kg):            5.40 €     
Total Incl. Tax:                        19.40 €       
VAT 20%:                                 3.23 €        
Total Excl. Tax:                    16.17 €        
 
 
Here is my last version of order_total module Total Amount Excl. Tax (VAT) with no core change : http://addons.oscommerce.com/info/9568
 

I think "Order Editor" needs core changes to apply "ot_custom/discount" to this new class (ot_total_ht) because when I edit the edit_order.php or edit_order_ajax.php, the addition of "ot_custom/discount" value to "ot_total" value is forced :
 

            $new_order_totals[] = array('title' => $ot_title,
										'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount
                                        'sort_order' => $j);
            $order->info['total'] += $ot_value;
			$written_ot_totals_array[] = $ot_class;
		    $written_ot_titles_array[] = $ot_title;
            $j++;

$order->info['total'] += $ot_value;

This line adds $ot_value to $order->info['total'] but it has no impact on total_ht.
 
 
Here is the structure of my ot_total_ht class :

    function process() {
      global $order, $currencies;

	  reset($order->info['tax_groups']);
      while (list($key, $value) = each($order->info['tax_groups'])) {
		if (DISPLAY_PRICE_WITH_TAX == 'true') {
		  $total_ht = $order->info['total'] - $value;
		} else {
		  $total_ht = $order->info['total'] + $value;
		}
//      $this->output[] = array('title' => $this->title . ':',
		$this->output[] = array('title' => (DISPLAY_PRICE_WITH_TAX == 'true' ? MODULE_ORDER_TOTAL_TOTAL_HT_TITLE : MODULE_ORDER_TOTAL_TOTAL_TTC_TITLE) .':',
								'text' => $currencies->format($total_ht, true, $order->info['currency'], $order->info['currency_value']),
								'value' => $total_ht);
      }
    }

Ca anyone help me to get correct total calculating for "ot_total_ht" ?

 

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

@@milerwan  And to continue the conversation....

 

@milerwan  Gwenn....I'm afraid I'm a bit confused...lets back up....is there some reason this needs to be in a module rather than in the actual edit_order.php or edit_order_ajax.php file which is working nicely at this point?  Would it be easier just to make the changes you want to either of those files?   If you have it working there you could then pull it out and put it in a module if you want.

 

Dan

Edited by Dan Cole
Link to comment
Share on other sites

Here is the problem (for anyone who wants to help).

In "includes/modules/order_total" you have :
- ot_total.php :                  'value' => $order->info['total']);
- ot_tax.php :                    'value' => $value);
- ot_total_ht.php (mine) :   'value' => $order->info['total'] - $value);
 
 
The problem is that Order Editor, to add discount value (ot_custom/discount), use this code in "edit_order(_ajax).php" files :

            $new_order_totals[] = array('title' => $ot_title,
				        'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount
                                        'sort_order' => $j);
            $order->info['total'] += $ot_value;

$order->info['total'] += $ot_value;
 
 
But $order->info['total'] variable is not affected by this add if you try an "echo $order->info['total']" from any order_total module.

So all is needed is to recover/transmit this updated variable to affect $order->info['total'] value from "order_total" modules.
 
But I don't know how to proceed. ^_^'

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

I'm having a problem using the version for OSC 2.3.  I have Discount Codes and Shipping Insurance mods installed.  The Discount Codes work fine.  I can add a coupon on the backend with no issue.  Shipping insurance however will not let me add $1.95 to the field.  This is a pre-populated field on the front end where if a user selects it, it is automatically added.   If I edit the order and add $1.95 to that field it resets it back to $0.  I also cannot add any fields to the order totals by hitting the + even though it is an option.  Does anyone have any ideas as to why this Is happening or how to fix it?

Link to comment
Share on other sites

Here is the problem (for anyone who wants to help).

 

In "includes/modules/order_total" you have :

- ot_total.php :                  'value' => $order->info['total']);

- ot_tax.php :                    'value' => $value);

- ot_total_ht.php (mine) :   'value' => $order->info['total'] - $value);

 

 

The problem is that Order Editor, to add discount value (ot_custom/discount), use this code in "edit_order(_ajax).php" files :

            $new_order_totals[] = array('title' => $ot_title,
				        'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount
                                        'sort_order' => $j);
            $order->info['total'] += $ot_value;

$order->info['total'] += $ot_value;

 

 

But $order->info['total'] variable is not affected by this add if you try an "echo $order->info['total']" from any order_total module.

 

So all is needed is to recover/transmit this updated variable to affect $order->info['total'] value from "order_total" modules.

 

But I don't know how to proceed. ^_^'

 

Gwenn....I'm attaching my modified edit_orders_ajax.php file which I hope will be of some help to you....I was able to adjust the $order->info['total'] like this...

// Add tax to ot_custom bof	- used to adjust the order total			
				if ($order_totals[$i]['code'] == 'ot_total') {
				    if ($tax_to_add < 0) {
						 $order->info['total'] = (($order_totals[$i]['value'] += $tax_to_add) + $coupon_value);
					 }
				   $order_totals[$i]['text'] = $currencies->format($order_totals[$i]['value'], true, $order->info['currency'], $order->info['currency_value']);
                 }
// Add tax to ot_custom eof

The $coupon_value is set a little further on in the code but I don't think you'll need to do that depending on what exactly it is that you are adding to the $order->info['total'].

 

Dan

edit_orders_ajax.zip

Link to comment
Share on other sites

So all is needed is to recover/transmit this updated variable to affect $order->info['total'] value from "order_total" modules.

 

@@milerwan Gwenn....another thought....can you just write the value you want out to the order_totals_table directly?

 

Dan

Link to comment
Share on other sites

Here is the problem (for anyone who wants to help).

 

In "includes/modules/order_total" you have :

- ot_total.php :                  'value' => $order->info['total']);

- ot_tax.php :                    'value' => $value);

- ot_total_ht.php (mine) :   'value' => $order->info['total'] - $value);

 

 

The problem is that Order Editor, to add discount value (ot_custom/discount), use this code in "edit_order(_ajax).php" files :

            $new_order_totals[] = array('title' => $ot_title,
				        'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount
                                        'sort_order' => $j);
            $order->info['total'] += $ot_value;

$order->info['total'] += $ot_value;

 

 

But $order->info['total'] variable is not affected by this add if you try an "echo $order->info['total']" from any order_total module.

 

So all is needed is to recover/transmit this updated variable to affect $order->info['total'] value from "order_total" modules.

 

But I don't know how to proceed. ^_^'

 

@@Dan Cole

 

It's ok, I found the way to have correct calculating of "ot_total_ht" value ($order->info['total_ht']).

 

In "edit_orders.php" and "edit_order_ajax.php" files, add these new occurences between -> // Add ot_total_ht :

				if ($ot_title != '') { //7
// Add ot_total_ht
				  if ($order_totals[$i]['code'] != 'ot_total_ht') {
// Add ot_total_ht
					$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);
												'sort_order' => ((array_key_exists($order_totals[$i]['code'], $sort_order)) ? $sort_order[$order_totals[$i]['code']] : $j));
// Add ot_total_ht
				  } else {
					$new_order_totals[] = array('title' => $ot_title,
												'text' => $currencies->format($order->info['total_ht'], true, $order->info['currency'], $order->info['currency_value']),
												'value' => $order->info['total_ht'],
												'code' => 'ot_total_ht',
//                                                'sort_order' => $j);
												'sort_order' => ((array_key_exists($order_totals[$i]['code'], $sort_order)) ? $sort_order[$order_totals[$i]['code']] : $j));
				  }
// Add ot_total_ht
				  $written_ot_totals_array[] = $ot_class;
				  $written_ot_titles_array[] = $ot_title;
                  $j++;

                } else { //within 7

And a little lower :

            $new_order_totals[] = array('title' => $ot_title,
										'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $ot_value,
// Add ot_discount
//                                        'code' => 'ot_custom_' . $j,
                                        'code' => 'ot_discount',
// Add ot_discount
//                                        'sort_order' => $j);
                                        'sort_order' => ((array_key_exists($order_totals[$i]['code'], $sort_order)) ? $sort_order[$order_totals[$i]['code']] : $j));
            $order->info['total'] += $ot_value;
// Add ot_total_ht 
			reset($order->info['tax_groups']);
			while (list($key, $value) = each($order->info['tax_groups'])) {
			  if ($value != '') {
				$order->info['total_ht'] -= $tax_to_add - $ot_value;
			  } else {
				$order->info['total_ht'] += $ot_value;  
			  }
			}
// Add ot_total_ht
			$written_ot_totals_array[] = $ot_class;
		    $written_ot_titles_array[] = $ot_title;
            $j++;
          } //end 3

Now "ot_total_ht" class is fully supported under Order Editor.  :thumbsup:

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Link to comment
Share on other sites

Now "ot_total_ht" class is fully supported under Order Editor.  :thumbsup:

 

Well done Gwenn.   I'm sure it will be a big help to those who need to display the VAT in the way that you have had to.   :thumbsup: 

 

Dan

Link to comment
Share on other sites

  • 2 weeks later...

Replaced path/filename parameters with actual paths

Although the contribution 7844 is called Order_Editor_for_2.3.4_BS_v1.2.4.1,
I found it is not fully compatible with OsCommerce 2.3.4BS Edge.

In OsCommerce 2.3.4BS Edge, the files catalog/includes/filenames.php and catalog/admin/includes/filenames.php no longer exist.
All path/filename references are supposed to be hard coded

So I edited the files I found via http://addons.oscommerce.com/info/7844
All went well except for the following lines of edit_orders.php:

181:

          if (FILENAME_EMAIL_STATUS !== 'FILENAME_EMAIL_STATUS'     ) {

247

        if (FILENAME_GOOGLE_MAP     !== 'FILENAME_GOOGLE_MAP'     ) {

784

      if ( FILENAME_EMAIL_ORDER_TEXT !== 'FILENAME_EMAIL_ORDER_TEXT' ){	

907

      if ('invoice_pdf.php'    !== 'FILENAME_PDF_INVOICE'    ) {

1128-1141

<!- bof 5.0.8 -->		    
		    <?php if ('invoice_pdf.php'   !== 'FILENAME_PDF_INVOICE'   ) { ?>        			   
       			 <li><?php echo '<a href="' . tep_href_link('invoice_pdf.php',       'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice_pdf.gif', IMAGE_ORDERS_INVOICE) . '</a>'; ?></li>  
			<?php } ?>	
		    <?php if ('packingslip_pdf.php'   !== 'FILENAME_PDF_PACKINGSLIP'   ) { ?>        			   
       			 <li><?php echo '<a href="' . tep_href_link('packingslip_pdf.php',       'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip_pdf.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>'; ?></li>  
			<?php } ?>				
		    <?php if (FILENAME_ORDERS_LABEL   !== 'FILENAME_ORDERS_LABEL'   ) { ?>        			   
       			 <li><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_LABEL,       'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_label.gif', IMAGE_ORDERS_LABEL) . '</a>'; ?></li>  
			<?php } ?>		 				    
		    <?php if (FILENAME_GOOGLE_MAP     !== 'FILENAME_GOOGLE_MAP'     ) { ?>        			   
       			 <li><?php echo '<a href="' . tep_href_link(FILENAME_GOOGLE_MAP,         'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_google_directions.gif', IMAGE_GOOGLE_DIRECTIONS) . '</a>'; ?></li>  
			<?php } ?>	
<!- eof 5.0.8 -->							
     			   

What Should be done with these lines? Help, explain,  please?

So I updated the files asto the best of my knowledge.
I corrected the layout (statement indentation, which was a mess).
I also translated the language file to Dutch

The results are attached.

If you think I did it right, please update the contribution at  http://addons.oscommerce.com/info/7844 using my input?

Best regards

Eveline

Denkster_corrections on 7844_Order_editor_for_2.3.4BS.zip

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...