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

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • 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  * Расширения товара для включения его в SpecialCatalog
 5  *
 6  * @package cart
 7  * @author inxo
 8  */
 9 class ExtendProductSpecialCatalog extends DataObjectDecorator {
10 
11     function extraStatics() {
12         return array(
13             'belongs_many_many' => array(
14                 'SpecialCatalogs' => 'SpecialCatalog',
15             ),
16 
17         );
18     }
19 
20     function updateCMSFields(&$fields) {
21         /* Специальные списки */
22         if ($specials = DataObject::get('SpecialCatalog')) {
23             $fields->addFieldToTab('Root.Content', new Tab("Catalogs", _t('Product.tab_Catalogs', 'Other catalogs')), 'Metadata');
24             $fields->addFieldToTab("Root.Content.Catalogs", new CheckboxSetField('SpecialCatalogs', _t('Product.many_many_SpecialCatalogs', 'Special Catalogs'), $specials));
25         }
26     }
27 
28     function updateDiscount(&$percent) {
29         if ($this->owner->SpecialCatalogs()) {
30             foreach ($this->owner->SpecialCatalogs() as $spec) {
31                 if ($spec->Discount > 0 && $percent < $spec->Discount) {
32                     $percent = $spec->Discount;
33                 }
34             }
35         }
36     }
37     
38     /**
39      * Определяет, находится ли товар в корзине
40      *      
41      * 
42      * @return bool
43      */ 
44     function InCart() {
45         return Cart::in_cart($this->owner->ID);
46     }
47     
48     /**
49      * Определяет, находится ли товар в заданном спецкаталоге
50      * 
51      * @param int $specialCatalogID 
52      * 
53      * @return bool
54      */ 
55     function InSpecialCatalog($specialCatalogID) {
56         if (($catalogs = $this->owner->SpecialCatalogs()) && $catalogs->Count()) {
57             if ($catalogs->find('ID', $specialCatalogID)) {
58                 return true;
59             }
60         }
61         return false;
62     }
63 }
64 
[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.2 API Docs API documentation generated by ApiGen 2.8.0