Bigpost Integration with Magento 2

BigPost is a shipping carrier that provides a REST API for developers to integrate their shipping services into e-commerce platforms.

To integrate BigPost API with Magento, you can follow these general steps:

-Obtain API credentials: You need to register with BigPost and obtain API credentials such as API Key, API Secret, and Merchant ID.

-Install and configure the BigPost extension: Search for the BigPost extension on the Magento Marketplace, download and install it, and configure it with the API credentials obtained in step 1.

-Set up shipping methods and rates: Configure the shipping methods and rates in Magento by specifying the shipping options available and the corresponding rates for different destinations and package sizes.

-Test the integration: Test the integration by placing orders in Magento and verifying that the shipping rates are calculated correctly and that the orders are transmitted to BigPost for shipping.

To Create an integration with Magento

  1. Create a custom module: Create a custom module in Magento 2 by following the Magento 2 module development guidelines.
  2. Create a shipping carrier class: In your custom module, create a shipping carrier class that extends the Magento\Shipping\Model\Carrier\AbstractCarrier class. This class will handle the logic for the custom shipping method.
  3. Implement the required methods: Implement the required methods in the shipping carrier class, such as the collectRates() method, which calculates the shipping rates based on the BigPost API response.
  4. Configure the module: Configure the custom shipping method in the Magento 2 admin panel by specifying the method name, title, and other relevant settings.
  5. Test the shipping method: Test the custom shipping method by placing test orders in Magento 2 and verifying that the shipping rates are calculated correctly.
<?php

namespace Vendor\Module\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Carrier\AbstractCarrier;
use Magento\Shipping\Model\Carrier\CarrierInterface;

class BigPost extends AbstractCarrier implements CarrierInterface
{
    protected $_code = 'bigpost';

    public function collectRates(RateRequest $request)
    {
        // Call BigPost API to get shipping rates
        // Parse the API response to get the shipping rates
        // Add the shipping rates to the Magento 2 quote
        // Return the shipping rates as an array of Magento\Quote\Model\Quote\Address\RateResult\Method objects
    }

    public function getAllowedMethods()
    {
        return [$this->_code => $this->getConfigData('name')];
    }
}

Create system.xml file inside etc folder of the module

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="carriers" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="freightcost" translate="label" type="text" sortOrder="900" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Freight Cost</label>
                <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Title</label>
                </field>
                <field id="name" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Method Name</label>
                </field>
                <field id="shipping_cost" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0" >
                    <label>Shipping Cost</label>
                    <validate>validate-number validate-zero-or-greater</validate>
                </field>
                <field id="sallowspecific" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Ship to Applicable Countries</label>
                    <frontend_class>shipping-applicable-country</frontend_class>
                    <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model>
                </field>
                <field id="specificcountry" translate="label" type="multiselect" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Ship to Specific Countries</label>
                    <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
                    <can_be_empty>1</can_be_empty>
                </field>
                <field id="showmethod" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Show Method if Not Applicable</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <frontend_class>shipping-skip-hide</frontend_class>
                </field>
                <field id="token_api" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Acess Token API</label>
                </field>
                <field id="price_api" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Price Calculation API</label>
                </field>
                <field id="customet_id" translate="label" type="text" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Ezysend Customer ID</label>
                </field>
                <field id="carrier_id" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Carrier ID</label>
                </field>
                <field id="carrier_account" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Carrier Account</label>
                </field>
                <field id="warehouse_locality" translate="label" type="text" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Warehouse Locality</label>
                </field>
                 <field id="warehouse_postcode" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Warehouse PostCode</label>
                </field>
                <field id="warehouse_territory" translate="label" type="text" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Warehouse Territory(Short Name)</label>
                </field>
                <field id="extra_cost" translate="label" type="text" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Extra(%)</label>
                </field>
                <field id="sort_order" translate="label" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Sort Order</label>
                </field>
            </group>
        </section>
    </system>
</config>

Leave a comment

Your email address will not be published. Required fields are marked *