Inheritance: extends Form
Esempio n. 1
0
 /**
  * A form for updating cart items
  */
 public function CartForm()
 {
     $cart = $this->Cart();
     if (!$cart) {
         return false;
     }
     $form = CartForm::create($this, "CartForm", $cart);
     $this->extend('updateCartForm', $form);
     return $form;
 }
 /**
  * A form for updating cart items
  */
 public function CartForm()
 {
     $cart = $this->Cart();
     if (!$cart) {
         return false;
     }
     $form = CartForm::create($this, "CartForm", $cart);
     $this->extend('updateCartForm', $form);
     // if accessing through the model, warn that the hook is going to go away
     $this->dataRecord->extend('updateCartForm', $form, $cart);
     if ($this->dataRecord->hasMethod('updateCartForm')) {
         Deprecation::notice('2.0', 'Please access updateCartForm through CartPage_Controller instead of CartPage (this extension point is due to be removed)');
     }
     return $form;
 }
Esempio n. 3
0
 /**
  * Form including quantities for items for displaying on the cart page.
  * 
  * @return CartForm A new cart form
  */
 function CartForm()
 {
     return CartForm::create($this, 'CartForm')->disableSecurityToken();
 }
 /**
  * Form including quantities for items for displaying on the cart page.
  * 
  * @return CartForm A new cart form
  */
 function CartForm()
 {
     $fields = new FieldSet();
     $validator = new CartFormValidator();
     $currentOrder = $this->Cart();
     $items = $currentOrder->Items();
     if ($items) {
         foreach ($items as $item) {
             $quantityField = new CartQuantityField('Quantity[' . $item->ID . ']', '', $item->Quantity, null, null, $item);
             $fields->push($quantityField);
             $itemOptions = $item->ItemOptions();
             if ($itemOptions && $itemOptions->exists()) {
                 foreach ($itemOptions as $itemOption) {
                     //TODO if item option is not a Variation then add it as another row to the checkout
                     //Like gift wrapping as an option perhaps
                 }
             }
             $validator->addRequiredField('Quantity[' . $item->ID . ']');
         }
     }
     $actions = new FieldSet(new FormAction('updateCart', _t('CartPage.UPDATE_CART', "Update Cart")), new FormAction('goToCheckout', _t('CartPage.GO_TO_CHECKOUT', "Go To Checkout")));
     $cartForm = new CartForm($this, 'CartForm', $fields, $actions, $validator, $currentOrder);
     $cartForm->disableSecurityToken();
     return $cartForm;
 }