/** * Function to generate order table * * This function generate order table * * * @param $params contains option of the generated result * @param $template to associate generated result * * @return string HTML code of the order table <table>...</table> */ function smarty_function_sirclo_render_order_table($params, $template) { $html = ''; if (isset($params['order'])) { $colors = array('color1' => Helper_Structure::getArrayValue($params, 'color1'), 'color2' => Helper_Structure::getArrayValue($params, 'color2')); $html = Helper_Renderer::renderOrderTable($params['order'], $colors); } return $html; }
static function getCase_StoreCartJson_TestEditCart($controller) { $testEditCart = self::getCase_StoreCartJson_TestSuccess($controller); $testEditCart['cart']['shipping'] = rand(10, 100); $shipping_value = Helper_Structure::getArrayValue($_POST, 'shipping_value'); if ($shipping_value != 'ID') { $testEditCart['shipping_cities'] = array(); } $testEditCart['cart']['shipping_city'] = $shipping_value; return $testEditCart; }
static function calculateAdvancedProductPriceWithRule($controller, $cartItem, $member, $product, $rule) { $conditions = Helper_Structure::getArrayValue($rule, 'conditions'); if (!$conditions) { return NULL; } if (self::isConditionsSatisfied($controller, $cartItem, $member, $product, $conditions)) { $price = self::applyPricing($controller, $cartItem, $member, $product, Helper_Structure::getArrayValue($rule, 'pricing')); return $price; } }
/** * Function to generate json representation of the cart information * * This function generate json representation of the cart information * * * @param $params contains option of the generated result * @param $template to associate generated result * * @return string json code of the cart information */ function smarty_function_sirclo_render_cart_json($params, $template) { $jsonData = array(); $renderer = new Renderer_Cart(); $renderer->cartTableMode = 'mini'; if ($message = $template->smarty->getTemplateVars('message')) { $jsonData['message'] = $message; $jsonData['message_type'] = $template->smarty->getTemplateVars('message_type'); } $cart = $params['cart']; $jsonData['cart'] = Helper_Structure::filterArrayByKeys($cart, array('currency_symbol', 'total_items', 'grand_total')); $jsonData['cart_html'] = $renderer->renderCartTable($cart); return json_encode($jsonData); }
static function buildNavFromArticles($controller, $articleLabel, $articles, $articleFid = NULL) { $tempNav = array(); $nArticles = count($articles); foreach ($articles as $obj) { $objFid = $obj->getFriendlyId(); $item = array('title' => $obj->getTitle($controller->lang), 'link' => Helper_Structure::composeArticleLink($controller, $articleLabel, $nArticles > 1 ? $objFid : ''), '_fid' => $objFid); $isItemActive = FALSE; if ($obj->getFriendlyId() == $articleFid) { $isItemActive = TRUE; $item['is_active'] = TRUE; } $navKey = $obj->getTitle(); if ($group = $obj->getGroup()) { $navKey = $group; if (!isset($tempNav[$navKey])) { $tempNav[$navKey] = array('title' => $group, 'link' => '', '_fid' => $group); } if ($isItemActive) { $tempNav[$navKey]['is_active'] = TRUE; } } if (isset($tempNav[$navKey])) { if ($navKey == $obj->getTitle()) { $tempNav[$navKey] = $item + $tempNav[$navKey]; } else { $subFid = "{$articleLabel}/" . $item['_fid']; unset($item['_fid']); $tempNav[$navKey]['sub_nav'][$subFid] = $item; } } else { $tempNav[$navKey] = $item; } } $nav = array(); foreach ($tempNav as $item) { $key = "{$articleLabel}/" . $item['_fid']; unset($item['_fid']); $nav[$key] = $item; } return $nav; }
function smarty_modifier_cc_filter_array_by_keys($arr, $keys) { return Helper_Structure::filterArrayByKeys($arr, $keys); }
static function getFullUrlFromServerVar($server) { return self::getUrlSchemeFromServerVar($server) . "://" . Helper_Structure::getArrayValue($server, 'HTTP_HOST') . Helper_Structure::getArrayValue($server, 'REQUEST_URI'); }
/** * Function to change texts into options * * This function get string from text and make it into options * * * @param $texts * * @return options that resulted from text */ function smarty_modifier_sirclo_texts_to_options($texts) { return Helper_Structure::getOptionsFromTexts($texts); }
static function renderOrderInfo($order, $colors = NULL) { $color1 = Helper_Structure::getArrayValue($colors, 'color1', '#333333'); $color2 = Helper_Structure::getArrayValue($colors, 'color2', '#EEEEEE'); $billInfo = $order['billing_info']; $deliverInfo = $order['delivery_info']; $infoHeader = "\n<table style='border-collapse:collapse; width:100%; margin-top:15px;'>\n<tr>\n<th style='width:50%; background-color:{$color1}; color:#FFFFFF; padding:5px 10px; font-size:13px; font-weight:bold; text-align:left;'>Delivery Address</th>\n<th style='width:50%; background-color:{$color1}; color:#FFFFFF; padding:5px 10px; font-size:13px; font-weight:bold; text-align:left;'>Billing Address</th>\n</tr>"; $deliveryCell = self::getAddressCell($deliverInfo, $color1, $color2); $billingCell = self::getAddressCell($billInfo, $color1, $color2); $infoData = "\n<tr>\n{$deliveryCell}\n{$billingCell}\n</tr>"; return $infoHeader . $infoData . "\n</table>"; }
function _renderDiscountRows($cart) { $trs = ''; $discTotal = 0; foreach ($cart['discounts'] as $discount) { $discountCell = $discount['title']; if (Helper_Structure::getArrayValue($discount, 'type') !== 'special') { $discountCell .= " (" . $discount['code'] . ")"; } $discountCell .= ":"; $discountVal = $discount['value']; $trs .= $this->_renderRow(' ', ' ', $discountCell, $this->dol($discountVal)); $discTotal += $discountVal; } if ($discTotal && isset($this->withTotalAfterDiscounts) && $this->withTotalAfterDiscounts) { $itemTotal = Helper_Cart::getItemTotal($this->cart['items']); $trs .= $this->_renderRow(' ', ' ', $this->xmlTag('strong', 'Total after Discounts:'), $this->xmlTag('strong', $this->dol($itemTotal + $discTotal))); } return $trs; }
static function getPackageConfigValueById($id, $key) { $package = Helper_Structure::getArrayValue(self::$packages, $id); return Helper_Structure::getArrayValue($package, $key); }
static function getPointsEarnedByAmountSpent($controller, $amount) { $pointRule = $controller->getPointRule(); $pointPerDollar = Helper_Structure::getArrayValue($pointRule, 'point_per_dollar', 0); $points = (int) ($pointPerDollar * $amount); return $points; }
static function setSystemEventObjProperties($obj, $val) { $obj->setTitle(Helper_Structure::getArrayValue($val, 'title')); $obj->setTriggerType(Helper_Structure::getArrayValue($val, 'type')); $obj->setTriggerParams(Helper_Structure::getArrayValue($val, 'filters')); $action = Helper_Structure::getArrayValue($val, 'action'); $obj->setActionType(Helper_Structure::getArrayValue($action, 'type')); $obj->setActionParams(Helper_Structure::getArrayValue($action, 'attrs')); }
static function arrayMergeIfKeyEmpty($arr1, $arr2) { $merged = $arr1; foreach ($arr2 as $key => $value) { if (!Helper_Structure::getArrayValue($merged, $key)) { $merged[$key] = $value; } } return $merged; }
static function getFilterFields($controller, $filterFields, $params, $fieldValues = NULL) { $options = self::getFilterOptions($params); if (isset($options['filters'])) { foreach ($options['filters'] as $key => $val) { $filterField =& self::selectFilterField($filterFields, $key); if ($filterField) { $filterField['selected'] = $val; } } } if ($filterFields) { foreach ($filterFields as $key => &$field) { $fieldOptions = NULL; $curFieldValues = Helper_Structure::getArrayValue($fieldValues, $key); if (isset($field['options'])) { $fieldOptions = $field['options']; if ($field['options'] === 'content') { $field['options'] = array(); $fieldOptions = array(); if (is_array($curFieldValues)) { $fieldOptions = self::getFieldOptionsFromFieldValues($field, $curFieldValues); } } } else { if (isset($field['options_source'])) { $fieldOptions = Helper_Crud::getOptionsFromSource($controller, $field['options_source']); $field['options'] = $fieldOptions; } } if (isset($field['options']) && is_array($field['options'])) { $field['options'] = self::_normalizeOptions($field['options']); } if (isset($fieldOptions) && isset($curFieldValues) && ($withFilterOptions = Helper_Structure::getArrayValue($field, 'with_filter_options')) !== FALSE) { $fieldOptions = self::_normalizeOptions($fieldOptions); $withCount = $withFilterOptions !== 'nocount'; $field['options'] = self::_filterOptions($fieldOptions, $curFieldValues, $field['operator'], $withCount); } } } return $filterFields; }