+ Reply to Thread
Results 1 to 14 of 14

Thread: Display a product outside of SquirrelCart on Main (general) web page

  1. #1
    Client
    Join Date
    Nov 2007
    Location
    Cornwall, UK
    Posts
    2
    Squirrelcart version
    v2.6.3

    Display a product outside of SquirrelCart on Main (general) web page

    I would like to feature one product outside of the squirrelcart folder on our main website.

    So visible on:

    http://www.example.com/page.php

    as well as:

    http://www.example.com/squirrelcart/store.php

    It must show image and full description as well as add to cart and option choices.

    Is this possible?

    Would anyone care to give me some tips as how to do it!

    Thanks!

  2. #2
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,719
    Squirrelcart version
    v3.3.7
    I know those are example URLs, but I would recommend not using "squirrelcart" in your store URL to avoid confusion between the actual "squirrelcart" installation folder. If you'd like your store in a subdirectory, I'd recommend doing something like:
    http://www.example.com/store/
    or
    http://www.example.com/shop/

    As for your question:

    1. You can put Squirrelcart code on any .php page. Your index page will need to be renamed to index.php. All HTML in it now should work fine, but changing the extension to .php will allow PHP to parse it.

    2. Open the page you want to add Squirrelcart code to (index.php?)

    3. Add this at the very top:
    PHP Code:
    <?php include 'squirrelcart/pre_storefront.php' ?>
    If your squirrelcart folder is in a different directory, you'll need to change that to match it's location, like this example:
    PHP Code:
    <?php include 'shop/squirrelcart/pre_storefront.php' ?>
    4. If you want Squirrelcart's stylesheet on that page, add this inside the <head/> tag:
    PHP Code:
    <?php stylesheet("store.css"?>
    5. If you want other Squirrelcart code on that page (QuickTotal module, other module CSS files, etc...), add this inside the <head/> tag:
    PHP Code:
    <?php include $cart_isp_root.'/storefront_head.php' ?>
    6. Add this directly before the closing </body> tag:
    PHP Code:
    <?php
        
    // This line must go directly before your closing body tag
        
    include $SC['cart_isp_root'].'/post_storefront.php';
    ?>
    7. You now have everything you need in that file to be able to add additional code to call Squirrelcart functions. To show a product in detail mode, add a call to show_product_detail() where you want it to appear on that page:

    PHP Code:
    <?php show_product_detail(391); ?>
    Set the number inside the function parenthesis to the record number of the product you want to show.

  3. #3
    Client
    Join Date
    Nov 2006
    Location
    Illinois
    Posts
    185
    Squirrelcart version
    v3.3.4
    wow thats great, thanks for all that info jamie, that top of the file threw me for somthing ive been working on

    Dave

  4. #4
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,719
    Squirrelcart version
    v3.3.7
    You're welcome

  5. #5
    Client
    Join Date
    Sep 2008
    Posts
    3
    Squirrelcart version
    not specified!
    Is it possible to display a subset of the objects of the product detail? For example, say I want to show the Price, Quantity entry field, and Add to Cart button, but not the product description.

  6. #6
    Client
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    55
    Squirrelcart version
    v2.6.3
    Jamie, that is absolutely fantastic mate!! What a great help.

  7. #7
    Client
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    55
    Squirrelcart version
    v2.6.3
    Jamie, just a quick question mate. Is there a way to find out what possible functions there are to choose from to add to a page? For example, the show_product_detail() function. Perhaps some templates to look?

    Thanks so much Jamie!

  8. #8
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,719
    Squirrelcart version
    v3.3.7
    Quote Originally Posted by tiskilwa View Post
    Is it possible to display a subset of the objects of the product detail? For example, say I want to show the Price, Quantity entry field, and Add to Cart button, but not the product description.
    If you are specifically referring to doing that after implementing this custom code, it is possible with some changes:
    1. Read this, and make sure you understand how to modify template files via a custom theme folder:
    http://squirrelcart.com/help/?Modify...Templates.html

    2. Put a copy of the product_detail.tpl.php template file in your custom theme folder squirrelcart/themes/YOUR_THEME/

    3. Rename that template file to something like product_detail_custom.tpl.php

    4. The show_product_detail() function in the above code doesn't do much. It just calls show_product(), which does most of the work. You need to change the function call in the code shown above to this:
    PHP Code:
    <?php
    show_product
    (391,'squirrelcart/themes/YOUR_THEME/product_detail_custom.tpl.php');
    That will tell that function to use your custom template.

    5. Open that custom template file, and alter it however you like.
    If you are instead looking to change the product detail page for ALL products, you would just need to modify the product_detail.tpl.php template file and remove the <?=$Description?> variable.

  9. #9
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,719
    Squirrelcart version
    v3.3.7
    Quote Originally Posted by marty177 View Post
    Jamie, just a quick question mate. Is there a way to find out what possible functions there are to choose from to add to a page? For example, the show_product_detail() function. Perhaps some templates to look?
    You're welcome. We don't have a function reference. You can dig around in squirrelcart/functions and open the function files to see what they do. They have comment sections at the top explaining how to call them. The majority of them wouldn't be of much use to you, though some certainly can be. I'll be writing a short developer's guide in the documentation for v3.0.0 listing some of the functions that can be used for custom coding.

  10. #10
    Client
    Join Date
    Sep 2008
    Posts
    3
    Squirrelcart version
    not specified!
    awesome. thanks jamie!

  11. #11
    Client
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    55
    Squirrelcart version
    v2.6.3
    Thanks from me too, Jamie.

  12. #12
    Client
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    55
    Squirrelcart version
    v2.6.3
    My main concern at this stage with having custom made 'add to cart' pages is just whether I can integrate some sort of inventory check.

    For example, check the quantity if someone adds too many items and show a message, and place an 'out of stock' button there when needed.

    All these things you've already done so well in the full package

    Marty

  13. #13
    Client SketchWork's Avatar
    Join Date
    Aug 2007
    Posts
    79
    Squirrelcart version
    v3.3.2
    Hi Jamie,

    Does this still work on version 3 or does it need any specific changes.

    Many thanks,

    Justin

  14. #14
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,719
    Squirrelcart version
    v3.3.7
    Yes, if you change the function name to sc_product().

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts