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

  • Catalog
  • CatalogAdmin
  • CatalogCMSActionDecorator
  • CatalogMemberDecorator
  • CatalogPrice
  • CMSSiteTreeFilter_Catalog
  • Monument
  • MonumentCatalog
  • MonumentForm
  • Orders1CExchange_SiteConfig
  • PaymentType
  • Product
  • ProductCatalogSiteConfig
  • ProductSearchPage
  • SimpleOrderButton
  • SimpleOrderData
  • SimpleOrderForm
  • SimpleOrderPage
  • StartCatalog
  • VirtualProduct

Interfaces

  • OrderButtonInterface
 1 <?php
 2 
 3 /**
 4  * Кнопка заказать, если не используется модуль cart
 5  *
 6  * @package Catalog
 7  * @author inxo, dvp
 8  */
 9 class SimpleOrderButton extends ViewableData implements OrderButtonInterface {
10     
11     private $product = 0;
12 
13     function __construct($product) {
14         parent::__construct();
15         $this->product = $product;
16     }
17     
18     /**
19      * Получение страницы заказа для показа нужной кнопки
20      *   
21      * 
22      * @return SiteTree
23      */
24     static function get_order_page() {
25         if ($page = DataObject::get_one('SimpleOrderForm')) {
26             return $page;
27         }
28         if ($page = DataObject::get_one('SimpleOrderPage')) {
29             return $page;
30         }
31         return false;
32     }
33 
34     /**
35      * Показывает кнопку для заказа товара
36      * 
37      * @param bool $withNum  - флаг показывать ли поле для ввода кол-ва товаров
38      * 
39      * @return Form
40      */
41     public function Show($withNum = false) {
42         $fields = new FieldSet();
43         $fields->push(new HiddenField('itemId', '', $this->product));
44         if ($withNum) {
45             $fields->push($f = new NumericField('Num', '', 1));
46             $f->addExtraClass('OrderNumField');
47             $f->addExtraClass('AddProductNum');
48             $f->addExtraAttribute('title', _t('SimpleOrderButton.OrderNum', 'Product count to add...'));
49         }
50         $actions = new FieldSet($a = new FormAction("checkout", _t('SimpleOrderButton.AddToCart', 'Checkout')));
51         $a->addExtraClass('AddProductAction');
52 
53         $orderPage = self::get_order_page();
54         if (!$orderPage) {
55             user_error(_t('SimpleOrderPage.OrderPageNeed', 'Need to create order page first'), E_USER_ERROR);
56             return false;
57         }
58         $controller = ModelAsController::controller_for($orderPage);
59         $form = new Form($controller, "checkout", $fields, $actions);
60 
61         $form->setTemplate('SimpleOrderButton');
62         $form->setHTMLID('AddProductForm_'. $this->product);
63         $form->addExtraClass('AddProductForm');
64         $form->getValidator()->setJavascriptValidationHandler('none');
65         $form->disableSecurityToken();
66         $form->setFormMethod('GET');
67         return $form;
68     }
69 
70     /**
71      * Показывает кнопку для заказа 1 товара
72      * 
73      * @return Form
74      */
75     public function One() {
76         return $this->Show();
77     }
78 
79     /**
80      * Показывает кнопку для заказа товара с полем кол-ва
81      * 
82      * @return Form
83      */
84     public function WithNum() {
85         return $this->Show(true);
86     }
87 
88     /**
89      * Отображение кнопки в шаблонах "по-умолчанию"
90      * 
91      * @return string
92      */
93     public function forTemplate() {
94         return $this->One()->forTemplate();
95     }
96 }
97 
[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