Cart
class Cart extends BaseModel (View source)
Traits
Properties
array | $cachableProperties | Array of cachable class properties. |
|
$subTotal | The cart sub total. |
||
$subTotalDiscounted | The cart sub total. |
||
$shippingSubTotal | The shipping sub total for the cart. |
||
$shippingTotal | The shipping total for the cart. |
||
$taxTotal | The cart tax total. |
||
$discountTotal | The discount total. |
||
null|DiscountBreakdown> | $discountBreakdown | All the discount breakdowns for the cart. |
|
$shippingBreakdown | All the shipping breakdowns for the cart. |
||
$total | The cart total. |
||
null|TaxBreakdown> | $taxBreakdown | All the tax breakdowns for the cart. |
|
null|Promotion> | $promotions | The cart-level promotions. |
|
null|Discount> | $discounts | The cart-level discounts. |
|
null|FreeItem> | $freeItems | Qualifying promotional free items. |
|
protected array | $guarded | Define which attributes should be protected from mass assignment. |
|
protected array | $casts | The attributes that should be cast. |
|
int | $id | ||
?int | $user_id | ||
?int | $customer_id | ||
?int | $merged_id | ||
int | $currency_id | ||
int | $channel_id | ||
?int | $order_id | ||
?string | $coupon_code | ||
Carbon | $completed_at | ||
Carbon | $created_at | ||
Carbon | $updated_at |
Methods
Get new instance of the registered model.
Handle dynamic and static method calls into the model.
Forward a method call to the model only when calling a method on the model.
Register a model event with the dispatcher.
Fire the given event for the model.
Remove all the event listeners for the model.
Handle dynamic static method calls into the model.
Return a new factory instance for the model.
Return the cart lines relationship.
Return the currency relationship.
Return the user relationship.
Return the customer relationship.
No description
Return the addresses relationship.
Return the shipping address relationship.
Return the billing address relationship.
Return the order relationship.
Apply scope to get active cart.
Return the draft order relationship.
Return the completed order relationship.
Return the carts completed order.
Return whether the cart has any completed order.
Add or update a purchasable item to the cart
Add cart lines.
Update cart line
Update cart lines.
Deletes all cart lines.
Associate a user to the cart
Add an address to the Cart.
Set the shipping address.
Set the billing address.
Set the shipping option to the shipping address.
Get the shipping option for the cart
Returns whether the cart has shippable items.
Create an order from the Cart.
Returns whether a cart has enough info to create an order.
Get a unique fingerprint for the cart to identify if the contents have changed.
Check whether a given fingerprint matches the one being generated for the cart.
Details
Model
newInstance(array $attributes = [], bool $exists = false)
Get new instance of the registered model.
mixed
__call(string $method, array $parameters)
Handle dynamic and static method calls into the model.
Model
swap(string $newModelClass)
Swap the model implementation.
string
getMorphClass()
Get the class name of the base model.
protected bool
forwardCallsWhen(string $method, Model $model)
Forward a method call to the model only when calling a method on the model.
static protected void
registerModelEvent(string $event, QueuedClosure|Closure|string $callback)
Register a model event with the dispatcher.
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
static void
flushEventListeners()
Remove all the event listeners for the model.
__construct(array $attributes = [])
Create a new instance of the Model.
LogOptions
getActivitylogOptions()
Get the log options for the activity log.
static mixed
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the model.
static
bootCachesProperties()
No description
refresh()
No description
protected string
cachePropertiesPrefix()
Returns a unique key for the cache.
void
cacheProperties()
Cache properties for reuse in same request.
void
restoreProperties()
Restores properties from the same request.
static protected CartFactory
newFactory()
Return a new factory instance for the model.
HasMany
lines()
Return the cart lines relationship.
BelongsTo
currency()
Return the currency relationship.
BelongsTo
user()
Return the user relationship.
BelongsTo
customer()
Return the customer relationship.
scopeUnmerged($query)
No description
HasMany
addresses()
Return the addresses relationship.
HasOne
shippingAddress()
Return the shipping address relationship.
HasOne
billingAddress()
Return the billing address relationship.
HasMany
orders()
Return the order relationship.
Builder
scopeActive(Builder $query)
Apply scope to get active cart.
HasOne
draftOrder(int $draftOrderId = null)
Return the draft order relationship.
HasOne
completedOrder(int $completedOrderId = null)
Return the completed order relationship.
HasMany
completedOrders()
Return the carts completed order.
bool
hasCompletedOrders()
Return whether the cart has any completed order.
Cart
calculate()
Calculate the cart totals and cache the result.
Cart
add(Purchasable $purchasable, int $quantity = 1, array $meta = [], bool $refresh = true)
Add or update a purchasable item to the cart
bool
addLines(iterable $lines)
Add cart lines.
Cart
remove(int $cartLineId, bool $refresh = true)
Remove a cart line
Cart
updateLine(int $cartLineId, int $quantity, array $meta = null, bool $refresh = true)
Update cart line
Cart
updateLines(Collection $lines)
Update cart lines.
clear()
Deletes all cart lines.
Cart
associate(User $user, string $policy = 'merge', bool $refresh = true)
Associate a user to the cart
Cart
addAddress(Addressable $address, string $type, bool $refresh = true)
Add an address to the Cart.
Cart
setShippingAddress(Addressable $address)
Set the shipping address.
Cart
setBillingAddress(Addressable $address)
Set the billing address.
Cart
setShippingOption(ShippingOption $option, $refresh = true)
Set the shipping option to the shipping address.
ShippingOption|null
getShippingOption()
Get the shipping option for the cart
bool
isShippable()
Returns whether the cart has shippable items.
Order
createOrder(bool $allowMultipleOrders = false, int $orderIdToUpdate = null)
Create an order from the Cart.
bool
canCreateOrder()
Returns whether a cart has enough info to create an order.
string
fingerprint()
Get a unique fingerprint for the cart to identify if the contents have changed.
bool
checkFingerprint(string $fingerprint)
Check whether a given fingerprint matches the one being generated for the cart.