News:

Looking for documentation? Take a look on our wiki

Main Menu

Can't Save Order Statuses Ordering

Started by jdwire, December 13, 2011, 23:54:10 PM

Previous topic - Next topic

jdwire

I'm using VM2 RC3 Pre-K on Joomla 1.7.3, and when I try to save a new order status in Configuration->Order Statuses, I get an error saying "You cannot change the order of items, as an item in the list is `Checked Out`".

System Information:
Database Version: 5.1.41-3ubuntu12.10
Database Collation: utf8_general_ci
PHP Version: 5.3.2-1ubuntu4.10
Web Server: Apache/2.2.14 (Ubuntu)
WebServer to PHP Interface: apache2handler
Joomla! Version: Joomla! 1.7.3 Stable [ Ember ] 14-Nov-2011 14:00 GMT
Joomla! Platform Version: Joomla Platform 11.2.0 Stable+Modified [ Omar ] 27-Jul-2011 00:00 GMT ::)

Steps to Reproduce:
1. Create new order status under Configuration->Order Status
   Order Status Name: Failed
   Order Status Code: F
   Description: empty
   Vendor: Washupito
   Ordering: New items default to the last place. Ordering can be changed after this item is saved.
2. Save and Close
3. Sort by ordering
4. Type "6" into the ordering field for Failed
5. Click the save icon next to the ordering header.
6. Observe message box saying "You cannot change the order of items, as an item in the list is `Checked Out`"

I believe that this error is caused by "Shipped" and "Pending" not having any checkboxes, and Line 484 of joomla core javascript(/media/system/js/core-uncompressed.js) checks for checkboxes and gives this message if a checkbox does not exist.

As a temporary workaround, I can change the ordering by opening the item and changing the "Ordering Field"

Also, the "Order Status Code" field is disabled when creating a new order, causing the save to fail with "vmError: TableOrderstates Order Status Code in record is missing ! Can't save the record with no Order Status Code.", unless the field is enabled with a html editor.

Milbo

#1
Hmmmm,

the problem is also that it does not make sense to add new order statuses,.. they are anyway whitelisted. When someone actually needs todo something like that then we needa pluginable solution. This view is mostly done just to rename the orderstatuses to the personal taste. The thing is that this is used for a workflow,.. a new orderstatus would just have no workflow.

[Edit: changed and enhanced see http://docs.virtuemart.net/manual/general-concepts/220-orders.html]
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jdwire

#2
I created a new order status ("Failed", Status Code:F) to specify that the payment had failed. In the PayPal payment plugin, there are three fields allowing the user to pick the order status for a pending payment, successful payment, and a failed payment. I created a failed order status to specify that the payment had failed instead of the suggested canceled status which would indicate that the order has been cancelled, and could cause confusion.

To allow changing the order of order status, the following code changes could be made to allow the checkbox to be present, which will let Joomla save the ordering, and to allow entering the status code for new orders.

1. Add remove function to order status model (/administrator/com_virtuemart/models/orderstatus.php) that prevents deletion of core order statuses.

   /**
* removes an order status
*
* @author Joshua Dwire
*/
public function remove($ids) {

$table = $this->getTable($this->_maintablename);

$ok = true;
$vmCoreStatusCodes = $this->getVMCoreStatusCode();
foreach($ids as $id) {
$row = $table->load($id);
//Prevent removal of core order statuses
$coreStatus = (in_array($row->order_status_code, $vmCoreStatusCodes));
if($coreStatus){
$this->setError(JText::_('COM_VIRTUEMART_ORDER_STATUS_CODE_CORE'));
$ok = false;
continue;
}

if (!$table->delete($id)) {
$this->setError($table->getError());
$ok = false;
}
}

return $ok;
}


2. Change order status view (/administrator/components/com_virtuemart/views/orderstatus/tmpl/default.php) to have a hidden checkbox in addition to the lock icon by changing the following code (lines 78-80) from
   $checked = ($coreStatus) ?
[code]'<span class="hasTip" title="'. JText::_('COM_VIRTUEMART_ORDER_STATUS_CODE_CORE').'">'. $image .'</span>' :
JHTML::_('grid.id', $i, $row->virtuemart_orderstate_id);

   to
   $checked = ($coreStatus) ?
[code]'<span class="hasTip" title="'. JText::_('COM_VIRTUEMART_ORDER_STATUS_CODE_CORE').'">'. $image .'</span><span style="display:none">'.JHTML::_('grid.id', $i, $row->virtuemart_orderstate_id).'</div>' :
JHTML::_('grid.id', $i, $row->virtuemart_orderstate_id);

   
3. Allow entering of order status code for new order statuses by changing order status edit view (/administrator/components/com_virtuemart/views/orderstatus/tmpl/edit.php) to make order status code writable for new order statuses by adding
   $isNew = $this->orderStatus->virtuemart_orderstate_id==0;
   on line 33,
   
   and changing line 40 from
   <?php echo VmHTML::row('input','COM_VIRTUEMART_ORDER_STATUS_CODE','order_status_code',$this->orderStatus->order_status_code,'class="inputbox" readonly','',3,1); ?>
   to
   <?php echo VmHTML::row('input','COM_VIRTUEMART_ORDER_STATUS_CODE','order_status_code',$this->orderStatus->order_status_code,'class="inputbox" '.($isNew?'':'readonly'),'',3,1); ?>

4. Code could also be added to the model or table to prevent the changing of order status codes.

These changes would allow new order statuses to be created, but would prevent the deletion of core order status and prevent the changing of order status codes. If you do not want to support new order statuses, I would think that it would be best to show a message explaining this, and/or remove the "New" button, rather than partially supporting new order statuses.

Milbo

People like you should then just manually add the orderstatus.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jdwire

#4
By using a database editor?
Also, this prevents users from using the textboxes to reorder any order statuses.

jdwire

If anyone is interested, I have posted a svn patch file containing these code changes to the "Modifications, Hacks, and Tweaks" forum at http://forum.virtuemart.net/index.php?topic=94988.0.

Jason Farmer

#6
Quote from: jdwire on December 14, 2011, 18:28:24 PM
If anyone is interested, I have posted a svn patch file containing these code changes to the "Modifications, Hacks, and Tweaks" forum at http://forum.virtuemart.net/index.php?topic=94988.0.

Thank you - I can't see why your changes haven't been incorporated yet (using 2.0.10) - useful bug fix to a frustrating issue for many many users. Would be nice to have a fix for shopperfields too :)

[tr][td][/td][td]
Development[/td][td]Production[/td][/tr]
[tr][td]VirtueMart   [/td][td]
2.0.12b
[/td][td]
1.1.3
[/td][/tr]
[tr][td]Joomla!   [/td][td]
2.5.6
[/td][td]
1.5.14
[/td][/tr]
[tr][td]Mysql  [/td][td]
5.5.8
[/td][td]
5.0.51
[/td][/tr]
[tr][td]PhP   [/td][td]
5.3.5
[/td][td]
5.2.4
[/td][/tr]
[/table]

gba

Hi!

QuoteThank you - I can't see why your changes haven't been incorporated yet (using 2.0.10) - useful bug fix to a frustrating issue for many many users. ...

I agree - using v3.0.12.

Kind regards,
Gerald

lindapowers

#8
There was some work done recently here, the order status couldn't be unpublished, now that works.

However is true that changing ordering of order status from backend doesn't work. We did that directly from the database. The bug is present but since you wont be changing order regularly I guess, do it directly from database.



Regards

gba

Hi!

Thank you for your reply.
This is not practicable for non technician store manager.

Kind regards,
Gerald

lindapowers

Hi, im no technician and I did it, nasty but it works. I edited it with the image of the table in phpmyadmin.

Ofc the issues should be solved in backend by the vm team.

Milbo

#11
When you want to reorder, sort first for "ordering", then use the arrows. I just tried it DOES work.

Look at the thread starter 2011. The "fix" was given in 2012, it was anyway solved abstract (vmmodel) and I did the last fix for it in 3.0.12. So it WORKS!
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

lindapowers

Quote from: Milbo on November 12, 2015, 23:50:35 PM
When you want to reorder, sort first for "ordering", then use the arrows. I just tried it DOES work.

Look at the thread starter 2011. The "fix" was given in 2012, it was anyway solved abstract (vmmodel) and I did the last fix for it in 3.0.12. So it WORKS!

Ouch true, it works!

Milbo

It anyway changes only the ordering with the lists and dropdowns. It does not change the function, nor workflow
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gba

Hi all!

Quote from: lindapowers on November 13, 2015, 13:38:31 PM
Ouch true, it works!
You are right - order states having a checkbox ARE reorderable.
But I am sorry  :-\, I cannot confirm, that reordering of order states, which have the padlock instead of the checkbox, is possible - neither with a value in the textbox, nor with the arrow button.

By the way: Is there a special reason, why only the first line has an up AND down button, and the others just an up button?

Kind regards,
Gerald