Author Topic: Order Edit Addon  (Read 53361 times)

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Order Edit Addon
« on: January 30, 2006, 16:08:52 pm »
Mod Note: this topic deals with an earlier version of the Order Edit Addon. You can find an active project dealing with this on our project management tools: Order Edit Addon.


This addon will enable you to edit orders in the adminpages

It will show up as a new tab right beside "Order Status Change" and "Order History".

It will allow you to Change Shpping rate, Shipping tax, Change Discount, Coupon Discount and the qunatity of the order items.

It will not allow you to add new items to the order, because of limitations in the virtuemart database.

Installtion:

1. Download the attached file
2. Gunzip it
3. Put it in your administrator/components/com_virtuemart/classes directory
4. Edit administrator/components/com_virtuemart/html/order.order_print.php
5. Replace the line

$tab->endPane();

with

require_once(CLASSPATH.'ps_order_edit.php');
$tab->endPane();   

6. Done..


Report bugs here.. Use with caution.. I have not fully tested it yet... So consider it a beta release..

[attachment cleanup by admin]

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Order Edit Addon
« Reply #1 on: January 31, 2006, 19:14:37 pm »
Seems to working ;) Thanks, I just needed it!
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

deneb

  • Full Member
  • ***
  • Posts: 654
Re: Order Edit Addon
« Reply #2 on: February 02, 2006, 06:26:50 am »
This is a nice addon.
Super easy to install! I like the logic of the class file. It also updates the tables for use in the print view.

Allow me to critique:
you did use 'jos_vm' in some of your SQL statements...what if my db prefix is different? (which mine is: mos_)
it should be '#__{vm}' to account for this?

1)Item Quantity: changing the item quantity works good for that line item only. it updates the quantity and the line item total. it does not update the cart subtotal, nor the grand total. even with zero entered.

2)Shipping and Handling Fee shipping fee add or change works good and updates the grand total, except for the following: a) if a non-numeric is entered it updates the order with zero amount for shipping. can you make it so the shipping stays the same as it was before the false entry? b) minor item: It does not update the db with the new shipping_rate_id. so the Shipping Information portion of the report is not correct. And how does this affect the shipping tax?

3)Shipping Taxshipping tax add or change works good and updates the grand total.

4)Coupon Discount does not seem to work...maybe due to SQL table prefix issue? does it add one if there was not an original coupon on the order?

5)Discount does not seem to work...maybe due to SQL table prefix issue? how is the discount applied again? cart grand total percentage or flat amt?

Okay, i'm so curious at this point ...i try replacing  'jos_vm' with '#__{vm}'

* now the Item Quantity update works but tax is not updated.
* Shipping Fee works but no shipping tax update, if applicable. i guess this would be entered manually.
* somehow i've managed to erase the tax (not shipping tax) from view, yet it is still in the grand total.
* oooooh nice coupon discount add on, ok it works now. this will be handy!
* the regular discount does not seem to work.

All in all, it needs more work but, This is promising!

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #3 on: February 02, 2006, 10:14:40 am »
Allow me to critique:
you did use 'jos_vm' in some of your SQL statements...what if my db prefix is different? (which mine is: mos_)
it should be '#__{vm}' to account for this?

I have attached a new version where this is fixed.

1)Item Quantity: changing the item quantity works good for that line item only. it updates the quantity and the line item total. it does not update the cart subtotal, nor the grand total. even with zero entered.

This is a jos_vm bug.. If you edit the file and change to #__{vm} it should work.

2)Shipping and Handling Fee shipping fee add or change works good and updates the grand total, except for the following: a) if a non-numeric is entered it updates the order with zero amount for shipping. can you make it so the shipping stays the same as it was before the false entry? b) minor item: It does not update the db with the new shipping_rate_id. so the Shipping Information portion of the report is not correct. And how does this affect the shipping tax?

Good point, will fix so that the old value is used insted of 0 when I get som spare time.
Well the way it works is that you set your own shipping and tax in the order table.. shipping info is not change.
I should probably use a dropdown menu of shipping rates insted of two input text boxes.. I'll have a look at that too later on when I get some spare time (I would guess this weekend)

3)Shipping Taxshipping tax add or change works good and updates the grand total.

This should not be a text input box, it should use the value of the comming dropdownbox.

4)Coupon Discount does not seem to work...maybe due to SQL table prefix issue? does it add one if there was not an original coupon on the order?

This is a jos_vm bug.. If you edit the file and change to #__{vm} it should work.

5)Discount does not seem to work...maybe due to SQL table prefix issue? how is the discount applied again? cart grand total percentage or flat amt?

This is a jos_vm bug.. If you edit the file and change to #__{vm} it should work.

The largest problem with editing a order is that there is no information stored about the discounts of an order exept the value.. So I have no way of knowing if it was a 5% discount or a 10%.. or even a fixed value..
So I can never recalculate the discounts when the order is changed.. so the discouonts remain the same fixed value. (Unless you change it by hand)

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #4 on: February 02, 2006, 22:25:07 pm »
I have now changed so if standard shipping is used then a dropdown box with all shipping rates will show up..

deneb

  • Full Member
  • ***
  • Posts: 654
Re: Order Edit Addon
« Reply #5 on: February 03, 2006, 20:20:11 pm »
Hey Mr_Smurf,

I have applied the latest version of this addon. Just to try and debug this sucker. I know it is difficult to account for all possible scenarios...I am having issues with the tax stuff; shipping tax and order tax.

shipping tax
============
On orders with standard_shipping where the shipping drop-down displays, came up as blank form (no selections available.)

order tax
==============
when adjusting the quantity of a product, the order tax is not recalculated and updated. Actually it removes tax from the orders table field: order_tax, but leaves the original tax in the grand total.


My configuration
-----------------------
My store is set to base tax off of the ship-to address, AND, I do NOT charge tax on shipping...only the cart items total after discounts are applied.

My one and only Tax Rate has a tax_rate_id='2', with tax_rate='.0725'. I believe this is how VM comes setup. I just changed the rate, country, and state.

All my products have a product_tax_id='2' set.

All of my shipping rates have a shipping_rate_vat_id='0' set. You have to change this manually in the db anyway, each shipping rate has no place to change the tax id in the VM form.

So, no shipping rates show up because it can't match the tax ids.

debugging attempts
------------------------------
I created an additional tax rate: id: 0, state: FOO, country: FOO, and rate:0

now the shipping rates come up in the form. when selecting one and submit, it properly adjusts shipping charges, but shipping tax is added: shipping rate * my tax rate (.0725). I do not want shipping tax.

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #6 on: February 04, 2006, 10:33:15 am »
now the shipping rates come up in the form. when selecting one and submit, it properly adjusts shipping charges, but shipping tax is added: shipping rate * my tax rate (.0725). I do not want shipping tax.

You can always edit the query and remove all references to shpping tax and taxrates.

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 43
    • UWiX
  • VirtueMart Version: 3.x
Re: Order Edit Addon
« Reply #7 on: February 17, 2006, 23:47:32 pm »
Followed all the install instructions and the tab appears correctly (had to adjust the pane name in order.order_print.php to prevent javascript error though).

But when I change the quantaty of a product it just doesn't change at all. Cannot seem to find the problem.

Any suggestions? Anyone?
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #8 on: February 19, 2006, 22:15:05 pm »
Followed all the install instructions and the tab appears correctly (had to adjust the pane name in order.order_print.php to prevent javascript error though).

But when I change the quantaty of a product it just doesn't change at all. Cannot seem to find the problem.

Any suggestions? Anyone?


Does any of the other updates work like tax and discoount?

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 43
    • UWiX
  • VirtueMart Version: 3.x
Re: Order Edit Addon
« Reply #9 on: February 19, 2006, 23:49:16 pm »
Now that you mention it... No nothing updates at all. What step did I miss in the installation?
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #10 on: February 20, 2006, 09:49:04 am »
The installation is so simple that if the tab shows up, then the installation is ok..

What version of php anv virtuemart are you using?

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 43
    • UWiX
  • VirtueMart Version: 3.x
Re: Order Edit Addon
« Reply #11 on: February 20, 2006, 10:57:39 am »
Testing under PHP 4.3.3 and VirtueMart 1.0.2.

I'll try later this day the pages with the debug function on. Just thought of that possibility...  ::)
I'll let ya know...

Tried the debug option:

Change a quantity from 250 to 260, when pushing the update-button I can see the following variables are given (according to the debug function):

Code: [Select]
$vars: product_quantity=>260
edit_pane=>1
page=>order.order_print
option=>com_virtuemart
func=>
order_item_id=>7
order_id=>5
update_quantity_x=>8
update_quantity_y=>11
8fc79ea3d3d9be91018e834de89c552b=>622daa9eecff57991395877bccad724b
virtuemart=>88bb89bfd554cddea6106f7313292f1d
a97e03ad184a3622b5de2f812c33d28c=>644a464c33741fc2741ad2bcdf44379d
keyword=>
user_info_id=>0

But..... Nothing is changed, really. The quantity still remains on 250! Maybey it's a user-right problem...  does the storeadmin has enough rights? Hmmm... I'll try it with a full administrator account...

Shoot, doesn't make any difference with the administrator account... Now I'm stuck....
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 43
    • UWiX
  • VirtueMart Version: 3.x
Re: Order Edit Addon
« Reply #12 on: February 20, 2006, 12:46:53 pm »
Did a lot of debugging the last hour... It seems the function update_quantity isn't started. I've added several checklines in the function but they don't display at all!

Very weird, everything should be okay in the source. One thing I noticed; the <form> statement points to \administrator\index2.php. Is that correct? It confuses me a bit 'cause the source is working with order.order_print.php and ps_order_edit.php. Well, maybey I'm just staring blind on the <from> line...
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Mr_Smurf

  • Jr. Member
  • **
  • Posts: 94
Re: Order Edit Addon
« Reply #13 on: February 20, 2006, 12:57:11 pm »
What browser are you using?

it seems that your browser does not send the value of the Update button, it only sends the coordiates of where on the image you pressed..

Modifiy the the lines

                if( mosgetparam( $_REQUEST, 'update_quantity' ) != '' )
                        $this->update_quantity();
                elseif( mosgetparam( $_REQUEST, 'update_coupon_discount' ) != '' )
                        $this->update_coupon_discount();
                elseif( mosgetparam( $_REQUEST, 'update_discount' ) != '' )
                        $this->update_discount();
                elseif( mosgetparam( $_REQUEST, 'update_standard_shipping' ) != '' )
                        $this->update_standard_shipping();
                elseif( mosgetparam( $_REQUEST, 'update_shipping' ) != '' )
                        $this->update_shipping();
                elseif( mosgetparam( $_REQUEST, 'update_shipping_tax' ) != '' )
                        $this->update_shipping_tax();         

to


                if( mosgetparam( $_REQUEST, 'update_quantity_x' ) != '' )
                        $this->update_quantity();
                elseif( mosgetparam( $_REQUEST, 'update_coupon_discount_x' ) != '' )
                        $this->update_coupon_discount();
                elseif( mosgetparam( $_REQUEST, 'update_discount_x' ) != '' )
                        $this->update_discount();
                elseif( mosgetparam( $_REQUEST, 'update_standard_shipping_x' ) != '' )
                        $this->update_standard_shipping();
                elseif( mosgetparam( $_REQUEST, 'update_shipping_x' ) != '' )
                        $this->update_shipping();
                elseif( mosgetparam( $_REQUEST, 'update_shipping_tax_x' ) != '' )
                        $this->update_shipping_tax();         




UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 43
    • UWiX
  • VirtueMart Version: 3.x
Re: Order Edit Addon
« Reply #14 on: February 20, 2006, 13:02:47 pm »
Thanx Man, that fixed the problem...  Strange, I'm still trying to understand  :D
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x