Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[API]adding promotions with expire date#12013

Merged
GSadee merged 3 commits into
Sylius:masterfrom
arti0090:api-promotions-with-exp-date
Nov 6, 2020
Merged

[API]adding promotions with expire date#12013
GSadee merged 3 commits into
Sylius:masterfrom
arti0090:api-promotions-with-exp-date

Conversation

@arti0090
Copy link
Copy Markdown
Contributor

@arti0090 arti0090 commented Nov 6, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
License MIT

@arti0090 arti0090 added Feature New feature proposals. API APIs related issues and PRs. labels Nov 6, 2020
@arti0090 arti0090 requested a review from a team as a code owner November 6, 2020 09:36
@arti0090 arti0090 force-pushed the api-promotions-with-exp-date branch from 59b7c4e to 0958db2 Compare November 6, 2020 09:52
Comment thread src/Sylius/Behat/Context/Api/Shop/PromotionContext.php Outdated
Comment thread src/Sylius/Behat/Context/Api/Shop/PromotionContext.php Outdated
Comment thread src/Sylius/Behat/Context/Api/Shop/PromotionContext.php Outdated
Comment thread src/Sylius/Bundle/ApiBundle/CommandHandler/Cart/ApplyCouponToCartHandler.php Outdated
@GSadee GSadee merged commit a7ad25b into Sylius:master Nov 6, 2020
@GSadee
Copy link
Copy Markdown
Member

GSadee commented Nov 6, 2020

Thank you, @arti0090! 🎉

{
$response = $this->cartsClient->getLastResponse();

Assert::same($response->getStatusCode(), 500);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

500 is a wrong indicator of wrong coupon code usage. We should add validation to this feature.

Comment on lines +62 to +80
if (null !== $couponUsageLimit) {
Assert::greaterThan($couponUsageLimit, 0, 'Promotion coupon usage has expired');
}

$couponExpireDate = $promotionCoupon->getExpiresAt();

if (null !== $couponExpireDate) {
Assert::greaterThan($couponExpireDate, new DateTime(), 'Promotion coupon has expired');
}

$promotion = $promotionCoupon->getPromotion();

Assert::notNull($promotion, 'Could not find promotion linked with this coupon');

$promotionEndDate = $promotion->getEndsAt();

if (null !== $promotionEndDate) {
Assert::greaterThan($promotionEndDate, new DateTime(), 'Promotion has expired');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have to check all these things to perform this action? Most of it seems to be related to validation and processing logic.

GSadee added a commit that referenced this pull request Nov 11, 2020
This PR was merged into the 1.9-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | #12013 like this but better 
| License         | MIT


Commits
-------

071b43e changed way how it is validated
1d5617e fixed issues and changed validator logic
e5e252f Fixed minor issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API APIs related issues and PRs. Feature New feature proposals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants