Skip to content

Commit

Permalink
More 158+ content for modules
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcwilson committed May 10, 2024
1 parent 3fa54b7 commit a96bcb8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
11 changes: 9 additions & 2 deletions content/dev/code/Modules/clone_payment.md
Expand Up @@ -2,6 +2,9 @@
title: Cloning a Payment Module
description: Building a new payment module based on an existing one
---

**Note:** These instructions are for Zen Cart 1.5.8 and above. For Zen Cart 1.5.7 and below, please see [Cloning a Payment Module in 1.5.7 and below](/dev/code/modules/clone_payment_157/).

You can create new Payment Module by making a clone of the closest matching Payment Module to what you are trying to do.

As an example, we will consider the `moneyorder` payment module.
Expand All @@ -12,9 +15,11 @@ The code file is located in:
`/includes/modules/payment/moneyorder.php`

The language file is located in:
`/includes/languages/english/modules/payment/moneyorder.php`
`/includes/languages/english/modules/payment/lang.moneyorder.php`

To clone this module, for example, to `venmo.php` you would copy the two `moneyorder.php` files to `venmo.php`
To clone this module, for example, to `venmo.php` you would:
- copy `moneyorder.php` to `venmo.php`
- copy `lang.moneyorder.php` to `lang.venmo.php`

**Note:** Be sure the filename you choose does not have an underscore (`_`) in it.

Expand Down Expand Up @@ -48,6 +53,8 @@ $this->code = 'venmo';
$this->title = MODULE_PAYMENT_VENMO_TEXT_TITLE;
```

Be sure to make this change in the `remove()` function as well.

These plugins might also help:
* [Optional Payment Method](https://www.zen-cart.com/downloads.php?do=file&id=1930)

56 changes: 56 additions & 0 deletions content/dev/code/Modules/clone_payment_157.md
@@ -0,0 +1,56 @@
---
title: Cloning a Payment Module (1.5.7 and below)
description: Building a new payment module based on an existing one
---

**Note:** These instructions are for Zen Cart 1.5.7 and below. For Zen Cart 1.5.8 and higher, please see [Cloning a Payment Module](/dev/code/modules/clone_payment/).

You can create new Payment Module by making a clone of the closest matching Payment Module to what you are trying to do.

As an example, we will consider the `moneyorder` payment module.

Payment Modules have 2 parts:

The code file is located in:
`/includes/modules/payment/moneyorder.php`

The language file is located in:
`/includes/languages/english/modules/payment/moneyorder.php`

To clone this module, for example, to `venmo.php` you would copy the two `moneyorder.php` files to `venmo.php`

**Note:** Be sure the filename you choose does not have an underscore (`_`) in it.

Next, you need to change all occurrences of the strings `moneyorder` and `MONEYORDER` as follows:

OLD | NEW
----|----
`moneyorder` | `venmo`
`MONEYORDER` | `VENMO`

These identifiers are case sensitive.

These words are written separately or within the constants such as:


```
class moneyorder {
...
$this->code = 'moneyorder';
...
$this->title = MODULE_PAYMENT_MONEYORDER_TEXT_TITLE;
```

becomes

```
class venmo {
...
$this->code = 'venmo';
...
$this->title = MODULE_PAYMENT_VENMO_TEXT_TITLE;
```

These plugins might also help:
* [Optional Payment Method](https://www.zen-cart.com/downloads.php?do=file&id=1930)

2 changes: 1 addition & 1 deletion content/dev/code/Modules/order_total_modules.md
Expand Up @@ -11,7 +11,7 @@ white-space: pre-wrap !important;
Zen Cart *order-total* modules are used to calculate (and display) sub-totals, taxes, totals and other intermediary values for an order. *Order-total* modules can also calculate discounts or other subtractions from the amount a customer owes for an order. Each module includes, at a minimum, two files:

1. A `class` file: /includes/modules/order_total/`my_order_total`.php
1. A `language` file: /includes/languages/`current_language`/modules/order_total/`my_order_total`.php
1. A `language` file: /includes/languages/`current_language`/modules/order_total/`lang.my_order_total`.php (or simply `my_order_total.php` in 1.5.7 and below)

The `language` file contains all the translatable language text for the module while the `class` file contains the module's processing portion.

Expand Down
2 changes: 1 addition & 1 deletion content/dev/code/Modules/shipping_modules.md
Expand Up @@ -11,7 +11,7 @@ white-space: pre-wrap !important;
A shipping module applies a shipping cost to an order, based on some calculation method. Each shipping module requires a minimum of two files:

1. A `class` file: /includes/modules/shipping/`modulename`.php
1. A `language` file: /includes/languages/`current_language`/modules/shipping/`modulename`.php
1. A `language` file: /includes/languages/`current_language`/modules/shipping/`lang.modulename`.php (or simply `modulename.php` in 1.5.7 and below).

The `language` file contains all the translatable language text for the module while the `class` file contains the module's processing portion. A shipping module can include one or more `methods`.

Expand Down

0 comments on commit a96bcb8

Please sign in to comment.