Had a conversation with bojanz in Slack.
The crux of my issue is this paragraph:
The problem I have is that if I create a custom packer to do this [remove items from being packed], then no other packer can ever run on the site, because my packer would have to be the first one that runs. There doesn't seem to be any flexibility there. I'm working with another developer on commerce_fedex, with a custom packer there to handle things such as special packing for dry ice and hazmat shipments. That is a good use case for a custom packer it seems, but I would't be able to use it on my site because I want to remove quote items from being packed and that requires me to take over the entire packing process.
His idea for a potential solution to that:
I guess we could refactor $order->getItems() into a helper method on the DefaultPacker that runs an event afterwards
I just about have a patch ready for testing and further discussion on this issue, as well.
Comment | File | Size | Author |
---|---|---|---|
#10 | 2858724-10.patch | 7.15 KB | bamberjp |
#9 | commerce_shipping-before_packer_event-2858724-9.patch | 3.75 KB | bmcclure |
Comments
Comment #2
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedComment #3
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedPatch for review, creates a CommerceShippingEvents::BEFORE_PACK event.
Comment #4
googletorp CreditAttribution: googletorp at Reveal IT commentedWe need test coverage for this.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedI approve of the approach, but wanted to bikeshed the event name.
Comment #6
googletorp CreditAttribution: googletorp at Reveal IT commentedI feel like we can do better as well, BEFORE_PACK seems a bit weird.
Comment #7
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedMy thinking was that a packer's purpose is to pack, so a natural event system to modify that behavior seems like it would be BEFORE_PACK and AFTER_PACK. However I can definitely see how, outside of the context of a packer, the name doesn't make much sense, and since the name's used globally, maybe something more descriptive would be helpful.
Comment #8
amkloseNot seeing any further discussion on this, I rerolled the patch from #3 to apply to the current 8.x-2.x dev branch.
Comment #9
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedRe-rolling this again for the latest conflicting changes, mainly in DefaultPacker
Comment #10
bamberjp CreditAttribution: bamberjp commentedNot familiar with this issue but noted patch #9 removes BeforePackEvent and CommerceShippingEvents. Not found in current 8.x-2.x-dev.