Merge pull request #140 from ChrisThompsonTLDR/master

Add a cart instance string property on CartItems
This commit is contained in:
Patrick
2022-01-17 19:28:05 +01:00
committed by GitHub
2 changed files with 23 additions and 0 deletions

View File

@@ -813,6 +813,8 @@ class Cart
$cartItem->setQuantity($qty);
}
$cartItem->setInstance($this->currentInstance());
return $cartItem;
}

View File

@@ -95,6 +95,13 @@ class CartItem implements Arrayable, Jsonable
*/
private $discountRate = 0;
/**
* The cart instance of the cart item.
*
* @var null|string
*/
public $instance = null;
/**
* CartItem constructor.
*
@@ -372,6 +379,20 @@ class CartItem implements Arrayable, Jsonable
return $this;
}
/**
* Set cart instance.
*
* @param null|string $instance
*
* @return \Gloudemans\Shoppingcart\CartItem
*/
public function setInstance($instance)
{
$this->instance = $instance;
return $this;
}
/**
* Get an attribute from the cart item or get the associated model.
*