Skip to content
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

Get shipping methods already filtered on carriers and countries and weight #41

Conversation

Valerie-Tylski-Vincent
Copy link
Contributor

Some SendCloud contracts have a huge number of shipping methods.
This can be source of memory problems (code is stopped on line 114 of vendor/jouwweb/sendcloud/src/Client.php, because in this case, the result is too heavy to be decoded).

While we can't filter more the result of shipping methods on this endpoint, we can use another endpoint, that is mentionned in this page of SendCloud documentation:
https://api.sendcloud.dev/docs/sendcloud-public-api/branches/v2/shipping-products/operations/list-shipping-products

The body given as response is a list of shipping methods grouped by "shipping products", that have common characteristics. I compared the 2 requests, the shipping IDs returned are the same if we keep the same filters.

The advantage of this endpoint is that we can filter with a lot of parameters (I set only some of possible parameters in Client.php, to avoid encomber the code with unused parameters, but we could add other parameters, depending to user needs).

The disadvantage of this endpoint is that we can't have the prices with it. That's why I named the new function getShippingMethodsWithoutPrice().

Copy link
Member

@villermen villermen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for your interest and contribution! I've got nothing to remark on the implementation of the API call, but have left some suggestions on the approach on a higher level. Let me know if you have questions or can use my assistance in finishing up!

src/Service/ShippingMethodService.php Outdated Show resolved Hide resolved
src/Client.php Outdated Show resolved Hide resolved
src/Client.php Outdated Show resolved Hide resolved
src/Client.php Outdated Show resolved Hide resolved
@villermen
Copy link
Member

@Valerie-Tylski-Vincent Thanks for your diligent work! I pushed some minor adjustments like the one to make $fromCountry a required parameter during manual verification of the changes. Everything seems to work just fine so I will merge and publish a new version shortly.

@villermen villermen merged commit 63d25c1 into Webador:master Dec 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants