PHP code example of lunarphp / table-rate-shipping

1. Go to this page and download the library: Download lunarphp/table-rate-shipping library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lunarphp / table-rate-shipping example snippets


use Lunar\Admin\Support\Facades\LunarPanel;
use Lunar\Shipping\ShippingPlugin;
// ...

public function register(): void
{
    LunarPanel::panel(function (Panel $panel) {
        return $panel->plugin(new ShippingPlugin());
    })->register();
    
    // ...
}

$options = \Lunar\Base\ShippingManifest::getOptions(
    $cart
);

\Lunar\Shipping\Facades\Shipping::getSupportedDrivers();

\Lunar\Shipping\Facades\Shipping::with('ship-by')->resolve(
    new \Lunar\Shipping\DataTransferObjects\ShippingOptionRequest(
        shippingRate: \Lunar\Shipping\Models\ShippingRate $shippingRate,
        cart: \Lunar\Models\Cart $cart
    )
);

$shippingZones = Lunar\Shipping\Facades\Shipping::zones()
    ->country(\Lunar\Models\Country $country)
    ->state(\Lunar\Models\State $state)
    ->postcode(
        new \Lunar\Shipping\DataTransferObjects\PostcodeLookup(
            country: \Lunar\Models\Country $country,
            postcode: 'NW1'
        )
    )->get()
    
$shippingZones->map(/* .. */);

$shippingRates = \Lunar\Shipping\Facades\Shipping::shippingRates(
    \Lunar\Models\Cart $cart
);

$shippingOptions = \Lunar\Shipping\Facades\Shipping::shippingOptions(
    \Lunar\Models\Cart $cart
);