Example #1
0
 private function buildValidator()
 {
     // validate contact info
     $validator = $this->getValidator("registrationValidator", $this->request);
     $this->validateAddress($validator, 'billing_');
     $this->validateEmail($validator);
     if ($this->config->get('PASSWORD_GENERATION') == 'PASSWORD_REQUIRE' || $this->request->get('password')) {
         $this->validatePassword($validator);
     }
     if (!$this->config->get('REQUIRE_SAME_ADDRESS') && $this->order->isShippingRequired()) {
         $this->validateAddress($validator, 'shipping_', true);
     }
     SessionUser::getAnonymousUser()->getSpecification()->setValidation($validator);
     return $validator;
 }
Example #2
0
 public function testOrderTotalsWithRoundedPrices()
 {
     $currency = Currency::getNewInstance('RON');
     $currency->setRoundingRule(0, Currency::TRIM, 0.09);
     $currency->save();
     $product = Product::getNewInstance(Category::getRootNode());
     $product->isEnabled->set(true);
     $product->setPrice($currency, 1.26);
     $product->save();
     $order = CustomerOrder::getNewInstance(SessionUser::getAnonymousUser());
     $order->addProduct($product);
     $order->save(true);
     $item = array_shift($order->getItemsByProduct($product));
     $this->assertEquals($product->getPrice($currency), 1.29);
     $this->assertEquals($item->getSubTotal(), 1.29);
     $item->count->set(2);
     $this->assertEquals($item->getSubTotal(), 2.58);
     $this->assertEquals($order->getTotal(true), 2.58);
     // add another currency to mix - no rounding rules
     $bgn = Currency::getNewInstance('BGN');
     $bgn->rate->set(2);
     $bgn->save();
     $item->count->set(2);
     $order->changeCurrency($bgn);
     $this->assertEquals($product->getPrice($bgn), 0.63);
     $this->assertEquals($item->getPrice(), 0.63);
     $this->assertSame($item->getCurrency(), $bgn);
     $this->assertEquals($item->getSubTotal(), 1.26);
     $this->assertEquals($order->getTotal(true), 1.26);
     // add rounding rules
     $bgn->clearRoundingRules();
     $bgn->setRoundingRule(0, Currency::TRIM, 0.07000000000000001);
     $order->changeCurrency($bgn);
     $this->assertEquals($product->getPrice($bgn), 0.67);
     $this->assertEquals($item->getSubTotal(), 1.34);
     $this->assertEquals($order->getTotal(true), 1.34);
 }