Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 48
  1. #11
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Quote Originally Posted by Ajeh View Post
    It works on the 1st time you add from the Product page but if you go to the Product page again and do the add you continue to be able to get an additional Product in the cart ...

    To replicate this, you need to be adding a Download Product that has 2 downloads like the Demo Product for:
    /index.php?main_page=product_info&cPath=54_60&products_id=133
    Hmm, I'm not seeing that. If I add the English/PDF option it adds to cart. I return to the product page to add another English/PDF and get the "I limited your quantity" message and only 1 is in the cart. I return to the product page and add English/Word and it properly adds.

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

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Are you using this in Zen Cart v1.5 or v1.5.1 or which version ... I trip the error by add quantity 1 from:
    /index.php?main_page=product_info&cPath=54_60&products_id=133

    Then go to:
    /index.php?main_page=product_info&cPath=54_60&products_id=133

    and add quantity 1 and I now have 2 in the shopping_cart ...

    This is in v1.5.1 and in v1.5 ...

    Sorry I could not get to this earlier today ...
    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. #13
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Using ZC 1.5.1 (two localhost installations), PHP 5.3.8 (although I don't think that that's the difference). Using the following for /includes/extra_cart_actions/limit_downloads.php:
    Code:
    <?php
    /**
     * Extra shopping Cart actions supported.
     *
     * @copyright Copyright 2009-2012 Vinos de Frutas Tropicales
     * @copyright Copyright 2003-2010 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: limit_downloads.php 2012-11-26 lat9
     *
     * The main cart actions supported by the current shoppingCart class.
     *
     * This module checks for a downloadable and/or virtual product already present in the cart and disallows an additional product
     * quantities of the exactly-same configuration to be added.
     *
     * NOTE:  See also \includes\languages\english\extra_definitions\YOURTEMPLATE\limit_downloads.php for language constants.
     *
     */
    
    switch ($_GET['action']) {
      /*---- Update product quantities in the cart ----
      */
      case 'update_product':
        if (isset($_POST['products_id'])) {
          for ($i = 0, $n=sizeof($_POST['products_id']); $i < $n; $i++) {   
            if (!(in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()))) && $_POST['cart_quantity'][$i] > 1 ) {
              if (isset($_POST['id'][$_POST['products_id'][$i]])) {
                foreach($_POST['id'][$_POST['products_id'][$i]] as $option => $value) {
                  if (ldProductIsDownload ($_POST['products_id'][$i], $option, $value)) {
                    $_POST['cart_quantity'][$i] = 1;
                    $messageStack->add_session('header', sprintf(ERROR_MAXIMUM_DOWNLOADS, zen_get_products_name($_POST['products_id'][$i])), 'caution');
                    break;
                  }
                }
              } 
            }
          }
        }
      break;
      /*---- Add a product to cart ----
      **
      ** If a product is being added to the cart (with a quantity greater than 0) and that product includes attributes (the $_POST['id'] array
      ** is set), then if either that product is already in the cart -OR- if the quantity to be added is greater than 1,
      ** check each of the attributes being added to see if there is a download/virtual product amongst them.  If so,
      ** don't allow the duplicate download/virtual product to be added to the cart ... or just add 1 if this is the original add.
      */
      case 'add_product':
    //-bof-v1.1.1c
        if (isset($_POST['products_id']) && $_POST['cart_quantity'] > 0 && isset($_POST['id']) && is_array($_POST['id'])) {
          $the_ids = $_POST['id'];
          foreach($_POST['id'] as $option => $value) {
            if (ldProductIsDownload ($_POST['products_id'], $option, $value)) {
              if ($_SESSION['cart']->in_cart(zen_get_uprid($_POST['products_id'], $the_ids))) {
                $messageStack->add_session('header', sprintf(ERROR_MAXIMUM_DOWNLOADS, zen_get_products_name($_POST['products_id'])), 'caution');
                zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters)));
                
              } elseif ($_POST['cart_quantity'] > 1) {
                $_POST['cart_quantity'] = 1;
                $messageStack->add_session('header', sprintf(ERROR_MAXIMUM_DOWNLOADS, zen_get_products_name($_POST['products_id'])), 'caution');
                
              }
              break;
            }
          }
        }
    //-eof-v1.1.1c
      break;
    }
    
    function ldProductIsDownload ($products_id, $options_id, $options_value_id) {
      global $db, $zco_notifier;
      if (zen_get_products_virtual($products_id)) return true;
      
      $sql = "SELECT count(*) as count
              FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
              WHERE pa.products_id = " . (int)$products_id . "
              AND   pa.options_id = " . (int)$options_id . "
              AND   pa.options_values_id = " . (int)$options_value_id . "
              AND   pa.products_attributes_id = pad.products_attributes_id";
      $sql_result = $db->Execute($sql);
    
      $zco_notifier->notify('LD_CHECK', array ('products_id' => $products_id, 'options_id' => $options_id, 'options_value_id' => $options_value_id, 'is_download' => $sql_result->fields['count']));
      return ($sql_result->fields['count'] > 0) ? true : false;
    }
    Using index.php?main_page=product_info&products_id=133, I add "quantity = 1" to the cart (English/PDF) and go back to add another "quantity=1" (English/PDF) and receive the message "The quantity for Multiple Downloads was adjusted in your cart. Your cart can hold at most one copy of each customization for a downloadable/virtual product.". I can add "quantity = 1" of the Spanish/PDF version.

    I'm perplexed as to why your installation isn't experiencing the same behavior.

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

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    And we have a winner!

    Using that code it works properly on Single Download, Multiple Download and Triple Download, tossed that in for giggles and grins, and now works in v1.3.9h, v1.5, v1.5.1, as well as the up and coming v1.5.2 and v1.6

    Excellent job and thanks for the assist ...

    Now I just have to fun the weird bug this tripped on a code fix that I did from my original code that tells me we doth have a potential bug in some re-writes I am working on in the shopping cart class ... but that is new code and nothing you did wrong, just helped to trigger a bizzaro error that I will need the guys to help me sort through my madness ...

    Thanks again for the excellent code and hope nobody can come along and break it ...
    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. #15
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Nobody else, that is! Thanks for the update that it's working, now. I'll get this packaged up to the Plugins.

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

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    I appreciate you taking the time to work through this so that even I cannot break things ... yet ... a definite asset to the community ...
    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. #17
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    I have been sitting back watching two of the smartest women in this community working it out!!! AWESOME!!! Now that the dust has settled I can update my store..

    Thanks for the hard work ladies!!!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

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

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    I had the easy part ... breaking stuff ...
    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. #19
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Quote Originally Posted by Ajeh View Post
    I had the easy part ... breaking stuff ...
    That is the fun part!!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

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

    Default Re: Limit Quantities for Downloads and Virtual Products [Support Thread]

    Yes ... it is ...
    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 2 of 5 FirstFirst 1234 ... LastLast

Similar Threads

  1. v154 All Products Virtual -- No Shipping [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 16
    Last Post: 22 Jul 2019, 12:04 PM
  2. v153 Restrict Digital Downloads [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 112
    Last Post: 19 Jan 2016, 05:46 PM
  3. v154 Email Downloads Support Thread
    By swguy in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 17 Jun 2015, 06:41 PM
  4. v151 Virtual Agent ASKOM Support Thread
    By askom in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 3 Apr 2014, 09:13 AM
  5. difference between downloads and virtual products
    By artcoder in forum General Questions
    Replies: 2
    Last Post: 20 Feb 2008, 11:42 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