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] NthOrderRuleChecker should be more strict #1476

Merged
merged 1 commit into from
Sep 30, 2014

Conversation

stloyd
Copy link
Contributor

@stloyd stloyd commented May 8, 2014

No description provided.

@pjedrzejewski
Copy link
Member

Btw. won't this count carts as well? @umpirsky It should count only completed orders, right?

@stloyd
Copy link
Contributor Author

stloyd commented May 8, 2014

@pjedrzejewski No, it can't get carts as only Core\Order can contain user, the only problem you are right is that this don't count completed orders. I will fix this.

@stloyd
Copy link
Contributor Author

stloyd commented May 8, 2014

@pjedrzejewski @umpirsky I guess it's now more correct approach =)

return PaymentInterface::STATE_COMPLETED === $order->getPaymentState();
});

if ($orders->isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? The case where orders is empty is covered by the count === 0, I don't see what this if is adding.

@stloyd
Copy link
Contributor Author

stloyd commented Jul 4, 2014

@pjedrzejewski What do you think about this?

@stloyd
Copy link
Contributor Author

stloyd commented Jul 9, 2014

@pjedrzejewski @umpirsky Any feedback on this?

@@ -285,7 +285,18 @@ public function getPaymentState()
*/
public function setPaymentState($paymentState)
{
$this->paymentState = $paymentState;
if (BasePaymentInterface::STATE_COMPLETED === $paymentState) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not code I would like to see in data model.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's definitely not the right place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@umpirsky @pjedrzejewski Other place where it can be done is probably OrderPaymentCallback::updateOrderOnPayment() or OrderPaymentListener::updateOrderPayment() but I'm not sure which fits better.

@umpirsky
Copy link
Contributor

umpirsky commented Jul 9, 2014

@stloyd Looks good except comment I posted above. 👍


if ($payments->count() === $this->payments->count()) {
$this->paymentState = BasePaymentInterface::STATE_COMPLETED;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@stloyd I don't think this is right. We might have failed payment linked to the order.

IMO we should let OrderPaymentCallback::updateOrderOnPayment() do all the work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I have considered this, but in fact I noticed that we have job duplication in OrderPaymentCallback & OrderProcessing\StateResolver both handle similar case (check of amount in payment & in order, one marks order state, second call state machine).

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, I think we can fix OrderPaymentCallback in another PR.

@stloyd
Copy link
Contributor Author

stloyd commented Sep 30, 2014

@pjedrzejewski ping.

pjedrzejewski pushed a commit that referenced this pull request Sep 30, 2014
[Core] NthOrderRuleChecker should be more strict
@pjedrzejewski pjedrzejewski merged commit 9ee3451 into Sylius:master Sep 30, 2014
@pjedrzejewski
Copy link
Member

Thank you Joseph! 👍

@stloyd stloyd deleted the bugfix/nth_order branch September 30, 2014 11:28
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[Core] NthOrderRuleChecker should be more strict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants