+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 15 of 51

Thread: Using the cart only to check out, not to generate prod. pgs

  1. #1
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7

    Using the cart only to check out, not to generate prod. pgs

    01/09/2006 Note: The technique described in this post is for versions of Squirrelcart 1.6.3 or older. For versions 2.1.3 and newer, please see the instructions in the documentation:
    http://www.squirrelcart.com/help/?Ad...0Manually.html

    If you are using versions 2.0.0 - 2.1.2, you will need to upgrade to v2.1.3 to get this functionality.

    10/01/2005 Note: This technique described in this post does not work for v2.0.0. We will be issuing an updated version to handle this functionality. When we do, this post will be updated.

    02/21/2005 Note: This post has been updated to include support for the security fix posted here:
    http://www.ldev.com/forums/showthread.php?t=1768

    Suppose you already have a site completely designed, including all of the pages necessary to display your products. If you wish, you can use the cart just for the checkout process, and link your already designed product pages to it. This configuration is not recommended, but works fine if you are in this situation. Here is how to do it:

    Follow the normal installation instructions, then take a look below:

    1. Rename demo.php (store.php in newer versions) to shop.php (or whatever)
    2. Make all the required changes to your config.php file, including changing the value of your cart_page variable
    3. Log into http://YOURSITE.COM/squirrelcart
    4. Click the "store settings" icon
    5. Make sure "cart behavior" is set to go to checkout
    6. You need to design shop.php so it fits in with the existing design of the cart. If you have a particular navigation scheme, or logo, or whatever, put it on this page. When you add to the cart, the customer will be redirected to this page, so you will want it to look as close to your other pages as possible.
    7. Add your products and descriptions into the cart's DB via the admin page - http://YOURSITE.COM/squirrelcart. Even though you already have static html pages designed to display your products, you still need to add them to the database. The cart looks the info up in the DB so it can display the items in the checkout table. Basically, the only information you need to enter in the product records is:
    • Name
      Price
      Thumnbnail Image
      Description

    You don't have to worry about categories.
    8. Write down the "record_numbers" that the cart assigns the products
    9. Now...you need to figure out how to get the already designed pages to add the products to the cart. Here is how the form would look:

    Code:
    <form action="http://YOURSITE.COM/store.php?show_cart=1" method="post"> 
    <img src="someproduct.jpg">Buy this great product<br> 
    <b>Quantity: </b><input type="text" name="quantity" size="3" value="1"> 
    <input type="hidden" name="add_to_cart" value="1"> 
    <!--make the below match the product's record_number in the Squirrelcart DB-->
    <input type="hidden" name="prod_rn" value="173"> 
    <input type="image" src="images/add_to_cart.gif"> 
    </form>
    As long as these form elements are on your page, and the prod_rn field is set to the proper product's record number, the item will be added to the cart, and the customer will be redirected to your cart page (store.php in this example)

    10. By default, when a customer views all the items in the cart at checkout, thumbnail images are shown along with each item. These thumbnails are also links to display the product in the manner the cart would normally display it in. Because you are using your own design to display the items, you probably will want to remove this link altogether, and just display the image. You can do it by modifying the template file "view_cart_item.php". Make sure you read the documentation on the proper way to modify template files. Then see the example below:
    You need to find this code:
    Code:
    <a href="<?=$Product_Link?>"> 
       <img border="0" src="<?=$Thumbnail_Image ?>"> 
    </a>
    And change it to:
    Code:
    <img border="0" src="<?=$Thumbnail_Image ?>">
    11. You will probably also want to add some sort of continue shopping link to get them back to the store itself. You can do this in the template files "view_cart_header.php" OR "view_cart_footer.php". Just add a link like this:
    Code:
    <a href="javascript:history.go(-1)">Continue Shopping</a>
    This link is just like clicking the "back" button on your browser. You may want to change the number 1 to a 2 to go back 2 pages.

    Edit: 11/20/2004
    If you wish to add product options to your pages, you will need to generate code for each option. For a select input, the code would be similar to this:
    Code:
    Add extra blades: 
    <select name="option[]">
        <option value="Extra Blades^^^^----^^----"></option>
        <option value="Extra Blades^^5 pack^^.99^^1.5">5 pack: $.99</option>
        <option value="Extra Blades^^70 pack^^15.99^^5.5">70 pack: $15.99</option>
    </select>
    For a textarea input:
    Code:
    <input name='option[]' type='hidden' value='----'>
    Message for gift card:  <br>
    <textarea style='vertical-align: top; width: 200px; height: 100px' type='text' name='text_option[0]'></textarea>
    <input type='hidden' name='option_name[0]' value='Gift Card'>
    <input type='hidden' name='option_price[0]' value='----'>
    <input type='hidden' name='option_weight[0]' value='----'>
    <input type='hidden' name='option_type[0]' value='Textarea Input'>
    For a text input:
    Code:
    <input type="hidden" name="option[]" value="----">
    Enter message: <input type="text" style="width: 200" type="text" name="text_option[0]">
    <input type="hidden" name="option_name[0]" value="Message">
    <input type="hidden" name="option_price[0]" value="----">
    <input type="hidden" name="option_weight[0]" value="----">
    <input type="hidden" name="option_type[0]" value="Text Input">
    02/21/2005 Edit: You will also need to add the product options to the product's record (or it's category). The options need to match exactly, or Squirrelcart will not add them when adding the product to the cart.

    08/02/2005 Edit: As of v1.5.3, Squirrelcart checks product options when adding an item to the cart, to ensure that they have not been altered by a customer (i.e, to change the price, etc). The code that does this check will cause any options coded as described above to not add to the cart. To resolve this, you will need to disable the "tamper check". Here is how to do that:
    1. Open the file squirrelcart/functions/checkout/add_to_cart.func.php
    2. Find this line (around 90 to 100, depending on your version):
    PHP Code:
    if ($SC['prod_opt_cache'][$prod_rn][$cache_key]) $new_option[] = $option[$r]; 
    Change the line to this:
    PHP Code:
    if ($SC['prod_opt_cache'][$prod_rn][$cache_key] || true$new_option[] = $option[$r]; 
    Last edited by Jamie; January 9th, 2006 at 05:17 PM. Reason: Update for v2.0.0

  2. #2
    Client jmoody's Avatar
    Join Date
    Jul 2002
    Posts
    17
    Squirrelcart version
    not specified!
    Jamie -
    I have a great example of this on http://www.blatantusa.com if anybody wants to see it. The flash opens up a product detail window that then adds the product to the cart. Just thought you might like to have an example.

    Jared

  3. #3
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Very nice! Thanks for the link!

    -Jamie

  4. #4
    demo
    Guest

    integration question

    Hi,

    Well, I have a catalog driven in php/mysql. The system already has :
    product_Name
    product_Price
    product_Thumb
    product_Desc

    Could I mesh my catalog with the cart checkout/order forms? I'm looking for a ecommerce solution to my catalog site : http://www.justautomirrors.com.

    Thank you-
    Todd

  5. #5
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Hi Todd,

    As long as you put the form in step 9 on the page, with an "add to cart" button, it should work fine.

    Thanks,
    Jamie

  6. #6
    Client
    Join Date
    Oct 2003
    Location
    San Diego, CA
    Posts
    14
    Squirrelcart version
    not specified!

    Adding options

    Hello Jaime,
    I am currently hooking up a cart as described here. Can I add additional options to my form that can add to the base price when selected and submitted?
    Thanks,
    Rich

  7. #7
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Hi Rich,

    Yes, you can do this. The best way to figure this out is to add the options in the cart's admin interface, and let the cart generate the product display. Then view source, and copy the code that controls the option fields.

    Thanks,
    Jamie

  8. #8
    Client
    Join Date
    Apr 2004
    Location
    NC
    Posts
    17
    Squirrelcart version
    v2.4.5

    Smile

    I also have an existing mysql database that has all the information I need (except a nice cart!) including:

    - our internal 'record number'
    - Name
    - Price
    - Image filename (if any)
    - Description

    Here are my thoughts:

    1) modify the structure of squirrelcart.products to eliminate the 'auto-increment' functionality on the record number. This is because I want to be able to specify this.

    2) write a sql query I can run periodically against my existing 'store' to create an input file for the squirrelcart.products table. This would include the 5 fields listed above.

    3) preiodically empty the squirrelcart.products table and import the data from step#2 above.

    I would perform steps #2 and #3 whenever we update our master database with new information. We currently have over 500,000 unique part numbers in our master database, so manual updates to the squirrelcart tables is out of the question.

    questions:

    a) does this seem logical to anyone but me?
    b) will emptying and re-filling the 'squirrelcart.products' table periodically pose a problem as long as the record numbers remain constant from update to update?
    c) is there a better way to do this ?

    I thought of trying to combine our existing master product tables with the squirrelcart products table, but it seems more trouble than it's worth if steps #2 and #3 can be automated.

    Thoughts?

    Thanks,
    -Brian (recent SquirrelCart purchaser)

  9. #9
    Client
    Join Date
    Apr 2004
    Location
    NC
    Posts
    17
    Squirrelcart version
    v2.4.5
    Quote Originally Posted by Jamie

    Code:
    <form action="http://YOURSITE.COM/store.php?show_cart=1" method="post"> 
    <img src="someproduct.jpg">Buy this great product<br> 
    <b>Quantity: </b><input type="text" name="quantity" size="3" value="1"> 
    <input type="hidden" name="add_to_cart" value="1"> 
    <input type="hidden" name="base_price" value="169.00"> 
    
    <!--make the below match the product's record_number in the Squirrelcart DB-->
    <input type="hidden" name="prod_rn" value="173"> 
    
    <input type="hidden" name="prod_name" value="100 Watt Receiver"> 
    <input type="image" src="images/add_to_cart.gif"> 
    </form>
    I notice in the code above, that the item's price must be passed to the cart. Doesn't this pose a risk if users can just change that value and submit the form to the cart with a price of $1.00 ?

    I notice that I can do this in the cart out-of-the-box. Is there some way to prevent this kind of form tampering? If the price is already in the database, why must it be passed to the cart?

    Thanks in advance!,

    -Brian

  10. #10
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Hi Brian,

    I notice in the code above, that the item's price must be passed to the cart. Doesn't this pose a risk if users can just change that value and submit the form to the cart with a price of $1.00 ?
    In some cases, yes. The cart has a function that checks the referring address when adding to the cart. If the referring page is not on your site, it does not allow the person to add to the cart. Because modifying the form would mean that the person would have to load it locally, and then submit it, this SHOULD stop the person from being able to add to the cart.

    HOWEVER, we had some people complain that their customers where getting an access denied message during this check, because their browser was not passing a referring address. This usually happened when posting via a secure URL. Because of this, we added a line to the function that controls this to basically assume that when no referer was present, it was OK to add the item to the cart. We have removed this line in the next version, and going forward, those that have the problem I mentioned will need to manually put it back.

    If you want to update your cart to remove this line, just replace your "squirrelcart/functions/check_referer.func" file with the one attached.

    Thanks,
    Jamie
    Attached Files

  11. #11
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    a) does this seem logical to anyone but me?
    Yes.

    b) will emptying and re-filling the 'squirrelcart.products' table periodically pose a problem as long as the record numbers remain constant from update to update?
    The only problem I see is with step number 1. I would recommend that you use a different field to store your unique record number if possible, and leave the auto-increment there. You might be able to use the product code or SKU fields to hold that data. I can't guarantee that taking the auto-increment off will not cause a problem.

    c) is there a better way to do this ?
    Not that I know of.

    Thanks,
    Jamie

  12. #12
    Client
    Join Date
    Apr 2004
    Location
    NC
    Posts
    17
    Squirrelcart version
    v2.4.5

    Thought of another way...

    I thought of another way to populate the squirrelcart product database when used in conjunction with an existing store database.

    In this case, the 'master' database for my product information / price etc is stored in a pre-existing mysql database. I _had_ planned to periodically dump the squirrelcart database and repopulate it with data from the master store database.

    The problem is that this takes time and must be done after any change is made to the master database. There is a possibility of the two databases not matching which would lead to problems.

    Here's my idea:
    Don't put any data into the squirrelcart database until a visitor presses the 'add to cart' button in my store. When a user tries to add an item to the cart, I will immediately look that item up in the master DB and insert it into the squirrelcart DB. This way, the data will always be 100% correct and there is no need to do any periodic updates... I'll just let the customers do it for me.

    Does that sound stupid?

    -Brian Adkins

  13. #13
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Hi Brian,

    It doesn't sound stupid. It would require a major reworking of some of Squirrelcart's code to accomplish. Please be aware that we wouldn't be able to provide much support should you go that route. You would need to rewrite any code that currently does a lookup on Squirrelcart's product table.

    Thanks,
    Jamie

  14. #14
    Client
    Join Date
    Apr 2004
    Location
    NC
    Posts
    17
    Squirrelcart version
    v2.4.5

    Red face

    >>It would require a major reworking of some of Squirrelcart's code to accomplish

    I got it working without changing the Squirrelcart code a bit (Other than Jamie's original post above).

    When a user visits my existing store and views a product detail page, my existing store automatically updates the Squirrelcart PRODUCTS database with the name, base price, and record number of the item. Then, if the user clicks the "add to cart" button, they are transferred to the Squirrelcart which happily shows the correct information since it was just updated.

    I actually did add a few lines to the cart so that it would pull all data from the PRODUCTS db instead of from hidden form fields as items are added to the cart. This was covered in another thread on this board.

    The nice thing about this set up, is that I can change the variable for my profit margin in my existing store, and not have to worry about updating the Cart's database since it is updated item-by-item as users visit the product detail pages of my pre-existing store.

    -Brian
    Last edited by brianadkins; June 8th, 2004 at 07:11 PM.

  15. #15
    Client
    Join Date
    Dec 2003
    Posts
    43
    Squirrelcart version
    not specified!

    Shipping and Taxes

    Using your own pages and just the checkout feature in Quirrelcart, Jamie, you say that you only have to add to products,
    Name
    Price
    Thumnbnail Image
    Description

    Can I also use the shipping options on each product page to generate the shipping costs? and how about taxing items if being shipped in state?

    Search features? Keywords?

    thanks

    larry

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast

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