Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Adding Model To Shopping Cart

    I am trying to add the product_id and model to the shopping cart form. I have this code:

    PHP Code:
    <?php echo '<li>Part#' TEXT_OPTION_DIVIDER $product['id'] . '</li>';
                            
    $products_model $db->Execute("SELECT products_model FROM " TABLE_PRODUCTS " WHERE products_id = " $product['id'] . " LIMIT 1;");
                              if (
    $products_model->RecordCount() > 0) {
                                
    $products_model $products_model->fields['products_model'];  
                                echo 
    '<li>Mfg Part#' TEXT_OPTION_DIVIDER $products_model '</li>';
                              } 
    ?>
    It worked fine; until I tested it with a product that has attributes.

    If I add a product with attribute I get this error

    Code:
    Part# - 2791:3b55bc83a02d362882e9292dddf7eb29
    1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':3b55bc83a02d362882e9292dddf7eb29 LIMIT 1' at line 1
    in:
    [SELECT products_model FROM products WHERE products_id = 2791:3b55bc83a02d362882e9292dddf7eb29 LIMIT 1;]
    Any idea how to fix this.

  2. #2
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    6,197
    Plugin Contributions
    0

  3. #3
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Re: Adding Model To Shopping Cart

    Thanks that did take care of the model issue, but any idea why when adding a product with attribute the products_id is always followed by :session_id?

    Only items with attributes show that.

    Part# - 2786:31c900c2a34b6ef10e6c880139e956ae

  4. #4
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: Adding Model To Shopping Cart

    Quote Originally Posted by CoolCarPartsOnline View Post
    Thanks that did take care of the model issue, but any idea why when adding a product with attribute the products_id is always followed by :session_id?

    Only items with attributes show that.

    Part# - 2786:31c900c2a34b6ef10e6c880139e956ae
    Pretty sure thats not a session id.
    I believe thats a products_prid.
    Its a form of hash that enables the cart to keep track of the same item with same or different attributes.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Re: Adding Model To Shopping Cart

    How can I disable that. Even if I add the product_id outside the attribute function it still display the number.

  6. #6
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: Adding Model To Shopping Cart

    Quote Originally Posted by CoolCarPartsOnline View Post
    How can I disable that. Even if I add the product_id outside the attribute function it still display the number.
    Use the function zen_get_prid() around this value
    This will return the only the products_id and strip off the unwanted bits

  7. #7
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Re: Adding Model To Shopping Cart

    adding (int) in front of it also worked.

  8. #8
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    6,197
    Plugin Contributions
    0

    Default Re: Adding Model To Shopping Cart

    Just curious what is the final code to make the Product ID and Model number appear in the shopping cart?

  9. #9
    Join Date
    Feb 2008
    Posts
    1,336
    Plugin Contributions
    1

    Default Re: Adding Model To Shopping Cart

    For my application, I included within the attribute id so if product has attribute it will show within the list.

    PHP Code:
    echo '<li>Part#' TEXT_OPTION_DIVIDER . (int)($product['id']) . '</li>';
                      echo 
    '<li>Mfg Part#' TEXT_OPTION_DIVIDER zen_products_lookup($product['id'], 'products_model') . '</li>'

 

 

Similar Threads

  1. model or mfgr in shopping cart?
    By gentlemoms in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 23 Jan 2012, 02:52 PM
  2. Show comments field below shopping cart if cart contains certain product model
    By frank18 in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 9 Feb 2010, 11:37 AM
  3. Product Model to display in Shopping Cart?
    By kazie in forum General Questions
    Replies: 2
    Last Post: 27 May 2009, 05:39 PM
  4. Showing Model # in Shopping Cart
    By Yesac13 in forum Customization from the Admin
    Replies: 4
    Last Post: 4 Oct 2008, 07:22 PM
  5. how do i show model # in shopping cart
    By flowerguy in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 18 Nov 2006, 09:24 PM

Posting Permissions

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