This is an old revision of the document!


Dynamically customising the URL/text of the Web Receipt "Continue To" Button

If you'd like to change the URL or text on the web receipt “Continue To” button, you can use this snippet to look through the items in the cart for any items with a specified category. If that category is found in the cart, you can display the desired text on your button. The logic can also be updated to look for other conditions too, such as a specific product code or even a custom session attribute.

For this specific example, you'll need to have created your desired category in the Categories section of the admin, and used the specific categories in your product add to cart links/forms. Go here for more details on working with categories.

Step 1: Apply the snippet to your configuration

You can apply the snippet below within the “receipt” section of your store's FoxyCart administration - you'll need to select the “Custom Template” option to enable the custom receipt template text area and look for this line: {% embed 'receipt.inc.twig' %} within the template code. Before this line, you'll paste the following twig code:

{% set has_category_item = false %}
{% for item in items %}
    {% if item.category == "your_category_here" %}
        {% set has_category_item = true %}
    {% endif %}
{% endfor %}
{% if has_category_item %}
    {# Change the continue to text #}
    {% set custom_lang = config.lang|merge({"checkout_continue_to": "Your custom text here "}) %}
    {% set config = config|merge({"lang": custom_lang}) %}
    {# Change the continue to URL #}
    {% set continue_url = "https://www.your-custom-continue-url.com" %}
{% endif %}

Step 2: Customise conditions

You'll need to update the text your_category_here to what ever the category is that you assigned to the product. You'll also need to change Your custom text here to your desired text to display on the button and the https://www.your-custom-continue-url.com to your desired URL.

If you don't want to change the text of the button, but just the URL, you can remove the lines

Site Tools