How to make change to cart include template for cart ONLY and not anything else (i.e. checkout)?

I think I asked about this a long time ago (I searched and searched but could not find where I asked about this so I figured it wouldn't hurt to ask about it again) but how do I make a change within the cart include template (as opposed to the cart template) such that the change will ONLY affect the Cart and not anything else that might use the cart include template like the checkout or receipt?

What I am looking to do is add an asterisk after the Order Total dollar figure and tie that asterisk to a note that shipping charges will be added to the total at checkout.

That will require a change to the cart include twig template.

I think what I need to do is use twig to include a modified cart include template file inside the cart template code and automagic that.

Does that sound about right? Just looking for confirmation of this.

Thanks.

Carlos
Comments
  • I was reviewing past threads and some documentation and I think i figured this one out too so I won't need input on this thread.

    Basically (and please correct me and give me input IF I am wrong on this):

    Since FoxyCart is not set up to include external twig files that I might create and want cached through automagic functionality I must either:

    1 include the full cart include template (as an example) within the cart template

    OR

    2. I must use twig logic inside the cart include template twig to limit what I want to do to rendering only within the context that I want it to render in.

    Those are my only options.

    Carlos

  • fc_adamfc_adam FoxyCart Team
    Just for a resolution to the thread - your two options there are spot on. Depending on the type of customisation you're doing which is the better option may change - but generally speaking I'd recommend option 2.
  • With respect to modifications to the checkout (as opposed to the cart which I was talking about above)...how do I use option #2 to modify the checkout.inc.twig file and include those modifications into the checkout page?

    The checkout template available through the FoxyCart admin interface pulls it in like so...


    {% embed 'checkout.inc.twig' %}
    {% endembed %}


    But there is no modification possible of the checkout.inc.twig file from within the admin interface as there is for the cart include template (i.e. cart.inc.twig).

    Is this a case of where the checkout.inc.twig code must be included in full (i.e. option #1 above) within the checkout template? Where one cannot use option #2 at all to make modifications to the checkout.inc.twig file that is pulled in by the checkout template itself?

    Carlos



  • fc_adamfc_adam FoxyCart Team
    @carlos123,

    There are two ways you can approach editing the checkout template. You could paste in the whole template if you wanted to, and edit the parts you need. That may be desirable if you're making a lot of changes.

    If you're just changing a come specific parts though - you can also make use of a new feature we added recently which is the embed tags you noted above. What the embed tags does is allows you to overwrite blocks within the template without having to paste in the whole template. As a basic example, let's say you wanted to change the logo HTML to be a h2 instead of a h1 for some reason. You could do that like this:
    {% embed 'checkout.inc.twig' %}

    {% block logo %}
    {% if config.store_logo_url %}
    <img id="fc-logo" src="{{ config.cache_path }}{{ config.store_logo_url }}" class="fc-logo__image" alt="{{ store_name }}">
    {% else %}
    <h2 class="fc-logotype">{{ config.store_name }}</h2>
    {% endif %}
    {% endblock logo %}

    {% endembed %}
    What I've done there is found the block related to the logo, and copied it within the embed tags. This in essence overwrites the default logo block with the one I pasted in there. I can then make any changes required and not have to paste in the whole template.

    This is great for some things, but unfortunately the block coverage in our existing templates isn't enough. Some blocks are quite large and there are some small sections of the code that missed being wrapped within a block. We have a ticket to fix that in the future so that the embed tag will be even more useful.
  • Great input Adam. I will look around and see if that meets my needs.

    Thanks.

    Carlos
Sign In or Register to comment.