Skip to content

Create basic checkout permalink w/ products and coupon support#2887

Closed
ajello-meta wants to merge 5 commits intomainfrom
cart-permalink-base
Closed

Create basic checkout permalink w/ products and coupon support#2887
ajello-meta wants to merge 5 commits intomainfrom
cart-permalink-base

Conversation

@ajello-meta
Copy link
Copy Markdown
Contributor

@ajello-meta ajello-meta commented Feb 14, 2025

Changes proposed in this Pull Request:

This PR introduces a custom checkout permalink to the user's WooCommerce store. These changes unlock the ability to build and render a checkout based solely on a URL. Unlike the default /checkout path, the checkout permalink is shareable, as there is no redirect involved and the URL persists. The permalink path is /fb-checkout and takes in the query parameters products= and coupon=, which populates the cart accordingly.

Example Permalink: https://www.example.com/fb-checkout?products=12345:2,23456:1&coupon=10off

The Checkout class is added, which handles the creation and management of checkout permalinks. Key functionalities include:

  • Rewrite Rule Addition: A new rewrite rule is added to handle URLs with the fb-checkout endpoint, enabling the checkout permalink functionality.
  • Query Variables: New query variables (checkout, products, and coupon) are introduced to facilitate the passing of cart data through the URL.
  • Cart Management: The cart is cleared and repopulated based on the products query parameter, which specifies product IDs and quantities.
  • Coupon Application: A coupon code can be applied to the cart using the coupon query parameter.
  • Template Loading: A custom template is loaded to display the checkout permalink page.
  • Rewrite Rules Flushing: Rewrite rules are flushed upon plugin activation and deactivation to ensure the new permalink structure is recognized.

Screenshots:

Screen.Recording.2025-02-14.at.3.27.50.AM.mov

Detailed test instructions:

  1. Test checkout permalink with one product (e.g. `/fb-cart?products=:<#>)
  2. Test checkout permalink with two product (e.g. `/fb-cart?products=:<#>,:<#>)
  3. Test checkout permalink with products and a coupon (e.g. `/fb-cart?products=:<#>,:<#>&coupon=)

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ajello-meta ajello-meta changed the title Create basic cart permalink w/ products and coupon support [WIP] Create basic cart permalink w/ products and coupon support Feb 14, 2025
@ajello-meta ajello-meta changed the title [WIP] Create basic cart permalink w/ products and coupon support [WIP] Create basic checkout permalink w/ products and coupon support Feb 20, 2025
@ajello-meta ajello-meta changed the title [WIP] Create basic checkout permalink w/ products and coupon support Create basic checkout permalink w/ products and coupon support Feb 20, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta merged this pull request in adb2593.

facebook-github-bot pushed a commit that referenced this pull request Mar 11, 2025
Summary:
### Changes proposed in this Pull Request:
This PR introduces an improved UI for the custom checkout permalink of the user's WooCommerce store. These changes renders the custom checkout UI to be exactly the same as the native checkout UI at `/checkout`.

Original template created in #2887.

### Screenshots:
Custom Checkout (Before):
<img width="1724" alt="Screenshot 2025-03-11 at 5 59 44 PM" src="https://github.com/user-attachments/assets/22beb885-b743-4545-9b7f-dac6720be56f" />

Custom Checkout (After):
<img width="1724" alt="Screenshot 2025-03-11 at 5 57 01 PM" src="https://github.com/user-attachments/assets/35203c56-13b9-4c3e-b1bc-df6bd95afd7d" />

Default Checkout:
<img width="1724" alt="Screenshot 2025-03-11 at 5 56 54 PM" src="https://github.com/user-attachments/assets/d44d8071-39b7-4967-bd5f-e5debd7f561b" />

### Detailed test instructions:
1. Test checkout permalink with one product (e.g. `/fb-checkout?products=<ID>:<#>`)
2. Test checkout permalink with two product (e.g. `/fb-checkout?products=<ID>:<#>,<ID>:<#>`)
3. Test checkout permalink with products and a coupon (e.g. `/fb-checkout?products=<ID>:<#>,:<ID>:<#>&coupon=<CODE>`)
4. Test default checkout with products and a coupon (e.g. `/checkout`)

Pull Request resolved: #2930

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!**
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/14918173837908345
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1
https://internalfb.com/intern/testinfra/testrun/12947849000938296

Reviewed By: carterbuce, nrostrow-meta

Differential Revision: D70997308

Pulled By: ajello-meta

fbshipit-source-id: 24f9bec26bd3492c82e268f8deb518b912cd9794
@carterbuce carterbuce mentioned this pull request May 29, 2025
@tzahgr tzahgr mentioned this pull request Jun 4, 2025
facebook-github-bot pushed a commit that referenced this pull request Jun 4, 2025
Summary:
= 3.5.0 - 2025-05-28 =
*  Add - Create basic checkout permalink w/ products and coupon support by ajello-meta in #2887
*  Add - Common Feed Upload Framework by Jmencab in #2875
*  Fix - Fix bug where templates were not loading correctly by ajello-meta in #2915
*  Tweak - Change MICE to use base site url instead of shop url by carterbuce in #2934
*  Tweak - Improve custom checkout UI by ajello-meta in #2930
*  Tweak - Make custom checkout UI mobile compatible by ajello-meta in #2942
*  Fix - Update parsing for Checkout URL Product IDs by carterbuce in #2935
*  Add - Implement dummy logging util by nealweiMeta in #2920
*  Add - Setup cron job for batch logging with global message queue by nealweiMeta in #2924
*  Add - Error log request api activate by nealweiMeta in #2933
*  Add - Log locally with debug mode enabled by nealweiMeta in #2939
*  Add - Ratings and reviews feed upload by nrostrow-meta in #2937
*  Tweak - Feed upload skip logic and logging calls by nrostrow-meta in #2964
*  Add - Add function to fetch feed upload instance by nrostrow-meta in #2970
*  Tweak - Have feed uploads always use feed generator by nrostrow-meta in #2971
*  Tweak - Trigger metadata feed uploads on CPI ID change (post onboarding) by nrostrow-meta in #2995
*  Add - Shipping profile feed upload button by nrostrow-meta in #3140
*  Add - Navigation menu feed upload logic by nrostrow-meta in #3159
*  Fix - Fixing some fclose and logging gaps in the feed upload logic by nrostrow-meta in #3192
*  Add - Enabling navigation menu feed upload and adding manual sync button by nrostrow-meta in #3223
*  Add - Promotions feed upload by carterbuce in #2941
*  Add - Plugin AJAX API Framework by sol-loup in #2928
*  Tweak - Test Infrastructure Enhancement by sol-loup in #2944
*  Add - Implement telemetry logs api by nealweiMeta in #2940
*  Fix -  Make error logging event configurable by nealweiMeta in #2954
*  Add - Implement logging toggle by nealweiMeta in #2959
*  Fix - auto products sync by nealweiMeta in #2978
*  Tweak - Sync products with restriction by nealweiMeta in #2983
*  Fix - Fix use_enhanced_onboarding for legacy connections by carterbuce in #2986
*  Add - Create enhanced settings UI by ajello-meta in #2968
*  Add - Create new troubleshooting drawer from legacy debug settings by ajello-meta in #2977
*  Add - Add manual product and coupon sync buttons by ajello-meta in #2984
*  Tweak - Make page title in enhanced settings static by ajello-meta in #2985
*  Tweak - Align finalized content for logging toggle by nealweiMeta in #2992
*  Tweak - Improve local log by nealweiMeta in #3009
*  Fix - Fix free shipping coupon sync by carterbuce in #2993
*  Tweak - Add logging for feed generation scheduling failure by carterbuce in #2994
*  Tweak - Add logging in checkout for coupon code by ajello-meta in #2991
*  Tweak - Clean up CSS in enhanced settings UI by ajello-meta in #2996
*  Tweak - Remove the "Advertise" tab by ajello-meta in #3024
*  Tweak - Sync "Usage Count" in Promos Feed by carterbuce in #3036
*  Tweak - Disable mini_shops product capability for unsupported items by carterbuce in #3084
*  Add - Add usage logging for enhanced settings tabs by ajello-meta in #3202
*  Tweak - Remove UI of a checkbox that controls enablement of the new style feed generation by mshymon in #3056
*  Fix - Fix linter errors for ./includes/fbutils.php files by ajello-meta in #3075
*  Fix - Hotfix for Rollout Switches by vinkmeta in #3236
*  Add - Opt out sync experience. by SayanPandey in #3220
*  Fix - Added a transient flag to avoid flooding of product set api requests by vinkmeta in #3245
*  Fix - Additional check for the opt-out banner by SayanPandey in #3259
*  Fix - Bump up GraphAPI version to 21 by vahidkay-meta in #3219
*  Fix - fix linter errors for ./class-wc-facebookcommerce.php by ajello-meta in #3255
*  Fix - fix linter errors for ./facebook-commerce-events-tracker.php by ajello-meta in #3254
*  Fix - fix linter errors for ./includes/Admin/Settings_Screens/Advertise.php by ajello-meta in #3237
*  Fix - fix linter errors for ./includes/Admin/Settings_Screens/Product_Sync.php by ajello-meta in #3239
*  Fix - fix function return typing for get_settings() by ajello-meta in #3257
*  Tweak - Addition check for opt out by SayanPandey in #3259
*  Tweak - Update the GraphAPI version to 21 by vahidkay-meta in #3219
*  Fix - Enabled rollout switch only for plugin admins by vinkmeta in #3242
*  Add - reset connection functionality by jczhuoMeta in #3262
*  Fix - fixing the non static method called as static issue by SayanPandey in #3263
*  Fix - Fix linter errors for ./facebook-commerce.php by ajello-meta in #3251

Pull Request resolved: #3264

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!**
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V7
https://internalfb.com/intern/testinfra/testrun/10414574226197703
MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V7
https://internalfb.com/intern/testinfra/testrun/844425351364266

Reviewed By: vinkmeta, nrostrow-meta

Differential Revision: D75569981

Pulled By: carterbuce

fbshipit-source-id: 11bb39a9d66dfcbc80af413466feef0792d27ce4
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.

2 participants