diff --git a/content/dev/moduleSupport/_index.md b/content/dev/moduleSupport/_index.md new file mode 100644 index 000000000..ea84f7cb7 --- /dev/null +++ b/content/dev/moduleSupport/_index.md @@ -0,0 +1,16 @@ +--- +title: Modules Infrastructure +description: New modules infrastructure +weight: 100 +layout: docs +--- + +{{% wip %}} + +In order to make it easier and quicker to write modules(Payment/Shipping/Order Totals) a new infrastructure for these modules has been created. + +This new infrastructure will reduce the amount of boilerplate code required, minimize copy/paste coding and adds helpers for common coding requirements. + +{{% alert title="Note" color="primary" %}} +Previous Payment/Shipping/Order total modules will continue to work without modification. +{{% /alert %}} diff --git a/content/dev/moduleSupport/base/_index.md b/content/dev/moduleSupport/base/_index.md new file mode 100644 index 000000000..368728d62 --- /dev/null +++ b/content/dev/moduleSupport/base/_index.md @@ -0,0 +1,113 @@ +--- +title: Base Module Support +description: +weight: 10 +layout: docs +--- + +{{% wip %}} + +# Introduction + +The base module support classes contain common code that is used across all module types e.g Payments, Shipping and Order Total modules. + +It also provides some common helper methods that you can use in your modules. + +## Accessing Define Values + +All module types store information about themselves in the database `configuration` table. + +The `keys` for this table will look something like + +- MODULE_PAYMENT_COD_STATUS +- MODULE_SHIPPING_FLAT_COST +- MODULE_ORDERTOTAL_TOTAL_SORT_ORDER + +The structure of these defines is + +MODULE_[module type]\_[module name]\_[define name] + +where module type is one of `PAYMENT` or `SHIPPING` or `ORDERTOTAL` + +The module name is taken from the $code class variable of the module, and the define name describes the purpose of the define. + +In previous versions of Zen Cart,these configuration values were accessed directly using the key that was stored in the database, however using +the new module support classes we access them through a helper method. + +e.g. In legacy code we might have done + +`$this->sort_order = defined('MODULE_PAYMENT_COD_SORT_ORDER') ? MODULE_PAYMENT_COD_SORT_ORDER : null;` + +With the new infrastructure we can simply do + +`$this->sort_order = $this->getDefine('SORT_ORDER);` + +The `getDefine` method is context aware, so knows which type of module you are using(PAYMENT/SHIPPING/ORDERTOTAL) and the current define name (e.g. COD) for +the module you are using. + +Furthermore, you can also set a value that will be returned from the method if the configuration value does not exist. + +In the example above, the method will return `null` if the `MODULE_PAYMENT_COD_SORT_ORDER` does not exist. + +However you could also do `$this->sort_order = $this->getDefine('SORT_ORDER, 0);` + +and the method will return `0`, if the configuration value does not exist. + +There are also a number of helper methods to get some of the most common module configuration keys. + +### getTitle + +This gets the title for the Module. + +It looks for defines with suffixes in an array of ['TITLE', 'TEXT_TITLE', 'CATALOG_TITLE'] + +If your module uses a different define for the title then you should override the getTitle method. + +### getAdminTitle + +This returns a title to display on the Admin interface. In general this would be the same as the getTitle as above, but sometimes you may want it to be different. +It expects to be passed a default title, which would normally be what the getTitle function returns, and will use this if it does not find a define related to the admin title. + +This function looks for defines with a suffix in an array ['TITLE_ADMIN', 'TEXT_TITLE_ADMIN', 'ADMIN_TITLE'] + +If your admin title is defined through other means, then you will need to override this method in your module. + +### getDescription + +returns a module define with the suffix `DESCRIPTION` + +### getSortOrder + +returns a module define with the suffix `SORT_ORDER` + +### getZone + +returns a module define with the suffix `ZONE` + +### getDebugMode + +returns a module define with the suffix `DEBUG_MODE` + +### isEnabled + +This function checks to see if the module is enabled. + +it first checks to see if the module has any missing configurations and then check the module define suffix `STATUS` + +### moduleAutoloadSupportClasses + +This function is only called if it exists. + +It allows a module to add autoload classes using the psr4autoload Aura autoload. + +e.g. + +``` php + protected function moduleAutoloadSupportClasses(Loader $psr4Autoloader): Loader + { + $psr4Autoloader->addPrefix('Stripe', DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/stripe_pay/stripe-php-13.15.0/lib/'); + $psr4Autoloader->addPrefix('Monolog', DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/stripe_pay/monolog/src/Monolog/'); + $psr4Autoloader->addPrefix('Zencart\Logger', DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/stripe_pay/Logger/'); + return $psr4Autoloader; + } +``` diff --git a/content/dev/moduleSupport/base/classVariables/_index.md b/content/dev/moduleSupport/base/classVariables/_index.md new file mode 100644 index 000000000..286358d4a --- /dev/null +++ b/content/dev/moduleSupport/base/classVariables/_index.md @@ -0,0 +1,38 @@ +--- +title: Class Variables +description: +weight: 140 +layout: docs +--- + +{{% wip %}} + +The base module provides the following class variables for all other module types. + +## public int $_check + +## public string $description + +## public bool $enabled + +## public ?int $sort_order + +## public string $code = '' + +## protected string $defineName = '' + +## protected string $version = '' + +## public string $title = '' + +## protected array $configurationKeys + +## protected int $zone + +## protected array $configureErrors = [] + +## protected Logger $logger + +## protected $storeLanguageSuffixes = ['TITLE', 'TEXT_TITLE', 'CATALOG_TITLE'] + +## protected $adminLanguageSuffixes = ['TITLE_ADMIN', 'TEXT_TITLE_ADMIN', 'ADMIN_TITLE'] diff --git a/content/dev/moduleSupport/base/configurationSettings/_index.md b/content/dev/moduleSupport/base/configurationSettings/_index.md new file mode 100644 index 000000000..74d5f2b57 --- /dev/null +++ b/content/dev/moduleSupport/base/configurationSettings/_index.md @@ -0,0 +1,80 @@ +--- +title: Configuration Settings +description: +weight: 80 +layout: docs +--- + +{{% wip %}} + +In Zen Cart modules written before this module infrastructure code, configuration settings used SQL statements for those settings. + +This was usually done in a module method called `install` and would look something like. + +``` php + function install() { + global $db, $messageStack; + if (defined('MODULE_PAYMENT_FREECHARGER_STATUS')) { + $messageStack->add_session('FreeCharger module already installed.', 'error'); + zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=freecharger', 'SSL')); + 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 Free Charge Module', 'MODULE_PAYMENT_FREECHARGER_STATUS', 'True', 'Do you want to accept Free Charge 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, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_FREECHARGER_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, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_FREECHARGER_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, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_FREECHARGER_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())"); + } + +``` + +With the new module infrastructure code this is simplified. + +The base module classes define a default set of configurations settings for payment/shipping/order total classes, and 3rd party modules can add to those settings. + +Rather than use SQL statements, we now use an array based method of defining the settings. + +If a module needs to add extra settings, it should define a method called `addCustomConfigurationKeys` + +An example, taken from a rewritten moneyorder payment module. + +```php + protected function addCustomConfigurationKeys(): array + { + $configKeys = []; + $key = $this->buildDefine('PAYTO'); + $configKeys[$key] = [ + 'configuration_value' => 'the Store Owner/Website Name', + 'configuration_title' => 'Make Payable to:', + 'configuration_description' => 'Who should payments be made payable to?', + 'configuration_group_id' => 6, + 'sort_order' => 1, + ]; + return $configKeys; + } +``` + +## Module Settings Keys + +The following is a list of module settings keys and their usage as per the `configuration` database table. + +### configuration_title + +### configuration_key + +### configuration_value + +### configuration_description + +### sort_order + +### last_modified + +### date_added + +### use_function + +### set_function + +### val_function + + diff --git a/content/dev/moduleSupport/base/configurationerrors/_index.md b/content/dev/moduleSupport/base/configurationerrors/_index.md new file mode 100644 index 000000000..821a78ce6 --- /dev/null +++ b/content/dev/moduleSupport/base/configurationerrors/_index.md @@ -0,0 +1,53 @@ +--- +title: Configuration Errors +description: +weight: 100 +layout: docs +--- + +{{% wip %}} + +# Introduction + +The new module support infrastructure allows you to define methods to capture errors in the configuration of a module +and display these errors in the admin title for the module. + +If the errors are considered `fatal` the system will also ensure that the module cannot be enabled until the errors are fixed. + +Two methods are used which you can add to your module. + +`checkNonFatalConfigureStatus` and `checkFatalConfigureStatus` + +some examples. + +The moneyorder payment module defines a `checkNonFatalConfigureStatus` method + +``` php + protected function checkNonFatalConfigureStatus(): void + { + if ($this->getDefine('PAYTO') == 'the Store Owner/Website Name' || $this->getDefine('PAYTO') == '') { + $this->configureErrors[] = '(not configured - needs pay-to)'; + } + } +``` + +The Stripe Pay module defines a `checkFatalConfigureStatus` method + + +```php + protected function checkFatalConfigureStatus(): bool + { + $configureStatus = true; + $toCheck = 'LIVE'; + if ($this->getDefine('MODE') == 'Test') { + $toCheck = 'TEST'; + } + if ($this->getDefine($toCheck . 'PUB_KEY') == '' || $this->getDefine($toCheck . '_SECRET_KEY') == '') { + $this->configureErrors[] = sprintf('(not configured - needs %s publishable and secret key)', $toCheck); + $configureStatus = false; + } + return $configureStatus; + } +``` + + diff --git a/content/dev/moduleSupport/base/languagedefines/_index.md b/content/dev/moduleSupport/base/languagedefines/_index.md new file mode 100644 index 000000000..0f2503518 --- /dev/null +++ b/content/dev/moduleSupport/base/languagedefines/_index.md @@ -0,0 +1,52 @@ +--- +title: Language defines +description: +weight: 120 +layout: docs +--- + +{{% wip %}} + +Language define files for modules follow the same format as normal array based language defines. + +They are stored in `includes/languages/{language}/modules/` and at the very least should have an english translation. + +e.g. + +`includes/languages/english/modules/payment/lang.cod.php` + +`includes/languages/english/modules/shipping/lang.flat.php` + +`includes/languages/english/modules/order_total/lang.ot_subtotal.php` + + +Like module configuration keys, naming of module language defines are the same +e.g. + +`MODULE_[module type]\_[module name]\_[define name]` + +There are some other rules. + +language define names should be unique and not match any other module configuration defines. + +At a minimum you should provide the following + +`'TEXT_TITLE' => 'Stripe Checkout',` + +`'TEXT_DESCRIPTION' => 'Stripe Pay',` + + +e.g + +``` php +$define = [ + 'MODULE_PAYMENT_STRIPE_PAY_TEXT_TITLE' => 'Stripe Checkout', + 'MODULE_PAYMENT_STRIPE_PAY_TEXT_DESCRIPTION' => 'Stripe Pay', +]; +return $define; +``` + +Note: also if you want to provide a different title in the admin interface you can add something like + +`MODULE_PAYMENT_STRIPE_PAY_TEXT_TITLE_ADMIN' => 'Stripe Checkout(ADMIN)` + diff --git a/content/dev/moduleSupport/base/logging/_index.md b/content/dev/moduleSupport/base/logging/_index.md new file mode 100644 index 000000000..7f73253e3 --- /dev/null +++ b/content/dev/moduleSupport/base/logging/_index.md @@ -0,0 +1,92 @@ +--- +title: Error Logging +description: +weight: 120 +layout: docs +--- + +{{% wip %}} + +All modules have access to a new logging infrastructure. + +This logging infrastructure uses monolog as the log provider. + +It provides 3 log handlers + +- File logging +- Console logging +- Email Logging + +To log something in a module you can do + +`$this->logger->log($logLevel, $message, $context)` + +$logLevel is based on the standard log levels that PSR/log supports. + +i.e + +``` +class LogLevel +{ + const EMERGENCY = 'emergency'; + const ALERT = 'alert'; + const CRITICAL = 'critical'; + const ERROR = 'error'; + const WARNING = 'warning'; + const NOTICE = 'notice'; + const INFO = 'info'; + const DEBUG = 'debug'; +} +``` + +$context is not required but if passed, should be an array of values. + +## File logging + +This logs the message and context (if passed) to a file. + +Logs all messages with a level of `debug` or higher. + +The file name that is used is determined as follows. + +A prefix will be generated based on the log channel, which is based on the module type. + +e.g. payment/shipping/order_total. + +The code of the module is then added. + +e.g. `flat` or `paypal` etc. + +following this a string will be added based on whether the code generating the log is either admin or storefront code. + +The log file name will then be suffixed with the current date using a format that means logs will be aggregated daily. + +### For logs generated by Admin code. + +This will be prefixed with `admin-` + +and the current session admin id will be added if applicable. + +Then if the code generating the error references an order, the order id will be added. + +### For logs generated by store front code. + +This will be prefixed with `store-` + +Then if a customer id is available in the context of the log then the customer id, and a partial customer first name and last name will be added to the log file name. + + +## Console Logging + +This will log the error message and context(if passed) to the javascript console. + +So will be viewable using your browser's developer console. + +Logs all messages with a level of `debug` or higher. + +## Email Logging + +This will send an email to the email address of the store owner. Currently there is no way to change this but that might change in the future. + +Logs all messages with a level of `error` or higher. + diff --git a/content/dev/moduleSupport/order_totals/_index.md b/content/dev/moduleSupport/order_totals/_index.md new file mode 100644 index 000000000..56d86a16d --- /dev/null +++ b/content/dev/moduleSupport/order_totals/_index.md @@ -0,0 +1,14 @@ +--- +title: Order Totals Modules +description: +weight: 140 +layout: docs +--- + +{{% wip %}} + +Order total modules are slightly more complex than payment/shipping modules in that there are two distinct types of order total modules. + +- Basic order total modules +- Credit class order total modules + diff --git a/content/dev/moduleSupport/order_totals/basicOrderTotals/_index.md b/content/dev/moduleSupport/order_totals/basicOrderTotals/_index.md new file mode 100644 index 000000000..c69e6aabb --- /dev/null +++ b/content/dev/moduleSupport/order_totals/basicOrderTotals/_index.md @@ -0,0 +1,48 @@ +--- +title: Basic Order Total Modules +description: +weight: 100 +layout: docs +--- +{{% wip %}} + +These modules are fairly simple and provide minimal interaction in the checkout, and are usually used to aggregate values. + +examples would be + +- calculate/display the order sub total (e.g. the total of all product costs) +- calculate/display the total tax for the order +- calculate/display the total shipping cost for the order +- calculate/display a simple low order fee + +A basic order total module should use this basic skeleton, adjusting the class name and class variables where appropriate. + +``` php +output[] = array('title' => $this->title . ':', + 'text' => $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']), + 'value' => $order->info['total']); + } +``` diff --git a/content/dev/moduleSupport/order_totals/basicOrderTotals/classVariables/_index.md b/content/dev/moduleSupport/order_totals/basicOrderTotals/classVariables/_index.md new file mode 100644 index 000000000..26ba065c3 --- /dev/null +++ b/content/dev/moduleSupport/order_totals/basicOrderTotals/classVariables/_index.md @@ -0,0 +1,10 @@ +--- +title: Class Variables +description: +weight: 120 +layout: docs +--- + +{{% wip %}} + +## public array $output = [] diff --git a/content/dev/moduleSupport/order_totals/basicOrderTotals/configurationSettings/_index.md b/content/dev/moduleSupport/order_totals/basicOrderTotals/configurationSettings/_index.md new file mode 100644 index 000000000..423f1468c --- /dev/null +++ b/content/dev/moduleSupport/order_totals/basicOrderTotals/configurationSettings/_index.md @@ -0,0 +1,44 @@ +--- +title: Configuration Settings +description: +weight: 100 +layout: docs +--- + +{{% wip %}} + +The default configuration settings for a basic order total module are :- + +``` php + protected function setCommonConfigurationKeys(): array + { + $configKeys = []; + $key = $this->buildDefine('STATUS'); + $configKeys[$key] = [ + 'configuration_value' => 'False', + 'configuration_title' => 'Enable this module', + 'configuration_description' => 'Enable this order total module', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_option(array('True', 'False'), ", + ]; + $key = $this->buildDefine('SORT_ORDER'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Sort order of display.', + 'configuration_description' => 'Sort order of display. Lowest is displayed first.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + ]; + $key = $this->buildDefine('DEBUG_MODE'); + $configKeys[$key] = [ + 'configuration_value' => '--none--', + 'configuration_title' => 'Use debug mode', + 'configuration_description' => 'Debug Mode adds extra logging to file, email and console output', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_multioption(array('File', 'Email', 'BrowserConsole'), ", + ]; + return $configKeys; + } +``` diff --git a/content/dev/moduleSupport/order_totals/creditClassOrderTotal/_index.md b/content/dev/moduleSupport/order_totals/creditClassOrderTotal/_index.md new file mode 100644 index 000000000..eca2dc6ba --- /dev/null +++ b/content/dev/moduleSupport/order_totals/creditClassOrderTotal/_index.md @@ -0,0 +1,50 @@ +--- +title: Credit Class Modules +description: +weight: 120 +layout: docs +--- +{{% wip %}} + +These modules usually involve some interaction during checkout and also add options to allow for more complex tax calculations. + +examples would be + +- Group Pricing +- Discount Coupons +- Gift Vouchers +- Reward points modules + +The skeleton for these credit class order total modules would be + +``` php +buildDefine('INC_SHIPPIMG'); + $configKeys[$key] = [ + 'configuration_value' => 'false', + 'configuration_title' => 'Include Shipping', + 'configuration_description' => 'Include Shipping value in amount before discount calculation?', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'), ', + ]; + $key = $this->buildDefine('INC_TAX'); + $configKeys[$key] = [ + 'configuration_value' => 'true', + 'configuration_title' => 'Include Tax', + 'configuration_description' => 'Include Tax value in amount before discount calculation?', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'), ', + ]; + $key = $this->buildDefine('CALC_TAX'); + $configKeys[$key] = [ + 'configuration_value' => 'Standard', + 'configuration_title' => 'Re-calculate Tax', + 'configuration_description' => 'How to Re-calculate Tax', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => 'zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', + ]; + $key = $this->buildDefine('TAX_CLASS'); + $configKeys[$key] = [ + 'configuration_value' => '0', + 'configuration_title' => 'Tax Class', + 'configuration_description' => 'Use the following tax class when treating module as a Credit Note.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'use_function' => 'zen_get_tax_class_title', + 'set_function' => 'zen_cfg_pull_down_tax_classes(', + ]; + return $configKeys; + } +``` + diff --git a/content/dev/moduleSupport/payment/_index.md b/content/dev/moduleSupport/payment/_index.md new file mode 100644 index 000000000..e1956a0b0 --- /dev/null +++ b/content/dev/moduleSupport/payment/_index.md @@ -0,0 +1,42 @@ +--- +title: Payment Modules +description: +weight: 100 +layout: docs +--- + +{{% wip %}} + +A payment module class should use this basic skeleton. + +e.g. + +``` php +buildDefine('STATUS'); + $configKeys[$key] = [ + 'configuration_value' => 'False', + 'configuration_title' => 'Enable this module', + 'configuration_description' => 'Do you want to accept payments using this module', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_option(array('True', 'False'), ", + ]; + $key = $this->buildDefine('SORT_ORDER'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Sort order of display.', + 'configuration_description' => 'Sort order of display. Lowest is displayed first.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + ]; + $key = $this->buildDefine('ZONE'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Payment Zone', + 'configuration_description' => 'If a zone is selected, only enable this payment method for that zone.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_pull_down_zone_classes(", + ]; + $key = $this->buildDefine('DEBUG_MODE'); + $configKeys[$key] = [ + 'configuration_value' => '--none--', + 'configuration_title' => 'Use debug mode', + 'configuration_description' => 'Debug Mode adds extra logging to file, email and console output', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_multioption(array('File', 'Email', 'BrowserConsole'), ", + ]; + return $configKeys; + } +``` diff --git a/content/dev/moduleSupport/shipping/_index.md b/content/dev/moduleSupport/shipping/_index.md new file mode 100644 index 000000000..6370377e0 --- /dev/null +++ b/content/dev/moduleSupport/shipping/_index.md @@ -0,0 +1,44 @@ +--- +title: Shipping Modules +description: +weight: 100 +layout: docs +--- + +{{% wip %}} + +A shipping module class should use this basic skeleton. + +e.g. + +``` php +quotes = [ + 'id' => $this->code, + 'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE, + 'methods' => [ + [ + 'id' => $this->code, + 'title' => MODULE_SHIPPING_FLAT_TEXT_WAY, + 'cost' => MODULE_SHIPPING_FLAT_COST, + ], + ], + ]; + if ($this->tax_class > 0) { + $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); + } + + if (!empty($this->icon)) { + $this->quotes['icon'] = zen_image($this->icon, $this->title); + } + + return $this->quotes; + } +``` + diff --git a/content/dev/moduleSupport/shipping/classVariables/_index.md b/content/dev/moduleSupport/shipping/classVariables/_index.md new file mode 100644 index 000000000..4e9fc79ae --- /dev/null +++ b/content/dev/moduleSupport/shipping/classVariables/_index.md @@ -0,0 +1,12 @@ +--- +title: Class Variables +description: +weight: 120 +layout: docs +--- + +{{% wip %}} + +## public string $tax_class = '' +## public string $tax_basis = '' +## public $quotes diff --git a/content/dev/moduleSupport/shipping/configurationSettings/_index.md b/content/dev/moduleSupport/shipping/configurationSettings/_index.md new file mode 100644 index 000000000..309dc5592 --- /dev/null +++ b/content/dev/moduleSupport/shipping/configurationSettings/_index.md @@ -0,0 +1,76 @@ +--- +title: Configuration Settings +description: +weight: 100 +layout: docs +--- + +{{% wip %}} + +## Configuration settings + +The default configuration settings for a shipping module are :- + +``` php + protected function setCommonConfigurationKeys(): array + { + $configKeys = []; + $key = $this->buildDefine('STATUS'); + $configKeys[$key] = [ + 'configuration_value' => 'False', + 'configuration_title' => 'Enable this module', + 'configuration_description' => 'Do you want to accept payments using this module', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_option(array('True', 'False'), ", + ]; + $key = $this->buildDefine('SORT_ORDER'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Sort order of display.', + 'configuration_description' => 'Sort order of display. Lowest is displayed first.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + ]; + $key = $this->buildDefine('TAX_CLASS'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Tax Class', + 'configuration_description' => 'Use the following tax class on the shipping fee.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'use_function' => 'zen_get_tax_class_title', + 'set_function' => "zen_cfg_pull_down_tax_classes(", + ]; + $key = $this->buildDefine('TAX_BASIS'); + $configKeys[$key] = [ + 'configuration_value' => 'Shipping', + 'configuration_title' => 'Tax Basis', + 'configuration_description' => 'On what basis is Shipping Tax calculated. Options are
Shipping - Based on customers Shipping Address
Billing Based on customers Billing address
Store - Based on Store address if Billing/Shipping Zone equals Store zone', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'use_function' => 'zen_get_tax_class_title', + 'set_function' => 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', + ]; + $key = $this->buildDefine('ZONE'); + $configKeys[$key] = [ + 'configuration_value' => 0, + 'configuration_title' => 'Payment Zone', + 'configuration_description' => 'If a zone is selected, only enable this shipping method for that zone.', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_pull_down_zone_classes(", + ]; + + $key = $this->buildDefine('DEBUG_MODE'); + $configKeys[$key] = [ + 'configuration_value' => '--none--', + 'configuration_title' => 'Use debug mode', + 'configuration_description' => 'Debug Mode adds extra logging to file, email and console output', + 'configuration_group_id' => 6, + 'sort_order' => 1, + 'set_function' => "zen_cfg_select_multioption(array('File', 'Email', 'BrowserConsole'), ", + ]; + return $configKeys; + } +``` diff --git a/content/dev/payment/_index.md b/content/dev/payment/_index.md deleted file mode 100644 index 107bf8801..000000000 --- a/content/dev/payment/_index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Payment Module Technical Information -description: Writing and Troubleshooting Payment Modules -weight: 100 -layout: docs ---- diff --git a/content/dev/payment/paypal_testing.md b/content/dev/payment/paypal_testing.md deleted file mode 100644 index 7e6ee3f6d..000000000 --- a/content/dev/payment/paypal_testing.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: Testing PayPal Modules -description: -weight: 10 ---- - - -## Testing PayPal Transactions - -To test that PayPal is properly configured, you should test two methods: - -1. Test by paying for something using a PayPal account (not the same account as your store). -2. Test by paying for something with a credit card WITHOUT creating or using a PayPal account for payment. - -All of these tests are to be performed in "production" or "live" mode. Do NOT use a Sandbox for testing. _(If you don't know what this means, just proceed with testing.)_ - -### Testing using a PayPal account - -1. You need a second PayPal account to do this. PayPal allows you to have two accounts per person: one personal and one business. For this test, you will pay for your purchase using funds on account in your personal PayPal account. You will be paying money to your store account (and refunding it). -2. Create or select a product which has a low price, such as $0.01 or maybe $1.00. -3. Purchase that product. -4. During checkout, choose the lowest-price shipping option. -5. During checkout, choose PayPal. -6. After the Checkout Confirmation screen, you'll be taken to the PayPal website to make payment. -7. Enter your PERSONAL PayPal account username and password. -8. Confirm the transaction. -9. You will be returned to your store after completion. -10. Verify that you received two or three emails: one from PayPal, one from the store to you as a customer, and one from the store to your _Admin_ address. If you did not receive the emails from the store within five minutes, then go to the Troubleshooting section of this document, above. -11. Log in to your BUSINESS PayPal account and refund your test transaction. - -### Testing without a PayPal account - -To test payment by credit card without using a PayPal account, use these steps: - -_(Before proceeding, find your credit cards, and select one that's not already associated with any PayPal account !!)_ - -1. Create or select a product in your store which has a low price, such as $0.01 or maybe $1.00. -2. Purchase that product. -3. During checkout, choose the lowest-price shipping option. -4. During checkout, choose PayPal. -5. After the Checkout Confirmation screen, you'll be taken to the PayPal website to make payment. -6. Underneath the login box for PayPal username/password, there is a link to Purchase without a PayPal account. Click that link. -7. Fill in and/or confirm your personal information. -8. Fill in your payment details including credit card number. (You should NOT use a credit card number that's already associated with any PayPal account !!) -9. Confirm the transaction. -10. You will be returned to your store after completion. -11. Verify that you received two or three emails: one from PayPal, one from the store to you as a customer, and one from the store to your _Admin_ address. If you did not receive the emails from the store within five minutes, then go to the Troubleshooting section of this document, above. -12. Log in to your BUSINESS PayPal account and refund your test transaction. - diff --git a/layouts/shortcodes/wip.html b/layouts/shortcodes/wip.html new file mode 100644 index 000000000..01c1c1681 --- /dev/null +++ b/layouts/shortcodes/wip.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/layouts/user/baseof.html b/layouts/user/baseof.html index 491e53916..5dba11e46 100644 --- a/layouts/user/baseof.html +++ b/layouts/user/baseof.html @@ -1,7 +1,7 @@ - {{ partial "head.html" . }} +