Repository navigation
fix: add the saas onboarding pattern to the shop, checkout and order received #20
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
Open
YvesCesar
wants to merge
3
commits into
main
Choose a base branch
from
fix/saas-onboarding-pattern
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
888e209
fix: add the saas onboarding pattern to the shop, checkout and order …
YvesCesar c3b4f82
fix: hide the saas onboarding when paying an existing order or receiv…
YvesCesar 24d96f8
fix: hide the saas onboarding when the cart renews, resubscribes or s…
YvesCesar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?php | ||
| /** | ||
| * SaaS onboarding: shown only while buying a new plan. | ||
| * | ||
| * @package libresign | ||
| */ | ||
|
|
||
| defined( 'ABSPATH' ) || exit; | ||
|
|
||
| function libresign_theme_show_saas_onboarding_only_on_new_purchases( $block_content, $block ) { | ||
| $class_names = explode( ' ', $block['attrs']['className'] ?? '' ); | ||
| if ( ! in_array( 'libresign-saas-onboarding', $class_names, true ) ) { | ||
| return $block_content; | ||
| } | ||
|
|
||
| if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'order-pay' ) ) { | ||
| return ''; | ||
| } | ||
|
|
||
| $order_id = absint( get_query_var( 'order-received' ) ); | ||
| if ( $order_id && function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id, array( 'renewal', 'switch', 'resubscribe' ) ) ) { | ||
| return ''; | ||
| } | ||
|
|
||
| if ( libresign_theme_cart_continues_an_existing_subscription() ) { | ||
| return ''; | ||
| } | ||
|
|
||
| return $block_content; | ||
| } | ||
| add_filter( 'render_block_core/group', 'libresign_theme_show_saas_onboarding_only_on_new_purchases', 10, 2 ); | ||
|
|
||
| function libresign_theme_cart_continues_an_existing_subscription() { | ||
| if ( ! function_exists( 'wcs_cart_contains_renewal' ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| return wcs_cart_contains_renewal() || wcs_cart_contains_resubscribe() || wcs_cart_contains_switches(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php | ||
| /** | ||
| * Title: SaaS onboarding | ||
| * Slug: libresign/saas-onboarding | ||
| * Inserter: no | ||
| */ | ||
| ?> | ||
|
|
||
| <!-- wp:group {"align":"wide","className":"libresign-saas-onboarding","style":{"spacing":{"margin":{"bottom":"var:preset|spacing|40"}}},"layout":{"type":"default"}} --> | ||
| <div class="wp-block-group alignwide libresign-saas-onboarding" style="margin-bottom:var(--wp--preset--spacing--40)"> | ||
| <!-- wp:heading {"level":2,"fontSize":"large"} --> | ||
| <h2 class="wp-block-heading has-large-font-size"><?php echo esc_html__( 'How your LibreSign workspace works', 'libresign' ); ?></h2> | ||
| <!-- /wp:heading --> | ||
|
|
||
| <!-- wp:columns --> | ||
| <div class="wp-block-columns"> | ||
| <!-- wp:column --> | ||
| <div class="wp-block-column"> | ||
| <!-- wp:heading {"level":3,"fontSize":"medium"} --> | ||
| <h3 class="wp-block-heading has-medium-font-size"><?php echo esc_html__( '1. Choose a plan', 'libresign' ); ?></h3> | ||
| <!-- /wp:heading --> | ||
|
|
||
| <!-- wp:paragraph --> | ||
| <p><?php echo esc_html__( 'Pick the plan that fits your team.', 'libresign' ); ?></p> | ||
| <!-- /wp:paragraph --> | ||
| </div> | ||
| <!-- /wp:column --> | ||
|
|
||
| <!-- wp:column --> | ||
| <div class="wp-block-column"> | ||
| <!-- wp:heading {"level":3,"fontSize":"medium"} --> | ||
| <h3 class="wp-block-heading has-medium-font-size"><?php echo esc_html__( '2. Create your workspace', 'libresign' ); ?></h3> | ||
| <!-- /wp:heading --> | ||
|
|
||
| <!-- wp:paragraph --> | ||
| <p><?php echo esc_html__( 'Set your email and password and complete the payment.', 'libresign' ); ?></p> | ||
| <!-- /wp:paragraph --> | ||
| </div> | ||
| <!-- /wp:column --> | ||
|
|
||
| <!-- wp:column --> | ||
| <div class="wp-block-column"> | ||
| <!-- wp:heading {"level":3,"fontSize":"medium"} --> | ||
| <h3 class="wp-block-heading has-medium-font-size"><?php echo esc_html__( '3. Start signing', 'libresign' ); ?></h3> | ||
| <!-- /wp:heading --> | ||
|
|
||
| <!-- wp:paragraph --> | ||
| <p><?php echo esc_html__( 'Sign in to LibreSign with the same email and password.', 'libresign' ); ?></p> | ||
| <!-- /wp:paragraph --> | ||
| </div> | ||
| <!-- /wp:column --> | ||
| </div> | ||
| <!-- /wp:columns --> | ||
| </div> | ||
| <!-- /wp:group --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { expect, Page, test } from '@playwright/test'; | ||
|
|
||
| import { addThePlanToTheCart, fillTheBillingAddress, placeOrder } from '../support/store'; | ||
|
|
||
| async function expectTheOnboarding( page: Page ): Promise< void > { | ||
| await expect( page.getByRole( 'heading', { name: 'How your LibreSign workspace works' } ) ).toHaveCount( 1 ); | ||
| await expect( page.getByRole( 'heading', { name: '1. Choose a plan' } ) ).toBeVisible(); | ||
| await expect( page.getByRole( 'heading', { name: '2. Create your workspace' } ) ).toBeVisible(); | ||
| await expect( page.getByRole( 'heading', { name: '3. Start signing' } ) ).toBeVisible(); | ||
| } | ||
|
|
||
| test.describe( 'Showing how the workspace works while buying', () => { | ||
| test( 'on the shop', async ( { page } ) => { | ||
| await page.goto( '/shop/' ); | ||
|
|
||
| await expectTheOnboarding( page ); | ||
| } ); | ||
|
|
||
| test( 'on the checkout', async ( { page } ) => { | ||
| await addThePlanToTheCart( page ); | ||
| await page.goto( '/checkout/' ); | ||
|
|
||
| await expectTheOnboarding( page ); | ||
| } ); | ||
|
|
||
| test( 'on the order received', async ( { page } ) => { | ||
| await addThePlanToTheCart( page ); | ||
| await fillTheBillingAddress( page, 'Brazil', '529.982.247-25' ); | ||
| await page.getByLabel( 'I agree to the terms and privacy policy before placing the order.' ).check(); | ||
| await placeOrder( page ); | ||
|
|
||
| await expect( page ).toHaveURL( /\/order-received\// ); | ||
| await expectTheOnboarding( page ); | ||
| } ); | ||
|
|
||
| test( 'not on other pages', async ( { page } ) => { | ||
| await page.goto( '/product/basic/' ); | ||
|
|
||
| await expect( page.getByRole( 'heading', { name: 'How your LibreSign workspace works' } ) ).toHaveCount( 0 ); | ||
| } ); | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.