MOON
Server: Apache
System: Linux server.royaltuning.hu 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Tue Feb 21 04:20:52 EST 2023 x86_64
User: royaltuning (1001)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/apache/htdocs/Modules/Shipping/Method.php
<?php

namespace Modules\Shipping;

use Modules\Support\Money;
use Modules\Cart\Facades\Cart;

class Method
{
    public $name;
    public $label;
    public $cost;

    public function __construct($name, $label, $cost)
    {
        $this->name = $name;
        $this->label = $label;
        $this->cost = Money::inDefaultCurrency($cost);
    }

    public function available($freeShipCoupon=false)
    {
        if ($this->name !== 'free_shipping') {
            return true;
        }

        return $this->freeShippingMethodIsAvailable($freeShipCoupon);
    }

    private function freeShippingMethodIsAvailable($freeShipCoupon=false)
    {
        $minimumAmount = Money::inDefaultCurrency(setting('free_shipping_min_amount'));
        if ($freeShipCoupon) {
            return true;
        } else {
            return Cart::subTotal()->greaterThanOrEqual($minimumAmount);
        }

    }
}