Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25
  1. #11
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    66,813
    Plugin Contributions
    6

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    NOTE: these would be better checks on the extra stock check:

    Code:
    //        if ( (zen_get_products_stock($products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($products[$i]['id']) - $_SESSION['cart']->get_quantity($products[$i]['id']))) <= 0) {
              if ($_SESSION['cart']->in_cart_mixed($products[$i]['id']) > zen_get_products_stock($products[$i]['id'])) {
    Code:
    //      if ( (zen_get_products_stock($order->products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($order->products[$i]['id']) - $_SESSION['cart']->get_quantity($order->products[$i]['id']))) <= 0) {
          if ($_SESSION['cart']->in_cart_mixed($order->products[$i]['id']) > zen_get_products_stock($order->products[$i]['id'])) {
    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.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  2. #12
    Join Date
    Apr 2009
    Location
    In a traffic jam
    Posts
    1,998
    Plugin Contributions
    1

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    I believe that the same issue applies to the quantity in cart feature on the product_info page. By which I mean that with two identical products, except for text attributes that differ, the quantity in cart is shown as 1. I am working on a 'far from clean' install so perhaps I am mistaken.

    I also wonder if corresponding changes need to be made to ipn_main_handler.php ? Sort of similar to the changes required by stock by attributes.

  3. #13
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    66,813
    Plugin Contributions
    6

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    Make sure that in the Configuration ... Stock ... you have turned on the Stock Check:
    Check stock level
    Check to see if sufficent stock is available
    true
    Subtract stock
    Subtract product in stock by product orders
    true
    Allow Checkout
    Allow customer to checkout even if there is insufficient stock
    false
    Make sure that on the Product you have set:
    Product Qty Min/Unit Mix: Yes
    Make sure that you made the extra stock check on the:
    /includes/modules/pages/shopping_cart/header_php.php
    /includes/modules/pages/checkout_shipping/header_php.php
    /includes/modules/pages/checkout_payment/header_php.php
    /includes/modules/pages/checkout_confirmation/header_php.php

    I am also assuming that you are using the current Zen Cart v1.5 ...

    from above ...
    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.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  4. #14
    Join Date
    Apr 2009
    Location
    In a traffic jam
    Posts
    1,998
    Plugin Contributions
    1

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    It is a test install of 1.5. Just cleaned it down and restarted from scratch.

    How to repeat:
    1. Create a product with an attribute (size) and a text attribute.
    2. Add the product to the cart with a text attribute set.
    2. Add the product to the cart again with a different text attribute

    The products both show in the cart. However, back on the product_info page the 'Quantity in Cart' shows as one.

    Basically in the shopping_cart class function get_quantity($products_id) returns the value of the first product with the correct id. It does not have anything to do with the stock check. ( But I have the settings and changes that you detailed above)

    The source below shows the cart object has three products all with the same id. But get_quantity returns a value of 3 which is the stock level of the first one in the list.

    Code:
    Session Cart<br>shoppingCart Object
    (
        [contents] => Array
            (
                [7:f1319f0c3751189feae9d6c0df890476] => Array
                    (
                        [qty] => 3
                        [attributes_values] => Array
                            (
                                [3] => ffff
                            )
    
                        [attributes] => Array
                            (
                                [3] => 0
                                [4_chk7] => 7
                                [2] => 3
                                [1] => 6
                            )
    
                    )
    
                [7:4cfb5324f02c287e27107f9e5453bbdb] => Array
                    (
                        [qty] => 1
                        [attributes_values] => Array
                            (
                                [3] => 44
                            )
    
                        [attributes] => Array
                            (
                                [3] => 0
                                [4_chk7] => 7
                                [2] => 3
                                [1] => 6
                            )
    
                    )
    
                [7:a5d012a3cd410db0c8e57446dabae7d8] => Array
                    (
                        [qty] => 1
                        [attributes_values] => Array
                            (
                                [3] => 55
                            )
    
                        [attributes] => Array
                            (
                                [3] => 0
                                [4_chk7] => 7
                                [2] => 2
                                [1] => 5
                            )
    
                    )
    
            )
    
        [total] => 2050
        [weight] => 0
        [cartID] => 16821
        [content_type] => 
        [free_shipping_item] => 0
        [free_shipping_weight] => 0
        [free_shipping_price] => 0
    )
    <br>get_quantity returns <br>3<br>
    Also, as I said the stock check in ipn_main_handler.php will not cope with this situation. It checks the stock on a product per product basis. So, it will see both those products as being in stock. As similar fix to that detailed above is required where the extra stock check is added in to the code. As I say, similar to the extra checks that are needed for stock by attributes to function properly with ipn_main_handler.

  5. #15
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    66,813
    Plugin Contributions
    6

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    You could try this new test ...

    Put all your files back how they were and just make this one change to the file:
    /includes/functions/functions_lookups.php

    And add the code in RED:

    Code:
      function zen_check_stock($products_id, $products_quantity) {
        //$stock_left = zen_get_products_stock($products_id) - $products_quantity;
        $stock_left = zen_get_products_stock($products_id) - $_SESSION['cart']->in_cart_mixed($products_id);
        $out_of_stock = '';
    
        if ($stock_left < 0) {
          $out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
        }
    
        return $out_of_stock;
      }
    Just to that one function and see if it fixes everything from the PayPal button, to shopping_cart to checkout_shipping, to checkout_payment to checkout_confirmation and ipn_main_handler...
    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.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  6. #16
    Join Date
    Apr 2009
    Location
    In a traffic jam
    Posts
    1,998
    Plugin Contributions
    1

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    Yeah, I think that is the heart of the issue. $_SESSION['cart']->in_cart_mixed works better than just the quantity.

    So, actually in tpl_product_info_default.php I think that it shoud read:

    Code:
        $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->in_cart_mixed($_GET['products_id']) . '</p>' : '');

  7. #17
    Join Date
    Apr 2009
    Location
    In a traffic jam
    Posts
    1,998
    Plugin Contributions
    1

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    And the slight issue here is that it marks all products out of stock. So with a stock of one and two in the cart with different attributes both are marked out of stock although one is actually purchasable.

    Where I came to this is by a module that is under work to exclude some attributes from stock by attribute calculations. A parallel problem arose an I needed to write a stock check function that looped through the cart and calculated the total of the product in the cart at that point. So with two products the first one would have a 'total in the cart so far' count of one and would be in stock. The second product would have a 'total in the cart so far' count of two and would be out of stock.

    A bit of a pain ...

  8. #18
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    66,813
    Plugin Contributions
    6

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    First, please make the one change in the one function zen_check_stock and see if that fixes everything everywhere ... and ensure the checkout is working ...
    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.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  9. #19
    Join Date
    Apr 2009
    Location
    In a traffic jam
    Posts
    1,998
    Plugin Contributions
    1

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    Sorry, I had written a longer post and then censored myself for being wordy.

    Yes, that is what I did. Works fine for everything to do with the cart and checkout. So, yes, that is a nicer solution than changing the header_php files. But doesn't solve any issues that those changes didn't.

    Where it doesn't work by itself is in product_info.

    Also, as I say it marks multiple products out of stock when only some of them are actually out of stock. Which ones should actually be marked out of stock is a bit moot.

  10. #20
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    66,813
    Plugin Contributions
    6

    Default Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.

    Have you an URL on your site where we can perhaps see this working or not working as you are wanting it to?
    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.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Requiring some text (attribute) when placing order...
    By rebekah in forum Setting Up Categories, Products, Attributes
    Replies: 15
    Last Post: 12 Dec 2011, 09:11 AM
  2. Stock By Attributes & Attribute order
    By laurenjj in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 10 Jul 2011, 12:00 AM
  3. Stock by Attribute setup and product has stock when added to card says out of stock
    By kwrosenzweig in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 9 Jun 2011, 06:18 PM
  4. error when checking out with stock by attribute mod
    By zoaconner in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 2 Feb 2010, 07:02 AM
  5. Replies: 4
    Last Post: 22 Jan 2010, 10:43 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
  •