vanilophp / cart Goto Github PK
View Code? Open in Web Editor NEWCart Module for Vanilo (or any Laravel app)
Home Page: https://vanilo.io
License: MIT License
Cart Module for Vanilo (or any Laravel app)
Home Page: https://vanilo.io
License: MIT License
The current addItem() combines quantity for same product, that works perfectly well for normal physical products. However, when it comes to service-based products with customisations, it is often different for each item.
e.g. A sticker printing company sells 10x10cm label sticker as a product but every order and item is considered unique because the print design is different. It wouldn't make sense to add millions of product since there's practically no limit to people's designs.
This would add the functionality of Cart::addServiceItem() where it allows the cart to store individual entries. So the customer can order 10x10cm label with multiple designs.
This applies to service oriented (built-to-order) industries / businesses:
Vanilo\Cart\CartManager.php
/**
* @inheritDoc
*/
public function addServiceItem(Buyable $product, $qty = 1, $params = []): CartItem
{
$cart = $this->findOrCreateCart();
return $cart->addServiceItem($product, $qty, $params);
}
Vanilo\Cart\Models\Cart.php
/**
* @inheritDoc
*/
public function addServiceItem(Buyable $product, $qty = 1, $params = []): \Vanilo\Cart\Contracts\CartItem
{
$item = $this->items()->create(
array_merge(
$this->getDefaultCartItemAttributes($product, $qty),
$this->getExtraProductMergeAttributes($product),
$params['attributes'] ?? []
)
);
$this->load('items');
return $item;
}
Our site allows donations of arbitrary amounts. Is there a way to make the price of a product variable?
My cart keeps disappearing when i use both settings in the vanilo.php config file. When i remove one of the setting (and use php artisan cache:clear
) the cart is remembered. For example i've removed merge_duplicated and i can see the cart in the database table.
I am using version 1.1.1 of vanilo.
I'm using a config file with this content:
<?php
return [
'cart' => [
/*
* @see https://github.com/vanilophp/cart#preserve-the-cart-for-users-across-logins
*/
'preserve_for_user' => true,
'merge_duplicates' => true,
]
];
Is it possible to add an item more than once to the cart and it won't increase the quantity but add a separate item to cart.
So I've implemented using the cart library in my project but i can't seem to be able to update a cart item's quantity. How do I do that?
Currently Vanilo assumes that the table name is carts
, and there is no way to configure this. Can you make this a config setting, please?
I'll try to submit a pull request.
Hi
The migrations and config file is not published when running php artisan vendor:publish when only this package is being installed instead of whole framework.
For each product i've got a seperate 'product_remarks' field which can be filled before adding the buyable product to the cart. This field can contain 'custom information' about the product and it should be possible to edit this field.
The first time i add a product to the cart this attribute is saved properly. However the second time it is ignored. This can be traced to the if in: src\Models\Cart.php > addItem()
To be clear, i'm not using this attribute to copy existing buyable model attributes, but to add a custom attribute. Is it possible to implement something like this?
If I open /shop uri or product page, Cart::getItems() return all items from database that belongs to different carts and users. On other pages everything works fine.
dd(Cart::model()) on /shop uri show this
#relations: array:2 [▼
"user" => User {#722 ▶}
"items" => Collection {#713 ▼
#items: array:4 [▶]
}
]
on any other page:
#relations: []
And ideas why?
Vanilo Cart 0.5.1
I have a special type of product in database for which I need to insert the product into the cart from the product.show
page as new item not to update the quantity every time I insert it like it is standard for inserting the same product. Therefore, I have extended the Cart
model to modify the addItem(Buyable $product, $qty = 1, $params = [])
. The only issue that I had implementing it that there are two methods that are private in the Vanilo\Cart\Models\Cart
getDefaultCartItemAttributes(Buyable $product, $qty)
getExtraProductMergeAttributes(Buyable $product)
I just had to copy and paste them around from the parent class. Do you have a particular reason these methods are private
please? Is it possible that the methods can be protected
instead? Thank you for help.
Hi, I'm trying to use the instructions for the Permanent Extra Fields, but it references a config file (config/vanilo.php) that I don't have. I'm only using the Cart module, not the framework - is this not doable in that context?
I'm implementing a custom Buyable Model but after successfully adding to Cart, cart count returns the correct values but after page refresh cart count goes back to zero.
Environment: Laravel 5.5.39
Standalone: vanila/cart: 0.2
Code:
$product = \App\Models\Banner::find(1);
\Cart::addItem($product, 1, ['width' => 123, 'height' => 12]);
There is no column in the cart_item table to store the additional parameters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.