CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

View Decrypted String

view_decrypted_string decrypts a token produced by view_encrypted_string.

Use this on pages that receive encrypted URL values (for example invoice/order routes) and need the original plain value.

See also:

Parameters

string

Required. Encrypted token to decrypt (commonly from a URL segment).

If string is empty, the tag returns an empty string.

string="{segment_3}"

key

Optional decryption key.

If a custom key was used during encryption, the same key must be used here.

key="10asl15bajkls8bb"

Output

Returns the decrypted plain value by applying:

  1. base64_decode(string)
  2. rawurldecode(...)
  3. Encrypt::decode(decoded, key)

Behavior and Constraints

  1. string is required for decryption; empty input returns empty output.
  2. Input is expected to be the URL-safe token from view_encrypted_string.
  3. If a custom key is used, encryption/decryption keys must match.
  4. Decryption result is returned directly from the encryption service decode call.

Examples

Basic usage with a known encrypted value:

{exp:cartthrob:view_decrypted_string string="ZE83M2FBVndWanhSVitkRWxsckNBbko1Qm81Rzh0RUpnNE1hUG1Qak14STlZY20wSy9OdHhUQ1QwYVhhNG1RSm5ZYkVCL2l3MGQ3SFBJV3l1MHdhQWc9PQ%3D%3D" key="10asl15bajkls8bb"}

Invoice page pattern from installer templates:

{if "{exp:cartthrob:view_decrypted_string string='{segment_3}' parse_inward='yes'}" != ""}
    {embed="store/_invoice" entry_id="{exp:cartthrob:view_decrypted_string string='{segment_3}' parse_inward='yes'}"}
{/if}

Twig pattern from installer templates:

{% set decrypted_string = exp.cartthrob.view_decrypted_string({string:segment_3}) %}