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

[Promotion] Add FreeProduct promotion #698

Merged
merged 11 commits into from
Jan 18, 2014

Conversation

winzou
Copy link
Contributor

@winzou winzou commented Dec 7, 2013

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 of entity as we don't want to store the full entity in the serialized field configuration of PromotionAction model. Not perfect, but simple.

Feedbacks welcomed.

use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Sylius\Bundle\ResourceBundle\Model\RepositoryInterface;
Copy link
Contributor

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.

@pjedrzejewski
Copy link
Member

Very nice, with few little changes we can make this even more awesome.

  • Rename the promotion action to just "Add product" not "free product".
  • Make the price configurable instead of hardcoded "0", just like you did with the quantity. We can default price to 0 if you wish.

This way we have a more powerful promotion action, with very little effort. What do you think?


return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

php-cs-fixer

@ghost ghost assigned winzou Jan 9, 2014
new Type(array('type' => 'numeric')),
)
))
->add('quantity', 'integer', array(
Copy link
Contributor

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?

Copy link
Contributor Author

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...

@winzou
Copy link
Contributor Author

winzou commented Jan 18, 2014

@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 |
Copy link
Member

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)

Copy link
Contributor Author

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.

pjedrzejewski pushed a commit that referenced this pull request Jan 18, 2014
[Promotion] Add FreeProduct promotion
@pjedrzejewski pjedrzejewski merged commit 57c18fc into Sylius:master Jan 18, 2014
@pjedrzejewski
Copy link
Member

I'll be nice and fix these for you after the merge. Thanks Alexandre! This is very cool feature. :)

@winzou winzou deleted the freeproduct-promotion branch January 19, 2014 06:20
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

5 participants