Adding custom text to the TTG CE4 Cart

The TTG CE4 Cart has plenty of options in its admin area, but one thing it doesn’t have is a way to add some text to the block above the actual cart information. So if you need to add custom text to the TTG CE4 Cart, the only way to do this is by using phplugins. Fortunately, Matt’s provided a hook specifically for the Cart.

First thing you’ll need to do is to enable phplugins. The instructions for that can be found here.

Note: you don’t need to enable phplugins site-wide if you don’t want to, but it’s a really good idea to do so, just so your site is ready in case you ever want to use custom css or control your navigation with phplugins. If the only thing you want to do is add some text to the cart, you can enable phplugins for the cart gallery template you’re creating. But since this is a template, you’ll still need to provide the server path to the phplugins file created by that template. In this case you can obtain it by going to http://www.your-site.com/ttg-be/templates/gallery/name-of-your-cart-template/phplugins/path.php. Of course, you’ll need to substitute “your-site.com” and “name-of-your-cart-template” with the actual names

Once you’ve got this all set up, open the phplugins.php file with a plain text editor (Notepad ++ for Windows is my preferred editor. Text Wrangler for Mac is highly recommended) and paste the following in somewhere after the notice: // SET USER FUNCTIONS BELOW but not inside any of the included functions.

function ttg_block_top( $style, $path){
if (G_STYLE == 'CE4-CART') {
echo' <p>All prices include tax.</p>
';
return true; //places text at the top of the block in the cart
}
return true; //keeps content of other page blocks in place
}

What this function does is insert the text “All prices include tax.” into the top of the block of the Cart, right above the rest of the Cart itself. And it only inserts the text into the Cart. That’s what this portion of the code ensures:
if (G_STYLE == 'CE4-CART')
That’s the hook Matt’s included to target only the Cart.
The function “ttg_block_top” is what controls where on the page the text is inserted.

You can expand on this if you wish. You can apply styles to the <p> tag or assign it a custom class that you style with custom css.
You can insert images if you wish, or even a responsive grid framework for columns of text with detailed instructions or your return policy or whatever you wish.

Text added to the Block above the Cart.
Text added to the Block above the Cart.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

About this site

This site is: a repository of time-savers and best practices from a user's perspective, picked up from several years of using TTG plugins.
This site is not: a support site.
Read more here.

Tip Jar

If this site has saved you some time, kept your hair attached, or otherwise prevented you from tossing the mouse through the monitor, feel free to donate.

Categories


Highly recommended. This is my go-to Lightroom book. Click on the book image. (affiliate link)

Affiliate link!

Current TTG versions

Backlight Versions

Backlight 1.2.2
Pages module 1.2.1
Cart Add-on 4.1.3
Client Response Add-on 7.1.2
Theater Add-on 1.2.1
WordPress Add-on 1.2.1
Publisher 3.2.2

CE4 Versions

TTG-BE: 2.0.5a
Autoindex: 7.0.8
Cart: 3.1.4a
CRG: 6.1.3a
Gallery: 6.1.9
Pages: 7.0.15
Publisher: 2.3.3
Stage: 6.1.6
Theme for WordPress: 3.1.2

Subscribe to new posts