Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The checkout pane assumes that there’s only a single shipment for now.
It then embeds the entity form for the shipment, starting with the shipping profile field (allowing the user to provide an address).
If someone attached a custom field such as Special Instructions, it would show up as well.
Then it shows the available rates below the entity form.
A followup would be to make the pane ask for a shipping profile, then show an entity form for each shipment with the shipping profile element hidden. That allows for rates per shipment, while still keeping a common shipping profile.
Comment | File | Size | Author |
---|---|---|---|
#14 | commerce_shipping-order_information_pane-2826307-14.patch | 7.05 KB | bmcclure |
Comments
Comment #2
swickham CreditAttribution: swickham at Acro Commerce commentedComment #3
swickham CreditAttribution: swickham at Acro Commerce commentedWork is located in this branch, just an initial commit so far - https://github.com/swickham78/commerce_shipping/tree/shipping_info_pane
Comment #4
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedI've abstracted the changes from GitHub into a patch here that should be able to apply against the latest dev version from d.o. All credit for the work done so far goes to swickham, I just wanted to be able to apply the patch to my version of the module to see where things stand.
Comment #5
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedCorrected filename spelling.
Comment #6
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedActually it seems like perhaps only the checkout pane class itself needs to be added, I believe the changes from the mentioned commit which create commerce_shipping.module aren't needed anymore due to the order fields being modified a different way. Verifying this and will post another patch if that's the case.
Comment #7
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedConfirmed. Here's a patch that has only the checkout pane class itself.
Comment #8
jsacksick CreditAttribution: jsacksick at Centarro for Adapt commentedThis needs to be updated...
You need to check if the order type has the 'order_shippable' trait, in order to do that you need to load the order type.
Furthermore, the shipments field is multiple ('shipments') and should be accessed like this ($this->order->get('shipments').
And I don't think we should create the shipment ourselves if it doesn't exist...
Comment #9
bojanz CreditAttribution: bojanz at Centarro for Adapt commentedI'll take this over once I push the packers.
Comment #10
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedCool, glad to see it's getting some more attention!
I've been working all evening last night trying to get a basic shipping pane fully working with the latest commerce_shipping (with a few other various patches applied from the queue here), and I'm just about there. I'll have another patch likely in a little while today that at least resolves most of the existing issues and offers a shipping pane that works at a basic level.
Not sure how close that'll be to what you guys are envisioning, but it perhaps could be used as a starting point if it's not too far off.
Comment #11
bojanz CreditAttribution: bojanz at Centarro for Adapt commentedOkay, I'll wait for your updated patch. Thank you for your efforts.
Comment #12
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commented@bojanz Are the packers what will create the shipment entities and reference them in the orders, or if not what is (or should be) responsible for that behavior?
I know this probably isn't the best place to discuss that, but if work on that feature is almost done then I probably don't need to spend much more time figuring out how to deal with there being no shipments referenced when the pane is rendered.
Thanks for clarifying!
Comment #13
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedJust answered my own question by reading the task in the issue queue for the packers. Sounds like they'll be what handles creating the shipments before the pane's rendered.
Comment #14
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedI haven't gotten as far as I planned yet, but since it's taking longer I wanted to post my progress.
Here's a new patch which fixes a few of the issues with the shipping pane. It lets you fill in a shipping profile, and I *think* it properly saves it to the shipment upon submitting the form, and properly shows you the profile in the summary on the Review page (previously it was showing the billing profile in the shipping summary).
Since packers aren't here yet, there are two temporary methods in the pane class currently responsible for loading or creating a shipment on an order. Obviously once packers are working, the pane class should not concern itself with creating shipments and both of the private methods should be able to go away.
There are some obviously outstanding items here, apart from any existing bugs, just want to call them out specifically as I've noticed them:
- Need to offer existing shipping profiles rather than requiring a new one to be created each time.
- Shipping method options need to be offered in the pane, particularly if there's more than one available.
- The shipping method options need to refresh after updating the shipping profile information so that new rates can be displayed (I think).
- The selected shipping method needs to be stored when submitting the pane.
- The selected shipping method needs to be displayed in the pane summary on the Review page.
Comment #15
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commented@bojanz You finished packers quickly! Feel free to pick this one up if you're ready, you've got a much clearer vision of what needs to happen here so I should get out of your way for now :)
Comment #16
mikelutzSo, I've been looking into this. Are we attempting to do the entire thing in one pane with Ajax, or are we doing two separate panes, one with shipping information, and a second one on a shipping step with shipping selection, like we do in 7.x.2.x? The second way certainly seems more reliable and easier, but I wasn't sure. There doesn't seem to be a way to add a shipping step to the MultistepDefault checkout flow, so we could create a new flow called MultistepShipping or something that adds an extra step. Then we could gather the shipping information, and on the next page send that and the order to the packer, then to the shippers to get rates and choose one.
Thoughts?
Comment #17
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedPersonally, I like the approach Commerce 2 seems to be taking with the "Order Information" page being where all information is gathered.
I would rather see a shipping method selection populate underneath once you select or create a shipping profile, rather than have to go to another page after entering my address.
This feels like it's in line with much of how the D8 UI works, populating forms within forms using AJAX. Many core and contrib forms seem to use this pattern without appearing to have a separate page to fall back to if JS is disabled, so it seems safe to assume we have access to AJAX. Or is this assumption faulty?
It also feels more modern to me if it's all on a single page with fewer page loads. A shipping method selection form is a very small amount of HTML compared with an entire page, and keeping them together would keep the other order information easily accessible without having to go back and forth between steps.
Ultimately, I don't know how separate steps would function when you've got multiple shipments. Would you choose a shipping profile for each shipment on one step, then shipping method for each on the next step, or would each shipment be its own 2-step workflow? That in itself might be a reason to keep everything in one pane and use AJAX, so that the information can all be presented in a neat and orderly way regardless of the number of shipments.
Comment #18
mikelutzI'm fine with trying to do it on one page, I think it's a cleaner solution. The next question is, how do we determine that there is enough of a shipping profile filled out to attempt to retrieve shipping quotes. Combining that with the possibility of multiple shipments, and it makes for a complex UI.
Looking around the web for inspiration, I think we need to have a button that saves and validates the shipping profile, and renders it uneditable, and loads the shipping options. Clicking a change button to change the profile information would hide the shipping rates again until the profile is finalized. An option for multiple shipments could be worked into the shipping profile form as well, letting you select a shipping profile to use for each item, such that when it is finalized again, we have enough information to create the shipping options for each shipment.
I think this flow would give an opportunity to create a framework that would let us get a patch that supports single shipments to start, but is extensible once that is working as well.
Comment #19
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedI'm all for that idea! I haven't had a chance to get back to this issue since my last patch in #14, but the site I'm working on now is very much in need of a functioning shipping information pane, as well as FedEx integration for it (the port I started recently that's underway).
I'm working through some other priority items on my project at the moment, but any day now I'll be able to pick up trying to help wrapping up anything I can with this shipping information pane if there isn't a working version by then, and then trying to wrap up the FedEx port.
Comment #20
bojanz CreditAttribution: bojanz at Centarro for Adapt commentedI should have the commit up today. It escalated a bit. Stay tuned.
We indeed have a single pane. We show the Shipping profile, then a hidden "Recalculate shipping" button, then the rest (form per shipment).
When the address changes, our JS hits the button, causing the rest of the form to be rebuilt.
You have a setting "Hide shipping costs until an address is entered" that defaults to TRUE.
Comment #21
mikelutzLooking forward to it. I'll find something else to work on.
Comment #22
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedbojanz: That sounds perfect, thanks!
Once I finish some other QA items on a project, I can focus on wrapping up my initial commerce_fedex port and testing it with the upcoming shipping pane work.
Comment #23
mikelutzHow's this one coming? Are there any blockers I can help with, or anything else I can to do contribute, or a partially finished patch I can work with? I appreciate all the work everybody is doing. I'm looking forward to seeing this pane.
Comment #24
bojanz CreditAttribution: bojanz at Centarro for Adapt commentedSorry for the wait, everyone. Here's the commit (well, more like 5 squashed into one :P)
Spent quite a bit of time on tests.
The "recalculate shipping" button currently needs to be manually clicked.
I'll commit the code that hides it + clicks it automatically on address change in a followup.