-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
3,563 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,3 +214,4 @@ pip-log.txt | |
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
/nbproject/ |
18 changes: 18 additions & 0 deletions
18
1_Installation_files/YOUR_ADMIN/includes/auto_loaders/config.cash_on_pickup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/* | ||
* | ||
* @copyright Copyright 2003-2019 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 Cittins 2.0.0 by Zen4All | ||
* | ||
*/ | ||
|
||
if (!defined('IS_ADMIN_FLAG')) { | ||
die('Illegal Access'); | ||
} | ||
|
||
$autoLoadConfig[999][] = array( | ||
'autoType' => 'init_script', | ||
'loadFile' => 'init_cash_on_pickup.php' | ||
); |
122 changes: 122 additions & 0 deletions
122
1_Installation_files/YOUR_ADMIN/includes/init_includes/init_cash_on_pickup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
/* | ||
* init_cash_on_pickup.php | ||
* | ||
* @copyright Copyright 2003-2019 Zen Cart Development Team | ||
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 | ||
* @version Author: Erik Kerkhoven 1-3-2019 | ||
* | ||
*/ | ||
|
||
if (!defined('IS_ADMIN_FLAG')) { | ||
die('Illegal Access'); | ||
} | ||
|
||
$module_constant = 'CASH_ON_PICKUP_VERSION'; | ||
$module_installer_directory = DIR_FS_ADMIN . 'includes/installers/cash_on_pickup'; | ||
$module_name = 'Cash on Pickup'; | ||
$module_file_for_version_check = ''; | ||
$zencart_com_plugin_id = 1242; | ||
|
||
$configuration_group_id = ''; | ||
if (defined($module_constant)) { | ||
$current_version = constant($module_constant); | ||
} else { | ||
$current_version = '0.0.0'; | ||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION_GROUP . " (configuration_group_title, configuration_group_description, sort_order, visible) | ||
VALUES ('" . $module_name . "', '" . $module_name . " Settings', '1', '0');"); | ||
$configuration_group_id = $db->Insert_ID(); | ||
|
||
$db->Execute("UPDATE " . TABLE_CONFIGURATION_GROUP . " | ||
SET sort_order = " . $configuration_group_id . " | ||
WHERE configuration_group_id = " . $configuration_group_id . ";"); | ||
|
||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, set_function) | ||
VALUES ('Version', '" . $module_constant . "', '0.0.0', 'Version installed:', " . $configuration_group_id . ", 0, NOW(), NOW(), 'trim(');"); | ||
} | ||
if ($configuration_group_id == '') { | ||
$config = $db->Execute("SELECT configuration_group_id | ||
FROM " . TABLE_CONFIGURATION . " | ||
WHERE configuration_key= '" . $module_constant . "'"); | ||
$configuration_group_id = $config->fields['configuration_group_id']; | ||
} | ||
|
||
$installers = scandir($module_installer_directory, 1); | ||
|
||
$newest_version = $installers[0]; | ||
$newest_version = substr($newest_version, 0, -4); | ||
|
||
sort($installers); | ||
if (version_compare($newest_version, $current_version) > 0) { | ||
foreach ($installers as $installer) { | ||
if (version_compare($newest_version, substr($installer, 0, -4)) >= 0 && version_compare($current_version, substr($installer, 0, -4)) < 0) { | ||
include($module_installer_directory . '/' . $installer); | ||
$current_version = str_replace("_", ".", substr($installer, 0, -4)); | ||
$db->Execute("UPDATE " . TABLE_CONFIGURATION . " | ||
SET configuration_value = '" . $current_version . "' | ||
WHERE configuration_key = '" . $module_constant . "' | ||
LIMIT 1;"); | ||
$messageStack->add("Installed " . $module_name . " v" . $current_version, 'success'); | ||
} | ||
} | ||
} | ||
|
||
// Version Checking | ||
$module_file_for_version_check = ($module_file_for_version_check != '') ? DIR_FS_ADMIN . $module_file_for_version_check : ''; | ||
if ($zencart_com_plugin_id != 0 && $module_file_for_version_check != '' && $_SERVER["PHP_SELF"] == $module_file_for_version_check) { | ||
$new_version_details = plugin_version_check_for_updates($zencart_com_plugin_id, $current_version); | ||
if ($_GET['gID'] == $configuration_group_id && $new_version_details != false) { | ||
$messageStack->add("Version " . $new_version_details['latest_plugin_version'] . " of " . $new_version_details['title'] . ' is available at <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>', 'caution'); | ||
} | ||
} | ||
|
||
if (!function_exists('plugin_version_check_for_updates')) { | ||
|
||
function plugin_version_check_for_updates($plugin_file_id = 0, $version_string_to_compare = '') { | ||
if ($plugin_file_id == 0) { | ||
return false; | ||
} | ||
$new_version_available = false; | ||
$lookup_index = 0; | ||
$url = 'https://www.zen-cart.com/downloads.php?do=versioncheck' . '&id=' . (int)$plugin_file_id; | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_VERBOSE, 0); | ||
curl_setopt($ch, CURLOPT_HEADER, false); | ||
curl_setopt($ch, CURLOPT_USERAGENT, 'Plugin Version Check [' . (int)$plugin_file_id . '] ' . HTTP_SERVER); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$response = curl_exec($ch); | ||
$error = curl_error($ch); | ||
if ($error > 0) { | ||
curl_setopt($ch, CURLOPT_URL, str_replace('tps:', 'tp:', $url)); | ||
$response = curl_exec($ch); | ||
$error = curl_error($ch); | ||
} | ||
curl_close($ch); | ||
if ($error > 0 || $response == '') { | ||
$response = file_get_contents($url); | ||
} | ||
if ($response === false) { | ||
$response = file_get_contents(str_replace('tps:', 'tp:', $url)); | ||
} | ||
if ($response === false) { | ||
return false; | ||
} | ||
$data = json_decode($response, true); | ||
if (!$data || !is_array($data)) { | ||
return false; | ||
} | ||
// compare versions | ||
if (strcmp($data[$lookup_index]['latest_plugin_version'], $version_string_to_compare) > 0) { | ||
$new_version_available = true; | ||
} | ||
// check whether present ZC version is compatible with the latest available plugin version | ||
if (!in_array('v' . PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR, $data[$lookup_index]['zcversions'])) { | ||
$new_version_available = false; | ||
} | ||
|
||
return ($new_version_available) ? $data[$lookup_index] : false; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
1_Installation_files/YOUR_ADMIN/includes/installers/cash_on_pickup/1_2_0.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* 1_2_0.php | ||
* | ||
* @copyright Copyright 2003-2018 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 Author: Zen4All | ||
*/ | ||
|
||
if (!zen_page_key_exists('configCashOnPickup') && (int)$configuration_group_id > 0) { | ||
zen_register_admin_page('configCashOnPickup', 'BOX_CONFIGURATION_CASH_ON_PICKUP', 'FILENAME_CONFIGURATION', 'gID=' . $configuration_group_id, 'configuration', 'N', $configuration_group_id); | ||
} |
9 changes: 9 additions & 0 deletions
9
...allation_files/YOUR_ADMIN/includes/languages/english/extra_definitions/cash_on_pickup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/* | ||
* | ||
* cash_on_pickup.php | ||
* | ||
* @copyright Copyright 2019 Zen4All | ||
*/ | ||
|
||
define('BOX_CONFIGURATION_CASH_ON_PICKUP', 'Cash on Pickup'); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<?php | ||
/** | ||
* COD Payment Module | ||
* | ||
* @package paymentMethod | ||
* @copyright Copyright 2016 Zen4All | ||
* @copyright Portions Copyright 2003-2018 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: Author: Zen4All | ||
*/ | ||
class cop { | ||
|
||
var $code, $title, $description, $enabled; | ||
|
||
// class constructor | ||
function __construct() | ||
{ | ||
global $order; | ||
|
||
$this->code = 'cop'; | ||
$this->title = MODULE_PAYMENT_COP_TEXT_TITLE; | ||
$this->description = MODULE_PAYMENT_COP_TEXT_DESCRIPTION; | ||
$this->sort_order = defined('MODULE_PAYMENT_COP_SORT_ORDER') ? MODULE_PAYMENT_COP_SORT_ORDER : null; | ||
$this->enabled = (defined('MODULE_PAYMENT_COP_STATUS') && MODULE_PAYMENT_COP_STATUS == 'True'); | ||
|
||
if (defined('MODULE_PAYMENT_COP_ORDER_STATUS_ID') && (int)MODULE_PAYMENT_COP_ORDER_STATUS_ID > 0) { | ||
$this->order_status = MODULE_PAYMENT_COP_ORDER_STATUS_ID; | ||
} | ||
|
||
if (is_object($order)) { | ||
$this->update_status(); | ||
} | ||
} | ||
|
||
// class methods | ||
function update_status() | ||
{ | ||
global $order, $db; | ||
|
||
if (stristr($_SESSION['shipping']['id'], 'storepickup') == FALSE) { | ||
$this->enabled = ((MODULE_PAYMENT_COP_STATUS == 'True') ? true : false); | ||
$check_flag = false; | ||
$check = $db->Execute("SELECT zone_id | ||
FROM " . TABLE_ZONES_TO_GEO_ZONES . " | ||
WHERE geo_zone_id = '" . MODULE_PAYMENT_COP_ZONE . "' | ||
AND zone_country_id = " . (int)$order->delivery['country']['id'] . " | ||
ORDER BY zone_id"); | ||
foreach ($check as $item) { | ||
if ($item['zone_id'] < 1) { | ||
$check_flag = true; | ||
break; | ||
} elseif ($item['zone_id'] == $order->delivery['zone_id']) { | ||
$check_flag = true; | ||
break; | ||
} | ||
} | ||
|
||
if ($check_flag == false) { | ||
$this->enabled = false; | ||
} | ||
} | ||
|
||
// disable the module if the order only contains virtual products | ||
if ($this->enabled == true) { | ||
if ($order->content_type != 'physical') { | ||
$this->enabled = false; | ||
} | ||
} | ||
|
||
// other status checks? | ||
if ($this->enabled) { | ||
// other checks here | ||
} | ||
} | ||
|
||
function javascript_validation() | ||
{ | ||
return false; | ||
} | ||
|
||
function selection() | ||
{ | ||
return array( | ||
'id' => $this->code, | ||
'module' => $this->title | ||
); | ||
} | ||
|
||
function pre_confirmation_check() | ||
{ | ||
return false; | ||
} | ||
|
||
function confirmation() | ||
{ | ||
return false; | ||
} | ||
|
||
function process_button() | ||
{ | ||
return false; | ||
} | ||
|
||
function before_process() | ||
{ | ||
return false; | ||
} | ||
|
||
function after_process() | ||
{ | ||
return false; | ||
} | ||
|
||
function get_error() | ||
{ | ||
return false; | ||
} | ||
|
||
function check() | ||
{ | ||
global $db; | ||
if (!isset($this->_check)) { | ||
$check_query = $db->Execute("SELECT configuration_value | ||
FROM " . TABLE_CONFIGURATION . " | ||
WHERE configuration_key = 'MODULE_PAYMENT_COP_STATUS'"); | ||
$this->_check = $check_query->RecordCount(); | ||
} | ||
return $this->_check; | ||
} | ||
|
||
function install() | ||
{ | ||
global $db, $messageStack; | ||
if (defined('MODULE_PAYMENT_COP_STATUS')) { | ||
$messageStack->add_session('COP module already installed.', 'error'); | ||
zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=cop', 'NONSSL')); | ||
return 'failed'; | ||
} | ||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) | ||
VALUES ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COP_STATUS', 'True', 'Do you want to accept Cash On Pickup payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); | ||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) | ||
VALUES ('Payment Zone', 'MODULE_PAYMENT_COP_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); | ||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) | ||
VALUES ('Sort order of display.', 'MODULE_PAYMENT_COP_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); | ||
$db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) | ||
VALUES ('Set Order Status', 'MODULE_PAYMENT_COP_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); | ||
} | ||
|
||
function remove() | ||
{ | ||
global $db; | ||
$db->Execute("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key IN ('" . implode("', '", $this->keys()) . "')"); | ||
} | ||
|
||
function keys() | ||
{ | ||
return array('MODULE_PAYMENT_COP_STATUS', 'MODULE_PAYMENT_COP_ZONE', 'MODULE_PAYMENT_COP_ORDER_STATUS_ID', 'MODULE_PAYMENT_COP_SORT_ORDER'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
# Zen-Cart-Cash-on-Pickup | ||
|
||
Description: This module allows you to accept cash on pickup when a customer elects to use the 'Walk in' option at checkout. The option will not display when a customer elects another shipping method. | ||
## Description | ||
This module allows you to accept cash on pickup when a customer elects to use the 'Walk in' option at checkout. The option will not display when a customer elects another shipping method. | ||
|
||
|
||
Instructions: | ||
## Instructions | ||
Just unzip this into the includes folder of your zen cart. This will not replace any files under a standard installation. | ||
Setup is done via the zen cart admin -> modules -> payments. | ||
|
||
Setup is done via the zen cart admin -> modules -> payments. | ||
|
||
NOTE: this module was 'built' from the cod module, lending heavily. I thought I would share as I have seen a few questions around forums about how to do this. | ||
## NOTE | ||
this module was 'built' from the cod module, lending heavily. I thought I would share as I have seen a few questions around forums about how to do this. | ||
|
||
Module by: Stephen.Hewitson (at) gmail.com | ||
Updated by: Design75/Zen4All (http://zen4all.nl) | ||
- Original Module by: Stephen.Hewitson (at) gmail.com | ||
- Updated by: Design75/Zen4All (http://zen4all.nl) | ||
|
||
Change log: | ||
## Change log | ||
|
||
inlcludes/modules/payment/cop.php: | ||
|
||
Updated the code to make the module work with the current Zen Cart version (1.5.4), previous versions, and probably future versions as well. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.