PHP code example of drewdan / royal-mail-pricing

1. Go to this page and download the library: Download drewdan/royal-mail-pricing 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/ */

    

drewdan / royal-mail-pricing example snippets


use Drewdan\RoyalMailPricing\Models\Item;

$item = Item::make()
    ->setName('Test Item 1')
    ->setWeight(2101)
    ->setHeight(10)
    ->setWidth(10)
    ->setLength(10);

use Drewdan\RoyalMailPricing\Consignment;

$consignment = Consignment::make()
    ->addItem($item)
    ->assignToParcels()
    ->getConsignment();


$consignment->getPostageCost('firstClassPostage'); // Returns the price of the consignment for first class postage
$consignment->getPostageCost('secondClassPostage'); // Returns the price of the consignment for second class postage
$consignment->getParcels(); // Returns an array of parcels which make up the consignment
$consignment->getConsignmentWeight(); // Returns the total weight of the consignment
$consignment->getParcelCount(); // Returns the number of parcels in the consignment
$consignment->getItemCount(); // Returns the number of items in the consignment
bash
php artisan vendor:publish --provider="Drewdan\RoyalMailPricing\RoyalMailPricingServiceProvider" --tag="config"