File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040 'expiration ' => 4320 ,
4141 ],
4242 'session ' => [],
43+ 'null ' => [],
4344 ],
4445 ],
4546
Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ public function getModel(): Cart
8585 $ cart ->syncItems ();
8686 $ cart ->shipping ->calculateFee ();
8787 $ cart ->shipping ->calculateTaxes ();
88- $ cart ->getModel ()->calculateDiscount ();
88+ $ cart ->calculateTax ();
89+ $ cart ->calculateDiscount ();
8990 }
9091 });
9192 }
@@ -248,12 +249,22 @@ public function empty(): void
248249 $ this ->getModel ()->setRelation ('items ' , $ this ->getModel ()->items ()->getRelated ()->newCollection ());
249250
250251 $ this ->getShipping ()->update (['fee ' => 0 ]);
251- $ this ->getShipping ()->taxes ()->delete ();
252+ $ this ->getShipping ()->taxes ()->detach ();
252253 $ this ->getShipping ()->discounts ()->detach ();
253254
254255 $ this ->getModel ()->calculateDiscount ();
255256 }
256257
258+ /**
259+ * Delete the cart.
260+ */
261+ public function destroy (): void
262+ {
263+ $ this ->getModel ()->items ->each ->delete ();
264+ $ this ->getShipping ()->delete ();
265+ $ this ->getModel ()->delete ();
266+ }
267+
257268 /**
258269 * Get the number of the cart items.
259270 */
Original file line number Diff line number Diff line change @@ -36,4 +36,14 @@ public function createSessionDriver(): SessionDriver
3636 $ this ->config ->get ('bazar.cart.drivers.session ' , [])
3737 );
3838 }
39+
40+ /**
41+ * Create the null driver.
42+ */
43+ public function createNullDriver (): NullDriver
44+ {
45+ return new NullDriver (
46+ $ this ->config ->get ('bazar.cart.drivers.null ' , [])
47+ );
48+ }
3949}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Cone \Bazar \Cart ;
6+
7+ use Cone \Bazar \Models \Cart ;
8+ use Illuminate \Http \Request ;
9+
10+ class NullDriver extends Driver
11+ {
12+ /**
13+ * Resolve the cart for the current request.
14+ */
15+ public function resolve (Request $ request ): Cart
16+ {
17+ return Cart::proxy ()->newInstance ();
18+ }
19+ }
Original file line number Diff line number Diff line change 2929 * @method static bool applyCoupon(string|\Cone\Bazar\Models\Coupon $coupon)
3030 * @method static void removeCoupon(string|\Cone\Bazar\Models\Coupon $coupon)
3131 * @method static \Cone\Bazar\Gateway\Response checkout(string $driver)
32+ * @method static \Cone\Bazar\Cart\Driver driver(?string $driver = null)
3233 *
3334 * @see \Cone\Bazar\Cart\Driver
3435 */
You can’t perform that action at this time.
0 commit comments