singleton() public static method

Access for only allowing access to one (singleton) ShoppingCart.
public static singleton ( ) : ShoppingCart
return ShoppingCart
 /**
  * Adds a given product to the cart. If a hidden field is passed 
  * (ValidateVariant) then simply a validation of the user including that
  * product is done and the users cart isn't actually changed.
  *
  * @return mixed
  */
 public function addtocart($data, $form)
 {
     if ($variation = $this->getBuyable($data)) {
         $quantity = isset($data['Quantity']) && is_numeric($data['Quantity']) ? (int) $data['Quantity'] : 1;
         $cart = ShoppingCart::singleton();
         // if we are in just doing a validation step then check
         if ($this->request->requestVar('ValidateVariant')) {
             $message = '';
             $success = false;
             try {
                 $success = $variation->canPurchase(null, $data['Quantity']);
             } catch (ShopBuyableException $e) {
                 $message = get_class($e);
                 // added hook to update message
                 $this->extend('updateVariationAddToCartMessage', $e, $message, $variation);
             }
             $ret = array('Message' => $message, 'Success' => $success, 'Price' => $variation->dbObject('Price')->TrimCents());
             $this->extend('updateVariationAddToCartAjax', $ret, $variation, $form);
             return json_encode($ret);
         }
         if ($cart->add($variation, $quantity)) {
             $form->sessionMessage("Successfully added to cart.", "good");
         } else {
             $form->sessionMessage($cart->getMessage(), $cart->getMessageType());
         }
     } else {
         $variation = null;
         $form->sessionMessage("That variation is not available, sorry.", "bad");
         //validation fail
     }
     $this->extend('updateVariationAddToCart', $form, $variation);
     $request = $this->getRequest();
     $this->extend('updateVariationFormResponse', $request, $response, $variation, $quantity, $form);
     return $response ? $response : ShoppingCart_Controller::direct();
 }
 /**
  * Handles form submission
  * @param array $data
  * @return bool|\SS_HTTPResponse
  */
 public function addtocart(array $data)
 {
     $groupedProduct = $this->getController()->data();
     if (empty($data) || empty($data['Product']) || !is_array($data['Product'])) {
         $this->sessionMessage(_t('GroupedCartForm.EMPTY', 'Please select at least one product.'), 'bad');
         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
         return $response ? $response : $this->controller->redirectBack();
     }
     $cart = ShoppingCart::singleton();
     foreach ($data['Product'] as $id => $prodReq) {
         if (!empty($prodReq['Quantity']) && $prodReq['Quantity'] > 0) {
             $prod = Product::get()->byID($id);
             if ($prod && $prod->exists()) {
                 $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $prodReq;
                 $buyable = $prod;
                 if (isset($prodReq['Attributes'])) {
                     $buyable = $prod->getVariationByAttributes($prodReq['Attributes']);
                     if (!$buyable || !$buyable->exists()) {
                         $this->sessionMessage("{$prod->InternalItemID} is not available with the selected options.", "bad");
                         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                         return $response ? $response : $this->controller->redirectBack();
                     }
                 }
                 if (!$cart->add($buyable, (int) $prodReq['Quantity'], $saveabledata)) {
                     $this->sessionMessage($cart->getMessage(), $cart->getMessageType());
                     $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                     return $response ? $response : $this->controller->redirectBack();
                 }
             }
         }
     }
     $this->extend('updateGroupCartResponse', $this->request, $response, $groupedProduct, $data, $this);
     return $response ? $response : ShoppingCart_Controller::direct($cart->getMessageType());
 }
 function testCart()
 {
     $cart = $this->objFromFixture("Order", "cart");
     ShoppingCart::singleton()->setCurrent($cart);
     $page = new Page_Controller();
     $this->assertEquals("\$8.00", (string) $page->renderWith("CartTestTemplate"));
 }
 function dopayment($data, $form)
 {
     $SQLData = Convert::raw2sql($data);
     if (isset($SQLData['OrderID'])) {
         if ($orderID = intval($SQLData['OrderID'])) {
             $order = Order::get_by_id_if_can_view($orderID);
             if ($order && $order->canPay()) {
                 if (EcommercePayment::validate_payment($order, $form, $data)) {
                     $payment = EcommercePayment::process_payment_form_and_return_next_step($order, $form, $data);
                 }
                 if ($payment) {
                     ShoppingCart::singleton()->submit();
                     $order->tryToFinaliseOrder();
                     return $payment;
                 } else {
                     //error messages are set in validation
                     return $this->controller->redirectBack();
                 }
             } else {
                 $form->sessionMessage(_t('OrderForm.NO_PAYMENTS_CAN_BE_MADE_FOR_THIS_ORDER', 'No payments can be made for this order.'), 'bad');
                 return $this->controller->redirectBack();
             }
         }
     }
     $form->sessionMessage(_t('OrderForm.COULDNOTPROCESSPAYMENT', 'Sorry, we could not find the Order for payment.'), 'bad');
     $this->controller->redirectBack();
     return false;
 }
 /**
  * Clear the cart, and session variables on member logout
  */
 public function memberLoggedOut()
 {
     if (Member::config()->login_joins_cart) {
         ShoppingCart::singleton()->clear();
         OrderManipulation::clear_session_order_ids();
     }
 }
 public function testOffsitePaymentWithGatewayCallback()
 {
     //set up cart
     $cart = ShoppingCart::singleton()->setCurrent($this->objFromFixture("Order", "cart"))->current();
     //collect checkout details
     $cart->update(array('FirstName' => 'Foo', 'Surname' => 'Bar', 'Email' => '*****@*****.**'));
     $cart->write();
     //pay for order with external gateway
     $processor = OrderProcessor::create($cart);
     $this->setMockHttpResponse('PaymentExpress/Mock/PxPayPurchaseSuccess.txt');
     $response = $processor->makePayment("PaymentExpress_PxPay", array());
     //gateway responds (in a different session)
     $oldsession = $this->mainSession;
     $this->mainSession = new TestSession();
     ShoppingCart::singleton()->clear();
     $this->setMockHttpResponse('PaymentExpress/Mock/PxPayCompletePurchaseSuccess.txt');
     $this->getHttpRequest()->query->replace(array('result' => 'abc123'));
     $identifier = $response->getPayment()->Identifier;
     $response = $this->get("paymentendpoint/{$identifier}/complete");
     //reload cart as new order
     $order = Order::get()->byId($cart->ID);
     $this->assertFalse($order->isCart(), "order is no longer in cart");
     $this->assertTrue($order->isPaid(), "order is paid");
     //bring back client session
     $this->mainSession = $oldsession;
     $response = $this->get("paymentendpoint/{$identifier}/complete");
     $this->assertNull(Session::get("shoppingcartid"), "cart session id should be removed");
     $this->assertNotEquals(404, $response->getStatusCode(), "We shouldn't get page not found");
     $this->markTestIncomplete("Should assert other things");
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     //reset config
     $this->cart = ShoppingCart::singleton();
     $this->product = $this->objFromFixture('Product', 'mp3player');
     $this->product->publish('Stage', 'Live');
 }
 function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     $this->cartpage = $this->objFromFixture("CartPage", "cart");
     $this->cartpage->publish('Stage', 'Live');
     ShoppingCart::singleton()->setCurrent($this->objFromFixture("Order", "cart"));
     //set the current cart
 }
 function shippingmethod()
 {
     $form = $this->ShippingMethodForm();
     $cart = ShoppingCart::singleton()->current();
     if ($cart->ShippingMethodID) {
         $form->loadDataFrom($cart);
     }
     return array('OrderForm' => $form);
 }
 public function testLoginDoesntJoinCart()
 {
     Member::config()->login_joins_cart = false;
     $order = $this->objFromFixture("Order", "cart");
     ShoppingCart::singleton()->setCurrent($order);
     $member = $this->objFromFixture("Member", "jeremyperemy");
     $member->logIn();
     $this->assertEquals(0, $order->MemberID);
     $member->logOut();
     $this->assertTrue((bool) ShoppingCart::curr());
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     Order::config()->modifiers = array("FlatTaxModifier");
     FlatTaxModifier::config()->name = "GST";
     FlatTaxModifier::config()->rate = 0.15;
     $this->cart = ShoppingCart::singleton();
     $this->mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->mp3player->publish('Stage', 'Live');
 }
Esempio n. 12
0
 public function testItem()
 {
     $this->assertFalse($this->tshirt->IsInCart(), "tshirt is not in cart");
     $item = $this->tshirt->Item();
     $this->assertEquals(1, $item->Quantity);
     $this->assertEquals(0, $item->ID);
     $sc = ShoppingCart::singleton();
     $sc->add($this->tshirt, 15);
     $this->assertTrue($this->tshirt->IsInCart(), "tshirt is in cart");
     $item = $this->tshirt->Item();
     $this->assertEquals(15, $item->Quantity);
 }
Esempio n. 13
0
 public function addtocart($data, $form)
 {
     if ($buyable = $this->getBuyable($data)) {
         $cart = ShoppingCart::singleton();
         $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $data;
         $quantity = isset($data['Quantity']) ? (int) $data['Quantity'] : 1;
         $cart->add($buyable, $quantity, $saveabledata);
         if (!ShoppingCart_Controller::config()->direct_to_cart_page) {
             $form->SessionMessage($cart->getMessage(), $cart->getMessageType());
         }
         ShoppingCart_Controller::direct($cart->getMessageType());
     }
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     $this->mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->mp3player->publish('Stage', 'Live');
     $this->socks = $this->objFromFixture('Product', 'socks');
     $this->socks->publish('Stage', 'Live');
     $this->beachball = $this->objFromFixture('Product', 'beachball');
     $this->beachball->publish('Stage', 'Live');
     $this->checkoutcontroller = new CheckoutPage_Controller();
     ShoppingCart::singleton()->add($this->socks);
     //start cart
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     $this->mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->socks = $this->objFromFixture('Product', 'socks');
     $this->beachball = $this->objFromFixture('Product', 'beachball');
     $this->hdtv = $this->objFromFixture('Product', 'hdtv');
     $this->mp3player->publish('Stage', 'Live');
     $this->socks->publish('Stage', 'Live');
     $this->beachball->publish('Stage', 'Live');
     $this->hdtv->publish('Stage', 'Live');
     $this->shoppingcart = ShoppingCart::singleton();
 }
 function submit($data, $form)
 {
     if ($order = ShoppingCart::singleton()->current()) {
         $package = $order->createShippingPackage();
         $address = new Address();
         $form->saveInto($address);
         $estimator = new ShippingEstimator($package, $address);
         $estimates = $estimator->getEstimates();
         Session::set("ShippingEstimates", $estimates);
         if (Director::is_ajax()) {
             return json_encode($estimates->toArray());
             //TODO: replace with an AJAXResponse class that can output to different formats
         }
     }
     Director::redirectBack();
 }
 function submit($data, $form)
 {
     if ($order = ShoppingCart::singleton()->current()) {
         $estimator = new ShippingEstimator($order, new Address(Convert::raw2sql($data)));
         $estimates = $estimator->getEstimates();
         if (!$estimates->exists()) {
             $form->sessionMessage("No estimates could be found for that location.", "warning");
         }
         Session::set("ShippingEstimates", $estimates);
         if (Director::is_ajax()) {
             //TODO: replace with an AJAXResponse class that can output to different formats
             return json_encode($estimates->toArray());
         }
     }
     $this->controller->redirectBack();
 }
 public function setUp()
 {
     parent::setUp();
     $mockRequest2 = $this->getMockBuilder('Omnipay\\Braintree\\Message\\ClientTokenResponse')->disableOriginalConstructor()->getMock();
     $mockRequest2->expects($this->any())->method('getToken')->will($this->returnValue('abc123'));
     $mockRequest1 = $this->getMockBuilder('Omnipay\\Braintree\\Message\\ClientTokenRequest')->disableOriginalConstructor()->getMock();
     $mockRequest1->expects($this->any())->method('send')->will($this->returnValue($mockRequest2));
     $mockGateway = $this->getMock('Omnipay\\Braintree\\Gateway');
     $mockGateway->expects($this->any())->method('clientToken')->will($this->returnValue($mockRequest1));
     $this->cart = new Order();
     //$this->getFixtureFactory()->createObject('Order', 'o', ['Status' => 'Cart']);
     ShoppingCart::singleton()->setCurrent($this->cart);
     $this->sut = new BraintreePaymentCheckoutComponent();
     /** @var \Omnipay\Braintree\Gateway $mockGateway */
     $this->sut->setGateway($mockGateway);
 }
 public function testVariationOrderItem()
 {
     $cart = ShoppingCart::singleton();
     //config
     ProductVariation::config()->title_has_label = true;
     ProductVariation::config()->title_separator = ':';
     ProductVariation::config()->title_glue = ', ';
     $emptyitem = $this->redlarge->Item();
     $this->assertEquals(1, $emptyitem->Quantity, "Items always have a quantity of at least 1.");
     $cart->add($this->redlarge);
     $item = $cart->get($this->redlarge);
     $this->assertTrue((bool) $item, "item exists");
     $this->assertEquals(1, $item->Quantity);
     $this->assertEquals(22, $item->UnitPrice());
     $this->assertEquals("Size:Large, Color:Red", $item->SubTitle());
 }
Esempio n. 20
0
 public function testCustomProduct()
 {
     $thing = CustomProduct::create(array("Title" => "Thing", "Price" => 30));
     $thing->write();
     $cart = ShoppingCart::singleton();
     $options1 = array('Color' => 'Green', 'Size' => 5, 'Premium' => true);
     $this->assertTrue((bool) $cart->add($thing, 1, $options1), "add to customisation 1 to cart");
     $item = $cart->get($thing, $options1);
     $this->assertTrue((bool) $item, "item with customisation 1 exists");
     $this->assertEquals(1, $item->Quantity);
     $this->assertTrue((bool) $cart->add($thing, 2, $options1), "add another two customisation 1");
     $item = $cart->get($thing, $options1);
     $this->assertEquals(3, $item->Quantity, "quantity has updated correctly");
     $this->assertEquals("Green", $item->Color);
     $this->assertEquals(5, $item->Size);
     $this->assertEquals(1, $item->Premium);
     //should be true?
     $this->assertFalse($cart->get($thing), "try to get a non-customised product");
     $options2 = array('Color' => 'Blue', 'Size' => 6, 'Premium' => false);
     $this->assertTrue((bool) $cart->add($thing, 5, $options2), "add customisation 2 to cart");
     $item = $cart->get($thing, $options2);
     $this->assertTrue((bool) $item, "item with customisation 2 exists");
     $this->assertEquals(5, $item->Quantity);
     $options3 = array('Color' => 'Blue');
     $this->assertTrue((bool) $cart->add($thing, 1, $options3), "add a sub-variant of customisation 2");
     $item = $cart->get($thing, $options3);
     $this->assertTrue((bool) $cart->add($thing), "add product with no customisation");
     $item = $cart->get($thing);
     $order = $cart->current();
     $items = $order->Items();
     $this->assertEquals(4, $items->Count(), "4 items in cart");
     //remove
     $cart->remove($thing, 2, $options2);
     $item = $cart->get($thing, $options2);
     $this->assertNotNull($item, 'item exists in cart');
     $this->assertEquals(3, $item->Quantity);
     $cart->clear();
     //set quantity
     $options4 = array('Size' => 12, 'Color' => 'Blue');
     $resp = $cart->setQuantity($thing, 5, $options4);
     $item = $cart->get($thing, $options4);
     $this->assertTrue((bool) $item, 'item exists in cart');
     $this->assertEquals(5, $item->Quantity, "quantity is 5");
     $this->markTestIncomplete("what about default values that have been set");
     //test by using urls
     //add a partial match
 }
 /**
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function claim(SS_HTTPRequest $request)
 {
     /** @var Order $order */
     $order = Order::get()->byID($request->param('ID'));
     $hash = $request->param('OtherID');
     $realHash = FollowUpEmail::generate_hash($order);
     if (!$order || !$order->exists() || empty($hash) || $hash !== $realHash) {
         $this->httpError(404);
     }
     // Require a login if the order is attached to an account
     if ($order->MemberID && $order->MemberID != Member::currentUserID()) {
         return Security::permissionFailure($this->owner, _t('ShopEmail.NotYourOrder', 'You must log in to access this order.'));
     }
     // Otherwise if all is good, proceed to checkout
     ShoppingCart::singleton()->setCurrent($order);
     return $this->redirect(CheckoutPage::get()->first()->Link());
 }
 public function run($request)
 {
     $cart = ShoppingCart::singleton();
     $count = $request->getVar('count') ? $request->getVar('count') : 5;
     if ($products = Versioned::get_by_stage("Product", "Live", "", "RAND()", "", $count)) {
         foreach ($products as $product) {
             $variations = $product->Variations();
             if ($variations->exists()) {
                 $product = $variations->sort("RAND()")->first();
             }
             $quantity = (int) rand(1, 5);
             if ($product->canPurchase(Member::currentUser(), $quantity)) {
                 $cart->add($product, $quantity);
             }
         }
     }
     Controller::curr()->redirect(CheckoutPage::find_link());
 }
 /**
  *@param $object - the buyable / OrderItem
  **/
 function __construct($object, $parameters = null)
 {
     Requirements::javascript("ecommerce/javascript/EcomQuantityField.js");
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if ($object instanceof DataObject && $object instanceof BuyableModel) {
         $this->orderItem = ShoppingCart::singleton()->findOrMakeItem($object, $parameters);
         //provide a 0-quantity facade item if there is no such item in cart OR perhaps we should just store the product itself, and do away with the facade, as it might be unnecessary complication
         if (!$this->orderItem) {
             $className = $object->classNameForOrderItem();
             $this->orderItem = new $className($object->dataRecord, 0);
         }
     } elseif ($object instanceof OrderItem && $object->BuyableID) {
         $this->orderItem = $object;
     } else {
         user_error("EcomQuantityField: no/bad order item or buyable passed to constructor.", E_USER_WARNING);
     }
     $this->parameters = $parameters;
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     //reset config
     $this->mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->socks = $this->objFromFixture('Product', 'socks');
     //products that can't be purchased
     $this->noPurchaseProduct = $this->objFromFixture('Product', 'beachball');
     $this->draftProduct = $this->objFromFixture('Product', 'tshirt');
     $this->noPriceProduct = $this->objFromFixture('Product', 'hdtv');
     //publish some products
     $this->mp3player->publish('Stage', 'Live');
     $this->socks->publish('Stage', 'Live');
     $this->noPurchaseProduct->publish('Stage', 'Live');
     $this->noPriceProduct->publish('Stage', 'Live');
     //note that we don't publish 'tshirt'... we want it to remain in draft form.
     $this->cart = ShoppingCart::singleton();
 }
 public function addtocart($data, $form)
 {
     if ($buyable = $this->getBuyable($data)) {
         $cart = ShoppingCart::singleton();
         $request = $this->getRequest();
         $order = $cart->current();
         if ($request && $request->isAjax() && $order) {
             ShopTools::install_locale($order->Locale);
         }
         $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $data;
         $quantity = isset($data['Quantity']) ? (int) $data['Quantity'] : 1;
         $cart->add($buyable, $quantity, $saveabledata);
         if (!ShoppingCart_Controller::config()->direct_to_cart_page) {
             $form->SessionMessage($cart->getMessage(), $cart->getMessageType());
         }
         $this->extend('updateAddToCart', $form, $buyable);
         $this->extend('updateAddProductFormResponse', $request, $response, $buyable, $quantity, $form);
         return $response ? $response : ShoppingCart_Controller::direct($cart->getMessageType());
     }
 }
 public function testMembershipStep()
 {
     //this should still work if there is no cart
     ShoppingCart::singleton()->clear();
     $this->checkout->index();
     $this->checkout->membership();
     $this->post('/checkout/guestcontinue', array());
     //redirect to next step
     $this->checkout->createaccount(new SS_HTTPRequest('GET', "/checkout/createaccount"));
     $form = $this->checkout->MembershipForm();
     $data = array();
     $form->loadDataFrom($data);
     $data = array('FirstName' => 'Michael', 'Surname' => 'Black', 'Email' => '*****@*****.**', 'Password' => array('_Password' => 'pass1234', '_ConfirmPassword' => 'pass1234'), 'action_docreateaccount' => 'Create New Account');
     $response = $this->post('/checkout/CreateAccountForm', $data);
     //redirect to next step
     $member = ShopMember::get_by_identifier("*****@*****.**");
     $this->assertTrue((bool) $member, "Check new account was created");
     $this->assertEquals('Michael', $member->FirstName);
     $this->assertEquals('Black', $member->Surname);
 }
 function submit($data, $form)
 {
     if ($country = SiteConfig::current_site_config()->getSingleCountry()) {
         // Add Country if missing due to ReadonlyField in form
         $data['Country'] = $country;
     }
     if ($order = ShoppingCart::singleton()->current()) {
         $estimator = new ShippingEstimator($order, new Address(Convert::raw2sql($data)));
         $estimates = $estimator->getEstimates();
         if (!$estimates->exists()) {
             $form->sessionMessage(_t('ShippingEstimateForm.FormActionWarningMessage', 'No estimates could be found for that location.'), _t('ShippingEstimateForm.FormActionWarningCode', "warning"));
         }
         Session::set("ShippingEstimates", $estimates);
         if (Director::is_ajax()) {
             //TODO: replace with an AJAXResponse class that can output to different formats
             return json_encode($estimates->toNestedArray());
         }
     }
     $this->controller->redirectBack();
 }
 public function __construct($object, $parameters = null)
 {
     if ($object instanceof Buyable) {
         $this->item = ShoppingCart::singleton()->get($object, $parameters);
         //provide a 0-quantity facade item if there is no such item in cart
         if (!$this->item) {
             $this->item = $object->createItem();
         }
         $this->buyable = $object;
         //TODO: perhaps we should just store the product itself,
         //and do away with the facade, as it might be unnecessary complication
     } elseif ($object instanceof OrderItem) {
         $this->item = $object;
         $this->buyable = $object->Buyable();
     }
     if (!$this->item) {
         user_error("ShopQuantityField: no item or product passed to constructor.");
     }
     $this->parameters = $parameters;
     //TODO: include javascript for easy update
 }
 /**
  * checks for Combination Products and makes sure that enough of the component products are added.
  *
  */
 protected function addProductsPerCombo()
 {
     $reload = false;
     $shoppingCart = ShoppingCart::singleton();
     $combinationProductOrderItems = $this->loadCombinationProducts();
     if ($combinationProductOrderItems->count()) {
         foreach ($combinationProductOrderItems as $combinationProductOrderItem) {
             $combinationProduct = $combinationProductOrderItem->Buyable();
             $comboProductQTY = $combinationProductOrderItem->Quantity;
             $includedProducts = $combinationProduct->IncludedProducts();
             if ($includedProducts) {
                 foreach ($includedProducts as $includedProduct) {
                     $includedProductQTY = $this->countOfProductInOrder($includedProduct);
                     $difference = $comboProductQTY - $includedProductQTY;
                     if ($difference) {
                         $reload = true;
                         if ($comboProductQTY) {
                             //in case it has not been added
                             if (!$includedProduct->IsInCart()) {
                                 $includedProduct->setAlternativeClassNameForOrderItem("IncludedProduct_OrderItem");
                                 $item = $shoppingCart->addBuyable($includedProduct);
                                 if ($item) {
                                     $item->ParentOrderItemID = $combinationProductOrderItem->ID;
                                     $item->write();
                                 }
                             }
                             $shoppingCart->setQuantity($includedProduct, $comboProductQTY);
                         } else {
                             $shoppingCart->deleteBuyable($includedProduct);
                         }
                     }
                 }
             }
         }
     }
     if ($reload) {
         CartResponse::set_force_reload();
     }
 }
 public function submit(array $data, Form $form, $message = "order updated", $status = "good")
 {
     $order = ShoppingCart::current_order();
     if ($order) {
         $modifier = $order->Modifiers('DonationModifier');
         if ($modifier) {
             $modifier = $modifier->First();
             $modifier->updateAddDonation($data['DonationID']);
             $msg = $data['DonationID'] ? _t("AnyPriceRoundUpDonationModifier.UPDATED", "Round up donation added - THANK YOU.") : _t("AnyPriceRoundUpDonationModifier.UPDATED", "Round up donation removed.");
             if (isset($data['OtherValue'])) {
                 $modifier->updateOtherValue(floatval($data['OtherValue']));
                 if (floatval($data['OtherValue']) > 0) {
                     $msg .= _t("AnyPriceRoundUpDonationModifier.UPDATED", "Added donation - THANK YOU.");
                 }
             } else {
                 $modifier->updateOtherValue(0);
             }
             $modifier->write();
             return ShoppingCart::singleton()->setMessageAndReturn($msg, "good");
         }
     }
     return ShoppingCart::singleton()->setMessageAndReturn(_t("AnyPriceRoundUpDonationModifier.NOTUPDATED", "Could not update the round up donation status.", "bad"));
 }