Would anyone be able to help please?
If I have a customer tag of ‘Credit Limit: £100’ and a customer tag of ‘Account Balance: £60’, am I able to do a maths equation of the credit limit value minus the account balance value, to output ‘Remaining Balance: £40’ on the front end?
Thank you.
use Liquid code to perform this calculation and display the remaining balance on the front end.
{% assign credit_limit_tag = 'Credit Limit: £100' %}
{% assign account_balance_tag = 'Account Balance: £60' %}
{% assign credit_limit = credit_limit_tag | split: '£' | last | plus: 0 %}
{% assign account_balance = account_balance_tag | split: '£' | last | plus: 0 %}
{% assign remaining_balance = credit_limit | minus: account_balance %}
Remaining Balance: £{{ remaining_balance }}
This code first assigns the customer tags to variables credit_limit_tag and account_balance_tag. It then uses the split filter to extract the numeric values from these tags, converts them to integers using the plus filter, and assigns them to the credit_limit and account_balance variables.