/** * Generates an overview of the Order for the Customer to confirm * * Forward her to the processing of the Order after the button has been * clicked. * @return boolean True on success, false otherwise */ static function confirm() { global $_ARRAYLANG; // If the cart or address is missing, return to the shop if (!self::verifySessionAddress()) { \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } self::$show_currency_navbar = false; // The Customer clicked the confirm button; this must not be the case // the first time this method is called. if (isset($_POST['process'])) { return self::process(); } // Show confirmation page. self::$objTemplate->hideBlock('shopProcess'); self::$objTemplate->setGlobalVariable($_ARRAYLANG); // It may be necessary to refresh the cart here, as the customer // may return to the cart, then press "Back". self::_initPaymentDetails(); foreach (Cart::get_products_array() as $arrProduct) { $objProduct = Product::getById($arrProduct['id']); if (!$objProduct) { // TODO: Implement a proper method // unset(Cart::get_product_id($cart_id]); continue; } $price_options = 0; $attributes = Attributes::getAsStrings($arrProduct['options'], $price_options); $attributes = $attributes[0]; // Note: The Attribute options' price is added // to the price here! $price = $objProduct->get_custom_price(self::$objCustomer, $price_options, $arrProduct['quantity']); // Test the distribution method for delivery $productDistribution = $objProduct->distribution(); $weight = $productDistribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '-'; $vatId = $objProduct->vat_id(); $vatRate = Vat::getRate($vatId); $vatPercent = Vat::getShort($vatId); $vatAmount = Vat::amount($vatRate, $price * $arrProduct['quantity']); self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CUSTOM_ID' => $objProduct->code(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price * $arrProduct['quantity']), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => Currency::formatPrice($price), 'SHOP_UNIT' => Currency::getActiveCurrencySymbol())); if ($attributes && self::$objTemplate->blockExists('attributes')) { self::$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $attributes); } if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => $weight, 'TXT_WEIGHT' => $_ARRAYLANG['TXT_WEIGHT'])); } if (Vat::isEnabled()) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $vatPercent, 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($vatAmount) . ' ' . Currency::getActiveCurrencySymbol())); } self::$objTemplate->parse("shopCartRow"); } $total_discount_amount = 0; if (Cart::get_discount_amount()) { $total_discount_amount = Cart::get_discount_amount(); self::$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount))); } self::$objTemplate->setVariable(array('SHOP_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTALITEM' => Cart::get_item_count(), 'SHOP_PAYMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['payment_price']), 'SHOP_TOTALPRICE' => Currency::formatPrice(Cart::get_price()), 'SHOP_PAYMENT' => Payment::getProperty($_SESSION['shop']['paymentId'], 'name'), 'SHOP_GRAND_TOTAL' => Currency::formatPrice($_SESSION['shop']['grand_total_price']), 'SHOP_COMPANY' => stripslashes($_SESSION['shop']['company']), 'SHOP_TITLE' => stripslashes($_SESSION['shop']['gender']), 'SHOP_GENDER' => stripslashes($_SESSION['shop']['gender']), 'SHOP_LASTNAME' => stripslashes($_SESSION['shop']['lastname']), 'SHOP_FIRSTNAME' => stripslashes($_SESSION['shop']['firstname']), 'SHOP_ADDRESS' => stripslashes($_SESSION['shop']['address']), 'SHOP_ZIP' => stripslashes($_SESSION['shop']['zip']), 'SHOP_CITY' => stripslashes($_SESSION['shop']['city']), 'SHOP_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId']), 'SHOP_EMAIL' => stripslashes($_SESSION['shop']['email']), 'SHOP_PHONE' => stripslashes($_SESSION['shop']['phone']), 'SHOP_FAX' => stripslashes($_SESSION['shop']['fax']))); if (!empty($_SESSION['shop']['lastname2'])) { self::$objTemplate->setVariable(array('SHOP_COMPANY2' => stripslashes($_SESSION['shop']['company2']), 'SHOP_TITLE2' => stripslashes($_SESSION['shop']['gender2']), 'SHOP_LASTNAME2' => stripslashes($_SESSION['shop']['lastname2']), 'SHOP_FIRSTNAME2' => stripslashes($_SESSION['shop']['firstname2']), 'SHOP_ADDRESS2' => stripslashes($_SESSION['shop']['address2']), 'SHOP_ZIP2' => stripslashes($_SESSION['shop']['zip2']), 'SHOP_CITY2' => stripslashes($_SESSION['shop']['city2']), 'SHOP_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_PHONE2' => stripslashes($_SESSION['shop']['phone2']))); } if (!empty($_SESSION['shop']['note'])) { self::$objTemplate->setVariable(array('SHOP_CUSTOMERNOTE' => $_SESSION['shop']['note'])); } if (Vat::isEnabled()) { self::$objTemplate->setVariable(array('TXT_TAX_RATE' => $_ARRAYLANG['TXT_SHOP_VAT_RATE'], 'SHOP_TAX_PRICE' => Currency::formatPrice($_SESSION['shop']['vat_price']), 'SHOP_TAX_PRODUCTS_TXT' => $_SESSION['shop']['vat_products_txt'], 'SHOP_TAX_GRAND_TXT' => $_SESSION['shop']['vat_grand_txt'], 'TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'])); if (Vat::isIncluded()) { self::$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice($_SESSION['shop']['grand_total_price'] - $_SESSION['shop']['vat_price']))); } } // TODO: Make sure in payment() that those two are either both empty or // both non-empty! if (!Cart::needs_shipment() && empty($_SESSION['shop']['shipperId'])) { if (self::$objTemplate->blockExists('shipping_address')) { self::$objTemplate->hideBlock('shipping_address'); } } else { // Shipment is required, so if (empty($_SESSION['shop']['shipperId'])) { \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } self::$objTemplate->setVariable(array('SHOP_SHIPMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['shipment_price']), 'SHOP_SHIPMENT' => Shipment::getShipperName($_SESSION['shop']['shipperId']))); } // Custom. // Enable if Discount class is customized and in use. //self::showCustomerDiscount(Cart::get_price()); return true; }