Further fixes

This commit is contained in:
Patrick Henninger
2022-02-06 00:27:03 +01:00
parent c3d33a37f6
commit 66d23444b2
6 changed files with 29 additions and 39 deletions

View File

@@ -72,7 +72,7 @@ class Cart
{
$this->session = $session;
$this->events = $events;
$this->taxRate = config('cart.tax');
$this->taxRate = Config::get('cart.tax');
$this->instance(self::DEFAULT_INSTANCE);
}
@@ -747,7 +747,7 @@ class Cart
*/
private static function getTableName(): string
{
return config('cart.database.table', 'shoppingcart');
return Config::get('cart.database.table', 'shoppingcart');
}
/**
@@ -755,9 +755,9 @@ class Cart
*/
private function getConnectionName(): ?string
{
$connection = config('cart.database.connection');
$connection = Config::get('cart.database.connection');
return is_null($connection) ? config('database.default') : $connection;
return is_null($connection) ? Config::get('database.default') : $connection;
}
/**

View File

@@ -7,6 +7,7 @@ use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Money\Money;
use Money\Formatter\DecimalMoneyFormatter;
use Money\Currencies\ISOCurrencies;
@@ -164,8 +165,8 @@ class CartItem implements Arrayable, Jsonable
}
/**
* This will is the price of the CartItem considering the set quantity. If you need the raw price
* then simply access the price member.
* This will is the price of the CartItem considering the set quantity. If you need the single
* price just set the parameter to true.
*/
public function price(): Money
{
@@ -180,9 +181,9 @@ class CartItem implements Arrayable, Jsonable
public function discount(): Money
{
if ($this->discount instanceof Money) {
return $this->price()->subtract($this->discountRate);
return $this->price()->subtract($this->discount);
} else {
return $this->price()->multiply($this->discountRate, config('cart.rounding', Money::ROUND_UP));
return $this->price()->multiply($this->discount, Config::get('cart.rounding', Money::ROUND_UP));
}
}
@@ -200,7 +201,7 @@ class CartItem implements Arrayable, Jsonable
*/
public function tax(): Money
{
return $this->subtotal()->multiply($this->taxRate + 1, config('cart.rounding', Money::ROUND_UP));
return $this->subtotal()->multiply($this->taxRate + 1, Config::get('cart.rounding', Money::ROUND_UP));
}
/**

View File

@@ -11,7 +11,7 @@ class CreateShoppingcartTable extends Migration
*/
public function up()
{
Schema::create(config('cart.database.table'), function (Blueprint $table) {
Schema::create(Config::get('cart.database.table'), function (Blueprint $table) {
$table->string('identifier');
$table->string('instance');
$table->longText('content');
@@ -26,6 +26,6 @@ class CreateShoppingcartTable extends Migration
*/
public function down()
{
Schema::drop(config('cart.database.table'));
Schema::drop(Config::get('cart.database.table'));
}
}