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

feat: add option for a button after checkout #1521

Merged
merged 11 commits into from
Oct 3, 2023

Conversation

leogermani
Copy link
Contributor

@leogermani leogermani commented Aug 30, 2023

All Submissions:

Changes proposed in this Pull Request:

Implements an optional link to click after the transaction is complete on the modal checkout.

The button supports linking to the page referrer (which falls back to the current page URL if the referrer is empty) or a custom URL.

image

How to test the changes in this Pull Request:

  1. Checkout this branch and feat(woocommerce): thank you template hook newspack-theme#2180
  2. Add a checkout button to a page
  3. Select the option to go to the Referrer after purchase and add a button label
  4. Add a link to this page in the site menu
  5. Visit an article
  6. Go to the page via the menu link
  7. Click the button and buy the product
  8. Confirm the button shows up in the thank you message and link back to the article you were seeing
  9. In a new tab, copy and paste the page URL directly into the browser so you get no referrer
  10. Make the purchase again and confirm the button links to the current page
  11. Edit the button and choose to go to a custom URL
  12. Repeat the purchase and confirm the button now takes you to that URL
  13. Edit the button again and choose not to show the button
  14. Purchase again and confirm there is no button in the thank you message

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo force-pushed the feat/modal-checkout-after-success-button branch from 53690bd to d25e537 Compare September 20, 2023 22:26
@miguelpeixe miguelpeixe marked this pull request as ready for review September 22, 2023 18:22
@miguelpeixe miguelpeixe requested a review from a team as a code owner September 22, 2023 18:22
Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

When the custom URL field is never set, the button will not be displayed. To reproduce:

  1. Insert the checkout button on a page, choose "Go to referrer page" option
  2. Observe that the button is not rendered after checkout
  3. Back in the editor, choose "Go to a custom URL" option and fill in a URL. Save and edit again, choosing "Go to referrer page". Save again.
  4. Observe the button is rendered after checkout

options={ [
{ label: __( 'Do not show a button', 'newspack-blocks' ), value: '' },
{ label: __( 'Go to a custom URL', 'newspack-blocks' ), value: 'custom' },
{ label: __( 'Go to the referrer page', 'newspack-blocks' ), value: 'referrer' },
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: "previous page" might be more understandable for non-technical people.

Copy link
Member

Choose a reason for hiding this comment

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

Updated in 4325f94

@miguelpeixe
Copy link
Member

Do you think we should render the button linked to the current page when the URL is not filled?

@adekbadek
Copy link
Member

I think that without the URL set, the button should just close the modal. But the issue I'm describing is about something else: according to the testing instructions, if the URL is not filled and "Go to referrer page" is set, the button should be rendered and link to the referrer. And it's not, under conditions described in my review.

@miguelpeixe
Copy link
Member

Ah, sorry for the confusion. I was able to reproduce the issue.

4c514ae changes the block save to render the URL input if the afterSuccessBehavior is set, fixing the issue. I'm not rendering the inputs at all times because it causes a markup mismatch for existing blocks, requiring "attempt block recovery".

Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Left a wording suggestion.

@miguelpeixe miguelpeixe merged commit bdfb3c2 into master Oct 3, 2023
@miguelpeixe miguelpeixe deleted the feat/modal-checkout-after-success-button branch October 3, 2023 14:36
matticbot pushed a commit that referenced this pull request Oct 16, 2023
# [2.0.0-alpha.1](v1.75.5...v2.0.0-alpha.1) (2023-10-16)

### Bug Fixes

* **donate:** allow "once" in tiers-based layout ([ad7268a](ad7268a))
* **homepage-posts:** check existing "specific posts" recursively for deduplication ([#1541](#1541)) ([9755e40](9755e40))
* newspack.pub > newspack.com ([#1552](#1552)) ([343b80b](343b80b))

### Features

* add option for a button after checkout ([#1521](#1521)) ([bdfb3c2](bdfb3c2))
* **homepage-posts:** support deduplication toggling ([#1543](#1543)) ([6acc719](6acc719))
* remove AMP compatibility ([27ecf88](27ecf88))

### BREAKING CHANGES

* AMP will not be supported anymore by this plugin.
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Oct 31, 2023
# [2.0.0](v1.75.6...v2.0.0) (2023-10-31)

### Bug Fixes

* **donate:** allow "once" in tiers-based layout ([ad7268a](ad7268a))
* **homepage-posts:** check existing "specific posts" recursively for deduplication ([#1541](#1541)) ([9755e40](9755e40))
* newspack.pub > newspack.com ([#1552](#1552)) ([343b80b](343b80b))
* update WC's variation methods ([860f9fa](860f9fa))

### Features

* add option for a button after checkout ([#1521](#1521)) ([bdfb3c2](bdfb3c2))
* **homepage-posts:** support deduplication toggling ([#1543](#1543)) ([6acc719](6acc719))
* **modal checkout:** post-checkout newsletter signup ([#1561](#1561)) ([092007a](092007a))
* **modal-checkout:** implement ras overlay ([#1562](#1562)) ([8270c9b](8270c9b))
* remove AMP compatibility ([27ecf88](27ecf88))

### BREAKING CHANGES

* AMP will not be supported anymore by this plugin.
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants