• Hi. I am new to WordPress and have been fairly successful in creating a child theme and changing a few things around using tips I found on the various forums. So I thought I’d get adventurous and try my own bit of coding to add my own text below the “Cart Totals” area on my site. I wrote the following:
    /* Add custom text after the “Cart Totals” */
    add_action(‘after_cart_totals’,’my_cart_text’);
    function my_cart_text() { echo ‘<p id= “mytxt”>This is my custom text.</p>
    }
    When I go to the Cart page I get the following:
    Parse error: syntax error, unexpected ”<p id= “mytxt”>This is my cus’ (T_ENCAPSED_AND_WHITESPACE) in /home/content/p3pnexwpnas04_data03/46/2966846/html/wp-content/themes/storefront_child/functions.php on line 111
    I have tried to find where the syntax error is but I can’t. I know it will be glaringly obvious to someone, but would some kind soul please let me know where I went wrong, or if indeed I’m totally on the wrong bus? Cheers.

Viewing 1 replies (of 1 total)
  • Thread Starter JohnM13

    (@johnm13)

    Well I kept looking at the code and have identified 3 issues. Fixed them all and now it works, so it seems I wasted some space there. Sorry about that. But I’d like to amend the question if I may: I can add text above “Cart Totals” or below the whole “Cart Totals” area, but if I want to add text DIRECTLY BELOW the actual words “Cart Totals” but ABOVE the totals calculations, what changes do I need to make to my code? Cheers again.

Viewing 1 replies (of 1 total)
  • The topic ‘Syntax error – add action’ is closed to new replies.