/** * Populate info. * * @param ShoppingCart shoppingCart The shopping cart. */ protected function populateInfo(ShoppingCart $shoppingCart) { // general stuff // TODO: where from/to?? $languageId = $this->container->get('settingsService')->get('storeDefaultLanguageId'); // TODO: move all cart/session values into ShoppingCart $currencyCode = $this->container->get('session')->get('currency'); $couponAmount = 0; $couponCode = null; if (null != ($couponCodeId = $this->container->get('session')->get('cc_id'))) { $coupon = $this->container->get('couponService')->getCouponForId($couponCodeId, $languageId); if (null != $coupon) { $couponCode = $coupon->getCode(); $couponAmount = $coupon->getAmount(); } } $shippingMethod = $shoppingCart->getSelectedShippingMethod(); $paymentType = $shoppingCart->getSelectedPaymentType(); $orderStatus = DEFAULT_ORDERS_STATUS_ID; if (null != $paymentType && null !== ($pos = $paymentType->getOrderStatus())) { $orderStatus = $pos; } $tax = 0; $taxGroups = array(); foreach ($shoppingCart->getItems() as $item) { $itemTotal = $item->getItemTotal(false) + $item->getOneTimeCharge(false); $itemTotalPlusTax = $item->getItemTotal(true) + $item->getOneTimeCharge(true); $itemTax = $itemTotalPlusTax - $itemTotal; $productTaxRate = $item->getTaxRate(); $description = $productTaxRate->getDescription(); if (!array_key_exists($description, $taxGroups)) { $taxGroups[$description] = 0; } $taxGroups[$description] += $itemTax; $tax += $itemTax; } $info = array('order_status' => $orderStatus, 'currency' => $currencyCode, 'currency_value' => $this->container->get('currencyService')->getCurrencyForCode($currencyCode)->getRate(), 'payment_method' => null != $paymentType ? $paymentType->getTitle() : '', 'payment_module_code' => null != $paymentType ? $paymentType->getId() : '', 'coupon_code' => $couponCode, 'shipping_method' => null != $shippingMethod ? $shippingMethod->getName() : '', 'shipping_module_code' => null != $shippingMethod ? $shippingMethod->getShippingId() : '', 'shipping_cost' => null != $shippingMethod ? $shippingMethod->getCost() : '', 'subtotal' => $shoppingCart->getSubTotal(), 'shipping_tax' => 0, 'tax' => $tax, 'total' => $shoppingCart->getTotal() + $couponAmount, 'tax_groups' => $taxGroups, 'comments' => $shoppingCart->getComments()); $this->info = array_merge($this->info, $info); if ($this->container->get('settingsService')->get('apps.store.assertZencart', false)) { $this->assertInfo(false); } }