/** * executes the AddProductForm * @param Array $data * @param Form $form */ function addproductfromform(array $data, Form $form) { if (!$this->IsInCart()) { $quantity = round($data['Quantity'], $this->QuantityDecimals()); if (!$quantity) { $quantity = 1; } $product = Product::get()->byID($this->ID); if ($product) { ShoppingCart::singleton()->addBuyable($product, $quantity); } if ($this->IsInCart()) { $msg = _t("Order.SUCCESSFULLYADDED", "Added to cart."); $status = "good"; } else { $msg = _t("Order.NOTADDEDTOCART", "Not added to cart."); $status = "bad"; } if (Director::is_ajax()) { return ShoppingCart::singleton()->setMessageAndReturn($msg, $status); } else { $form->sessionMessage($msg, $status); $this->redirectBack(); } } else { return EcomQuantityField::create($this); } }
/** * * @return Field (EcomQuantityField) **/ function QuantityField() { return EcomQuantityField::create($this); }