![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/Corals/modules/Marketplace/Classes/Coupons/ |
<?php namespace Corals\Modules\Marketplace\Classes\Coupons; use Corals\Modules\Marketplace\Contracts\CouponContract; use Corals\Modules\Marketplace\Classes\ShoppingCart; use Corals\Modules\Marketplace\Traits\CouponTrait; /** * Class Fixed. */ class Fixed implements CouponContract { use CouponTrait; public $code; public $value; /** * Fixed constructor. * * @param $code * @param $value * @param array $options */ public function __construct($code, $value, $options = []) { $this->code = $code; $this->value = $value; $this->setOptions($options); } /** * Gets the discount amount. * * @param $throwErrors boolean this allows us to capture errors in our code if we wish, * that way we can spit out why the coupon has failed * * @return string */ public function discount($throwErrors = false) { $subTotal = app(ShoppingCart::SERVICE)->subTotal(false); $total = $subTotal - $this->value; if (config('shoppingcart.discountOnFees', false)) { $total = $subTotal + app(ShoppingCart::SERVICE)->feeTotals(false) - $this->value; } if ($total < 0) { return $subTotal; } return $this->value; } /** * Displays the value in a money format. * * @param null $locale * @param null $internationalFormat * * @return string */ public function displayValue($locale = null, $internationalFormat = null, $format = true) { return ShoppingCart::formatMoney( $this->discount(), $locale, $internationalFormat, $format ); } }