* @author Matthew Turnbull */ /** * Required classes */ GalleryCoreApi::requireOnce('modules/checkout/classes/CheckoutHelper.class'); GalleryCoreApi::requireOnce('modules/checkout/classes/GeneralHelper.class'); /** * This view is for letting the user confirm their order * * @package Checkout * @subpackage UserInterface */ class ConfirmPhotosView extends GalleryView { /** * @see GalleryView::loadTemplate */ function loadTemplate(&$template, &$form) { global $gallery; $session =& $gallery->getSession(); $total = unserialize($session->get('checkout.total')); /* Get the items from the cart */ list ($ret, $items) = CheckoutHelper::fetchCheckoutItems(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $itemList) = CheckoutHelper::loadCheckoutItems(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Get the product and pricing details */ list ($ret, $product, $price) = CheckoutHelper::fetchProducts(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Remove items with zero quantity selected */ if (!empty($items) && is_array($items)) { foreach ($itemList as $item) { $itemNotZero=false; for($x=0;$xgetId()]['quant'][$x]) ) { if ((int) $items[$item->getId()]['quant'][$x] > 0 ) { $itemNotZero=true; } } } if ( !$itemNotZero ) { unset($items[$item->getId()]); } } } /* Get the paper options */ list ($ret, $paper) = CheckoutHelper::fetchPapers(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Get the thumbnails */ list ($ret, $thumbnailList) = GalleryCoreApi::fetchThumbnailsByItemIds(array_keys($items)); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } foreach ($thumbnailList as $thumbnail) { $thumbnails[$thumbnail->getParentId()] = (array)$thumbnail; } /* Find all our payment plugins */ GalleryCoreApi::requireOnce('modules/checkout/classes/CheckoutPluginInterface_1_0.class'); list ($ret, $ids) = GalleryCoreApi::getAllFactoryImplementationIds('CheckoutPluginInterface_1_0'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $plugins = array(); foreach ($ids as $id => $className) { list ($ret, $instances[$id]) = GalleryCoreApi::newFactoryInstance('CheckoutPluginInterface_1_0', $className); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* * Get the plugin parameters */ list ($ret, $plugins[$id]['paymentText']) = $instances[$id]->getPaymentText(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $plugins[$id]['paymentTemplate']) = $instances[$id]->getPaymentTemplate(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } list ($ret, $plugins[$id]['paymentVariables']) = $instances[$id]->getPaymentVariables(); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } } list($ret, $tpl) = GeneralHelper::getModuleParameters('checkout', array('csymbol', 'postage', 'busname')); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $tpl['items'] = $items; $tpl['thumbnails'] = $thumbnails; $tpl['price'] = $price; $tpl['product'] = $product; $tpl['paper'] = $paper; $tpl['total'] = $total; $tpl['controller'] = 'checkout.Confirm'; $tpl['payments'] = $plugins; list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'checkout'); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $template->title($tpl['busname'] . '::' . $gallery->i18n('Checkout')); $template->setVariable('tpl', $tpl); return array(null, array('body' => 'modules/checkout/templates/ConfirmPhotos.tpl')); } } ?>