philipbrown / basket Goto Github PK
View Code? Open in Web Editor NEWThe missing link between your product pages and your payment gateway
License: MIT License
The missing link between your product pages and your payment gateway
License: MIT License
Steps:
dd($product->quantity)
is still 1.I'm aware it can be done like so:
if ($this->productIsInBasket($sku)) {
$this->basket->update($sku, function(Product $product) {
$product->increment();
});
} else {
$this->basket->add($sku, $request->get('name'), $price);
}
But wouldn't it be easier of the add method can do this already.
It might be nice to have a $basket->itemCount
property on the basket class which would just contain the amount of products * their quantity.
At the moment we can only get $basket->products()->count()
. But if a product is multiple times in the basket that wouldn't reflect the item count on the global basket.
Obviously both counts are useful.
Edit: I just found the $basket->count()
method but which basically is a product count, not an item count.
It would be nice to have basket information about totals, subtotals, coupons etc. before beginning the reconciling process.
For instance for a current view of the basket, but before processing it to an order. Since there are already methods to get the taxrate and currency, more could be added ?
Hello,
Related to the following issue, would a Money presenter be a good idea ? Instead of returning Money\Money
instance, returning a presenter from this package, as this would make the formatting easier.
The presenter could basically just have a __toString
method
public function __toString()
{
$formatter = new \NumberFormatter($jurisdiction->locale(), \NumberFormatter::CURRENCY);
return $formatter->format($this->getAmount() / 100);
}
This would require the presence of a container though. Since we can't just instantiate UnitedKingdom
or Belgium
jurisdiction. But rather use the implementation bound to the Jurisdiction
interface.
Thanks,
Hello,
This package is looking to be very clean, I'm considering using this package for an e-commerce application. I'm reading your blog on 'Creating a PHP Shopping Basket' which is very nice.
I've got some questions though about the usage in general of the package.
Thank you,
What do you think of renaming Basket
to DefaultBasket
, adding a basket interface which is implemented by the DefaultBasket
. This would allow binding that in the laravel's IoC container.
Loved your accompanying articles to this project. Very helpful.
I had a question about how you're handling discounts (and coupons).
At the moment, they are part of the Product
object. How would you deal with a discount that should be applied to the basket and not directly related to a product. Something like "$10 off your entire order"?
I do not understand why not use only a simple Product object as parameter instead of $sku, $name, $price, $action...
I store my all products in a database table and my API got a product ID from the frontend, find the product by ID, so I have a product record, in my case a Product eloquent object. I thought, that I wrap this eloquent object and create from it a new PhilipBrown\Basket\Product and add it to the basket. But I can not do this now.
public function add(Product $product)
{
$this->products->add($product->sku, $product);
}
Have you any idea what is the best solution for my problem?
Thanks in advance!
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.