66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Smarty plugin
|
|
* -------------------------------------------------------------
|
|
* Type: function
|
|
* Name: get_product_info
|
|
* Purpose: returns various information about order
|
|
* -------------------------------------------------------------
|
|
*/
|
|
|
|
use KupShop\OrderingBundle\Util\Order\OrderInfo;
|
|
|
|
function smarty_function_get_order_info($params, &$smarty)
|
|
{
|
|
$type = null;
|
|
$id = null;
|
|
/** @var Order $order */
|
|
$order = null;
|
|
$result = null;
|
|
|
|
extract($params);
|
|
|
|
if (empty($type)) {
|
|
trigger_error("Chybějící parametr 'type'");
|
|
}
|
|
|
|
if (empty($id) && empty($order)) {
|
|
trigger_error("Chybějící parametr 'id' nebo 'order'");
|
|
}
|
|
|
|
if (empty($id)) {
|
|
$id = $order->id;
|
|
}
|
|
|
|
switch ($type) {
|
|
case 'conversion_sent':
|
|
if ($order->getData('conversion_sent')) {
|
|
$result = false;
|
|
} else {
|
|
$order->setData('conversion_sent', 1);
|
|
$result = true;
|
|
}
|
|
break;
|
|
|
|
case 'heurekaDisagree':
|
|
$result = $order->getData('heurekaDisagree');
|
|
break;
|
|
|
|
case 'getUsedCoupons':
|
|
if ($coupons = OrderInfo::getUsedCoupons($order)) {
|
|
$result = $coupons;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
trigger_error("Neexistující 'type': {$type}");
|
|
}
|
|
|
|
if (!empty($params['assign'])) {
|
|
$smarty->assign($params['assign'], $result);
|
|
} else {
|
|
return $result;
|
|
}
|
|
}
|