1. Home
  2. Knowledge Base
  3. Account Funds for WooCommerce
  4. Store Credit WooCommerce Shortcodes: Display Customer Balances

Store Credit WooCommerce Shortcodes: Display Customer Balances

Account Funds provides shortcodes to display store credit WooCommerce information anywhere on your site. Use them in pages, posts, widgets, or theme templates to show customers their balance outside of the standard checkout and My Account areas.

Available Shortcodes

[store_credit_balance]

Displays the store credit balance for a customer.

Basic usage:

[store_credit_balance]

Shows the current user’s balance formatted with your store’s currency symbol (e.g., “$50.00”).

Parameters

Parameter Default Description
customer Current user ID User ID to display balance for
currency Store currency Currency code (e.g., “USD”, “EUR”)
formatted true Whether to format with currency symbol

Examples

Current user’s balance (default):

[store_credit_balance]

Output: $50.00

Specific customer’s balance:

[store_credit_balance customer="123"]

Shows balance for user ID 123.

Balance in specific currency:

[store_credit_balance currency="EUR"]

Shows balance in Euros (if multi-currency is configured).

Raw number without formatting:

[store_credit_balance formatted="false"]

Output: 50 (no currency symbol)

Legacy Shortcode

For backwards compatibility with older versions:

[get-account-funds]

This works identically to [store_credit_balance] and accepts the same parameters. We recommend using the newer shortcode name in new implementations.

Common Use Cases

Header Balance Display

Show customers their balance in the site header so it’s always visible:

Your Balance: [store_credit_balance]

Add this to a header widget, menu item, or theme template. Consider wrapping in a conditional to only show for logged-in users.

My Account Enhancement

Add a prominent balance display to custom My Account pages:

<div class="my-balance-box">

<h3>Available Store Credit</h3>

<p class="balance-amount">[store_credit_balance]</p>

<a href="/my-account/store-credit/">View History</a>

</div>

Promotional Pages

On landing pages explaining your store credit program:

You currently have [store_credit_balance] in store credit.

Start shopping to use your balance!

Email-Style Templates

If using page builders for order confirmations or custom emails:

Your updated store credit balance is [store_credit_balance].

Conditional Display

The shortcode returns empty output for guest users (not logged in). To show different content for guests vs. logged-in users, use WordPress conditional functions in your theme or a shortcode plugin.

PHP Example (Theme Template)

<p>Your balance: <?php echo do_shortcode( '[store_credit_balance]' ); ?></p>

<?php else : ?>

<p><a href="/my-account/">Log in</a> to see your store credit balance.</p>

<?php endif; ?>

Styling the Output

Basic CSS

The shortcode outputs plain text. Wrap it in HTML for styling:

<span class="store-credit-balance">[store_credit_balance]</span>

Then style in your CSS:

.store-credit-balance {

font-weight: bold;

color: #2e7d32;

font-size: 1.2em;

}

With Icon

Add a wallet or credit icon:

<span class="balance-display">

<span class="dashicons dashicons-money-alt"></span>

[store_credit_balance]

</span>

In a Card Layout

<div class="credit-card">

<div class="credit-label">Store Credit</div>

<div class="credit-amount">[store_credit_balance]</div>

<a href="/shop/" class="credit-cta">Shop Now</a>

</div>

Page Builders

Elementor

Use the Shortcode widget:

  1. Drag “Shortcode” widget to your page
  2. Enter [store_credit_balance]
  3. Style the widget container as needed

Gutenberg / Block Editor

Use the Shortcode block:

  1. Add a Shortcode block
  2. Enter [store_credit_balance]
  3. Wrap in a Group block for styling

WPBakery / Visual Composer

Use the Raw HTML or Text Block element:

  1. Add Text Block element
  2. Enter the shortcode
  3. Apply container styling

Widgets

Many themes support shortcodes in text widgets:

  1. Go to Appearance → Widgets
  2. Add a “Text” or “Custom HTML” widget to your sidebar/footer
  3. Enter: Your Balance: [store_credit_balance]
  4. Save

Note: Some themes require enabling shortcode processing in widgets. This is usually automatic in modern WordPress.

To show balance in navigation menus, you’ll need a plugin that enables shortcodes in menus (like “Shortcode in Menus”) or custom code.

With such a plugin:

  1. Go to Appearance → Menus
  2. Add a Custom Link
  3. URL: # or your store credit page
  4. Link Text: Balance: [store_credit_balance]

Multi-Currency Stores

If your store uses multiple currencies:

Display in Store Currency

[store_credit_balance]

Shows balance in your store’s default currency.

Display in Specific Currency

[store_credit_balance currency="GBP"]

Shows the customer’s balance in the specified currency (if they have a balance in that currency).

Important Notes

  • Store credit balances are stored per-currency
  • A customer may have different balances in different currencies
  • The shortcode shows one currency at a time

Performance Considerations

Caching

If you use page caching, the shortcode output could wind up cached. Potential solutions include:

  • Exclude pages with the shortcode from caching
  • Use AJAX to load the balance dynamically
  • Use fragment caching that respects logged-in users

Most caching plugins have options to serve different cached versions to logged-in vs. logged-out users, which resolves this issue, but if you have any issues, please contact support. We’re happy to get it resolved for you!

Multiple Calls

Using the shortcode multiple times on a page is fine—the balance is fetched efficiently and won’t cause performance issues.

Troubleshooting

Shows Wrong Balance

If the balance seems incorrect:

  • Clear any page caching
  • Verify you’re logged in as the expected user
  • Check if a customer ID parameter is overriding the default
  • Verify the currency parameter matches expected currency

Empty Output

If nothing displays:

  • Confirm the user is logged in (shortcode returns empty for guests)
  • Check the user has a balance (zero shows as “$0.00”)
  • Verify the shortcode isn’t wrapped in code that suppresses output

Formatting Issues

If the currency format looks wrong:

  • Check WooCommerce currency settings
  • Verify your store’s locale settings
Was this article helpful?

Related Articles