Skip to content

Conversation

@danielbreves
Copy link

@danielbreves danielbreves commented Dec 6, 2025

All Submissions:

  • My code follows the WordPress coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

This pull request fixes an incorrect conditional check in the get_dokan_gateway_fee method.
The logic previously checked ! empty( $processing_fee ) when determining whether to apply the dokan_gateway_fee_paid_by meta key.

The updated condition now checks ! empty( $gateway_fee ), ensuring paid_by is set when a valid gateway fee exists.

Related Pull Request(s)

How to test the changes in this Pull Request:

  1. Create or load an order that includes a gateway fee.
  2. Confirm that the dokan_gateway_fee_paid_by meta value is applied only when $gateway_fee is present.
  3. Test an order with processing_fee but no gateway_fee — the gateway fee logic should not be applied.
  4. Verify commission calculations remain correct in both scenarios.

Changelog entry

Bug Fix: Corrected conditional logic in get_dokan_gateway_fee so the gateway fee handling is based on $gateway_fee instead of $processing_fee.

Previously, the method incorrectly used $processing_fee to determine whether to apply the gateway fee logic.

Before Changes

The gateway fee logic would not me triggered as processing_fee was not present, causing inaccurate commission behavior.

After Changes

Gateway fee logic now correctly triggers only when a gateway fee exists, ensuring accurate fee calculation and vendor payouts.

Feature Video (optional)

N/A

PR Self Review Checklist:

  • Code follows style guidelines
  • Naming is clear and descriptive
  • Logic is simple and easy to follow (KISS)
  • No unnecessary duplication (DRY)
  • Readable and maintainable structure
  • No performance regressions
  • No confusing or overly complex conditionals
  • Spelling and grammar reviewed

FOR PR REVIEWER ONLY:

As a reviewer, please focus feedback on code quality and correctness.
As a contributor, improvements based on suggestions are encouraged to reach the best solution.

  • Correct — Fully meets requirements
  • Secure — Properly sanitized/escaped
  • Readable — Clear for future maintainers
  • Elegant — Fits existing architecture

Summary by CodeRabbit

  • Bug Fixes
    • Improved gateway fee initialization logic for order commissions to ensure proper handling in all payment scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Walkthrough

Modified the guard condition in get_dokan_gateway_fee() from checking processing_fee presence to checking gateway_fee presence, maintaining the empty gateway_fee_paid_by condition. This alters the gateway fee initialization trigger and affects related metadata handling.

Changes

Cohort / File(s) Summary
Gateway Fee Guard Condition
includes/Commission/OrderCommission.php
Replaced guard condition from processing_fee check to gateway_fee check in get_dokan_gateway_fee(), while maintaining the existing gateway_fee_paid_by empty check. Impacts gateway fee initialization logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that changing the guard condition from processing_fee to gateway_fee produces the intended behavior in all code paths where get_dokan_gateway_fee() is called
  • Confirm that the metadata normalization for gateway_fee_paid_by still functions correctly after this conditional change

Possibly related PRs

Suggested reviewers

  • mrabbani

Poem

🐰 A gateway fee guard stands tall,
From processing to gateway, heeding the call,
Condition reborn, initialization renewed,
The rabbit hops on, with logic reviewed! 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing a condition to check gateway fee instead of processing fee in the OrderCommission file.
Description check ✅ Passed The description covers all essential sections including proposed changes, related PRs, testing steps, changelog entry, before/after context, and self-review checklist.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60223f8 and 1059ca5.

📒 Files selected for processing (1)
  • includes/Commission/OrderCommission.php (1 hunks)
🔇 Additional comments (1)
includes/Commission/OrderCommission.php (1)

365-365: Unable to verify the review comment due to repository access failure. The claims made in the original review comment—including that $processing_fee was an undefined variable, that the change correctly references $gateway_fee, and the bug's severity—cannot be confirmed without direct access to the code.


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 and usage tips.

@danielbreves
Copy link
Author

cc @Aunshon @mrabbani @kzamanbd

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