Results 1 to 10 of 113

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,926
    Plugin Contributions
    96

    Default Re: Restrict Digital Downloads [Support Thread]

    Arggh, I should have seen that before. Do you have a customized /includes/modules/YOUR_TEMPLATE/attributes.php? For a 'out-of-the-box' Zen Cart attributes.php, the 'id' value will come back as an array in options_id => options_values_id format, like the following:
    Code:
    [14-Dec-2014 14:56:50 America/Los_Angeles] /home/XXXXXXXX/public_html/ZEN153/includes/extra_cart_actions/restrict_digital_downloads.php:Array
    (
        [securityToken] => Not sure if it is OK to post that
        [cart_quantity] => 1
        [products_id] => 776
        [id] => Array
            (
                [6] => 61
     
            )
    
    )

  2. #2
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: Restrict Digital Downloads [Support Thread]

    Quote Originally Posted by lat9 View Post
    Arggh, I should have seen that before. Do you have a customized /includes/modules/YOUR_TEMPLATE/attributes.php? For a 'out-of-the-box' Zen Cart attributes.php, the 'id' value will come back as an array in options_id => options_values_id format, like the following:
    No, I do not. Searched using Developers Took Kit and didn't find anything by that name.

    I did 'drop' the fileset into template_default instead of installing a vanilla template, did nothing on the admin side other than change template to classic_green.

    Same result.

    Work is calling my name so I'll be in and out for the next few hours.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,926
    Plugin Contributions
    96

    Default Re: Restrict Digital Downloads [Support Thread]

    There's got to be something different; I've tested this on a Zen Cart v1.5.1 and a Zen Cart v1.5.3 store and both stores log the 'id' variable as 'id'[options_id][values_id].

  4. #4
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: Restrict Digital Downloads [Support Thread]

    Sorry I couldn't reply sooner. This forum does not play nice with Surface tablets which is my only access in the manufacturing room.

    I was going to suggest that I wipe the sandbox and start from scratch instead of you tracking down ghosts or other unknowns.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  5. #5
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: Restrict Digital Downloads [Support Thread]

    That is the format of the logfile prior to the last suggested edit.

    includes/modules/attributes.php default file is being used.

    It looks like your download product examples have more than a single attribute choice. Ours currently only have a single attribute. Any chance that is related?

    Quote Originally Posted by lat9 View Post
    Arggh, I should have seen that before. Do you have a customized /includes/modules/YOUR_TEMPLATE/attributes.php? For a 'out-of-the-box' Zen Cart attributes.php, the 'id' value will come back as an array in options_id => options_values_id format, like the following:
    Code:
    [14-Dec-2014 14:56:50 America/Los_Angeles] /home/XXXXXXXX/public_html/ZEN153/includes/extra_cart_actions/restrict_digital_downloads.php:Array
    (
        [securityToken] => Not sure if it is OK to post that
        [cart_quantity] => 1
        [products_id] => 776
        [id] => Array
            (
                [6] => 61
     
            )
    
    )
    Last edited by RixStix; 16 Dec 2014 at 09:14 PM.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,926
    Plugin Contributions
    96

    Default Re: Restrict Digital Downloads [Support Thread]

    Quote Originally Posted by RixStix View Post
    That is the format of the logfile prior to the last suggested edit.

    includes/modules/attributes.php default file is being used.

    It looks like your download product examples have more than a single attribute choice. Ours currently only have a single attribute. Any chance that is related?
    You nailed it! I've got this replicated now on my local test site and should have a correction by the morning. Thanks a bunch!

  7. #7
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: Restrict Digital Downloads [Support Thread]

    You're welcome, I think.

    But I'm also thinking that in order to have an alternative choice for the digital download for the EU customers, at least a second attribute should be required for the choice of "Email the file to me" instead of the automated download.

    That would be a "my problem" not a lat9 problem to resolve? OR attribute to add?

    OK, I will hold off wiping the sandbox.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,926
    Plugin Contributions
    96

    Default Re: Restrict Digital Downloads [Support Thread]

    Quote Originally Posted by RixStix View Post
    You're welcome, I think.

    But I'm also thinking that in order to have an alternative choice for the digital download for the EU customers, at least a second attribute should be required for the choice of "Email the file to me" instead of the automated download.

    That would be a "my problem" not a lat9 problem to resolve? OR attribute to add?

    OK, I will hold off wiping the sandbox.
    I'll go for a "combined" problem. I believe that you should offer your customers an alternative-delivery choice, but the plugin should be bullet-proof.

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,926
    Plugin Contributions
    96

    Default Re: Restrict Digital Downloads [Support Thread]

    My internet access has been funky; I thought that I'd posted the corrections that are included in the (just uploaded) v1.0.1.

    Anyway, here are the two files that are changed in that version. First /includes/extra_cart_actions/restrict_digital_downloads.php:
    Code:
    // -----
    // Part of the "Restrict Digital Downloads" plugin
    // Copyright (c) 2014 Vinos de Frutas Tropicales
    //
    switch ($_GET['action']) {
      /*----
      ** If a product is being added to the cart and that product includes attributes (the $_POST['id'] array
      ** is set), then 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': {
        if ($_SESSION['is_restricted_ip'] && isset($_POST['products_id']) && $_POST['cart_quantity'] > 0) {
          $the_options = array ();
          if (isset($_POST['id']) && is_array($_POST['id'])) {
            $the_options = $_POST['id'];
            
          }
          if (isset ($_POST['download_options']) && is_array ($_POST['download_options'])) {
            foreach ($_POST['download_options'] as $option => $value) {
              if (!isset ($the_options[$option])) {
                $the_options[$option] = $value;
                
              }
            }
          }
          foreach ($the_options as $option => $value) {
            if (is_digital_download ($_POST['products_id'], $option, $value)) {
              $messageStack->add ('header', sprintf (CART_MESSAGE_DOWNLOAD_PRODUCT_RESTRICTED, zen_get_products_name ($_POST['products_id'])), 'caution');
              unset ($_GET['action']);
              break;
    
            }
          }
        }
        break;
      }
    }
    Secondly, /includes/templates/YOUR_TEMPLATE/{product_type}/extra_main_template_vars/restrict_digital_downloads.php:
    Code:
    <?php
    // -----
    // Part of the "Restrict Digital Downloads" plugin
    // Copyright (c) 2014 Vinos de Frutas Tropicales
    //
    // NOTE:  $products_options_names, $options_menu and $order_by are previously set by /includes/modules/attributes.php's processing.
    //
    if (isset ($_SESSION['is_restricted_ip']) && isset ($products_options_names)) {
      $products_options_names->Move (0);
      $products_options_names->MoveNext ();  //-Rewind the object to the beginning
      
      $download_selectors = '';
      $downloads_present = false;
      $option_count = 0;
      while (!$products_options_names->EOF) {
        $options_id = (int)$products_options_names->fields['products_options_id'];
        $products_options = $db->Execute ("SELECT pov.products_options_values_id, pov.products_options_values_name, pa.*
                                             from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
                                            where pa.products_id = '" . (int)$_GET['products_id'] . "'
                                              and pa.options_id = '$options_id'
                                              and pa.options_values_id = pov.products_options_values_id
                                              and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " . $order_by);
        $option_has_download = false;
        while (!$products_options->EOF) {
          $options_values_id = $products_options->fields['options_values_id'];
          $download_check = $db->Execute ("SELECT products_attributes_id FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE products_attributes_id = " . $products_options->fields['products_attributes_id'] . " LIMIT 1");
          if (!$download_check->EOF) {
            $option_has_download = true;
            $downloads_present = true;
            $products_options_type = zen_get_attributes_type ($products_options->fields['products_attributes_id']);
            switch ($products_options_type) {
              case PRODUCTS_OPTIONS_TYPE_SELECT: {
                $download_selectors .= (($products_options->RecordCount ()) == 1) ? ('#attrib-' . $options_id . '-' . $options_values_id . ', ') : ('#attrib-' . $options_id . ' option[value="' . $options_values_id . '"], ');
                break;
              }
              case PRODUCTS_OPTIONS_TYPE_RADIO: {
                $download_selectors .= '#attrib-' . $options_id . '-' . $options_values_id . ', ';
                break;
              }
              default: {
                break;
              }
            }
          }
          if ($option_has_download && $products_options->RecordCount () == 1 && $products_options_type != PRODUCTS_OPTIONS_TYPE_CHECKBOX) {
            $options_menu[$option_count] .= zen_draw_hidden_field ("download_options[$options_id]", $options_values_id);
            
          }
          $products_options->MoveNext ();
          
        }
        $option_count++;
        $products_options_names->MoveNext ();
        
      }
      if ($downloads_present != '') {
        $messageStack->add ('product_info', PRODUCT_MESSAGE_DOWNLOAD_PRODUCT_RESTRICTED, 'caution');
        
      }
      if ($download_selectors != '') {
        $download_selectors = substr ($download_selectors, 0, -2);  //-Strip trailing ', '
    ?>
    <script type="text/javascript">
    $(document).on ('ready', function(){
      $('<?php echo $download_selectors; ?>').each(function(){
        $(this).removeAttr( 'selected checked' );
        $(this).attr( 'disabled', 'disabled' );
      });
    });
    </script>
    <?php
      }
    }

  10. #10
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: Restrict Digital Downloads [Support Thread]

    TNX lat9

    I know funky internet . I'm lucky we have not had snow yet. Snow on the mountaintops usually plays havoc with our 1MB connection.

    I don't see any difference in functionality other than no MyDebug logs are generated.


    I get the yellow warning banner but am still able to add the product to the cart and complete the checkout.

    I have not changed any product details, nor have I added an attribute for a non-pdf choice.

    Before I wipe the sandbox and test with my database/product setup without any plugins or responsive template, do you have a specific downloadable product w/attributes setup example that I could use to generate a new product within the catalog for testing.
    Last edited by RixStix; 18 Dec 2014 at 04:17 PM.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

 

 

Similar Threads

  1. Hebrew Support - latest release [Support Thread]
    By eranariel in forum Addon Language Packs
    Replies: 22
    Last Post: 26 Jan 2026, 06:47 AM
  2. v151 Limit Quantities for Downloads and Virtual Products [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 47
    Last Post: 17 Jan 2016, 03:48 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. Digital Downloads
    By keithck73 in forum General Questions
    Replies: 8
    Last Post: 9 Mar 2009, 06:45 PM
  5. Admin Users - Restrict Product Categories Support Thread
    By anafor in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 13 Aug 2008, 09:30 AM

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