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

Initialise customer sessions on the order pay page #43858

Merged
merged 3 commits into from Jan 25, 2024

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Jan 22, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Logged-out customers only have a WooCommerce session initialised when they have a cart. Some pages, such as the order pay page, may require a session outside of the regular cart flow.

To negate the need for extensions to handle this case themselves, this PR sets the session on the order pay page.

Closes #23902

Because I'm not certain what payment gateways/extensions need this, I tested using a small snippet instead to ensure a session was set.

add_action(
	'wp_head',
	function () {
		var_dump( WC()->session->get( 'test_session_data' ) );
	}
);
add_action(
	'wp_footer',
	function () {

		WC()->session->set( 'test_session_data', 'Hello' );
	}
);

This will output Hello in the header after refreshing the page only if a session is set. Otherwise it will show NULL.

How to test the changes in this Pull Request:

Testers only need to test for regressions. Run through the checkout flow as a logged out guest user and ensure there are no errors.

Developer testing

  1. Use the snippet above.
  2. As a logged out guest with no cart (use private browser window if possible) visit the website. You should see NULL at the top of the page indicating there is no session.
  3. Visit the pay page. It can be an invalid link, it doesn't matter. e.g. https://store.local/checkout/order-pay/18/?pay_for_order=true&key=123);
  4. Now refresh or visit another page. See hello in the header instead of null. This means you now have a session.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Fix to ensure all customers have a session when visiting the order pay page.

Comment

@mikejolley mikejolley self-assigned this Jan 22, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 22, 2024
@woocommercebot woocommercebot requested review from a team and tarunvijwani and removed request for a team January 22, 2024 14:40
Copy link
Contributor

Hi @tarunvijwani,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

github-actions bot commented Jan 22, 2024

Test Results Summary

Commit SHA: ece851b

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 36s
E2E Tests241005502966m 44s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@tarunvijwani tarunvijwani left a comment

Choose a reason for hiding this comment

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

Works like a charm! Thank you for the fix, @mikejolley! 🎉

@mikejolley mikejolley merged commit dc6af08 into trunk Jan 25, 2024
34 checks passed
@mikejolley mikejolley deleted the fix/23902-create-session-on-page-page branch January 25, 2024 13:12
@github-actions github-actions bot added this to the 8.7.0 milestone Jan 25, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 25, 2024
@veljkho veljkho added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with credit cards on customer payment link
3 participants