# liquidlab-agency/magento2-sameday-validation-fix

> Magento 2 module that fixes the Sameday shipping method to properly validate Country field, which triggers shipping address validation and saving

`composer require liquidlab-agency/magento2-sameday-validation-fix`

Canonical URL: https://packagento.com/liquidlab-agency/magento2-sameday-validation-fix

## At a glance

- **Vendor**: liquidlab-agency (https://packagento.com/liquidlab-agency.md)
- **Latest version**: 1.0.1 — released 2025-08-14
- **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/liquidlab-agency/magento2-sameday-validation-fix 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 liquidlab-agency/magento2-sameday-validation-fix:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 module that fixes the Sameday shipping method to properly validate Country field, which triggers shipping address validation and saving

## README

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Magento 2](https://img.shields.io/badge/Magento-2.x-orange.svg)](https://magento.com/)
[![PHP](https://img.shields.io/badge/PHP-7.1%20to%208.3-blue.svg)](https://php.net/)

A Magento 2 module that fixes the Sameday shipping method to properly validate the Country field, which triggers shipping address validation and saving during checkout.

### 🚀 What This Module Does

This module solves a critical issue with the original `sameday/magento2-plugin` where:

- **Problem**: The shipping address is only saved when the "Country" field contains a valid value and passes Magento's default validation
- **Root Cause**: The Sameday plugin doesn't add validation rules for required fields like `country_id`, preventing the shipping address from being updated and saved
- **Solution**: This module adds proper validation rules for the Sameday shipping method that include required field validation for:
  - `country_id` (Country field)
  - `postcode` (Postal code)
  - `region_id` (Region/State)
  - `region_id_input` (Region input for manual entry)

### 🔍 Why This Fix Is Needed

In typical Magento 2 shipping method implementations (like `tablerate`), validation rules are properly defined to trigger address validation. However, the Sameday plugin was missing these crucial validation rules, causing:

1. Country field validation to be skipped
2. Shipping address not being updated when Sameday is selected
3. Incomplete address data being saved
4. Potential checkout issues and shipping calculation problems

### 📋 Requirements

- **PHP**: 7.1, 7.2, 7.3, 7.4, 8.1, 8.2, or 8.3
- **Magento**: 2.x (Community or Commerce Edition)
- **Dependencies**:
  - `magento/framework: ^103.0`
  - `magento/module-checkout: ^100.0`
  - `sameday/magento2-plugin: ^1.9`

### 📦 Installation

#### Via Composer (Recommended)

```bash
composer require liquidlab-agency/magento2-sameday-validation-fix
php bin/magento module:enable Liquidlab_SamedayValidationFix
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush
```

#### Manual Installation

1. Download or clone this repository
2. Copy the contents to `app/code/Liquidlab/SamedayValidationFix/`
3. Run the following commands:

```bash
php bin/magento module:enable Liquidlab_SamedayValidationFix
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush
```

### 🧪 Testing

After installation, test the fix by:

1. Go to your store's checkout page
2. Add a product to cart and proceed to checkout
3. Select "Sameday Courier" as shipping method
4. Verify that changing the country field triggers address validation
5. Confirm the shipping address is properly saved and updated

![Sameday Validation Demo](docs/images/checkout.png)

### 🔄 Compatibility

- **Magento Versions**: 2.3.x, 2.4.x
- **PHP Versions**: 7.1 - 8.3
- **Sameday Plugin**: Compatible with v1.9+
- **Themes**: Works with all themes (Luma, Blank, custom themes)

### 📚 Module Dependencies

This module depends on and extends:
- `Magento_Checkout` - For checkout functionality
- `SamedayCourier_Shipping` - The original Sameday plugin

### 📞 Support

For support, please:
1. Check the [GitHub Issues](https://github.com/liquidlab-agency/magento2-sameday-validation-fix/issues)
2. Contact us at support@liquidlab.ro

### 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

### 🤝 Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### 🏷️ Changelog

#### v1.0.0
- Initial release
- Added Country field validation for Sameday shipping method
- Fixed shipping address saving issue
- Full PHP 7.1-8.3 compatibility

---

**Made with ❤️ by [Liquidlab](https://liquidlab.ro)**

## Recent Versions

| Version | Released |
|---|---|
| 1.0.1 | 2025-08-14 |
| 1.0.0 | 2025-08-14 |

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | ^103.0 |
| magento/module-checkout | ^100.0 |
| php | ~7.1.0\|\|~7.2.0\|\|~7.3.0\|\|~7.4.0\|\|~8.1.0\|\|~8.2.0\|\|~8.3.0 |
| sameday/magento-2-plugin | ^1.9 |

## Quality

Latest release (1.0.1) passes 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 | not tested | – |
| 2.4.9 | – | – | not tested | not tested |


### 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 | Pass | 0 |  |
| PHPMD | Pass | 0 |  |
| Cpd | Pass | 0 |  |
| Composer validate | Pass | 0 |  |

#### 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 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### 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=["liquidlab-agency/magento2-sameday-validation-fix"],
  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

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

