-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shipment labels for multiple pieces #12
Comments
We should take the following steps to tackle this issue:
Above steps can be done without changing the current behavior. |
It would also be nice to have some methods for convenience like: function barcodes(): array
function labelIds(): array Backwards compatibility: function getBarcodeAttribute(): string
function getLabalIdAttribute(): string The latter would also be nice to have in case you are creating a shipment with just one piece (I am doing this most of the time). In this way you don't have to deal with the array of |
I would opt against this, it shouldn't matter in the code if you have a single piece or multiple pieces in a shipment. Having two code paths for two identical situations (from a technical point of view) introduces duplicate code and code smell. Why would you make your code only work most of the time? Most of the time you have 1 piece, but not all of the time. Since code should work all of the time and not most of the time, it should handle a collection of pieces in a shipment. Since the collection can have 1 item in it, it works perfectly fine all of the time. Not having to 'deal' with an array of piece items seems like an unavoidable reality and to me doesn't seem like that big of a thing to deal with. |
@mvdnbrk I'm not a fan of magic methods, because there is no autocompletion for magic methods in any ide. If you wan't to have a method to get the first item of an array, maybe we should make a ResourceCollection which should implement a first() method. I my opinion we should not worry about backwards compatibility, until we reach version 1.0. We should introduce breaking changes if necessary to create a solid base to work with. |
In my opinion it should be in seperate classes |
The |
@Thorry84 I would do something like this. public function getBarcode()
{
return $this->pieces->first()->tracker_code;
} So you can simply do Most of us will create a shipment with just one piece almost anytime I guess. Side note: I thought creating multiple pieces would create a multi collo shipment. |
@mvdnbrk I don't think that is a good idea. You should provide only one way to retrieve the tracking codes so it doesn't lead to confusion and it is easier to maintain. In your case it is easier to have a |
@jacobdekeizer You won't create a separate parcel for each item in an order will you? Typically an order = one parcel. |
@mvdnbrk An order can have multiple products which can be shipped as multiple pieces. It depends on the size of the product. |
@jacobdekeizer Makes sense 😄 |
My 2 cents: In all use cases I've seen we don't know in advance how many pieces there will be. I guess in most cases it will be 1 piece, but it could be multiple pieces. Since we don't know we should make sure the code handles multiple pieces at any time. I agree with @jacobdekeizer a single code path is the way to go. Breaking backwards compatibility isn't something to get hung up on. I would consider it a nice to have, only if it doesn't make the code worse in any way. People can always lock a version or make their own branch if backwards compatibility matters to them. |
I'd be interested in this feature as well, sometimes I need to have 2-3labels for one shipment, it would be great if I could add the quantity and the pieceNumber (or if it would be handled automatically) |
@jacobdekeizer I have merged in your PR #10.
We should still address the issue with shipment labels for a parcel with multiple pieces.
The text was updated successfully, but these errors were encountered: