Update Framework, Invoices

This commit is contained in:
Kevin Adametz 2022-04-14 13:14:36 +02:00
parent cc5c147c27
commit 9b0b5feb7e
174 changed files with 28356 additions and 8093 deletions

View file

@ -11,7 +11,6 @@ use Illuminate\Session\SessionManager;
use Illuminate\Contracts\Events\Dispatcher;
use Gloudemans\Shoppingcart\Contracts\Buyable;
class Yard extends Cart
{
private $shipping_price = 0;
@ -27,6 +26,8 @@ class Yard extends Cart
private $user_country_id;
private $user_country;
private $shopping_data = [];
private $events;
public function __construct(SessionManager $session, Dispatcher $events)
{
@ -71,6 +72,8 @@ class Yard extends Cart
$this->user_country = $this->getYardExtra('user_country');
}
$this->events = $events;
parent::__construct($session, $events);
@ -90,7 +93,7 @@ class Yard extends Cart
{
return config('cart.tax');
}
public function putYardExtra($key, $value){
$content = $this->getYContent();
@ -363,7 +366,7 @@ class Yard extends Cart
* @param string $thousandSeperator
* @return string
*/
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
public function total($decimals = NULL, $decimalPoint = NULL, $thousandSeperator = NULL, $withFees = true)
{
$content = $this->getContent();
$total = $content->reduce(function ($total, CartItem $cartItem) {
@ -381,7 +384,7 @@ class Yard extends Cart
* @param string $thousandSeperator
* @return float
*/
public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
public function tax($decimals = NULL, $decimalPoint = NULL, $thousandSeperator = NULL, $withFees = true)
{
$content = $this->getContent();
@ -584,4 +587,40 @@ class Yard extends Cart
return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
}
public function myStore($identifier, array $eventOptions = [])
{
// Remove any existing identifiers
// Although possibly first or update could work in future
$this
->getConnection()
->table($this->getTableName())
->where('identifier', $identifier)
->delete();
// Insert into the database with the new cart
$content = $this->getContent();
$this->getConnection()->table($this->getTableName())->insert([
'identifier' => $identifier,
'instance' => $this->currentInstance(),
'content' => serialize($content)
]);
$eventOptions = array_merge([
'cartInstance' => $this->currentInstance(),
], $eventOptions);
$this->events->dispatch('cart.stored', $eventOptions);
}
/**
* Restore the cart with the given identifier.
*
* @param mixed $identifier
* @return void
*/
}