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

product should not be priceless #11863

Conversation

abdellani
Copy link
Member

@abdellani abdellani commented Nov 27, 2023

What? Why?

What should we test?

4 things:

  1. create a product with price = blank using 'create' button
  2. create a product with price = blank using 'create and add another' button
  3. try to set the variant price to blank and click on 'update',
  4. after step 3, you should see the error messages (before this PR, it was not working)
  5. try cloning products
  6. try importing products

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

@abdellani abdellani force-pushed the 11862-fix-product-shoud-not-be-priceless branch from 267f34b to 103621b Compare November 27, 2023 16:18
@drummer83
Copy link
Contributor

@abdellani I know this is still work in progress but I need to ask one question: Will this PR prevent having any products/variants with price = 0?

@openfoodfoundation/train-drivers-product-owners I think there are use cases for free products, like some giveaways or whatever.

@abdellani
Copy link
Member Author

Will this PR prevent having any products/variants with price = 0?

that's what I understood from the issue description.

I don't think it'll make sense to prevent creating a product with a price=0, without preventing the variant's price from being 0.
In the end, the product's price will be stored on the variant that will be created automatically.

@RachL
Copy link
Contributor

RachL commented Nov 28, 2023

@abdellani I've just reproduced it and the problem in shopfronts happens when price is empty, not when price is equal to 0. Can we prevent empty prices and keep prices = to 0 ?

Basically it's about having prices as mandatory fields.

with redirect_to, the validation errors will be lost at the rendering time.
@abdellani abdellani force-pushed the 11862-fix-product-shoud-not-be-priceless branch from 103621b to a13e087 Compare November 28, 2023 12:45
@abdellani abdellani marked this pull request as ready for review November 28, 2023 15:11
@abdellani abdellani force-pushed the 11862-fix-product-shoud-not-be-priceless branch from 813f3de to da90032 Compare November 28, 2023 15:16
@abdellani abdellani self-assigned this Nov 28, 2023
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Good solution. I guess, as alternative, we could have added a presence validation on prices. But this should work for now as well.

filipefurtad0 added a commit to filipefurtad0/openfoodnetwork that referenced this pull request Nov 30, 2023
Enables/disables localization to make the scenario from openfoodfoundation#11863 fail/pass
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Good one 👍

@filipefurtad0 filipefurtad0 self-assigned this Dec 1, 2023
@filipefurtad0 filipefurtad0 added pr-staged-uk staging.openfoodnetwork.org.uk and removed pr-staged-uk staging.openfoodnetwork.org.uk labels Dec 1, 2023
@filipefurtad0
Copy link
Contributor

Hey @abdellani ,

Thanks for this fix 💪

I've tested in staging-UK with the localization option enabled (as described in this comment):

It introduces a validation on /admin/products/new:
(verified with both buttons Create and Create and add another)

image

  • Updating an existing product to have an empty price:

image

  • Saving a cloned product to have an empty price:

image

  • importing a product with empty price info
    image

  • importing a product with 0.0 as price

image

Other scenarios were also verified to allow for zero priced products.

As a quick double check disabled the localization option, which seems to not trigger the bug: all good as expected.

Merging!
Thanks 🎉

@filipefurtad0 filipefurtad0 merged commit f94d2c3 into openfoodfoundation:master Dec 1, 2023
52 checks passed
filipefurtad0 added a commit to filipefurtad0/openfoodnetwork that referenced this pull request Dec 1, 2023
Enables/disables localization to make the scenario from openfoodfoundation#11863 fail/pass
filipefurtad0 added a commit to filipefurtad0/openfoodnetwork that referenced this pull request Dec 1, 2023
@dacook
Copy link
Member

dacook commented Dec 6, 2023

I see that 'technical changes only' was ticked, but the label hasn't been applied. I think this is a user-facing bug so will leave it unlabelled (therefore "user-facing changes").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Priceless product registration
7 participants