Closed (fixed)
Project:
Commerce Point of Sale (POS)
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
24 Sep 2017 at 00:33 UTC
Updated:
13 Feb 2018 at 19:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sorabh.v6Are you talking about parking of orders as we do in D7 version?
Comment #3
smccabe commentedYes sorry, poor wording on my part, was thinking stash like git stash :P
Comment #4
smccabe commentedAlso, this patch will probably have to build off this #2911259: Track current POS order session
Comment #5
sorabh.v6@smccabe Another question, we will use serialised data or session for storing order data?
Comment #6
smccabe commented@sorabh.v6 you don't need to save any of the data, just the order_id, which can be used to reload the order, see the CurrentOrder stuff that got merged recently that tracks the order ID.
Comment #7
sorabh.v6Comment #8
sorabh.v6Comment #9
sorabh.v6@smccabe One last question, should it work on ajax or will it okay without ajax as well?
Comment #10
sorabh.v6The uploaded patch includes code that shows all parked orders in the pos form. It also allows unparking of particular order by clicking on its button, thereby making the current order to the parked state. Please review.
Comment #11
gauravjeet commentedFirst of all, a better UX demands the Retrieve Transaction # button be at the top.
I could not really review the patch functionality because of some issues and errors.
A scenario:
- create a POS order from /admin/commerce/pos
- park it from /admin/commerce/orders/5 (, say order id #5)
- now go back to /admin/commerce/pos
- edit the Order items
- hit save on the right >> this will/should/must not create a new order (not sure)
- click Retrieve Transaction #5
- Order #5 could not be retrieved
Comment #12
sorabh.v6@gauravjeet Not sure what you are trying to say. I applied patch on another d8 installation. And did what you mentioned. Its showing no error. And changing state of order from parked to draft. Please see attached gif -
Comment #13
sorabh.v6Comment #14
subhojit777The patch on #10 is out dated. Needs reroll. I am going to work on it.
Comment #15
subhojit777I have made the reroll but haven't tested it yet. I will have to follow the gif as mentioned in #13 and the steps mentioned in #11
Comment #16
subhojit777This is deprecated. As mentioned by phpstorm.
Comment #17
sorabh.v6@subhojit777 Yeah, it's deprecated. EntityTypeManagerInterface should be used instead. But in many places, we have the dependency for the EntityManagerInterface object.
Comment #18
smccabe commentedWe're going to need a park button right on the main POS screen, I would add it right between "Add Payment" and 'delete' on page one, use the same styling as "delete"
I would also add it to the payment page, put it after "Finish"
The retrieve parked order button I would probably put at the very top, above the Order Item widget, although only show it if there is at least 1 parked order.
As for the deprecated function, I believe we use that multiple places and we should open a separate issue to get it all at once, since it is not being added by this patch, but already exists for this class.
Comment #19
subhojit777Comment #20
subhojit777Comment #21
subhojit777#20 does this:
Comment #22
subhojit777Some observations and might be code improvement.
I observed that, after deleting the last/current order, when I revisit the main POS screen, it itself creates a new order. I am not sure where that logic is written.
Since it always creates a new order, then I think this
return $order_id ? Order::load($order_id) : NULLinsideCurrentOrder::get()can be altered to justreturn Order::load($order_id).And this will save multiple current order checks (#20).
Duplicate current order check.
Duplicate current order check.
Comment #23
subhojit777Covers
as mentioned in #18
Comment #24
subhojit777Covers
as in #18
Comment #25
subhojit777Comment #26
subhojit777#2933884: Remove usage of deprecated entity.manager service
Comment #27
subhojit777Comment #29
subhojit777Comment #30
subhojit777Comment #31
subhojit777Comment #32
subhojit777Do we have to add tests for this parking order feature?
Comment #33
subhojit777From #18:
Forgot to mention this -- The park order operation looks like a button, not like the Delete button. The Delete operation is actually, a link, not a button. We can add a custom style, style with class say
button--secondary, and there we write styles so that the button looks like a link.Please move this ticket to Needs work if you think this is necessary.
Comment #34
smccabe commentedThe button stylings are all over the place in POS and I'm gonna open a separate issue to fix them up all at once and get some consistency.
Comment #35
subhojit777And how about this:
From #32 @smccabe
Comment #36
smccabe commentedI can hear alexpott in the back of my head, yah we should add tests, probably a derivative of the POSForm test, but specific to this functionality. I wouldn't add more to the POSForm directly, since it is already a very large set of tests and this isn't directly related.
Comment #37
smccabe commentedSmall update to this patch to switch the button order so parked is in the correct place. Tests are still needed
Comment #38
subhojit777Will work on the failing tests. Then will add some tests supporting the change.
Comment #39
subhojit777Comment #40
subhojit777The problem was introduced here #2901030: Receipt Printing and should have been addressed there itself.
Comment #41
subhojit777Re #40:
Sorry. My bad. Not sure whether the problem got introduced in #2901030: Receipt Printing, since the tests are passing there. I tracked it from the commit.
Comment #42
subhojit777Comment #43
subhojit777I was expecting to click the button by value
Retrieve Transaction #<order_id>but I couldn't find a way to obtain order id from the test. This can be improved.Comment #44
subhojit777Will add functional tests for these two.
Comment #45
subhojit777quick cooked up version. Still working on it.
Comment #46
subhojit777Comment #47
alexpottI don't think this is working as expected at the moment. When an order is parked we need to create a new order.
I'm not sure that we need this
if. Retrieving an order unparks it.+ $parked_orders = $this->getParkedOrders();
+ if ($parked_orders) {
+ $form['parked'] = [
+ '#type' => 'container',
+ '#weight' => -1,
+ ];
+
+ foreach ($parked_orders as $parked_order) {
+ $form['parked'][$parked_order] = [
+ '#type' => 'submit',
+ '#value' => t('Retrieve Transaction #@id', ['@id' => $parked_order]),
+ '#submit' => ['::parkedTransactionRetrieve'],
+ ];
+ }
+ }
It's super weird to list parked orders at the top of the order screen. How did it work before?
Needs
'#limit_validation_errors' => []or we need validation since parking an empty order makes very little sense.I think parking an order should create a new current order. Basically it should call
\Drupal\commerce_pos\Form\POSForm::clearOrder().Comment #48
alexpottI've just tried out the D7 functionality and the parked orders can be retrieved from order screen but they appear at the bottom (rather than the top) which makes more sense.
Comment #49
alexpottI don't think this is necessary. PosForm::parkOrder() can set the state and save it. And there's never a reason to call isParked() as far as I can see.
Should this park an empty order?
Comment #50
subhojit777Comment #51
subhojit777Re #47:
I checked in Drupal 7. There is no new order created after parking an order. The state is changed. The same is happening in Drupal 8.
I am sure I am missing something obvious here. The Park Order button is not supposed to appear if the order is already parked.
Shawn decided to put this at the top. See #18
I checked the Drupal 7 code. I saw that there the Commerce Order's status is just changed. I do not know whether it is supposed to do it differently in Drupal 8.
Yeah. Makes sense.
Re #49:
I was trying to expose these as APIs. So that in future if there is a need to check whether
CurrentOrderis parked or not, or needs to be parked. Then we can do that from the service itself, rather than calling it from a function.Yes. We should put a check here.
Comment #52
subhojit777Comment #53
alexpott@subhojit777 in Drupal 7 when you a park an order the current order is cleared and you have a fresh order - otherwise what is the point in parking? I've tested this on https://posdemo.acromedia.com and that is exactly what occurs. Once you have this behaviour then the if's are unnecessary. In order to create a blank order you need to create a new order.
Comment #54
subhojit777Comment #55
subhojit777okay made some changes. Still #47.3 and #49 needs to be addressed.
Comment #56
subhojit777I still would want to move this inside
CurrentOrder::park(), so that the logic is in one place. And any other controller can easily park a current order. Please advice.Comment #57
alexpottThis is now not used by real code.
I'm not sure that the CurrentOrder is great class to have. Ideally we'd not have it at all. We'd just use the entity that's already attached to the POSForm. It's state and state introduces a whole interesting class of bugs and we already have form state and we have to keep this in-sync - which introduces another type of bug. Therefore I think we should just ditch this method and do it in the form - this also feels fine because (a) the form is where you interact with parked order (b) the order object already has methods to handle it's state.
Comment #58
subhojit777Comment #59
subhojit777Removed unnecessary code.
Comment #60
subhojit777I noticed that retrieval of a parked order is only possible for an empty current order. This is the behavior of Drupal 7. This is not present in the patch.
Comment #61
subhojit777Comment #62
subhojit777This works. But still, as a foolproof test, it would have been better if we checked this from the backend as well.
I have checked Commerce core tests, and they mostly rely on data from the db.
Comment #63
smccabe commentedMoved retrieving orders to it's own page, it's cleaner and scales better, plus we can use the order lookup stuff we already added.
I also added a few fields to the Parked Order lookup and backported them to the order lookup.
Tests still need work, not all passing.
Comment #65
alexpottSome tidy-ups. I think we need to remove the current order service. We shouldn't need it and using it makes work that we do on this module harder to bring back into the commerce project. All tests pass apart from
Drupal\Tests\commerce_pos_receipt\FunctionalJavascript\PosReceiptTest. I can't work out when this patch is causing that to fail (yet).Comment #66
alexpottlolz. The reason
Drupal\Tests\commerce_pos_receipt\FunctionalJavascript\PosReceiptTestwas failing locally for me was because I had the jQuery.Print library lying around.Comment #67
alexpottHere's just a little bit more tidy up.
Comment #69
smccabe commentedFunctionality all looks good, committing. I do have a couple of follow up questions for my own knowledge though.
Why do we need to build this out and not just use the getPage() like normal?
Also, why the change here, is one better than the other?
Comment #70
alexpottthe first thing is some debug I left in accidentally. I'll remove it with a commit. I just is more useful than a screenshot to see the current page if there are fails - you get the current html.
I converted the css selects to xpath because I found it easier to target the specific row - for some reason
#edit-result > table > tbody > tr:nth-child(1) > td:nth-child(7) > adidn't work.