Skip to content

feat(smartstone): gift character services via tokens#207

Merged
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:smartstone-voucher-gifting
Jul 19, 2026
Merged

feat(smartstone): gift character services via tokens#207
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:smartstone-voucher-gifting

Conversation

@Nyeriah

@Nyeriah Nyeriah commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

Adds optional gifting for the name, faction, race and customization character services using the smartstone token system in mod-chromiecraft-smartstone (the feature was recently renamed from "voucher" to "token").

When a buyer enters a recipient character name on the product page, the purchase grants a token to that account (.smartstone token grant <account> <type>, run over SOAP) instead of applying the change directly. The recipient then redeems it in-game (.smartstone token claim) on the character of their choice. Leaving the field blank keeps the existing self-service behaviour (instant apply to the selected character), unchanged.

Token types map 1:1 to the services (from the mod's TokenType enum): rename=1, faction=2, race=3, customize=4. char-restore-delete has no token equivalent and is excluded.

Config

Gated behind a new Smartstone Token Gifting toggle (acore_smartstone_enabled) on the admin Tools page, disabled by default. With it off, all the new code paths are inert, so behaviour is identical to today unless a server is running the smartstone module and opts in.

Changes

  • SmartstoneService: new grantToken($account, $type) SOAP helper.
  • CharChange: optional gift field, recipient resolution (character name to account), token grant on payment_complete, and gift display at checkout / in order meta.
  • CartValidation: validates the gift recipient (exists, not banned, account not banned) and skips the self character-selection requirement in gift mode. Mirrors the existing account-wide smartstone gifting checks.
  • Opts / Tools admin page: the new toggle.
  • The recipient account login is stored under a hidden _acore_gift_account order-item meta key so WooCommerce keeps it out of customer order details and emails (only the character name is shown). The same fix is applied to the existing account-wide smartstone gifting path, which shared the key.

Testing

  • Toggle off: services behave exactly as before.
  • Toggle on, gift field blank: normal self-service.
  • Toggle on, recipient name entered: order line shows "Gift for: ", and on checkout a token is granted to the recipient account (verified with .smartstone token list <account>). Free/$0 orders also work since WooCommerce fires payment_complete for zero-total carts.

Summary by CodeRabbit

  • New Features
    • Added support for gifting eligible character-change services to another character.
    • Added recipient validation to prevent gifting to unavailable or banned characters.
    • Added Smartstone token delivery to gift recipients after successful payment.
    • Added an admin setting to enable or disable Smartstone Voucher Gifting.
    • Gift details now appear in cart and order information.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 01ed943e-dc2a-4f85-bc72-b1dbcb11431f

📥 Commits

Reviewing files that changed from the base of the PR and between a9e8aa7 and a43dd44.

📒 Files selected for processing (6)
  • src/acore-wp-plugin/src/Components/AdminPanel/Pages/Tools.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CartValidation.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php
  • src/acore-wp-plugin/src/Manager/Opts.php
  • src/acore-wp-plugin/src/Manager/Soap/SmartstoneService.php

📝 Walkthrough

Walkthrough

Adds configurable Smartstone token gifting for eligible character-change products, including recipient validation, WooCommerce cart/order metadata, checkout display, and token fulfillment through SmartstoneService.

Changes

Smartstone token gifting

Layer / File(s) Summary
Gifting configuration and token contract
src/acore-wp-plugin/src/Components/AdminPanel/Pages/Tools.php, src/acore-wp-plugin/src/Manager/Opts.php, src/acore-wp-plugin/src/Manager/Soap/SmartstoneService.php, src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
Adds the Smartstone enable/disable setting, eligible SKU mappings, recipient helpers, and the token-grant command API.
Recipient validation and order data
src/acore-wp-plugin/src/Hooks/WooCommerce/CartValidation.php, src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php, src/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php
Validates gift recipients and stores, displays, and persists recipient account and character metadata through cart and order creation.
Gift token fulfillment
src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php, src/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php
Grants the mapped token to the recipient during payment completion and reads the hidden recipient account metadata for account-wide Smartstone handling.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Customer
  participant WooCommerce
  participant CharChange
  participant SmartstoneService
  Customer->>WooCommerce: Add eligible SKU with recipient
  WooCommerce->>CharChange: Validate and store gift metadata
  CharChange->>WooCommerce: Persist recipient data in cart and order
  WooCommerce->>CharChange: Complete payment
  CharChange->>SmartstoneService: Grant mapped token
Loading

Possibly related PRs

Suggested reviewers: thescrewedsoftware

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: gifting character services through Smartstone voucher tokens.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php`:
- Around line 56-73: The gift-recipient flow around validateGiftRecipient must
resolve and validate both the character and its account before allowing cart
creation. Reuse that complete recipient result when setting acore_gift_account
and acore_char_sel, and reject the add-to-cart operation if either lookup fails;
never return success with missing recipient metadata or fall through to
self-service fulfillment.
- Around line 244-253: The gift voucher branch in CharChange must preserve
failed fulfillment instead of allowing the exception handler to only log it.
Update the grantVoucher failure path and the surrounding per-item processing to
record the item’s failed fulfillment state, then propagate it into a durable
order note/status or the existing retry queue so the paid order remains
actionable and retryable.
- Around line 192-201: Update the gift metadata handling in CharChange so the
resolved recipient is stored under a hidden underscore-prefixed key such as
_acore_gift_account, while retaining acore_gift_charname as the customer-visible
metadata. Ensure all later code that reads the recipient uses the same private
key, and leave the SKU and character-name behavior unchanged.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f1a951e8-9350-4c18-bb38-4c61f3dac66e

📥 Commits

Reviewing files that changed from the base of the PR and between 34c811f and 6cef1a1.

📒 Files selected for processing (5)
  • src/acore-wp-plugin/src/Components/AdminPanel/Pages/Tools.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CartValidation.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
  • src/acore-wp-plugin/src/Manager/Opts.php
  • src/acore-wp-plugin/src/Manager/Soap/SmartstoneService.php

Comment thread src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
Comment thread src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
Comment thread src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php`:
- Around line 344-345: Update the target selection logic near $target to check
the legacy acore_gift_account metadata key when _acore_gift_account is empty,
before falling back to $accountName. Preserve the current preference for the new
key and ensure in-flight orders using the old key resolve the gift account
correctly.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb023c52-e365-4abc-9036-abed8dbb5f08

📥 Commits

Reviewing files that changed from the base of the PR and between 6cef1a1 and a9e8aa7.

📒 Files selected for processing (2)
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php
  • src/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/acore-wp-plugin/src/Hooks/WooCommerce/CharChange.php

Comment thread src/acore-wp-plugin/src/Hooks/WooCommerce/Smartstone.php
@Nyeriah Nyeriah changed the title feat(smartstone): gift character services via vouchers feat(smartstone): gift character services via tokens Jul 19, 2026
Add optional gifting for the name, faction, race and customization
character services using the mod-chromiecraft-smartstone token system.
When a buyer enters a recipient character name, the purchase grants a
token to that account (.smartstone token grant) instead of applying the
change directly, and the recipient redeems it in-game. Leaving the field
blank keeps the existing self-service (instant apply) behaviour.

Gated behind a new "Smartstone Token Gifting" toggle
(acore_smartstone_enabled) on the admin Tools page, disabled by default,
so nothing changes unless the module is in use. Token types map 1:1 to
the services (rename, faction, race, customize); char-restore-delete has
no token equivalent and is excluded.

The resolved recipient account login is stored under a hidden
_acore_gift_account order-item meta key so WooCommerce keeps it out of
customer order details and emails; only the character name is shown. The
same fix is applied to the existing account-wide smartstone gifting path,
which shared the key.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@Nyeriah
Nyeriah force-pushed the smartstone-voucher-gifting branch from 610f485 to a43dd44 Compare July 19, 2026 00:17
@Nyeriah
Nyeriah merged commit 5881c00 into azerothcore:master Jul 19, 2026
1 of 2 checks passed
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