Adjusting checkout template based on category

tannerdoodtannerdood Member
in Help edited February 2014
Hello,

I'm helping a client setup his shop using Wordpress+Foxyshop. He is wanting to sell guns, knives, holsters, etc. (he has his FFL). My question is, is there a way to automatically check the use different shipping address and disable it if there is a gun in the cart? The problem is, you have to ship the gun to a registered FFL dealer rather than shipping directly to an individual; however, if a person wants to purchase a holster then that item can go directly to their house. The test site is here: tanner.wactech.com/wordpress

Any help is appreciated.
Comments
  • fc_adamfc_adam FoxyCart Team
    @tannerdood,

    Something like this would do it - you'll need to add in your logic for checking if the product is there. Edit and paste right before the closing </head> tag of your checkout template.
    <script type="text/javascript">
    jQuery(document).ready(function() {
      for (var p=0; p < fc_json.products.length; p++) {
        if (fc_json.products[p].category == "CATEGORYCODE") {
          FC.checkout.requireShippingAddress();
        }
      }
    });
    </script>
    
  • Thanks for your help.

    Its giving me an error that it doesn't recognize fc_json. Am I missing an include file?
  • fc_adamfc_adam FoxyCart Team
    @tannerdood,

    Ah sorry - change fc_json to FC.json
  • It doesn't like this: FC.json.products.length

    I changed it to FC.json.product_count and it didn't error out. After I cached the page and went to a test checkout, then it gave me an error. Does it strip the jquery reference once you cache the page?
  • fc_adamfc_adam FoxyCart Team
    @tannerdood,

    Ok - my apologies again, I was confused between this thread and another I was working on - and gave you some bad advice in my last post.

    You'll want to maintain the code I originally gave you - that should be exactly what you need using fc_json. I just tested it out on your checkout and it worked fine for me. Could you revert it back and if you still get the error, I'll take a look at your checkout.
  • tannerdoodtannerdood Member
    edited February 2014
    Ok no problem.

    I'm getting this: ReferenceError: Can't find variable: fc_json on my template: http://tanner.wactech.com/wordpress/foxycart-checkout-template/

    And it cannot find jquery on my cached url.
  • fc_adamfc_adam FoxyCart Team
    @tannerdood,

    Yeah, fc_json is only defined on the actual checkout - it's included dynamically there. You won't find it on your actual raw template.
  • fc_adamfc_adam FoxyCart Team
    In terms of the jQuery not found error on your checkout, a javascript library is being included before jQuery is inserted automatically within the page. You can fix that type of error by ensuring all javascript is included after the <title> element and all CSS blocks. In your particular case though, you can remove the foxycart.colorbox.js file from your cart/checkout and receipt templates - it's not needed on those.
  • Ok, it looks like it is working. Thanks for your help!
Sign In or Register to comment.