Page 3 of 12 FirstFirst 12345 ... LastLast
Results 21 to 30 of 113
  1. #21
    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

  2. #22
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    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.

  3. #23
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    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
      }
    }

  4. #24
    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

  5. #25
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: Restrict Digital Downloads [Support Thread]

    I've got an option (radio-button) named "Delivery Method" that has two option values: I'll download it and Email it to me. I apply those two option/value pairs via the Attributes Controller to my downloads (the I'll download it option has the download file associated).

    If the responsive template you're using is one of Picaflor-Azul's, she's got a tendency to mis-code calls to get_template_dir like this:
    Code:
    <script src="<?php echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/back_to_top.min.js'; ?>" type="text/javascript"></script>
    where the proper coding is
    Code:
    <script src="<?php echo $template->get_template_dir('back_to_top.min.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/back_to_top.min.js';  ?>" type="text/javascript"></script>
    I ran into that gotcha in another customization that I created that uses the template-override method used by RDD.

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

    Default Re: Restrict Digital Downloads [Support Thread]

    I'm gonna have to wipe everything and start from scratch.

    Yes I am using one of Anne's templates. Made the edit for get_template.

    Create new temp digital download product category
    Create new product within that category
    Add attribute for download pdf file and associate a pdf to that attribute
    Add attribute for "Email the file to me"
    attribute option type is "Checkbox" (a couple products contain multiple download files)
    Is the checkbox the source of my headache?

    I get the yellow alert message but am still able to add the product to the cart regardless of chosen attribute.

    Checkout and receive the download link immediately.

    DarN. It may be a day or two before I have the time to start from scratch. Physical Christmas orders are a bit more pressing.
    Last edited by RixStix; 18 Dec 2014 at 05:39 PM.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

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

    Default Re: Restrict Digital Downloads [Support Thread]

    How dumb can a person feel?
    Can I claim a "DUH" moment?

    Repeat after me a kazillion times....

    Radio, Radio, Radio. NOT checkbox, NOT checkbox, NOT checkbox.

    Our initial reason for using checkbox is that we have a couple products which have 2 or more pdf associated with the product.
    More reason for me to redo things.

    Things appear to work when I use the proper setup. Says he with egg completely covering face.
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  8. #28
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: Restrict Digital Downloads [Support Thread]

    When the product was using a checkbox attribute, was it that the product (without the checkbox-option) was added to the cart? I tested using a checkbox-type attribute, thinking that there might be a product that could be either physical (unchecked) or virtual (checked).

  9. #29
    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
    When the product was using a checkbox attribute, was it that the product (without the checkbox-option) was added to the cart? I tested using a checkbox-type attribute, thinking that there might be a product that could be either physical (unchecked) or virtual (checked).
    download file attribute can be added to cart if checked, regardless of warning.

    product with no checkbox selected can be added to cart
    product with download attribute selected can be added to cart
    product with "email it to me" attribute selected can be added to cart
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  10. #30
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,494
    Plugin Contributions
    88

    Default Re: Restrict Digital Downloads [Support Thread]

    Can you post or PM a link?

 

 
Page 3 of 12 FirstFirst 12345 ... LastLast

Similar Threads

  1. Hebrew Support - latest release [Support Thread]
    By eranariel in forum Addon Language Packs
    Replies: 19
    Last Post: 23 Jan 2023, 08:04 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

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