<?php
if (!\Components\Website\Pages::currentPageQuery())
{
\Framework\HTTP\Redirection::redirect('/products/categories/', true);
}
if (!\Components\Settings\Components::isInstalled('\Components\Commerce\Products'))
{
exit();
}
// Redirect access through numerical ids to textual version
$strQuery = \Components\Website\Pages::currentPageQuery();
if($strQuery && is_numeric($strQuery))
{
$arrProduct = \Components\Commerce\Products::get($strQuery);
if($arrProduct && $arrProduct['product_uri'] && \Framework\HTTP\Request::getCurrentURIPath() != $arrProduct['product_uri'])
{
\Framework\HTTP\Redirection::redirect($arrProduct['product_uri']);
}
}
// AF - This is to allow a redirection to the course selector for courses without overriding /products/
if(\Components\Website\Pages::currentPageQuery())
{
$arrEventParams = array();
$arrEventParams[] = \Components\Website\Pages::currentPageQuery();
\Components\Commerce\Products::eventTrigger('viewProduct', $arrEventParams);
}
function orderProduct($iProductId, $iQty = null, $arrValues = null)
{
$arrProduct = \Components\Commerce\Products::get($iProductId);
if(!$arrProduct)
{
\Framework\HTTP\Redirection::redirect('/products/');
}
if($arrProduct['product_is_orderable_for_someone_else'])
{
\Framework\HTTP\Redirection::redirect('/commerce/order-for/' . $iProductId . '/');
} else
{
$arrOrderOptions = isset($arrValues['product_order_options']) ? $arrValues['product_order_options'] : null;
$arrOrderOptions = \Components\Commerce\Carts\Current::convertPostedProductOptionsToAssoc($iProductId, $arrOrderOptions);
if(isset($arrValues['bought_for_contact_id']))
{
foreach($arrValues['bought_for_contact_id'] as $iBoughtForContactId)
{
$iContactId = $iBoughtForContactId ? $iBoughtForContactId : null;
\Components\Commerce\Carts\Current::orderProduct($iProductId, $iQty, $arrOrderOptions, $iContactId);
}
} else
{
\Components\Commerce\Carts\Current::orderProduct($iProductId, $iQty, $arrOrderOptions, null);
}
// TODO: If statement - config
\Framework\HTTP\Redirection::redirect('/commerce/order/');
}
}
?>
<?php
if (!\Components\Website\Pages::currentPageQuery())
{
\Framework\HTTP\Redirection::redirect('/products/categories/', true);
}
if (!\Components\Settings\Components::isInstalled('\Components\Commerce\Products'))
{
exit();
}
// Redirect access through numerical ids to textual version
$strQuery = \Components\Website\Pages::currentPageQuery();
if($strQuery && is_numeric($strQuery))
{
$arrProduct = \Components\Commerce\Products::get($strQuery);
if($arrProduct && $arrProduct['product_uri'] && \Framework\HTTP\Request::getCurrentURIPath() != $arrProduct['product_uri'])
{
\Framework\HTTP\Redirection::redirect($arrProduct['product_uri']);
}
}
// AF - This is to allow a redirection to the course selector for courses without overriding /products/
if(\Components\Website\Pages::currentPageQuery())
{
$arrEventParams = array();
$arrEventParams[] = \Components\Website\Pages::currentPageQuery();
\Components\Commerce\Products::eventTrigger('viewProduct', $arrEventParams);
}
function orderProduct($iProductId, $iQty = null, $arrValues = null)
{
$arrProduct = \Components\Commerce\Products::get($iProductId);
if(!$arrProduct)
{
\Framework\HTTP\Redirection::redirect('/products/');
}
if($arrProduct['product_is_orderable_for_someone_else'])
{
\Framework\HTTP\Redirection::redirect('/commerce/order-for/' . $iProductId . '/');
} else
{
$arrOrderOptions = isset($arrValues['product_order_options']) ? $arrValues['product_order_options'] : null;
$arrOrderOptions = \Components\Commerce\Carts\Current::convertPostedProductOptionsToAssoc($iProductId, $arrOrderOptions);
if(isset($arrValues['bought_for_contact_id']))
{
foreach($arrValues['bought_for_contact_id'] as $iBoughtForContactId)
{
$iContactId = $iBoughtForContactId ? $iBoughtForContactId : null;
\Components\Commerce\Carts\Current::orderProduct($iProductId, $iQty, $arrOrderOptions, $iContactId);
}
} else
{
\Components\Commerce\Carts\Current::orderProduct($iProductId, $iQty, $arrOrderOptions, null);
}
// TODO: If statement - config
\Framework\HTTP\Redirection::redirect('/commerce/order/');
}
}
?>