mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Added InstanceIdentifier
This commit is contained in:
@@ -11,6 +11,7 @@ use Gloudemans\Shoppingcart\Contracts\Buyable;
|
|||||||
use Gloudemans\Shoppingcart\Exceptions\UnknownModelException;
|
use Gloudemans\Shoppingcart\Exceptions\UnknownModelException;
|
||||||
use Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException;
|
use Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException;
|
||||||
use Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException;
|
use Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException;
|
||||||
|
use Gloudemans\Shoppingcart\Contracts\InstanceIdentifier;
|
||||||
|
|
||||||
class Cart
|
class Cart
|
||||||
{
|
{
|
||||||
@@ -68,6 +69,12 @@ class Cart
|
|||||||
{
|
{
|
||||||
$instance = $instance ?: self::DEFAULT_INSTANCE;
|
$instance = $instance ?: self::DEFAULT_INSTANCE;
|
||||||
|
|
||||||
|
if ($instance instanceof InstanceIdentifier)
|
||||||
|
{
|
||||||
|
$this->discount = $instance->getInstanceGlobalDiscount();
|
||||||
|
$this->instance = $instance->getInstanceIdentifier();
|
||||||
|
}
|
||||||
|
|
||||||
$this->instance = sprintf('%s.%s', 'cart', $instance);
|
$this->instance = sprintf('%s.%s', 'cart', $instance);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
20
src/Contracts/InstanceIdentifier.php
Normal file
20
src/Contracts/InstanceIdentifier.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Gloudemans\Shoppingcart\Contracts;
|
||||||
|
|
||||||
|
interface InstanceIdentifier
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the unique identifier to load the Cart from
|
||||||
|
*
|
||||||
|
* @return int|string
|
||||||
|
*/
|
||||||
|
public function getInstanceIdentifier($options = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the unique identifier to load the Cart from
|
||||||
|
*
|
||||||
|
* @return int|string
|
||||||
|
*/
|
||||||
|
public function getInstanceGlobalDiscount($options = null);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user