Skip to content

Conversation

alexsmithext
Copy link
Contributor

@alexsmithext alexsmithext commented Sep 10, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Corrected price conversion for order line items to cents, removing a double-multiplication error that could inflate list and purchase prices. Prices, totals, and downstream calculations now reflect accurate values (e.g., $19.99 becomes 1999 cents). This ensures more reliable billing, taxes, and reporting across affected orders. No other user-facing behavior changed.

Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Walkthrough

The change updates price-to-cents conversion in helloextend-protection/includes/class-helloextend-protection-orders.php. Previously, listPrice and purchasePrice were multiplied by 100 before being passed to get_price_in_cents, which also multiplies by 100, causing double scaling. The patch now passes the raw price values directly to get_price_in_cents. Only the price fields within the product block of line item data are affected. No control flow, structure, or other fields were modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and succinctly describes the primary change—that the price was erroneously multiplied by 100 twice—and aligns directly with the modifications made in the diff by removing the extra multiplication step.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Poem

I thump my paws—precision wins today!
Cents align at last, no double-math ballet.
From 19.99 to 1999—hooray!
I nibble bugs like clover on the way.
Hop, hop, ship it—numbers now obey! 🥕✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch price-bug-fix

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
helloextend-protection/includes/class-helloextend-protection-orders.php (2)

157-160: Make minor-units conversion currency-aware and avoid float truncation.

Current cast-to-int can truncate (e.g., 19.995 → 1999) and always assumes 2 decimals. If the store (or order) currency has 0 or 3 decimals, values will be off. Prefer rounding with a decimals-derived factor.

Apply:

-    return (int) floatval($item_price * 100);
+    $decimals   = (int) wc_get_price_decimals(); // honors store/currency settings
+    $multiplier = (int) pow( 10, max( 0, $decimals ) );
+    return (int) round( (float) $item_price * $multiplier );

If you support multi-currency per order, consider passing the order currency into this helper and deriving decimals from it.


248-251: Consider using the order line’s actual unit price for purchasePrice.

Using $product->get_price() may ignore discounts/coupons applied on the order. Computing from the line total keeps Extend in sync with what the shopper paid.

-                        'purchasePrice' => $this->get_price_in_cents($product->get_price()),
+                        // Unit price actually paid (exclude/including tax per your API contract)
+                        // To include tax instead, use: ($item->get_total() + $item->get_total_tax())
+                        'purchasePrice' => $this->get_price_in_cents(
+                            $item->get_quantity() ? ($item->get_total() / $item->get_quantity()) : 0
+                        ),

Confirm whether Extend expects tax-inclusive or tax-exclusive unit price and adjust the formula accordingly.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6c56798 and 6289205.

📒 Files selected for processing (1)
  • helloextend-protection/includes/class-helloextend-protection-orders.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deploy-and-test
🔇 Additional comments (1)
helloextend-protection/includes/class-helloextend-protection-orders.php (1)

248-249: Approve changes. Double scaling removed by passing raw prices into get_price_in_cents; verification found no other pre-multiplication before this call.

@jm-extend jm-extend self-requested a review September 10, 2025 19:51
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.

2 participants