Closed (fixed)
Project:
Commerce Point of Sale (POS)
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
4 Sep 2017 at 06:36 UTC
Updated:
5 Dec 2017 at 00:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rigids commentedComment #3
smccabe commentedI added some config to use the basic order options, but this still needs to be done properly to match 7.x functionality.
Comment #4
rakesh.gectcrTalked to Shawn on DrupalCon Vienna Gonna work on it.
Comment #5
rakesh.gectcr@Shawn I am able to ge the auto complete Field widget with image (For the database search Alpha1 and Alpha2 will be search_api lik we discussed). for the entity_reference field type. Can you please direct me how to include this into the POSForm::
i will give the widget patch tomorrow. Was trying to figure out the POSForm:: Its getting little complicated. Kindly please direct me.
Comment #6
rakesh.gectcrLooks like it is coming from
core.entity_form_display.commerce_order.pos.default.ymlStill I am not clear.Comment #7
rakesh.gectcrJust Uploaded the very rough patch of the work. Will be working tomorrow as well,
TODO: lot of things
1) Correct template to show the searching data(Title, image, price)
2) Add to the current order link
3) Filter with the current store.
4) Search API will be a separate issue. First I will complete with the Database API then search API
Comment #8
rakesh.gectcrJust checking for the test
Comment #9
rakesh.gectcrThings are Done.
1) Auto Complete Widget for field
2) On the Close of Autocomplete. product will be automatically get added to Order / Cart. Sot it will be easy while doing the scanning also
Pending,
1) Theming for the widget
2) Filtering the product from the store.
@shawn please take a look at the patch.
Comment #10
smccabe commentedOverall the architecture seems good, a couple designs flaws though, noted below.
You're mixed up again with using the correct order. POS orders don't use "carts" you want to use the POS currentOrder service to get the active POS order, not the cart manager, which is for frontend orders that customers make themselves.
When displaying products, everything in the POS uses product variations directly, not the product unless needed for extra info like description or image. For example, if i look up "shirt" it is going to show me all the variations of the shirt, small, medium, large, blue, green, red, etc. I then can add the specific one, I don't just want the overall product and then have to pick a bunch of options, thats too slow. If you look closely at the 7.x version, you'll see it's going direct as well.
Comment #11
gauravjeet commentedYup, agree with smccabe's comment above. interdiff attached - this will show up product variations instead of product bundle itself.
Existing error: The Order Item widget has some issues while saving.
Caution: This change may not show product title in the absence of product attributes! so, a repeat of product title for different variations do not seem to be a good idea. Have to think of something better here.
Comment #12
rakesh.gectcrPlease review.
Comment #13
smccabe commented#12 wouldn't load a register correctly if already set, updated patch fixes that and also adds type hint for variation.
I was still unable to actually add a product though, would just highlight red and error, not sure of cause yet.
Comment #15
smccabe commentedlast patch was wrong, was missing new files, correct patch added.
Comment #16
smccabe commentedWIP Patch, removes a bunch of the default formatting so we can style it better in the future, will still need to add proper theme/twig hook eventually. Also I changed some of the logic from using a product, to product variation, as thats what it should be using.
The main problem I am currently struggling with is converting the product variation to an order item in the right place. I tried adding a process callback to the element, but it causes the autocomplete to no longer get called for some reason. Doing it in the autocomplete is too soon, as it involves saving a lot of order_items that may never get used. Adding it to the POSForm #submit seemed too hacky, as then the widget isn't usable anywhere else and there must be a better way.
Possible solutions:
Note: I used Inline Entity Form and Entity Autocomplete (core) as references for this, which helped but I got hungup on the creating the order_item, as autocomplete is too simple and IEF too complex.
Outstanding
Comment #17
rakesh.gectcrWhen I am trying to apply above patch, I am getting the following error,
Comment #18
rob c commentedpatch command gives similar output:
patch -p1 --dry-run < 2906515-16.patch
checking file commerce_pos.libraries.yml
Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED
checking file commerce_pos.routing.yml
checking file js/commerce_pos_widget.js
checking file src/Controller/AutoCompleteAddOrder.php
checking file src/Controller/PosOrderItemAutoComplete.php
checking file src/Form/POSForm.php
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] y
Hunk #1 FAILED at 77.
1 out of 1 hunk FAILED
checking file src/Plugin/Field/FieldWidget/PosOrderItemWidget.php
Rerolled the patch to apply to HEAD again. No further changes.
Comment #19
alexpottHere's some work-in-progress. The widget is working to add purchasable items as order items to the order. It is using auto-complete and the order form is automatically updating once the order item has been added. I've also added a script that can be run using
drush scrthat sets up a commerce site for testing this - ie. it creates a store, some products and variations.Still need to work on:
The theming is going to be using view modes. The current patch allows you to select a view mode for autocomplete product selection and also for how the order items are viewed.
Comment #20
alexpottMoved over to just using #ajax for all the processing - so no custom js or routes to update the order form.
Added buttons to increase and decrease quantity but they're not working quite right when you have more than one order item.
Comment #21
smccabe commentedComment #22
alexpottAdded a javascript test and moved some of the ajax processing around. This is definitely ready for reviews now.
Comment #23
alexpottSome code clean up.
Going to investigate why no tests running.
Comment #24
alexpottI see... I was adding a fixture to make it easy for people / myself to set up a site for commerce_pos testing. Unfortunately run-tests.sh was not able to work out it is not a test :( - removing the fixture for now.
Comment #25
smccabe commentedOverall works great, just a few display improvements to make 7.x parity
Turn SKU into link, remove label
Show unit price and make editable
Show adjustment option (possibly split this out into separate issue if it isn't easy)
Also minor, but there are a number of code sniff violations on the patch.
Note: we should create a follow up styling issue for this widget once this patch gets merged in.
Comment #26
alexpottHere's some coding standards fixes.
Going to work on "making the order item unit price editable".
Comment #27
alexpottSo making the unit price editable and work nicely has been held up by the discovery of #2923388: Add #ajax support to the commerce_price form element
Comment #28
alexpottI've moved the order items into a table - this will make it way easier to theme and I've move the quantity into a field. The latter brings up the point that maybe we just want to rely on HTML5 number fields for the + and - buttons since modern browsers will just add them to the number field. Also patch disables the ability to change the unit price because we're waiting on #2923388: Add #ajax support to the commerce_price form element. Tasks to bring this up to the same level as the Drupal 7 version is to handle adjustments and to add the ability to remove an order item with a single click.
I've left all the plumbing in for unit price changing including the tests so some code is commented out in the test but I think that is simpler.
Comment #29
alexpottI've added the remove button and the removing the + and - for quantity as I don't think there is any need to maintain this. I've opened #2924956: Handle adjustments on POS form for fixing and testing adjustments.
One question for usability - should we default the minimum quantity to 1 so the only way to remove an order item is to click on the remove button. I think that that might make for better usability. Amazon's order form in the UK works this way but we are dealing with a different level of access to the system here and sometimes for cashiers speed is everything.
Comment #30
smccabe commentedAgree on the usability of not letting you minus below 1 and handling that with a remove. I will split that into a separate issue though as we've already got quite a big patch here and follow ups are better.
Comment #32
smccabe commentedTested and review, all seemed to work well. Commited!
Thanks to everyone who bashed there head against this, it took a bit to come to the right solution.