1 <?php
2
3 4 5 6 7 8
9 class ExtendPageCart extends Extension {
10
11 12 13
14 function CartInfo() {
15 $cart = Cart::current_order();
16
17 if ($cart->getTotalQuantity() > 0) {
18 $result = new ArrayData(array(
19 'ItemName' => $cart->ItemName(),
20 'CountItems' => DBField::create('Int', $cart->getTotalQuantity()),
21 'CountLines' => DBField::create('Int', $cart->Items()->Count()),
22 'TotalPrice' => DBField::create('CatalogPrice', $cart->getTotalPrice()),
23 'CheckoutLink' => CheckoutPage::find_link(),
24 'CartLink' => CartPage::find_link(),
25 'Currency' => SiteConfig::current_site_config()->CatalogCurrency,
26 ));
27
28 return $result;
29 }
30 return null;
31 }
32
33 34 35 36 37 38
39 function CartBlock() {
40 return $this->owner->renderWith('CartBlock', array('CartInfo' => $this->CartInfo()));
41 }
42
43 44 45 46 47
48 function CartLink() {
49 return CartPage::find_link();
50 }
51
52 53 54 55 56
57 function CheckoutLink() {
58 return CheckoutPage::find_link();
59 }
60 }
61
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-