55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Core\Shipping\Carriers\BoxNow;
|
|
|
|
use Lunar\DataTypes\ShippingOption;
|
|
use Lunar\Shipping\DataTransferObjects\ShippingOptionRequest;
|
|
use Lunar\Shipping\Interfaces\ShippingRateInterface;
|
|
use Lunar\Shipping\Models\ShippingRate;
|
|
use Modules\Core\Shipping\Concerns\ResolvesFixedPricing;
|
|
use Modules\Core\Shipping\Contracts\DeclaresFulfillmentType;
|
|
|
|
/**
|
|
* Box Now has no pricing API, so this always resolves the method's normal
|
|
* charge_by + price-break configuration — the same mechanism the built-in
|
|
* flat-rate/ship-by drivers use. Does not implement SupportsLivePricing:
|
|
* there is no live option to offer.
|
|
*/
|
|
class BoxNowRateDriver implements ShippingRateInterface, DeclaresFulfillmentType
|
|
{
|
|
use ResolvesFixedPricing;
|
|
|
|
public ShippingRate $shippingRate;
|
|
|
|
public function name(): string
|
|
{
|
|
return 'Box Now Locker Delivery';
|
|
}
|
|
|
|
public function fulfillmentType(): string
|
|
{
|
|
return 'carrier';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Deliver to a Box Now parcel locker.';
|
|
}
|
|
|
|
public function resolve(ShippingOptionRequest $shippingOptionRequest): ?ShippingOption
|
|
{
|
|
return $this->resolveFixedPrice(
|
|
$shippingOptionRequest->shippingRate,
|
|
$shippingOptionRequest->shippingRate->shippingMethod,
|
|
$shippingOptionRequest->cart,
|
|
);
|
|
}
|
|
|
|
public function on(ShippingRate $shippingRate): self
|
|
{
|
|
$this->shippingRate = $shippingRate;
|
|
|
|
return $this;
|
|
}
|
|
}
|