Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Function to clear all gift certificates or a specific gift certificate from being redeemed
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Cartthrob Gift Certificates - clear_gift_codes


This function works with the Cartthrob Gift Certificates add-on version 1.1. Similar to Carthrob's clear_coupon_codes function, clear_gift_codes clears all gift certificates or a specific gift certificate from being redeemed.


Well... Why not? We see there is a function to clear coupon codes, so why not add it to the gift certificates as well. So, VOILA!


  1. Copy the function from clear_gift_codes.php.
  2. Open the file mod.cartthrob_gift_certificates.php located in the cartthrob_gift_certificates folder.
  3. Paste the code before the last closing curly brace in the file mod.cartthrob_gift_certificates.php

Example ExpressionEngine markup:

Add the redeem_gift_certificate_form

Add this to a template_group and template of your choice (we placed it in the

{exp:cartthrob_gift_certificates:redeem_gift_certificate_form return="/store/cart" error_handling="inline"}
    <input type="text" name="gift_certificate_code" >
    <input type="submit" value="Redeem Gift" >

    {!-- Display errors with error_handling="inline" set --}
    {if errors_exist}

    {if "{exp:cartthrob_gift_certificates:applied}" > "$0.00"}
        <p>Gift Amount Applied: <strong>{exp:cartthrob_gift_certificates:applied}</strong></p>
            <p>{gift_certificate_code} <a href="/store/remove-gift-codes/{gift_certificate_code}">Remove</a></p>
        <a href="/store/remove-gift-codes">Remove all gift certificates</a>

Add remove-gift-codes.html file

This can be in a template group of your choice (we placed it in the When the user clicks on the link to remove the specific code, the {segment_3} variable is passed as the parameter to the function and removes only that code if it is set. If there is no code parameter set, then all codes are removed.

{exp:cartthrob_gift_certificates:clear_gift_codes return="/store/cart" code="{segment_3}"}



Specify a path to redirect the user after clearing the code(s).


Specify a code to clear. Handy when there is more than one active code.


This has only been tested with Cartthrob version 2.2.5 and Cartthrob Gift Certificates version 1.1.

Many Thanks to:

Team Reusser for their continued support!

And, to the Carthrob Development Team for their awesome products and developer documentation! Really, Thank You!

Something went wrong with that request. Please try again.