Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • Cart
  • CartOrderButton
  • CartPage
  • CartSiteConfig
  • CartTableListField
  • CheckoutPage
  • ExtendGroupDiscount
  • ExtendMemberCart
  • ExtendPageCart
  • ExtendPageSpecialCatalog
  • ExtendProductSpecialCatalog
  • ExtendProfilePageOrder
  • Order
  • OrderAdmin
  • OrderExporter
  • OrderItem
  • OrderItemField
  • SpecialCatalog
  • TextLiteralField
 1 <?php
 2 
 3 /**
 4  * Расширения профиля пользователя для сбора информации для доставки
 5  *
 6  * @package cart
 7  * @author inxo
 8  */
 9 class ExtendMemberCart extends DataObjectDecorator {
10 
11     function extraStatics() {
12         return array(
13             'db' => array(
14                 'Phone' => 'Varchar(255)', // Телефон
15                 'Discount' => 'Int', // Скидка
16                 'CartData' => 'Text', // сериализованная текущая корзина пользователя
17             ),
18             'has_many' => array(
19                 'Orders' => 'Order',
20             )
21         );
22     }
23 
24     function updateCMSFields(&$fields) {
25         if ($orders = $fields->dataFieldByName('Orders'))
26             $orders->setPermissions(array());
27         
28         $fields->removeByName('CartData');
29     }
30 
31     function updateMemberFormFields(&$fields) {
32         $fields->removeByName('Discount');
33         $fields->removeByName('CartData');
34         $fields->insertBefore($fields->datafieldByName('Phone'), 'Password');
35     }
36     
37     function memberLoggedIn() {
38         if (method_exists('Cart', 'update_cart_from_cache')) {
39             Cart::update_cart_from_cache();
40         }
41     }
42     
43     function updateValidator(&$obj) {
44         $obj->addRequiredField('Phone');
45     }
46     
47     function getClientName() {
48         $title = $this->owner->getTitle();
49         return ($title) ? $title : $this->owner->Email;
50     }
51 
52     function getPersonalDiscount() {
53         $discount = $this->owner->Discount;
54         if ($groups = $this->owner->Groups()) {
55             foreach ($groups as $g) {
56                 if ($g->hasMethod('Discount') && $discount < $g->Discount()) {
57                     $discount = $g->Discount();
58                 }
59             }
60         }
61         if ($discount > 0) {
62             return $discount;
63         }
64         return false;
65     }
66 }
67 
[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. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0