Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Feb 2007
    Location
    New York
    Posts
    88
    Plugin Contributions
    0

    Default Show quantity in cart only when the product is already in shopping cart

    Hi,

    I'd like to know what I should do to make the "add to cart" button invisible on product info page when the product is already in the shopping cart?

    1. When the product is not in the shopping cart -> show "add to cart" button

    2. When the product is in the shopping cart -> show a message indicates that this product is already in the cart.

    Can this be done?

    Thanks for any suggestions!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show quantity in cart only when the product is already in shopping cart

    I know I made a post on this the other day, as in the last 45 days I think, that would change the add to cart to a delete button when the product is in the cart ...

    Not sure where I might have put that ...

    Pretty sure that was a post and not just a quick fix for someone ... I think ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Feb 2007
    Location
    New York
    Posts
    88
    Plugin Contributions
    0

    Default Re: Show quantity in cart only when the product is already in shopping cart

    Quote Originally Posted by Ajeh View Post
    I know I made a post on this the other day, as in the last 45 days I think, that would change the add to cart to a delete button when the product is in the cart ...

    Not sure where I might have put that ...

    Pretty sure that was a post and not just a quick fix for someone ... I think ...
    Hi. I tried to look in all the post you made but couldn't find anything related to my question.. Do you remember how you did that (change "add to cart" to "delete" when the product is in the cart) ?

    Anybody else??

    Thanks in advance.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show quantity in cart only when the product is already in shopping cart

    There is a function zen_get_buy_now_button ... that controls the button setting for add to cart so that it changes based on store status, customer authorization, product status such as call for price, sold out etc.

    Adding a new case to it that changes the button to a delete or something other than an add to cart vs the other choices was the basic idea ...

    This saved having to touch the code in numerous places ... and just using the one function to control it all ...

    In this circumstance, the idea was if a product existed in quantity of 1 or greater it would switch to a delete button ...

    Adding this code before the default in the last set of case statements should manage this:
    PHP Code:
    // switch to delete button when at least 1 is in the cart
        
    case ($_SESSION['cart']->get_quantity($product_id) > 0):
          
    $return_button '<a href="' zen_href_link($_GET['main_page'], m zen_get_all_get_params(array('action')) . 'action=remove_product&product_id=' $product_id) . '">' zen_image_button(BUTTON_IMAGE_DELETEBUTTON_IMAGE_DELETE_ALT) . '</a>';
          return 
    $return_button;
          break; 
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Feb 2007
    Location
    New York
    Posts
    88
    Plugin Contributions
    0

    Default Re: Show quantity in cart only when the product is already in shopping cart

    If I only want to show a message saying this product is already in your cart, wouldn't that be much easier than swtiching to "delete" button?

    Can't we just use something like:
    if cart quantity = 1 , then show message "You have this in your cart"
    else
    show "add to cart" button

    Of course the "code" is all wrong; maybe someone can help me put the code together?

    Thanks!

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show quantity in cart only when the product is already in shopping cart

    I am just showing you an example ...

    You can adjust that to add on text or what have you ... or adjust the existing case statements ...

    NOTE: The things in the cart when added already show:
    Quantity in Cart: 1

    However ... if the product is added with attributes, unless the customer comes in from the shopping_cart where the product includes the attributes it will not show ...

    This could be altered if only the products_id was checked without the attribute attached ...

    There is also the switch in the Catalog ... Product Type ... Edit Layout button where on the product_info page it shows this only if turned on:
    Show Quantity in Shopping Cart
    Display Quantity in Current Shopping Cart on Product Info 0= off 1= on
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Feb 2007
    Location
    New York
    Posts
    88
    Plugin Contributions
    0

    Default Re: Show quantity in cart only when the product is already in shopping cart

    I was "playing" with the code and I came up with something like this:

    PHP Code:
    <?php
         
    if ($_SESSION['cart']->in_cart($_GET['products_id'])) {
        
          echo 
    $display_qty;
          
        } else {  
         
          echo 
    $display_button
        }
    ?>
    It seems to work! It will say "Quantity in Cart: 1" when this product is in the shopping cart. If it's not in the cart, the "Add to Cart" button will show.

    Linda, what do you think? Is there any concerns???

    Thanks for any feedback!

    PS. All product include only one attribute (download only).
    Last edited by e81ny; 13 Jul 2007 at 04:10 AM.

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show quantity in cart only when the product is already in shopping cart

    Have you an URL to your site that I could peek at?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  9. #9
    Join Date
    Feb 2007
    Location
    New York
    Posts
    88
    Plugin Contributions
    0

    Default Re: Show quantity in cart only when the product is already in shopping cart

    Here it is:

    http://www.imagoformosa.com/catalog/

    PS. Of course the iPhone and the image of Phil Collins are just samples; they are not my work..

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Show quantity in cart only when the product is already in shopping cart

    From what I can see you are trying to fix Centerboxes such as:
    /includes/modules/new_products.php

    and alter the code for the link to change to text vs the link ...

    The other product_info appears to be working correctly ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 21 May 2011, 04:16 PM
  2. Show Product Quantity In Shopping Cart In Header?
    By mcqueeneycoins in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 29 May 2010, 05:14 PM
  3. shopping cart - hide the Cart Quantity Update button when not needed
    By dause in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 1 Oct 2009, 04:28 AM
  4. Show Product out of stock in checkout - not only in shopping cart.
    By Gomlers in forum Managing Customers and Orders
    Replies: 5
    Last Post: 13 Jul 2009, 03:01 PM
  5. shopping cart box only shows when cart is full
    By jamieboulder in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 26 Feb 2008, 05:29 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR