/** * 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 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; } }
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 getVariantsFieldDesc($controller, $obj) { $simpleProductObjs = $controller->products->getSimpleProductsOfAggregator($obj->getId())->getReturnedObj(); $simpleProductArrs = Helper_Krco::productsToVariantArrs($simpleProductObjs); $flipped = self::getFlippedOptionMap($controller); return array('option1_title' => $controller->getProductOptionTitleByKey(Helper_Structure::getArrayValue($flipped, 'Attribute1')), 'option2_title' => $controller->getProductOptionTitleByKey(Helper_Structure::getArrayValue($flipped, 'Attribute2')), 'with_price_per_variant' => !empty($controller->deployment_config['with_price_per_variant']), 'variants' => $simpleProductArrs); }
static function getFullUrlFromServerVar($server) { return self::getUrlSchemeFromServerVar($server) . "://" . Helper_Structure::getArrayValue($server, 'HTTP_HOST') . Helper_Structure::getArrayValue($server, 'REQUEST_URI'); }
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; }