# creatuity/magento2-order-status-adjust

> Adjust Order Status to specific one if Criteria are met

`composer require creatuity/magento2-order-status-adjust`

Canonical URL: https://packagento.com/creatuity/magento2-order-status-adjust

## At a glance

- **Vendor**: creatuity (https://packagento.com/creatuity.md)
- **Latest version**: 1.1.0 — released 2023-08-21
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/creatuity/magento2-order-status-adjust and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require creatuity/magento2-order-status-adjust:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Adjust Order Status to specific one if Criteria are met

## README

### Installation
Use composer to install. To proceed, run these commands in your terminal:
```
composer require creatuity/magento2-order-status-adjust
php bin/magento module:enable Creatuity_OrderStatusAdjust
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

### Example Use Cases
- set status "Hold - Liftgate" if order items total weight is >= 1000 lbs. and order state is "Processing"
- set status "Payment Review" if Check/Money payment method was used, order total was >= $1000.00 and order state is "Pending"
- set status "Pending - VIP" if "Exclusive Payment Method" was used and order state is "Pending"
- set status "Fraud" if Grand Total is >= $1000.00 and order state is "Pending"

### Usage
#### Configuration
Go to Admin Panel -> Stores -> Settings -> Order Status Adjust Rules.

Click on "Add New Rule" button located in the upper-right corner of the screen to add new rule.

Fill all required and possibly optional fields:
- Enabled - yes/no. Indicates if rule is active. If not - it will not be taken into account during Order updates.
- Rule Name - text. Human-friendly name of the rule, to easily distinguish what is its purpose.
- Sort Order - integer. Allows to sort which rules will have precedence. Rules with lower value will be executed as the first ones. If sort order will be same - rule with lower ID will execute as the first one.
- Date and Time
  - Start - datetime. Allows to select date and time from which rule will be effective. In Store's timezone.
  - End - datetime. Allows to select date and time to which rule will be effective. In Store's timezone.
- Condition - complex. Combination of rules revolving around Orders that can be used to select particular orders and update their status to desired one conditionally.
- Action (Set Order Status) - select. Select desired order status that should be set if rule will be applied.

Save rule

#### Troubleshooting
- My rules are not applying
  - verify enabled state
  - verify start and end date (ensure that they're in store timezone)
- Multiple rules are being applied
  - verify if your rules are excluding each other
    - example: Rule A sets "On Hold", Rule B sets "Cancelled". Make sure that Rule A is having condition "Status" is not 'On Hold' and Rule B is having condition "Status" is not 'Canceled' in their Conditions
- Module is throwing exceptions
  - Ensure that you're running on PHP 8.2 and Magento 2.4.6+
  - If issue is related to older version of Magento or PHP - feel free to open Issue and ask

#### Available Conditions
| Condition                    | Internal Code                |
|------------------------------|------------------------------|
| Subtotal (Excl. Tax)         | base_subtotal_with_discount  |
| Subtotal (Incl. Tax)         | base_subtotal_total_incl_tax |
| Subtotal                     | base_subtotal                |
| Tax Total                    | base_tax_amount              |
| Grand Total                  | base_grand_total             |
| Discount Total               | base_discount_amount         |
| Gift Cards Amount            | base_gift_cards_amount       |
| Total Canceled               | base_total_canceled          |
| Total Invoiced               | base_total_invoiced          |
| Total Paid                   | base_total_paid              |
| Total Refunded               | base_total_refunded          |
| Shipping Amount              | base_shipping_amount         |
| Shipping Canceled            | base_shipping_canceled       |
| Shipping Invoiced            | base_shipping_invoiced       |
| Shipping Refunded            | base_shipping_refunded       |
| Total Items Quantity Ordered | total_qty_ordered            |
| Total Weight                 | weight                       |
| Payment Method               | payment_method               |
| Shipping Method              | shipping_method              |
| Order Currency Code          | order_currency_code          |
| Order Store ID               | store_id                     |
| Coupon Code                  | coupon_code                  |
| Total Item Count             | total_item_count             |
| Customer Is Guest            | customer_is_guest            |
| Customer Group ID            | customer_group_id            |
| Customer Tax Vat             | customer_taxvat              |
| Remote IP                    | remote_ip                    |
| Status                       | status                       |
| State                        | state                        |

### Compatibility
Module was developed using Adobe Commerce 2.4.5 on PHP 8.1
It should work on any Magento Open Source or Adobe Commerce 2.4.4+ versions though.

### Plugin Development
You can easily add more Order (or any other) conditions.

1. Extend `\Magento\Rule\Model\Condition\AbstractCondition` in a similar manner to how it is extended by `\Creatuity\OrderStatusAdjust\Model\Condition\Type\Order`
2. Open di.xml and add newly created class into conditionTypes argument here:
   ````
   <type name="Creatuity\OrderStatusAdjust\Model\Condition\Combine">
       <arguments>
           <argument name="conditionTypes" xsi:type="array">
               <item name="INSERT_TITLE" xsi:type ="object">INSERT_FULLY_QUALIFIED_CLASS_NAME_WITH_NAMESPACE</item>
           </argument>
       </arguments>
   </type>
   ````
3. Make sure you've enabled your newly created module and regenerated static files.

## Recent Versions

| Version | Released |
|---|---|
| 1.1.0 | 2023-08-21 |
| 1.0.1 | 2023-05-18 |
| 1.0.0 | 2023-05-15 |

## Dependencies

### Require

| Package | Constraint |
|---|---|
| php | >=8.1.0 |

## Quality

Latest release (1.1.0) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | 1 | – |
| 2.4.9 | – | – | 1 | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 38 | 1 error, 37 warnings (ruleset: Magento2) — 4 auto-fixable with phpcbf |
| PHPMD | Warning | 24 | 24 rule violations (MissingImport:15, UnusedFormalParameter:5, UndefinedVariable:3, CyclomaticComplexity:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 2 | valid; 2 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 28 | 28 | – | – |
| 2.4.8 | – | 28 | 33 | – |
| 2.4.9 | – | – | 33 | 33 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["creatuity/magento2-order-status-adjust"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

creatuity is a Magento 2 vendor on Packagento. See https://packagento.com/creatuity.md for their full catalogue.

