Make the CartItem aware of its cart instance

This commit is contained in:
Chris Thompson
2021-11-30 17:25:47 -05:00
parent 7ceb550350
commit dcd41d3790
2 changed files with 23 additions and 0 deletions

View File

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

View File

@@ -95,6 +95,13 @@ class CartItem implements Arrayable, Jsonable
*/
private $discountRate = 0;
/**
* The cart instance of the cart item.
*
* @var string
*/
public $instance;
/**
* CartItem constructor.
*
@@ -372,6 +379,20 @@ class CartItem implements Arrayable, Jsonable
return $this;
}
/**
* Set cart instance
*
* @param 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.
*