static function renderEcommerceScript($order) { $functionContent = ''; $anContent = ''; $functionContent .= "var _gaq = _gaq || [];\n"; $revenue = $order['total_amount_raw'] - $order['shipping'] - $order['tax']; $addTrans = array('_addTrans', $order['order_id'], '', $revenue, $order['tax'], $order['shipping'], '', '', ''); $addTransJson = json_encode($addTrans); $functionContent .= "_gaq.push({$addTransJson});\n"; $newAddTrans = array('id' => $order['order_id'], 'revenue' => $revenue, 'tax' => $order['tax'], 'shipping' => $order['shipping']); $newAddTransJson = json_encode($newAddTrans); $anContent .= "ga('require', 'ecommerce', 'ecommerce.js');\n"; $anContent .= "ga('ecommerce:addTransaction', {$newAddTransJson});\n"; foreach ($order['detailed_items'] as $item) { $sku = $item['title']; if (isset($item['product_code']) && $item['product_code']) { $sku = $item['product_code']; } $addItem = array('_addItem', $order['order_id'], $sku, $item['title'], '', $item['price'], $item['quantity']); $newItem = array('id' => $order['order_id'], 'sku' => $sku, 'name' => $item['title'], 'price' => $item['price'], 'quantity' => $item['quantity']); $addItemJson = json_encode($addItem); $newAddItemJson = json_encode($newItem); $functionContent .= "_gaq.push({$addItemJson});\n"; $anContent .= "ga('ecommerce:addItem', {$newAddItemJson});\n"; } $functionContent .= "_gaq.push(['_trackTrans']);\n"; $anContent .= "ga('ecommerce:send');\n"; $scriptContent = $functionContent; $s = Helper_Xml::xmlTag('script', $scriptContent, array('type' => 'text/javascript')); $gaContent = ""; $newContent = <<<EOD if (window.ga) { {$anContent} } EOD; $new = Helper_Xml::xmlTag('script', $newContent, array('type' => 'text/javascript')); return $s . $new; }
static function renderFormRow($options, $lang = "en") { $_name = ""; $_sanitized_name = ""; $_label = ""; $_type = "text"; $_attribute = ""; $_value = ""; $_value_empty = ""; $_html_input = ""; $_html = ""; $_options = array(); $_selected = ""; if (!empty($options['name'])) { $_name = $options['name']; } if (!empty($options['name'])) { $_sanitized_name = preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $options['name']); } if (!empty($options['label'])) { $_label = $options['label']; } if (!empty($options['type'])) { $_type = $options['type']; } if (!empty($options['attribute'])) { $_attribute = $options['attribute']; } if (!empty($options['value'])) { $_value = $options['value']; } if (!empty($options['value_empty'])) { $_value_empty = $options['value_empty']; } if (!empty($options['options'])) { $_options = $options['options']; } if (!empty($options['selected'])) { $_selected = $options['selected']; } $_required = ""; if (strpos($_attribute, 'required') !== false) { $_required .= "<span class='required'>*</span>"; } if ($_type == "text" || $_type == "email" || $_type == "tel" || $_type == "password") { $_html_input .= "<input id='input_{$_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "textarea") { $_html_input .= "<textarea name='{$_name}' {$_attribute}></textarea>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "file") { $_html_input .= "<input id='input_{$_name}' type='file' name='{$_name}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "country") { $_countries = Helper_Paypal::getPaypalCountriesAssoc(); $_html_input_option = "<option value=\"\">-- Select Country --</option>"; foreach ($_countries as $_country_key => $_country_value) { if (!empty($_value) && $_value == $_country_key) { $_html_input_option .= "<option value='{$_country_key}' selected='selected'>{$_country_value}</option>"; } else { $_html_input_option .= "<option value='{$_country_key}'>{$_country_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "salutation") { if ($lang == "id") { $_salutations = array('' => '-- Harap Dipilih --', 'Mr' => 'Tuan', 'Mrs' => 'Nyonya', 'Miss' => 'Nona', 'Dr' => 'Dr'); } else { $_salutations = array('' => '-- Please Select --', 'Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr'); } $_html_input_option = ""; foreach ($_salutations as $_salutation_key => $_salutation_value) { if (!empty($_value) && $_value == $_salutation_value) { $_html_input_option .= "<option value='{$_salutation_key}' selected='selected'>{$_salutation_value}</option>"; } else { $_html_input_option .= "<option value='{$_salutation_key}'>{$_salutation_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "checkbox") { $_html_input .= "<input name='{$_name}' {$_attribute} type='checkbox'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-input checkbox'>\n {$_html_input}\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n </div>"; } else { if ($_type == "radio") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { $_html_image = ''; if (!empty($_v['image'])) { $_html_image = '<br/><img src="' . Helper_File::addSuffix($_v['image'], '_ori') . '"/>'; } if (isset($_selected) && $_v['value'] == $_selected) { $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . " checked='checked'>" . $_v['title'] . $_html_image . "</div>\n"; } else { $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . ">" . $_v['title'] . $_html_image . "</div>\n"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= <<<EOD <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'> <div class='sirclo-form-input radio'> {$_html_input}</div> </div> EOD; } else { if ($_type == "checkbox_multiple") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { if (!empty($_selected) && in_array($_v['value'], $_selected)) { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . " checked='checked'>" . $_v['title'] . "</div>"; } else { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . ">" . $_v['title'] . "</div>"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-input checkbox-multiple'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "subheader") { $_html .= "<h3 class='{$_sanitized_name}'>" . $_value . "</h3>"; } else { if ($_type == "hidden") { $_html .= "<input id='input_{$_sanitized_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; } else { if ($_type == "div") { $_html .= "<div {$_attribute}>"; } else { if ($_type == "div_close") { $_html .= "</div>"; } else { if ($_type == "submit") { if ($lang == "id") { $_html_input .= "<div class='sirclo-form-row notice'><span class='required'>*</span> wajib diisi.</div>"; } else { $_html_input .= "<div class='sirclo-form-row notice'>Fields marked with <span class='required'>*</span> are required.</div>"; } $_html_input .= "<input type='submit' value='{$_value}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n {$_html_input}\n </div>"; } else { if ($_type == 'dropdown') { $_attrs = array(); if ($_required) { $_attrs['required'] = 'required'; } $_html_input .= Helper_Xml::xmlSelect($_name, $_options, $_value, $_attrs); $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "plain_text") { $_html_input .= "<p>{$_value}</p>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n {$_html_input}\n </div>"; } } } } } } } } } } } } } } } return $_html; }
function _getDeliveryDateForm($cart) { if (isset($this->withDeliveryDate) && $this->withDeliveryDate) { $inputs = ''; $inputs .= Helper_Xml::xmlInputHidden('cmd', 'delivery_date'); $delDate = ''; if ($cart['delivery_timestamp']) { $delDate = Helper_Date::formatSgpDatetime($cart['delivery_timestamp'], FALSE); if ($this->withDeliveryDate === 'date') { $delDate = Helper_Date::formatSgpDate($cart['delivery_timestamp'], FALSE); } } $inputs .= Helper_Xml::xmlEmptyTag('input', array('type' => 'text', 'name' => 'delivery_date', 'value' => $delDate)); $inputs .= Helper_Xml::xmlEmptyTag('input', array('type' => 'submit', 'value' => 'Update')); $ddLabel = 'Delivery Date'; if (isset($this->deliveryDateLabel) && $this->deliveryDateLabel) { $ddLabel = $this->deliveryDateLabel; } $label = Helper_Xml::xmlTag('span', "{$ddLabel}: "); $shippingForm = Helper_Xml::xmlTag('form', $label . $inputs, array('action' => $cart['link'], 'method' => 'post', 'class' => 'cart-delivery-date')); return $shippingForm; } return ''; }
function xmlEmail($mail) { return Helper_Xml::xmlEmail($mail); }
static function getItemTitle($item, $withHtml = FALSE, $options = array(), $renderer = NULL, $cartRenderer = NULL) { $itemTitle = ''; if (method_exists($renderer, 'renderCartItemDescription')) { $itemTitle = $renderer->renderCartItemDescription($item, $options); } else { if (isset($item['link'])) { $itemTitle = Helper_Xml::xmlSpan($item['name'], array('class' => 'cart-item-title')); if (!isset($cartRenderer->withProductLink) || $cartRenderer->withProductLink !== FALSE) { $itemTitle = Helper_Xml::xmlA($item['name'], $item['link'], array('class' => 'cart-item-title')); } } $itemTitleRaw = $item['name']; $withBreak = !empty($options['with_break_options']); $optionStr = self::optionsToStr($item, $withBreak); if ($optionStr) { self::_addItemOptionStr($itemTitle, $item, $optionStr); self::_addItemOptionStr($itemTitleRaw, $item, $optionStr); } if (isset($options['with_edit_item']) && $options['with_edit_item']) { $itemTitle .= "\n"; $itemTitle .= Helper_Xml::xmlA('edit', $item['edit_link'], array('class' => 'cart-item-edit')); } } if ($withHtml) { return $itemTitle; } return $itemTitleRaw; }
static function renderFormRow($options, $lang = "en") { $_name = ""; $_sanitized_name = ""; $_label = ""; $_type = "text"; $_attribute = ""; $_value = ""; $_value_empty = ""; $_html_input = ""; $_html = ""; $_options = array(); $_selected = ""; if (!empty($options['name'])) { $_name = $options['name']; } if (!empty($options['name'])) { $_sanitized_name = preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $options['name']); } if (!empty($options['label'])) { $_label = $options['label']; } if (!empty($options['type'])) { $_type = $options['type']; } if (!empty($options['attribute'])) { $_attribute = $options['attribute']; } if (!empty($options['value'])) { $_value = $options['value']; } if (!empty($options['value_empty'])) { $_value_empty = $options['value_empty']; } if (!empty($options['options'])) { $_options = $options['options']; } if (!empty($options['selected'])) { $_selected = $options['selected']; } $_required = ""; if (strpos($_attribute, 'required') !== false) { $_required .= "<span class='required'>*</span>"; } /* <div class="form-group has-feedback"> <input type="text" class="form-control" placeholder="Email" /> <i class="fa fa-envelope s-top-less-margin form-control-feedback"></i> </div> */ if ($_type == "emailLogin") { $_html_input .= "<input id='input_{$_name}' class='form-control' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}' placeholder='Email'>\n\t\t\t\t\t\t\t <i class='fa fa-envelope s-top-less-margin form-control-feedback'></i>"; $_html .= '<div id="form-row-$_sanitized_name" class="form-group"> <div class="form-group has-feedback sirclo-form-input"> ' . $_html_input . ' </div> </div>'; } else { if ($_type == "passwordLogin") { $_html_input .= "<input id='input_{$_name}' class='form-control' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}' placeholder='Password'>\n\t\t\t\t\t\t\t <i class='fa fa-lock s-top-less-margin form-control-feedback'></i>"; $_html .= '<div id="form-row-$_sanitized_name" class="form-group"> <div class="form-group has-feedback sirclo-form-input"> ' . $_html_input . ' </div> </div>'; } else { if ($_type == "text" || $_type == "password" || $_type == "email" || $_type == "tel" || $_type == "date") { $_html_input .= "<input id='input_{$_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "textarea") { $_html_input .= "<textarea name='{$_name}' {$_attribute}></textarea>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "file") { $_html_input .= "<input id='input_{$_name}' type='file' name='{$_name}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "country") { $_countries = Helper_Paypal::getPaypalCountriesAssoc(); $_html_input_option = "<option value=\"\">-- Select Country --</option>"; foreach ($_countries as $_country_key => $_country_value) { if (!empty($_value) && $_value == $_country_key) { $_html_input_option .= "<option value='{$_country_key}' selected='selected'>{$_country_value}</option>"; } else { $_html_input_option .= "<option value='{$_country_key}'>{$_country_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "salutation") { if ($lang == "id") { $_salutations = array('' => '-- Harap Dipilih --', 'Mr' => 'Tuan', 'Mrs' => 'Nyonya', 'Miss' => 'Nona', 'Dr' => 'Dr'); } else { $_salutations = array('' => '-- Please Select --', 'Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr'); } $_html_input_option = ""; foreach ($_salutations as $_salutation_key => $_salutation_value) { if (!empty($_value) && $_value == $_salutation_value) { $_html_input_option .= "<option value='{$_salutation_key}' selected='selected'>{$_salutation_value}</option>"; } else { $_html_input_option .= "<option value='{$_salutation_key}'>{$_salutation_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "checkbox") { $_html_input .= "<input name='{$_name}' {$_attribute} type='checkbox'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group checkbox'>\n <label for='{$_name}'>\n <input name ='agreement' required type='checkbox'>\n {$_label}\n {$_required}\n </label>\n </div>"; } else { if ($_type == "radio") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { $_html_image = ''; if (!empty($_v['image'])) { foreach ($_v['image'] as $img) { if ($_html_image == '') { $_html_image .= '<br/>'; } $_html_image .= '<img class="s-icon-pay" src="' . $img . '"/>'; } } if (isset($_selected) && $_v['value'] == $_selected) { $_html_input .= "<label><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . " checked='checked'>" . $_v['title'] . $_html_image . "</label>\n"; } else { $_html_input .= "<label><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . ">" . $_v['title'] . $_html_image . "</label>\n"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= <<<EOD <div id='form-row-{$_sanitized_name}' class='form-group radio'> {$_html_input} </div> EOD; } else { if ($_type == "checkbox_multiple") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { if (!empty($_selected) && in_array($_v['value'], $_selected)) { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . " checked='checked'>" . $_v['title'] . "</div>"; } else { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . ">" . $_v['title'] . "</div>"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-input checkbox-multiple'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "subheader") { $_html .= "<h2 class='{$_sanitized_name}'>" . $_value . "</h2>"; } else { if ($_type == "hidden") { $_html .= "<input id='input_{$_sanitized_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; } else { if ($_type == "div") { $_html .= "<div {$_attribute}>"; } else { if ($_type == "div_close") { $_html .= "</div>"; } else { if ($_type == "submit") { if ($_value == "LOGIN") { $_html_input .= '<button class="btn btn-lg blue-button s-fullwidth s-bottom-margin s-top-less-margin s-login-button">LOGIN</button>'; } else { if ($_value == "REGISTER") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button"> REGISTER </button>'; } else { if ($_value == "SEND") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button">SEND</button>'; } else { if ($_value == "CHANGE PASSWORD") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button s-change-password-submit">CHANGE PASSWORD</button>'; } else { /* if ($lang == "id") { $_html_input .= "<div class='form-group notice'><span class='required'>*</span> wajib diisi.</div>"; } else { $_html_input .= "<div class='form-group notice'>Fields marked with <span class='required'>*</span> are required.</div>"; }*/ $_html_input .= "<input type='submit' value='{$_value}' {$_attribute}>"; } } } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n {$_html_input}\n </div>"; } else { if ($_type == 'dropdown') { $_attrs = array(); if ($_required) { $_attrs['required'] = 'required'; } $_html_input .= Helper_Xml::xmlSelect($_name, $_options, $_value, $_attrs); $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "plain_text") { $_html_input .= "<p>{$_value}</p>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n {$_html_input}\n </div>"; } } } } } } } } } } } } } } } } } return $_html; }