freshbitsweb / laravel-cart-manager Goto Github PK
View Code? Open in Web Editor NEWManaging the cart in your Laravel/E-commerce application is a breeze
License: MIT License
Managing the cart in your Laravel/E-commerce application is a breeze
License: MIT License
In CartManagerServiceProvider.php line 49:
Trying to access array offset on value of type null
Got this error just after,
composer require freshbitsweb/laravel-cart-manager
Currently, if I want to disable guest login it's not available. If we make this feature then it will boost some amount of performance.
Is your feature request related to a problem? Please describe.
Let's say a product is no longer available. It has to be removed from all carts immediately so that users' won't buy those items.
Describe the solution you'd like
From the documentation, I cannot find how to update all users' carts with the available methods. Does cart()
method apply to all users or just the current user?
Describe alternatives you've considered
I tried fetching all carts that include the given product id. After that, I check the carts but I can't find a way to remove and update the totals etc.
I tried your demo package. It's not support float numbers. Why? How I can use for quantity numbers as 0,5, 1,5, etc? Thank you!
Change in configuration options
I want to apply 0% tax. I have updated in cart_manager.php at following lines
'tax_percentage' => 0,
but still it gives 6% tax
can you please tell how i can make tax 0% and shipping 0% and other configurations 0%
thanks
I'm looking for a way to merge the carts when a guest logs in to their existing account, with a guest cart active, and already some cart Items that are added when the user was previous logged in.
Is this something that is already considered?
The discount percentage is applied to the whole cart now. But it would be nice if we could apply discount per product. Is it possible?
Is your feature request related to a problem? Please describe.
I cannot upgrade my app to Laravel 8, please update your composer.json dependency file
Describe the solution you'd like
Add Laravel 8, to your composer.json dependency file
Describe alternatives you've considered
None
Additional context
None
Describe the bug
cart() helper hit database query every time.
example:
protected function getCartDetails() { return [ 'items' => cart()->items($displayCurrency = true), 'totals' => cart()->totals(), ]; }
This function will hit database multiple times.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No duplicate query during request
Additional context
Suguest fix: Change bind to singleton in CartManagerServiceProvider
i attempt to update and remove the cart items, but it's not working, the error message says "There is no item in the cart at the specified index" but i'm sure the index is exist in db.
the error message
"msg": "Cant remove at index 12",
"detail": "Freshbitsweb\\LaravelCartManager\\Exceptions\\ItemMissing: There is no item in the cart at the specified index....
my composer.json
"php": "^7.1.3",
"freshbitsweb/laravel-cart-manager": "^1.2",
"laravel/framework": "6.0.*",
"laravel/passport": "^8.0",
my cart config
return [
// The driver that should be used to manage the cart (database/session/custom)
'driver' => Freshbitsweb\LaravelCartManager\Drivers\DatabaseDriver::class,
// The authentication guard that should be used to identify the logged in customer
'auth_guard' => 'api',
// Shipping charges are applied on order amount (subtotal - discount)
'shipping_charges' => 0,
// Specify the minimum order amount to avoid shipping charges
'shipping_charges_threshold' => 0,
// Tax amount is applied on net total (subtotal - discount + shipping charges)
// subtotal, tax, net total and total are rounded to 2 decimals
'tax_percentage' => 0,
// Round off the total amount (net total + tax) to nearest (0 or 0.05 or 0.1 or 0.5 or 1)
// Total amount is rounded off accordingly to come up the payable amount by the customer
'round_off_to' => 0,
// Name of the cookie that is used to identify a user session
'cookie_name' => 'cart_identifier',
// Number of minutes for which the cart cookie should be valid in user's browser
'cookie_lifetime' => 10080, // one week
// We use php's NumberFormatter class to display numbers as a currency value
// Ref - https://www.php.net/manual/en/class.numberformatter.php
// Locales list - https://stackoverflow.com/a/3191729/3113599
'locale' => 'en_US',
// Currency to display numbers with symbols - The 3-letter ISO 4217 currency code
'currency' => 'IDR',
// For Database driver only: Number of hours for which the cart data is considered valid
// You can run/schedule the lcm_cart:clear command to remove old/invalid data
'cart_data_validity' => 24 * 7, // a week
];
this is my delete function in controller
public function delete(Request $request)
{
$validator = Validator::make($request->all(), [
'cartid' => 'required | exists:carts,auth_user',
'item_id' => 'required | integer | exists:cart_items,id',
]);
if ($validator->fails()) {
return response()->json(['message' => 'Gagal mendapatkan keranjang belanja!'], 442);exit;
}
// set user to cart
$cart = cart()->setUser($request->cartid);
try {
// trying to remove item
$cart = cart()->removeAt($request->item_id);
return response()->json(['cart' => $cart, 'cart_id' => $request->cartid], 200);
} catch (\Throwable $th) {
return response()->json(['msg' => 'Cant remove at index '.$request->item_id, 'detail' => ''.$th,'cart_id' => $request->cartid, 'cart_items' => cart()->toArray()], 200);
}
}
at last, this is my sample response (get all items from cart)
"cart_items": {
"subtotal": "2.00",
"discount": "0.00",
"discountPercentage": "0.00",
"couponId": null,
"shippingCharges": "0.00",
"netTotal": "2.00",
"tax": "0.00",
"total": "2.00",
"roundOff": "0.00",
"payable": "2.00",
"items": [
{
"modelType": "App\\Product",
"modelId": 7,
"name": "Autem aut voluptas e",
"price": "1.00",
"image": "/userfile/5/Selection_006.png",
"quantity": 1,
"id": 9
},
{
"modelType": "App\\Product",
"modelId": 8,
"name": "asdasdff",
"price": "1.00",
"image": "/userfile/5/Selection_006.png",
"quantity": 1,
"id": 12
}
]
}
in the response above, i have 1 item with id of 12, but still i have this error no item at specified index 12
Describe the bug
A clear and concise description of what the bug is.
I'm using your official repository demo project. I'm installing packages, setup .env config & startup local server using Laravel server php artisan serve
, but I get on root page next error from Laravel.
Call to undefined function Freshbitsweb\LaravelCartManager\Core\money_format()
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
cart is not showing items although the items exist in the cart_items table, it's returning an empty array
i couldn't figure it out
not installing this error is showing on composer require freshbitsweb/laravel-cart-manager.
In CartManagerServiceProvider.php line 49:
Trying to access array offset on value of type null ,
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
Hello, I have a question. I want to add a coupon id to the card but I can't. How do I add a coupon id and update my card?
Is your feature request related to a problem? Please describe.
If the user want to update the cartItems quantity at big number, it's good to have a method to update the quantity with input instead of one by one.
Describe the solution you'd like
/**
* Set the quantity of a cart item.
*
* @param int Index of the cart item
* @param int quantity to be increased
* @return array
*/
public function setQuantityAt($cartItemIndex, $quantity = 1)
{
$this->existenceCheckFor($cartItemIndex);
$this->items[$cartItemIndex]->quantity = $quantity;
$this->cartDriver->setCartItemQuantity(
$this->items[$cartItemIndex]->id,
$this->items[$cartItemIndex]->quantity
);
return $this->cartUpdates();
}
Describe alternatives you've considered
Add a new method in CartItemsManager to let user update the quantity
protected function existenceCheckFor($cartItemIndex)
{
if (! $this->items->has($cartItemIndex)) {
throw new ItemMissing('There is no item in the cart at the specified index.');
}
}
Why do I always get false? Where does has() function come from?
$this->items returns array of object, doesn't it?
And $cartItemIndex is id column of cart_items table, isn't it?
is possible (shipping charge & tax & custom field ) each item dynamically getting from the database?
cart_manager.php to database
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.