Skip to content

Fixed: if Permalinks > Custom Base was previously modified with WooCommerce enabled, the view-product goal would wrongfully get a 2nd leading slash.#310

Merged
Dan0sz merged 2 commits into
developfrom
woocommerce_custom_base_fix
Jun 23, 2026
Merged

Fixed: if Permalinks > Custom Base was previously modified with WooCommerce enabled, the view-product goal would wrongfully get a 2nd leading slash.#310
Dan0sz merged 2 commits into
developfrom
woocommerce_custom_base_fix

Conversation

@Dan0sz

@Dan0sz Dan0sz commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Improved permalink/path normalization for consistent product URL handling across multisite and non-multisite setups.
    • Reorganized tracking method placement while preserving the existing add-to-cart tracking behavior.

…mmerce enabled, the view-product goal would wrongfully get a 2nd leading slash.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d769a05-70bf-4c54-9ea2-e9d33a111b33

📥 Commits

Reviewing files that changed from the base of the PR and between 34ec288 and 24a610b.

📒 Files selected for processing (1)
  • src/Integrations/WooCommerce.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Integrations/WooCommerce.php

📝 Walkthrough

Walkthrough

In src/Integrations/WooCommerce.php, the constructor's non-multisite permalink base normalization now applies trim($uri, '/') before prefixing /, replacing the raw '/'.$uri concatenation. Additionally, track_direct_add_to_cart() is relocated from between the AJAX handler and the regular add-to-cart section to a position later in the class, after get_wc_cart().

Changes

WooCommerce Integration

Layer / File(s) Summary
Permalink normalization and method relocation
src/Integrations/WooCommerce.php
Constructor trims leading/trailing slashes from product_base before prefixing / for the view-product goal URI pattern; track_direct_add_to_cart() is removed from its earlier location and reinserted after get_wc_cart() with identical logic.

Poem

A slash too many crept into the path,
So the rabbit trimmed it, avoiding the wrath.
A method wandered and needed a home,
Now tucked after cart, no longer to roam.
Tidy and neat, the code hops along! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main bug fix: normalizing the product_base URI to prevent double leading slashes in the view-product goal when using custom permalink bases in WooCommerce.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch woocommerce_custom_base_fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Integrations/WooCommerce.php`:
- Around line 33-35: In the is_multisite() conditional block, apply the same
slash normalization to the $uri variable before concatenating it with
get_blog_details()->path. Use trim($uri, '/') to remove leading slashes from
$uri before the concatenation, which will prevent double slashes from being
created when the multisite path (which has a trailing slash) is joined with the
product base URI (which has a leading slash).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0b72d271-073f-406e-a71c-d76237d8dcd5

📥 Commits

Reviewing files that changed from the base of the PR and between 413d2bf and 34ec288.

📒 Files selected for processing (1)
  • src/Integrations/WooCommerce.php

Comment thread src/Integrations/WooCommerce.php
…mmerce enabled, the view-product goal would wrongfully get a 2nd leading slash.
@Dan0sz Dan0sz merged commit 072e4cc into develop Jun 23, 2026
7 checks passed
@Dan0sz Dan0sz deleted the woocommerce_custom_base_fix branch June 23, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant