mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 15:41:24 +00:00
Make the CartItem aware of its cart instance
This commit is contained in:
@@ -813,6 +813,8 @@ class Cart
|
|||||||
$cartItem->setQuantity($qty);
|
$cartItem->setQuantity($qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cartItem->setInstance($this->instance);
|
||||||
|
|
||||||
return $cartItem;
|
return $cartItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,13 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
*/
|
*/
|
||||||
private $discountRate = 0;
|
private $discountRate = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cart instance of the cart item.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CartItem constructor.
|
* CartItem constructor.
|
||||||
*
|
*
|
||||||
@@ -372,6 +379,20 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
return $this;
|
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.
|
* Get an attribute from the cart item or get the associated model.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user