Skip to content

Conversation

@barryhughes
Copy link
Member

@barryhughes barryhughes commented Nov 2, 2022

If HPOS is disabled, or COT is no longer authoritative, then requests to access HPOS admin screens should result in redirects to the corresponding legacy order screen.

Closes #35074.

How to test the changes in this Pull Request:

  1. To test, you will first need to setup HPOS—making the custom order tables authoritative and enabling sync (please refer to this PR if you need a primer on how do this). You will also need a number of test orders to play with: if you don't have any existing order data, consider using a tool like WC Smooth Generator for that.
  2. Next, visit WooCommerce ‣ Settings ‣ Advanced ‣ Custom Data Stores and change the data store to the WordPress Posts Table.
  3. Try accessing the HPOS order admin list table at /wp-admin/admin.php?page=wc-orders: you should be redirected to the equivalent order post screen at wp-admin/edit.php?post_type=shop_order.
  4. Repeat, but use a paged URL such as wp-admin/edit.php?post_type=shop_order&paged=3: you should be redirected to /wp-admin/edit.php?paged=3&post_type=shop_order (assuming you have at least 3 pages of order data).
  5. Now try accessing the order editor via the HPOS new order screen at /wp-admin/admin.php?page=wc-orders&action=new: you should be redirected to /wp-admin/post-new.php?post_type=shop_order (simulates manually creating a new order).
  6. Try acessing the order editor for an existing order, using a URL like https://wordpress.lab/wp-admin/admin.php?page=wc-orders&action=edit&id=123: you should be redirected to /wp-admin/post.php?action=edit&post=123 (of course, change 123 to the ID of an actual existing order within your test site).

Now a more advanced test.

  1. Return to WooCommerce ‣ Settings ‣ Advanced ‣ Custom Data Stores and change the data store to the WooCommerce Orders Tables.
  2. Visit the order admin list table at /wc-admin/admin.php?page=wc-orders and select one or more orders, then perform a bulk action such as changing the order status to Completed.
    • You will also need to use your browser's developer tools for this test (if you are using Firefox, I recommend the Network tab with Persist Logs enabled), or some equivalent tool, to capture the initial URL that is created when you do this.
    • Typically, it will take the form /wp-admin/admin.php?page=wc-orders&_wpnonce=ABCDEF&_wp_http_referer=%2Fwp-admin%2Fadmin.php%3Fpage%3Dwc-orders&action=mark_completed&order%5B%5D=1&order%5B%5D=2&action2=mark_completed (but you may also see some extra query parameters in there).
  3. Go back to WooCommerce ‣ Settings ‣ Advanced ‣ Custom Data Stores and change the data store to the WordPress Posts Table.
  4. Now try "re-playing" the URL you captured earlier, but change both instances of mark_completed to mark_processing. An appropriate redirect should take place and the bulk action should be processed, in this case resulting in the two orders being set back to "Processing".

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 created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Nov 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Test Results Summary

Commit SHA: a087d68

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900302621m 7s
E2E Tests186006019213m 59s

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.

@barryhughes barryhughes changed the title Fix/35074 hpos cpt redirects Admin redirects for HPOS URLs Nov 2, 2022
@barryhughes barryhughes marked this pull request as ready for review November 2, 2022 02:33
@barryhughes barryhughes requested review from a team and vedanshujain and removed request for a team November 2, 2022 02:33
Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

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

Great work! Seems to be testing well!

@vedanshujain vedanshujain merged commit 925432a into trunk Nov 3, 2022
@vedanshujain vedanshujain deleted the fix/35074-hpos-cpt-redirects branch November 3, 2022 10:29
@github-actions github-actions bot added this to the 7.2.0 milestone Nov 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2022

Hi @vedanshujain, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

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

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

[HPOS] admin.php?page=wc-orders shows not allowed when CPT is active

3 participants