Restrict Digital Downloads [Support Thread]
You've got a Zen CartŪ store that currently delivers automatic digital downloads to your customers and you'd like to restrict the delivery of those automatic downloads based on a specific list of countries. This plugin (RDD) inspects the IPv4 address of a customer that "arrives" at your store, determines if their IP address is associated with a restricted country and, if so, disables any digital-download product options.
I'll post the Plugins area download link once I've received it; RDD will be available for download upon approval.
Plugin download link: http://www.zen-cart.com/downloads.php?do=file&id=1933
Re: Restrict Digital Downloads [Support Thread]
RDD is now available for download.
Re: Restrict Digital Downloads [Support Thread]
Thank you lat9 for this plugin.
It is probably a short circuit between the ears but I have read the instructions several times.
I assumed that to test the functionality, a person just adds US into the string of countries in
/YOUR_ADMIN/includes/extra_datafiles/ip2country_file_database_admin_names.php
update the IP2location csv
attempt to add a product which contains a download file (pdf) to the cart.
That must have been a wrong assumption because I can navigate to a downloadable product page and add it to the cart without receiving a message.
Any pointers appreciated.
As you indicated, the IP2location database table is 1.8Mb and contains 64,500 rows, though the data does not resemble an IP address.
I'm working in my sandbox
zc 1.5.3
php 5.3.28 (sandbox) prod 5.4.35
MySQL 5.5.40-cll (sandbox & prod)
template: picafluor-azul westminster_new responsive
chainweavers (d.o.t) info/ZEN153/
could it be related to document_product_info page instead of product_info page?
TNX again.
EDIT: answered my own question by duplicating the product_info folder as document_product_info.
I do see that there needs to be something done to product attributes to provide an alternate selection or some path for a user to choose.
Sorry that I didn't exercise all my thinking powers before asking a question
Re: Restrict Digital Downloads [Support Thread]
I get the yellow notice but nothing is preventing the item from being added to cart, so I must need to do something in addition to just creating the document_product_info file.
Re: Restrict Digital Downloads [Support Thread]
RixStix, you got the first bit right. The plugin includes support for product_info and product_music_info product types; to replicate for another (like document_product_info), you simply copy /includes/templates/YOUR_TEMPLATE/product_info (and all its files) to /includes/templates/YOUR_TEMPLATE/document_product_info (in your case).
There are some jQuery issues, at least on http://chainweavers (dot) info/ZEN153/index.php?main_page=document_product_info&cPath=22_138&products_id=776 so that the script associated with RDD is not run. You'll notice that your "Back to Top" widget isn't showing either.
I'm puzzled why the "backup" script (in the /extra_cart_actions folder) isn't kicking in, though.
Re: Restrict Digital Downloads [Support Thread]
TNX lat9
Removing the newly created /includes/templates/YOUR_TEMPLATE/document_product_info folder restores functionality to the "Back to TOP" widget (which was broken on all product_info pages (that I checked), not just digitaldownload pages. The only file in that folder is the RDD file.
I'm going out on a limb and guessing that things are somehow related to the responsive template functionality.
I'll install a vanilla template tomorrow and see what happens.
Re: Restrict Digital Downloads [Support Thread]
Does this suggest anything?
Code:
[14-Dec-2014 08:13:05 America/Los_Angeles] PHP Warning: sprintf(): Too few arguments in /home/XXXXXXXX/public_html/ZEN153/ADMIN_folder/tools_update_ip2country.php on line 57
Re: Restrict Digital Downloads [Support Thread]
Quote:
Originally Posted by
RixStix
Does this suggest anything?
Code:
[14-Dec-2014 08:13:05 America/Los_Angeles] PHP Warning: sprintf(): Too few arguments in /home/XXXXXXXX/public_html/ZEN153/ADMIN_folder/tools_update_ip2country.php on line 57
Nope. I just need to update the following statement in /YOUR_ADMIN/includes/languages/english/tools_update_ip2country.php:
Code:
define ('MESSAGE_NUM_RECORDS', 'Processing complete. %u records were added to the ' . TABLE_IP2COUNTRY . ' database table in %u seconds.');
to
Code:
define ('MESSAGE_NUM_RECORDS', 'Processing complete. %u records were added to the ' . TABLE_IP2COUNTRY . ' database table.');
Re: Restrict Digital Downloads [Support Thread]
You could try editing /includes/extra_cart_actions/restrict_digital_downloads.php, adding (temporarily) the code in red. That will at least give us a clue as to what's going on:
Code:
// -----
// Part of the "Restrict Digital Downloads" plugin by Cindy Merkin ([email protected])
// 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': {
error_log (__FILE__ . ':' . print_r ($_POST, true));
if ($_SESSION['is_restricted_ip'] && isset($_POST['products_id']) && $_POST['cart_quantity'] > 0 && isset($_POST['id']) && is_array($_POST['id'])) {
foreach($_POST['id'] 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;
}
}
Re: Restrict Digital Downloads [Support Thread]
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] => Array
(
[61] => 61
)
)
)