Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    413
    Plugin Contributions
    0

    Default "Display Cart After Adding Product" - Only if Stock is Less than 1

    Hi,

    In my ZC admin I have "Allow customer to checkout even if there is insufficient stock" set to true, and "Show Sold Out Image instead of Add to Cart Button" set to false. With this configuration customers can checkout even is there is insufficient stock, with their order being placed on backorder and shipped when available.

    As far as I can tell, the only time a customer would be actively informed about stock level/backordering is on the shopping_cart page via the "Products marked with *** are out of stock. Items not in stock will be placed on backorder." message. This is where the necessity to display the shopping_cart page ONLY when the stock level is less than 1 comes in...

    Desired results:

    Customers who add a product that is in stock to their cart, stay on the product_info page, with the "Successfully added Product to the cart ..." message shown (this is what currently already happens).

    Customers who add a product that is out of stock to their cart are forwarded to the shopping_cart page immediately after adding an out of stock product.

    Is this possible? If so, how?

    Thanks

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

    Default Re: "Display Cart After Adding Product" - Only if Stock is Less than 1

    You can try this ...

    Edit the file:
    /includes/init_includes/init_cart_handler.php

    and add the code in RED:
    Code:
      if ($session_started == false) {
        zen_redirect(zen_href_link(FILENAME_COOKIE_USAGE));
      }
    
    // bof: check to override DISPLAY_CART false
      $chk_products = $_POST['products_id'];
      $show_cart = false;
      if (is_array($chk_products)) {
        foreach ($chk_products as $key => $value) {
          if ((zen_get_products_stock($key) - ($value + $_SESSION['cart']->in_cart_mixed($key))) < 0) {
            $show_cart = true;
            break;
          }
        }
      } else {
        if (zen_get_products_stock($chk_products) <= 0) {
          $show_cart = true;
        }
      }
    
      if (DISPLAY_CART == 'true' || $show_cart) {
    // eof: check to override DISPLAY_CART false
        $goto =  FILENAME_SHOPPING_CART;
    see if that accomplishes what you are after ...
    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!]
    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
    May 2009
    Posts
    413
    Plugin Contributions
    0

    Default Re: "Display Cart After Adding Product" - Only if Stock is Less than 1

    Perfect!

    Thank you so much, Linda

    Edit: I noticed that there's an /overrides/ folder in /init_includes/ - should I stick the new edited file in there?

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

    Default Re: "Display Cart After Adding Product" - Only if Stock is Less than 1

    Yes, you can use the /overrides directory ...
    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!]
    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!

 

 

Similar Threads

  1. Blank Page after "adding product to Cart"
    By steve Nezia in forum General Questions
    Replies: 7
    Last Post: 18 Jan 2014, 12:37 AM
  2. v150 After adding to cart product goes to "Sold Out" even when in stock!
    By doooomed in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 8 Nov 2012, 11:31 PM
  3. v150 After adding new product it goes to "Sold Out" even when in stock!
    By oavs in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 20 Sep 2012, 02:52 AM
  4. Duplicated "new products" when they're less than 9
    By moosesoom in forum General Questions
    Replies: 5
    Last Post: 20 Jun 2010, 08:07 AM
  5. Adding more than one button "add to cart" on product info page....
    By Celebrimbor in forum General Questions
    Replies: 14
    Last Post: 4 Feb 2010, 05:41 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