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

[Core][Shipping] Fix shipping method choice type #5216

Conversation

Zales0123
Copy link
Member

Q A
Bug fix? yes
New feature? yes
BC breaks? yes
Related tickets
License MIT

There was a problem with ShippingMethodChoiceType, as it didn't use channel to list shipping methods and also not available for channel methods have been... available.
Instead of quick fix, I've rebuild deeply shipping methods resolver logic:

  • ShippingMethodChoiceType uses prioritized registry to get proper shipping methods resolver
  • there are now two shipping methods resolver:
    • resolver from Shipping returns all enabled shipping methods that are eligible (eligibility checker used(
    • resolver from Core returns all enabled shipping methods for shipment order address (zone matcher) and channel

This changes allowed to remove ShippingMethodChoiceType instance from Core. Also it's now highly simple to use own shipping methods resolver (it has to be just implemented and tagged with proper priority).

@pjedrzejewski pjedrzejewski added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). New Feature and removed Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). labels Jun 9, 2016
$methods = $resolver->getSupportedMethods($options['subject']);
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this logic to the "main" methods resolver and inject it here. It will support every shipment and use exactly this logic to get the right methods. (CompositeMethodsResolver as name, wdyt?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure 👍 Less logic in form type is always a good choice 😄

@Zales0123 Zales0123 force-pushed the list-checkout-shipping-methods-also-by-channel branch from 7135621 to 64c3676 Compare June 10, 2016 07:37
if ($this->sharedStorage->has('channel')) {
$channel = $this->sharedStorage->get('channel');
$channel->addShippingMethod($shippingMethod);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This if should be before $this->shippingMethodRepository->add($shippingMethod);. Right now the relation is not flushed in this step.

@Zales0123 Zales0123 force-pushed the list-checkout-shipping-methods-also-by-channel branch from 63c3f07 to d0ee908 Compare June 10, 2016 10:57
@pjedrzejewski pjedrzejewski merged commit db5a8dc into Sylius:master Jun 10, 2016
@pjedrzejewski
Copy link
Member

Nice work Mateusz, thanks!

Note: in separate PR, we could remove the CompositeMethodsResolverInterface - This could be an implementation of ShippingMethodsResolverInterface - no need for new contract. Anyway, this is a minor improvement. 👍

@Zales0123 Zales0123 deleted the list-checkout-shipping-methods-also-by-channel branch October 28, 2016 13:36
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
…methods-also-by-channel

[Core][Shipping] Fix shipping method choice type
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.

None yet

3 participants