overtrue / laravel-shopping-cart Goto Github PK
View Code? Open in Web Editor NEW:shopping_cart: Shopping cart for Laravel Application.
License: MIT License
:shopping_cart: Shopping cart for Laravel Application.
License: MIT License
在composer.json里面并没有看到你 require laravel 框架,但为何在代码里面却用到了laravel的组件。
另外,composer开发有相关的资料么,求推荐。我是雷俊,上回的线下聚会我也在。
In my CartController.php I am pasting "use Overtrue\LaravelShoppingCart\ShoppingCart;" and
public function index()
{
return ShoppingCart::content();
}
But the error I am getting: "Undefined type 'Overtrue\LaravelShoppingCart\ShoppingCart'.intelephense(1009)"
When I tried to click the add to cart button pointing to the CartContoller I have made then redirect back to the previous page the cart items becomes duplicate. Please help
我$row = ShoppingCart::add();後 查看$row資訊 成功儲存
但我到別的controller ShoppingCart::all() 卻回傳空的
我根據$row的id下去 ShoppingCart::get('id'); 也是空的
安神,你文档中写的使用静态方式调用是错误的吧,要先new一个对象,方法中没有加静态
我 dd ShoppingCart::associate('App\Models\Product') 的訊息
得到 #model: "App\Models\Product"
但我ShoppingCart::get('xxxxxxxx')取出購物車裡的商品時 裡面的 #mode: null
請問這個功能確實有作用嗎?
I want to set different carts for different vendors. How can I set a different cart name dynamically? Will have to call setName on each call? Please help.
Illuminate/Events/Dispatcher 类中的fire 方法 (在Larevel 5.4中不赞成使用,Larevel 5.8 已经被移除了)
应当使用它的替代方法 dispatch ,否则会报如下错误:
Oops! An unexpected error occurred: Call to undefined method Illuminate\Events\Dispatcher::fire()
public function add($id, $name = null, $qty = null, $price = null, array $attributes = [])
{
$cart = $this->getCart();
$this->event->dispatch('shopping_cart.adding', [$attributes, $cart]);
$row = $this->addRow($id, $name, $qty, $price, $attributes);
$this->event->dispatch('shopping_cart.added', [$attributes, $cart]);
return $row;
}
support 5.7?
先看代码:
public function add($id, $name = null, $qty = null, $price = null, array $attributes = [])
{
$cart = $this->getCart();
$this->event->fire('shopping_cart.adding', [$attributes, $cart]);
$row = $this->addRow($id, $name, $qty, $price, $attributes);
$this->event->fire('shopping_cart.added', [$attributes, $cart]);
return $row;
}
这一段是添加到购物车里面的代码,可以看到是先获取购物车,然后再添加到购物车,这时候触发added事件,传入的参数是$cart,可是这个是未添加入购物车之的,这样就导致传入的购物车实际上还是未添加状态的。应该要这样改:
$this->event->fire('shopping_cart.added', [$attributes, $this->getCart()]);
不知道这算是bug还有有意为之的feature?所有涉及到ed事件的应该都是存在这个问题的。
How i can Eager loading associate model for reduce query ?
I can get all the items and serialize that to store along with other order information.
I may need to edit the order to change the items or update the quantity or price. do you have any example of that? or is this package allow store and restore from database?
Update does not work properly during adding of the same item if quantity is different
Cart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
Cart::add(37, 'Item name', 1, 100.00, ['color' => 'red', 'size' => 'M']);
Cart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
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.