Skip to content

Commit

Permalink
lint: max 80 chars per line
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Oct 9, 2024
1 parent 881ab8b commit 9f6ac4e
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions add-custom-shipping-carrier.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

[TOC]

Mage-OS allows the creation of custom shipping carriers to handle various shipping methods for different carriers or logistics providers. A custom shipping carrier can be added by creating a Mage-OS module and configuring the required fields to handle shipping calculations, carrier configurations, and frontend integration.
Mage-OS allows the creation of custom shipping carriers to handle various shipping methods for

Check failure on line 5 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Line length

add-custom-shipping-carrier.md:5:81 MD013/line-length Line length [Expected: 80; Actual: 94] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
different carriers or logistics providers. A custom shipping carrier can be added by creating a

Check failure on line 6 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Line length

add-custom-shipping-carrier.md:6:81 MD013/line-length Line length [Expected: 80; Actual: 95] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
Mage-OS module and configuring the required fields to handle shipping calculations,
carrier configurations, and frontend integration.

## Module Setup

The first step in adding a custom shipping carrier is creating the necessary directory structure for the Mage-OS module:
The first step in adding a custom shipping carrier is creating the necessary directory structure

Check failure on line 12 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Line length

add-custom-shipping-carrier.md:12:81 MD013/line-length Line length [Expected: 80; Actual: 96] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
for the Mage-OS module:

```bash
app/code/MageOS/ShippingCarrier/
Expand Down Expand Up @@ -45,7 +49,8 @@ Next, you need to declare your module in `app/code/MageOS/ShippingCarrier/etc/mo

## Shipping Carrier Configuration

In the `config.xml` file, define the shipping carrier's core settings, such as its active state, title, and allowed countries. Create `app/code/MageOS/ShippingCarrier/etc/config.xml`:
In the `config.xml` file, define the shipping carrier's core settings, such as its active state,

Check failure on line 52 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Line length

add-custom-shipping-carrier.md:52:81 MD013/line-length Line length [Expected: 80; Actual: 96] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
title, and allowed countries. Create `app/code/MageOS/ShippingCarrier/etc/config.xml`:

```xml
<?xml version="1.0"?>
Expand Down Expand Up @@ -76,7 +81,8 @@ Explanation:

# Admin Configuration for Carrier

Check failure on line 82 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Multiple top-level headings in the same document

add-custom-shipping-carrier.md:82 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Admin Configuration for Carr..."] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md025.md

To allow store administrators to configure the shipping method, we define settings in `app/code/MageOS/ShippingCarrier/etc/adminhtml/system.xml`:
To allow store administrators to configure the shipping method, we define settings in

Check failure on line 84 in add-custom-shipping-carrier.md

View workflow job for this annotation

GitHub Actions / lint

Line length

add-custom-shipping-carrier.md:84:81 MD013/line-length Line length [Expected: 80; Actual: 85] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
`app/code/MageOS/ShippingCarrier/etc/adminhtml/system.xml`:

```xml
<?xml version="1.0"?>
Expand Down Expand Up @@ -124,11 +130,13 @@ To allow store administrators to configure the shipping method, we define settin
</config>
```

This configuration allows administrators to enable the carrier, set a title, and configure a handling fee through the Mage-OS admin panel.
This configuration allows administrators to enable the carrier, set a title, and configure a handling
fee through the Mage-OS admin panel.

# Shipping Carrier Model

The core logic for the custom shipping carrier is in the CustomCarrier.php model. This class extends Mage-OS's abstract shipping carrier class and implements the shipping calculation and rates.
The core logic for the custom shipping carrier is in the CustomCarrier.php model.
This class extends Mage-OS's abstract shipping carrier class and implements the shipping calculation and rates.

```php
<?php
Expand Down Expand Up @@ -213,12 +221,17 @@ class CustomCarrier extends AbstractCarrier implements CarrierInterface

Explanation:

- collectRates(): Calculates shipping rates based on the quote request and returns them. Here, a fixed rate of 10.00 is used.
- collectRates(): Calculates shipping rates based on the quote request and returns them.
Here, a fixed rate of 10.00 is used.
- getAllowedMethods(): Returns the allowed shipping methods for this carrier.

# Frontend Integration

Once the backend logic is in place, the custom shipping carrier will automatically appear in the Mage-OS checkout if it's enabled and configured properly. The title and price will be displayed as defined in the carrier configuration.
Once the backend logic is in place, the custom shipping carrier will automatically appear in the Mage-OS checkout
if it's enabled and configured properly. The title and price will be displayed as defined in the carrier configuration.

# Conclusion
This guide walks through the basic setup of a custom shipping carrier in Mage-OS. The carrier integrates with Mage-OS’s shipping framework, allowing you to customize the shipping calculation and display it during the checkout process. You can extend this basic structure to integrate with third-party APIs, offer dynamic shipping rates, or introduce more complex shipping logic based on cart contents or customer information.
This guide walks through the basic setup of a custom shipping carrier in Mage-OS.
The carrier integrates with Mage-OS’s shipping framework, allowing you to customize the shipping calculation
and display it during the checkout process. You can extend this basic structure to integrate with third-party APIs,
offer dynamic shipping rates, or introduce more complex shipping logic based on cart contents or customer information.

0 comments on commit 9f6ac4e

Please sign in to comment.