Calling foxycart for multiple templates

leehughesleehughes Member
in Help edited October 2010

I have just noticed that foxycart is only showing on 1 of my templates. I have 3 templates all product pages which display a different number of photos based on what we get.

My guess is that it isn't showing because I haven't told it to on those templates and this is the code that does that:
<?php if (is_page_template('product-template.php')) { ?>

So, how would I add more templates into this code? I tried to repeat this with the different ones but got a error :(
  • brettbrett FoxyCart Team
    I'm assuming that's Wordpress? I'm not positive but I'd do something like this:
    <?php if (is_page_template('product-template.php') OR is_page_template('product-template2.php') OR is_page_template('product-template3.php')) { ?>

    Try something like that (replacing the filenames as necessary) and let us know how it goes.
  • fc_adamfc_adam FoxyCart Team
    You can also use the pipe symbol in place of 'or', as in '||'
  • sorry wordpress yes.

    I have tried the code and it didn't work
    <?php if (is_page_template('product-template.php') || is_page_template('product-template-one-photo.php') || is_page_template('product-template-two-photos.php')) { ?>

    I have tried the OR as well

    I have checked the templates code to see if anything was missing and all have the same foxycart code
    div class="buy-now">
    					<form class="foxycart" action=""; method="post" accept-charset="utf-8">

    unfortunately I can not provide you with a link to one of the pages either as we would be breaking a contract between our supplier about the launch of a new season of wedding dresses etc.
  • brettbrett FoxyCart Team
    So the question is this: Why isn't it working? The assumption from your first post was that the FoxyCart includes weren't included in certain templates, but can you confirm that? What actually comes after the ?> and ends with something like <? } ?>

    Is it present on all templates or only on one? That'd be the next step. Also, you can whisper us URLs privately to take a look, which may not violate any agreements (maybe?). It'll be hard to troubleshoot if we can't see it though.
  • leehughesleehughes Member
    edited October 2010
    Hey Brett,

    I have uploaded via text file each one, hopefully you will be able to spot it

    Product listing working code
    Product page (not working)

    If you still need to take a look after this just give me a whisper and I will sort something out :)
  • brettbrett FoxyCart Team
    edited October 2010
    Response to whisper:
    No prob. Just whisper them over.

    Actually, that said, why are you trying to do this? All the files are loaded either from Google's CDN or from our Edgecast CDN and have the proper cache headers so they shouldn't impact pageload times significantly beyond the first load. Also, having them sitewide would allow you to have a persistent mini-cart or checkout links. Without the code sitewide any checkout links wouldn't function correctly for users with 3rd party cookies disabled.

    You may also want to check this blog post that just came across my Google Alerts today:
    It may make more sense to use an exclamation to say (basically), "If the template is _not_ the homepage, load the FoxyCart includes."
  • brettbrett FoxyCart Team
    Response to a whisper, because I think this may possibly help others.
    I am trying to do this because of my lack of coding skills, there's probably a snippet of code that could show only the right amount of dresses etc but I don't know that so my logical conclusion was to build 3 templates for which each have the right number of dresses.

    What I was getting at with my previous post was that you don't need the if is_page_template() stuff at all, do you? Just include the FoxyCart include files and be on your way. There's no harm in including them sitewide (unless I'm forgetting another issue you faced?). So just get rid of the <?php if (is_page_template()... bit, then the closing <? } ?> bit below (which I'm assuming is somewhere below) and you'll have the relevant code sitewide (which you actually need because you have a sitewide "view your cart" link).

    Does that clarify?
  • Ahh yes, thanks.

    Makes sense,

    Although I'm in talks with a friend who knows php so he might be able to get it sorted so everything is on the one template :)

  • brettbrett FoxyCart Team
    Let us know how it goes. Getting a friend involved sounds like a good option, especially if you can learn from what he does.
  • All sorted :)
Sign In or Register to comment.