-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Promotion] Add FreeProduct promotion #698
Conversation
use Symfony\Component\Validator\Constraints\NotBlank; | ||
use Symfony\Component\Validator\Constraints\Type; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
use Sylius\Bundle\ResourceBundle\Model\RepositoryInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to order this alphabetically.
Very nice, with few little changes we can make this even more awesome.
This way we have a more powerful promotion action, with very little effort. What do you think? |
|
||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php-cs-fixer
Items in cart are not inventory units
new Type(array('type' => 'numeric')), | ||
) | ||
)) | ||
->add('quantity', 'integer', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be price
field shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it but Github weirdly displays your comment at a different place...
@pjedrzejewski good to review & merge |
| Item total | Amount: 100 | | ||
And promotion "Free product" has following actions defined: | ||
| type | configuration | | ||
| Add product | variant:Lenny,quantity:1,price:10 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add spaces here, it should work fine and be more readable. (after the commas)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware of the spaces, I had put them at first try, but there is a str_replace(' ', '_')
somewhere and my quantity
index was changed in _quantity
(leading to some wtf). There must be a trim missing of whatever, I didn't dig into it.
[Promotion] Add FreeProduct promotion
I'll be nice and fix these for you after the merge. Thanks Alexandre! This is very cool feature. :) |
Hi,
Here is my FreeProductAction, that can add a free product to the cart when eligible. (it's actually free variant in the backend)
For the configuration form, I've used a
choice
type instead ofentity
as we don't want to store the full entity in the serialized fieldconfiguration
of PromotionAction model. Not perfect, but simple.Feedbacks welcomed.