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

[Simple Payments]: Do not duplicate productId on block duplication #20064

Closed
wants to merge 1 commit into from

Conversation

stacimc
Copy link
Contributor

@stacimc stacimc commented Jun 11, 2021

This PR is one possible solution to #12801. It relies on the addition of support for unique block attributes proposed in this (currently open) Gutenberg PR: WordPress/gutenberg#32604.

Fixes #12801

Changes proposed in this Pull Request:

When a Simple Payments block is duplicated, all of its attributes are copied including the productId. This causes the duplicated block to point to the same product resource under the covers -- so if the user then edits the duplicate and saves the post, the edits will (confusingly) be applied to both blocks. This PR resolves the problem by marking the productId attribute of the Simple Payments block as unique so that it is not copied on block duplication.

Now when the block is duplicated, all of its fields (price, title, description, etc) will be copied, but a new product is created on the backend. Edits to each block can be made individually.

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Pull this Gutenberg PR: [Block Attributes]: Add support for non-duplicable block attributes WordPress/gutenberg#32604.
  • Pull this branch in Jetpack
  • Sync both Gutenberg and Jetpack to your sandbox
  • Create a post and insert a Pay with Paypal block. Fill out all of its fields.
  • Duplicate the block. The new block should look identical to the first.
  • Optionally, view the blocks in the Code editor to see their attributes. Verify that they have different values for productId.
  • Edit the fields of the second block.
  • Save the post.
  • Refresh the page; your edits should only be applied to the second block. View the post on the frontend and verify that this true on the frontend as well.

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello stacimc! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D62724-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added [Block] Pay With Paypal aka Simple Payments [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jun 11, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jun 11, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • 🔴 Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


🔴 Action required: Please add missing changelog entries for the following projects: projects/plugins/jetpack

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: July 6, 2021.
  • Scheduled code freeze: June 28, 2021.

@jeherve
Copy link
Member

jeherve commented Jul 28, 2022

Closing this for now because of the lack of activity on this. We can always reopen in the future if needed.

@jeherve jeherve closed this Jul 28, 2022
@jeherve jeherve added the [Feature] Pay with PayPal aka Simple Payments label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Pay With Paypal aka Simple Payments [Feature] Pay with PayPal aka Simple Payments [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simple Payments / Pay with PayPal : Duplicated payment blocks affect original block on save
3 participants