Ejemplo n.º 1
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     modifier<br>
 * Name:     price<br>
 * Purpose:  getting formatted price with grouped thousands and
 *           decimal separators
 * Example:  {$price|price:"2":".":","}
 * -------------------------------------------------------------
 */
function smarty_modifier_format_price($price, $currency, $span_id = '', $class = '', $is_secondary = false, $live_editor_name = '', $live_editor_phrase = '')
{
    $value = fn_format_rate_value($price, $number_type, $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
    if (!empty($span_id) && $is_secondary) {
        $span_id = 'sec_' . $span_id;
    }
    $span_id = !empty($span_id) ? ' id="' . $span_id . '"' : '';
    $class = !empty($class) ? ' class="' . $class . '"' : '';
    $live_editor_attrs = '';
    if (Registry::get('runtime.customization_mode.live_editor') && !empty($live_editor_name)) {
        $live_editor_attrs = ' data-ca-live-editor-obj="' . $live_editor_name . '"';
        if (!empty($live_editor_phrase)) {
            $live_editor_attrs .= ' data-ca-live-editor-phrase="' . $live_editor_phrase . '"';
        }
    }
    if ($class) {
        $currency['symbol'] = '<span' . $class . '>' . $currency['symbol'] . '</span>';
    }
    $data = array('<span' . $span_id . $class . $live_editor_attrs . '>', $value, '</span>');
    if ($currency['after'] == 'Y') {
        array_push($data, '&nbsp;' . $currency['symbol']);
    } else {
        array_unshift($data, $currency['symbol']);
    }
    return implode('', $data);
}
Ejemplo n.º 2
0
function fn_get_single_map_data($order_info, $auth = null)
{
    $data = array();
    $data["order_date"] = date('d-m-Y', $order_info['timestamp']);
    $data["email"] = $order_info['email'];
    $data["customer_name"] = $order_info['firstname'] . ' ' . $order_info['lastname'];
    $data["order_id"] = $order_info['order_id'];
    $products = $order_info['products'];
    $products_arr = array();
    $currencies = Registry::get('currencies');
    $currency = isset($order_info['secondary_currency']) ? $currencies[$order_info['secondary_currency']] : $currencies[CART_SECONDARY_CURRENCY];
    #modified by Hungryweb 12.10.2015
    //$data["currency_iso"] = $currency['currency_code'];
    $data["currency_iso"] = 'USD';
    foreach ($products as $product) {
        $product_id = is_array($product) ? $product['product_id'] : intval($product);
        $product_data = array();
        $product_data['url'] = fn_get_product_url($product_id);
        #modified by Hungryweb 12.10.2015
        //$product_data['name'] = fn_get_product_name($product_id,CART_LANGUAGE,false);
        $product_data['name'] = fn_specific_development_get_category($product['product_id']) . ' ' . fn_get_product_name($product_id, CART_LANGUAGE, false);
        $product_data['description'] = db_get_field("SELECT full_description FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product_id, CART_LANGUAGE);
        if (isset($product_data['description'])) {
            $product_data['description'] = strip_tags(html_entity_decode($product_data['description'], ENT_NOQUOTES, 'UTF-8'));
        }
        $product_data['image'] = fn_get_product_image_url($product_id);
        $price = is_array($product) ? $product['base_price'] : fn_get_product_price($product_id, 1, $auth);
        $product_data['price'] = fn_format_rate_value($price, 'F', '2', '.', ',', $currency['coefficient']);
        $products_arr[$product_id] = $product_data;
    }
    $data['products'] = $products_arr;
    return $data;
}
Ejemplo n.º 3
0
 public function formBill($order_transaction, $order_info, $processor_data)
 {
     $order_total = fn_format_rate_value($order_info['total'], 'F', 2, '.', '', '');
     $user = str_replace(array('+', ' ', '(', ')', '-'), '', $order_info['payment_info']['phone']);
     $data = array('txn_id' => $order_transaction, 'from' => $processor_data['processor_params']['shop_id'], 'to' => '+' . $user, 'summ' => $order_total, 'currency' => $this->_currency, 'successUrl' => fn_url("payment_notification.return?payment=qiwi_rest"), 'failUrl' => fn_url("payment_notification.return?payment=qiwi_rest"), 'lifetime' => $processor_data['processor_params']['lifetime'] * 60, 'comm' => !empty($order_info['notice']) ? $order_info['notice'] : '');
     return $data;
 }
Ejemplo n.º 4
0
 public function register($order_info, $protocol = 'current')
 {
     $order_total = fn_format_rate_value($order_info['total'], 'F', 2, '.', '', '');
     $order_id = $order_info['order_id'];
     $orderNumber = $order_id . '_' . substr(md5($order_id . TIME), 0, 3);
     $data = array('userName' => $this->_login, 'password' => $this->_password, 'orderNumber' => $orderNumber, 'amount' => $order_total * 100, 'returnUrl' => fn_url("payment_notification.return?payment=alfabank&ordernumber={$order_id}", AREA, $protocol), 'failUrl' => fn_url("payment_notification.error?payment=alfabank&ordernumber={$order_id}", AREA, $protocol));
     $this->_response = Http::post($this->_url . 'register.do', $data);
     $this->_response = json_decode($this->_response, true);
     if (!empty($this->_response['errorCode'])) {
         $this->_error_code = $this->_response['errorCode'];
         $this->_error_text = $this->_response['errorMessage'];
     }
     return $this->_response;
 }
Ejemplo n.º 5
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     modifier<br>
 * Name:     price<br>
 * Purpose:  getting formatted price with grouped thousands and
 *           decimal separators
 * Example:  {$price|price:"2":".":","}
 * -------------------------------------------------------------
 */
function smarty_modifier_format_price($price, $currency, $span_id, $class = '', $is_secondary = false)
{
    $value = fn_format_rate_value($price, $number_type, $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
    if (!empty($class)) {
        $currency['symbol'] = '<span class="' . $class . '">' . $currency['symbol'] . '</span>';
    }
    if (!empty($span_id) && $is_secondary == true) {
        $span_id = 'sec_' . $span_id;
    }
    if (!empty($class) || !empty($span_id)) {
        $data = array('<span' . (!empty($span_id) ? ' id="' . $span_id . '"' : '') . (!empty($class) ? ' class="' . $class . '"' : '') . '>', $value, '</span>');
    } else {
        $data = array($value);
    }
    if ($currency['after'] == 'Y') {
        array_push($data, '&nbsp;' . $currency['symbol']);
    } else {
        array_unshift($data, $currency['symbol']);
    }
    return implode('', $data);
}
Ejemplo n.º 6
0
 public static function convertSum($price)
 {
     if (CART_PRIMARY_CURRENCY != 'RUB') {
         $currencies = Registry::get('currencies');
         if (!empty($currencies['RUB'])) {
             $currency = $currencies['RUB'];
             $price = fn_format_rate_value($price, 'F', 2, '.', '', $currency['coefficient']);
         }
     }
     return sprintf('%.2f', $price);
 }
Ejemplo n.º 7
0
            $data = array('order_info' => $order_info, 'total_print' => $total_print, 'fonts_path' => fn_get_theme_path('[relative]/[theme]/media/fonts'), 'url_qr_code' => $url_qr_code, 'email_subj' => __("sbrf_receipt_for_payment", array('[order_id]' => $order_info['order_id'])));
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'default_company_orders_department', 'data' => $data, 'attachments' => array(fn_get_files_dir_path() . 'sberbank_receipt.pdf'), 'tpl' => 'addons/rus_payments/print_sbrf_receipt.tpl', 'is_html' => true), 'A');
            fn_set_notification('N', __('notice'), __('text_email_sent'));
        }
    } else {
        $view->assign('show_print_button', true);
        $view->displayMail('addons/rus_payments/print_sbrf_receipt.tpl', true, 'C');
    }
    exit;
} elseif ($mode == 'print_invoice_payment' || $mode == 'send_account_payment') {
    $month = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря');
    $order_info = fn_get_order_info($_REQUEST['order_id']);
    $currencies = Registry::get('currencies');
    if (CART_SECONDARY_CURRENCY == 'RUB' && isset($currencies['RUB'])) {
        $currency = $currencies['RUB'];
        $for_rub = fn_format_rate_value($order_info['total'], 'F', $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
        if ($currency['decimals'] != 0) {
            $length_for_rub = $currency['decimals'] + 1;
            $rub = substr($for_rub, 0, -$length_for_rub);
            $length_for_kop = $currency['decimals'];
            $kop = substr($for_rub, -$length_for_kop);
            $total_print = '<strong>' . $rub . '</strong>&nbsp;' . __("sbrf_rub") . '&nbsp;<strong>' . $kop . '</strong>&nbsp;' . __("sbrf_kop");
        } else {
            $total_print = '<strong>' . $for_rub . '</strong>&nbsp;' . __("sbrf_rub");
        }
    } else {
        $total_print = fn_format_price_by_currency($order_info['total']);
    }
    $order_info['sum_tax'] = 0;
    if (!empty($order_info['taxes'])) {
        foreach ($order_info['taxes'] as $data_tax) {
Ejemplo n.º 8
0
function fn_get_review_ratings($thread_id, $no_attributes = false)
{
    if (!empty($thread_id) && !$no_attributes) {
        $_rating = db_get_array("SELECT a.rating, a.attr_id, a.post_id FROM ?:review_rating AS a LEFT JOIN ?:discussion_posts AS b ON a.post_id = b.post_id WHERE b.thread_id = ?i AND b.status = 'A'", $thread_id);
        if (!$_rating) {
            return array();
        }
        $post_count = db_get_field("SELECT COUNT(post_id) FROM ?:discussion_posts WHERE thread_id = ?i AND status = 'A'", $thread_id);
        $average = 0;
        ////Ruslan
        //		$attributes = Registry::get('view')->getTemplateVars('attributes');
        //
        //		foreach ($attributes as $k => $v) {
        //			$attr_ids[] = $v['attr_id'];
        //		}
        ////Ruslan/
        $average_by_attr = $_average_by_attr = $average_by_post = array();
        //
        //		foreach ($_rating as $k => $v) {
        //// 			if ($v['attr_id'] <= 6) {
        //// 				unset($_rating[$k]);
        //// 			}
        ////Ruslan
        //			if (is_array($attr_ids) && !in_array($v['attr_id'], $attr_ids)) {
        //				unset($_rating[$k]);
        //			}
        ////Ruslan/
        //		}
        $num = count($_rating);
        foreach ($_rating as $v) {
            $rating[$v['post_id']][$v['attr_id']] = $v['rating'];
            $average_by_attr[$v['attr_id']] += $v['rating'];
            $average_by_post[$v['post_id']] += $v['rating'];
            $average += $v['rating'];
        }
        foreach ($average_by_attr as $k => $v) {
            $_average_by_attr[$k]['value'] = $v / count($average_by_post);
            $_average_by_attr[$k]['value'] = fn_format_rate_value($_average_by_attr[$k]['value'], 'F');
            $_average_by_attr[$k]['percent'] = fn_format_rate_value($_average_by_attr[$k]['value'] * 100 / 5, 'P', 0);
        }
        $average_by_attr = $_average_by_attr;
        foreach ($average_by_post as $k => $v) {
            $average_by_post[$k] = $v / count($average_by_attr);
            $average_by_post[$k] = fn_format_rate_value($average_by_post[$k], 'F');
        }
        $average = $average / $num;
        return array('rating' => isset($rating) ? $rating : false, 'average_by_attr' => isset($average_by_attr) ? $average_by_attr : false, 'average_by_post' => isset($average_by_post) ? $average_by_post : false, 'average' => fn_format_rate_value($average, 'F'), 'count' => $post_count);
    } elseif (!empty($thread_id) && $no_attributes) {
        $average = db_get_field("SELECT AVG(a.rating_value) as val FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $thread_id);
        $post_count = db_get_field("SELECT COUNT(post_id) FROM ?:discussion_posts WHERE thread_id = ?i AND status = 'A'", $thread_id);
        return array('average' => $average, 'count' => $post_count);
    } else {
        return array();
    }
}
function fn_exim_mailru_export_price($price, $decimals_separator)
{
    return fn_format_rate_value($price, 'F', 2, $decimals_separator, '', '');
}
Ejemplo n.º 10
0
function fn_apply_text_placeholders($matches)
{
    if (isset($matches[1]) && !empty($matches[2])) {
        if ($matches[2] == 'price') {
            $currencies = Registry::get('currencies');
            $currency = $currencies[CART_SECONDARY_CURRENCY];
            $value = fn_format_rate_value($matches[1], 'F', $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
            return $currency['after'] == 'Y' ? $value . $currency['symbol'] : $currency['symbol'] . $value;
        } elseif ($matches[2] == 'weight') {
            return $matches[1] . '&nbsp;' . Registry::get('settings.General.weight_symbol');
        }
    }
}
Ejemplo n.º 11
0
function fn_format_price_by_currency($price, $currency_code = CART_SECONDARY_CURRENCY)
{
    $currencies = Registry::get('currencies');
    $currency = $currencies[$currency_code];
    $result = fn_format_rate_value($price, 'F', $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
    if ($currency['after'] == 'Y') {
        $result .= ' ' . $currency['symbol'];
    } else {
        $result = $currency['symbol'] . $result;
    }
    return $result;
}
Ejemplo n.º 12
0
function fn_yandex_money_get_sum($order_info, $processor_data)
{
    $price = $order_info['total'];
    if (CART_PRIMARY_CURRENCY != $processor_data['processor_params']['currency']) {
        $currencies = Registry::get('currencies');
        $currency = $currencies[$processor_data['processor_params']['currency']];
        $price = fn_format_rate_value($price, 'F', $currency['decimals'], '.', '', $currency['coefficient']);
    }
    return sprintf('%.2f', $price);
}
Ejemplo n.º 13
0
function fn_mailru_prepare_offer($products, $options, $enclosure)
{
    //array error
    $error_products = array('products_zero_price' => '', 'disabled_products' => '', 'out_of_stock' => '', 'empty_brand' => '', 'empty_model' => '', 'disable_cat_list' => '', 'disable_cat_list_d' => '');
    //data addons mail
    $addon_settings = Registry::get('addons.rus_tovary_mailru');
    $delivery_type = $addon_settings['delivery_type'];
    list($products, $product_ids) = fn_mailru_filter_products($products, $addon_settings, $error_products);
    if (empty($products)) {
        return true;
    }
    //category
    $visible_categories = fn_mailru_get_visible_categories($addon_settings);
    $fields = array('p.product_id', 'p.mailru_brand', 'p.mailru_model', 'p.mailru_delivery', 'p.mailru_pickup', 'p.mailru_cost', 'p.mailru_type_prefix', 'p.mailru_mcp');
    $fields[] = "(\n        SELECT GROUP_CONCAT(IF(pc2.link_type = 'M', CONCAT(pc2.category_id, 'M'), pc2.category_id))\n        FROM ?:products_categories as pc2\n        WHERE product_id = p.product_id\n    ) as category_ids";
    $mailru_products = db_get_hash_array('SELECT ' . implode(', ', $fields) . ' FROM ?:products as p WHERE product_id IN (?n)', 'product_id', $product_ids);
    $products_zero_price = '';
    foreach ($products as $key => $product) {
        $products[$key]['category_ids'] = $mailru_products[$product['product_id']]['category_ids'];
    }
    $params = array('get_options' => false, 'get_taxed_prices' => false, 'detailed_params' => false);
    fn_gather_additional_products_data($products, $params);
    foreach ($products as $data) {
        $yml = array();
        if ($data['status'] != 'A') {
            continue;
        }
        if ($addon_settings['disable_cat_d'] == "Y") {
            if (!in_array($data['category'], $visible_categories)) {
                $error_products['disable_cat_list_d'] .= $data['product_name'] . ', ';
                continue;
            }
        }
        $avail = fn_is_accessible_product(array('product_id' => $data['product_id'])) ? 'true' : 'false';
        $currency = Registry::get('currencies.' . CART_PRIMARY_CURRENCY);
        $data['price'] = !empty($data['price']) ? $data['price'] : $data['price'];
        $data['price'] = fn_format_price($data['price'], $currency['currency_code'], $currency['decimals'], false);
        if (CART_PRIMARY_CURRENCY != "RUB") {
            $currencies = Registry::get('currencies');
            if (isset($currencies['RUB'])) {
                $currency = $currencies['RUB'];
                $price = fn_format_rate_value($data['price'], 'F', $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
            } else {
                $price = $data['price'];
            }
            $price = !floatval($price) ? fn_parse_price($price) : $price;
            $delivery_cost = fn_mailru_format_price($mailru_products[$data['product_id']]['mailru_cost'], "RUB");
            $delivery_cost = !floatval($delivery_cost) ? fn_parse_price($delivery_cost) : $delivery_cost;
        } else {
            $price = !floatval($data['price']) ? fn_parse_price($data['price']) : $data['price'];
            $delivery_cost = !floatval($mailru_products[$data['product_id']]['mailru_cost']) ? fn_parse_price($mailru_products[$data['product_id']]['mailru_cost']) : $mailru_products[$data['product_id']]['mailru_cost'];
        }
        if (empty($price)) {
            $products_zero_price .= $data['product'] . ', ';
            continue;
        }
        $brand = fn_mailru_get_brand($data, $mailru_products[$data['product_id']], $addon_settings);
        $url = fn_url($data['product_url']);
        $url = htmlentities($url);
        $offer_attrs = '';
        if (!empty($mailru_products[$data['product_id']]['mailru_mcp'])) {
            $offer_attrs .= '@cbid=' . $mailru_products[$data['product_id']]['mailru_mcp'];
        }
        if (CART_PRIMARY_CURRENCY == "RUB") {
            $currency_id = "RUR";
        } elseif (CART_PRIMARY_CURRENCY == "EUR") {
            $currency_id = "EURO";
        } else {
            $currency_id = CART_PRIMARY_CURRENCY;
        }
        $image_url = fn_tovary_mailru_c_encode($data['image_url']);
        $s = urlencode("–");
        $image_url = str_replace("–", $s, $image_url);
        $yml['url'] = $url;
        $yml['price'] = $price;
        $yml['currencyId'] = $currency_id;
        $yml['categoryId'] = $data['category'];
        if (!empty($image_url)) {
            $yml['picture'] = $image_url;
        }
        if ($addon_settings['mail_settings'] == "type_name") {
            $yml['name'] = htmlspecialchars($data['product_name']);
        } elseif ($addon_settings['mail_settings'] == "type_detailed" && !empty($mailru_products[$data['product_id']]['mailru_model'])) {
            if ($addon_settings['type_prefix'] == "Y") {
                if (!empty($mailru_products[$data['product_id']]['mailru_type_prefix'])) {
                    $yml['typePrefix'] = $mailru_products[$data['product_id']]['mailru_type_prefix'];
                } else {
                    $yml['typePrefix'] = $data['category_descriptions'];
                }
            }
            if (empty($brand)) {
                $error_products['empty_brand'] .= $data['product_name'] . ', ';
            } else {
                $yml['vendor'] = $brand;
            }
            $yml['model'] = $mailru_products[$data['product_id']]['mailru_model'];
        } else {
            continue;
        }
        if (!empty($data['full_description'])) {
            $yml['description'] = $data['full_description'];
        }
        if (!empty($data['product_features'])) {
            foreach ($data['product_features'] as $feature) {
                $yml['param@name=' . fn_exim_mailru_get_product_info($feature['description'])] = $feature['value'];
            }
        }
        $yml['delivery'] = $mailru_products[$data['product_id']]['mailru_delivery'] == 'Y' ? 'true' : 'false';
        $yml['pickup'] = $mailru_products[$data['product_id']]['mailru_pickup'] == 'Y' ? 'true' : 'false';
        if ($addon_settings['local_delivery_cost'] == 'Y') {
            if ($delivery_cost == 0) {
                if ($delivery_type == 'value') {
                    $delivery_cost = "0";
                    $yml['local_delivery_cost'] = $delivery_cost;
                } elseif ($delivery_type == 'free') {
                    $delivery_cost = "Бесплатная доставка";
                    $yml['local_delivery_cost'] = $delivery_cost;
                }
            } else {
                $yml['local_delivery_cost'] = $delivery_cost;
            }
        }
        $yml_offers['offer@id=' . $data['product_id'] . '@available=' . $avail . $offer_attrs] = $yml;
        $_SESSION['mailru_export_count']++;
    }
    if ($products_zero_price) {
        fn_set_notification('W', __('error'), __('mailru_export_unsuccessfull') . $products_zero_price);
    }
    if (!empty($error_products) && $addon_settings['notify_disable_products'] == "Y") {
        foreach ($error_products as $key => $value) {
            if (!empty($value)) {
                fn_set_notification('W', __('error'), __('mailru_export_unsuccessfull_' . $key) . $value);
            }
        }
    }
    if (!empty($yml_offers)) {
        $yml_offers = fn_mailru_array_to_yml($yml_offers);
        fn_mailru_write_yml($options['filename'], 'a+', $yml_offers);
    }
    return true;
}
Ejemplo n.º 14
0
function fn_rbk_convert_price($price, $currency_to)
{
    if (CART_PRIMARY_CURRENCY != $currency_to) {
        $currencies = Registry::get('currencies');
        $currency = $currencies[$currency_to];
        $price = fn_format_rate_value($price, 'F', $currency['decimals'], '.', '', $currency['coefficient']);
    }
    return sprintf('%.2f', $price);
}
Ejemplo n.º 15
0
 protected function offer($product)
 {
     $yml_data = array();
     $offer_attrs = '';
     $market_categories = $this->getMarketCategories();
     if (!empty($product['yml_bid'])) {
         $offer_attrs .= '@bid=' . $product['yml_bid'];
     }
     if (!empty($product['yml_cbid'])) {
         $offer_attrs .= '@cbid=' . $product['yml_cbid'];
     }
     $price_fields = array('price', 'yml_cost', 'list_price', 'base_price');
     $currency_data = Registry::get('currencies.' . CART_PRIMARY_CURRENCY);
     foreach ($price_fields as $field) {
         $product[$field] = fn_format_price($product[$field], $currency_data['currency_code'], $currency_data['decimals'], false);
     }
     if (CART_PRIMARY_CURRENCY != "RUB" && CART_PRIMARY_CURRENCY != "UAH" && CART_PRIMARY_CURRENCY != "BYR" && CART_PRIMARY_CURRENCY != "KZT") {
         $currencies = Registry::get('currencies');
         if (isset($currencies['RUB'])) {
             $currency = $currencies['RUB'];
         } elseif (isset($currencies['UAH'])) {
             $currency = $currencies['UAH'];
         } elseif (isset($currencies['BYR'])) {
             $currency = $currencies['BYR'];
         } elseif (isset($currencies['KZT'])) {
             $currency = $currencies['KZT'];
         }
         if (!empty($currency)) {
             foreach ($price_fields as $field) {
                 $product[$field] = fn_format_rate_value($product[$field], 'F', $currency['decimals'], '.', '', $currency['coefficient']);
             }
         }
     }
     foreach ($price_fields as $field) {
         if (empty($product[$field])) {
             $product[$field] = floatval($product[$field]) ? $product[$field] : fn_parse_price($product[$field]);
         }
     }
     $yml_data['url'] = $product['product_url'];
     $yml_data['price'] = !empty($product['price']) ? $product['price'] : "0.00";
     if (!empty($product['base_price']) && $product['price'] < $product['base_price'] * 0.95) {
         $yml_data['oldprice'] = $product['base_price'];
     } elseif (!empty($product['list_price']) && $product['price'] < $product['list_price'] * 0.95) {
         $yml_data['oldprice'] = $product['list_price'];
     }
     $yml_data['currencyId'] = !empty($currency) ? $currency['currency_code'] : CART_PRIMARY_CURRENCY;
     $yml_data['categoryId'] = $product['category_id'];
     if ($this->options['market_category'] == "Y") {
         if ($this->options['market_category_object'] == "category" && isset($market_categories[$product['category_id']])) {
             $yml_data['market_category'] = $market_categories[$product['category_id']];
         } elseif ($this->options['market_category_object'] == "product" && !empty($product['yml_market_category'])) {
             $yml_data['market_category'] = $product['yml_market_category'];
         }
     }
     // Images
     $picture_index = 0;
     while ($image = array_shift($product['images'])) {
         $key = 'picture';
         if ($picture_index) {
             $key .= '+' . $picture_index;
         }
         $yml_data[$key] = $this->getImageUrl($image);
         $picture_index++;
     }
     $yml_data['store'] = $product['yml_store'] == 'Y' ? 'true' : 'false';
     $yml_data['pickup'] = $product['yml_pickup'] == 'Y' ? 'true' : 'false';
     $yml_data['delivery'] = $product['yml_delivery'] == 'Y' ? 'true' : 'false';
     if ($product['yml_adult'] == 'Y') {
         $yml_data['adult'] = 'true';
     }
     if ($this->options['local_delivery_cost'] == "Y") {
         $yml_data['local_delivery_cost'] = $product['yml_cost'] == 0 ? '0' : $product['yml_cost'];
     }
     $type = '';
     if ($this->options['export_type'] == 'vendor_model') {
         $type = '@type=vendor.model';
         if ($this->options['type_prefix'] == "Y") {
             if (!empty($product['yml_type_prefix'])) {
                 $yml_data['typePrefix'] = $product['yml_type_prefix'];
             } else {
                 $yml_data['typePrefix'] = $product['category'];
             }
         }
         $yml_data['vendor'] = $product['brand'];
         if ($this->options['export_vendor_code'] == 'Y') {
             $vendor_code = $this->getVendorCode($product);
             if (!empty($vendor_code)) {
                 $yml_data['vendorCode'] = $vendor_code;
             }
         }
         $yml_data['model'] = !empty($product['yml_model']) ? $product['yml_model'] : '';
     } elseif ($this->options['export_type'] == 'simple') {
         $yml_data['name'] = $product['product'];
         if (!empty($product['brand'])) {
             $yml_data['vendor'] = $product['brand'];
         }
         if ($this->options['export_vendor_code'] == 'Y') {
             $vendor_code = $this->getVendorCode($product);
             if (!empty($vendor_code)) {
                 $yml_data['vendorCode'] = $vendor_code;
             }
         }
     }
     if (!empty($product['full_description'])) {
         //Stripping the invalid chars
         $product['full_description'] = preg_replace('/[^\\x{0009}\\x{000A}\\x{000D}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}\\x{10000}-\\x{10FFFF}]/u', '', $product['full_description']);
         $yml_data['description'] = $product['full_description'];
     }
     if (!empty($product['yml_sales_notes'])) {
         $yml_data['sales_notes'] = $product['yml_sales_notes'];
     }
     if (!empty($product['yml_manufacturer_warranty'])) {
         $yml_data['manufacturer_warranty'] = $product['yml_manufacturer_warranty'];
     }
     if (!empty($product['yml_seller_warranty'])) {
         $yml_data['seller_warranty'] = $product['yml_seller_warranty'];
     }
     if (!empty($product['yml_origin_country']) && fn_yandex_market_check_country($product['yml_origin_country'])) {
         $yml_data['country_of_origin'] = $product['yml_origin_country'];
     }
     if (!empty($product['product_features'])) {
         foreach ($product['product_features'] as $feature) {
             $yml_data['param@name=' . $this->escape($feature['description'])] = $feature['value'];
         }
     }
     if ($product['amount'] > 0) {
         $avail = 'true';
     } else {
         $avail = 'false';
     }
     return array('offer@id=' . $product['product_id'] . $type . '@available=' . $avail . $offer_attrs, $yml_data);
 }
Ejemplo n.º 16
0
             $order['items'][] = array('title' => __('tax'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($tax['tax_subtotal'], 'F', 0, '.', '', ''));
         }
     }
 }
 $surcharge = isset($order_info['payment_surcharge']) ? intval($order_info['payment_surcharge']) : 0;
 if ($surcharge != 0) {
     $order['items'][] = array('title' => __('payment_surcharge'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($order_info['payment_surcharge'], 'F', 0, '.', '', ''));
 }
 $order['details'] = array('firstname' => $order_info['b_firstname'], 'lastname' => $order_info['b_lastname'], 'middlename' => '', 'email' => $order_info['email'], 'cellphone' => $order_info['b_phone']);
 $order['partnerId'] = $processor_data['processor_params']['kvk_shop_id'];
 $order['partnerName'] = Registry::get('settings.Company.company_name');
 $order['partnerOrderId'] = $kvk_order_id;
 $order['deliveryType'] = '';
 $base = base64_encode(json_encode($order));
 $sig = fn_rus_kupivkredit_hash_order($base, $processor_data['processor_params']['kvk_secret']);
 $order_total = fn_format_rate_value($order_info['total'], 'F', 2, '.', '', '');
 $view = Registry::get('view');
 $view->assign('order_id', $order_info['order_id']);
 $view->assign('data', $order);
 $view->assign('base', $base);
 $view->assign('sig', $sig);
 $view->assign('url', $url);
 $view->assign('order_total', $order_total);
 $view->assign('url_return', fn_url("payment_notification.close?payment=kupivkredit&order_id={$order_id}", AREA, 'current'));
 $view->assign('url_decision', fn_url("payment_notification.decision?payment=kupivkredit&order_id={$order_id}", AREA, 'current'));
 if (AREA == 'A') {
     $view->display('views/orders/components/kupivkredit.tpl');
 } else {
     $view->display('views/orders/processors/kupivkredit.tpl');
 }
 exit;
    function content_55d42e47d2cd88_81573964($_smarty_tpl)
    {
        if (!is_callable('smarty_block_hook')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/block.hook.php';
        }
        if (!is_callable('smarty_function_set_id')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.set_id.php';
        }
        fn_preload_lang_vars(array('text_gift_cert_amount_alert', 'recipients_name', 'purchasers_name', 'amount', 'gift_comment', 'text_no_products_defined', 'gift_add_products', 'how_to_send', 'send_via_email', 'send_via_postal_mail', 'email', 'template', 'phone', 'address', 'city', 'country', 'select_country', 'state', 'select_state', 'zip_postal_code', 'preview', 'purchase_gift_certificate', 'gift_certificate', 'text_gift_cert_amount_alert', 'recipients_name', 'purchasers_name', 'amount', 'gift_comment', 'text_no_products_defined', 'gift_add_products', 'how_to_send', 'send_via_email', 'send_via_postal_mail', 'email', 'template', 'phone', 'address', 'city', 'country', 'select_country', 'state', 'select_state', 'zip_postal_code', 'preview', 'purchase_gift_certificate', 'gift_certificate'));
        if ($_smarty_tpl->tpl_vars['runtime']->value['customization_mode']['design'] == "Y" && @constant('AREA') == "C") {
            $_smarty_tpl->_capture_stack[0][] = array("template_content", null, null);
            ob_start();
            $_smarty_tpl->tpl_vars["max_amount"] = new Smarty_variable($_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['max_amount']), 0));
            ?>

<?php 
            $_smarty_tpl->tpl_vars["min_amount"] = new Smarty_variable($_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount']), 0));
            ?>

<?php 
            $_smarty_tpl->tpl_vars["text_gift_cert_amount_alert"] = new Smarty_variable($_smarty_tpl->__("text_gift_cert_amount_alert", array("[min]" => $_smarty_tpl->tpl_vars['min_amount']->value, "[max]" => $_smarty_tpl->tpl_vars['max_amount']->value)), null, 0);
            ?>

<script type="text/javascript">
(function(_, $) {

    var max_amount = '<?php 
            echo strtr($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['max_amount'], array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/"));
            ?>
';
    var min_amount = '<?php 
            echo strtr($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount'], array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/"));
            ?>
';
    var send_via = '<?php 
            echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via']) === null || $tmp === '' ? "E" : $tmp, ENT_QUOTES, 'UTF-8');
            ?>
';

    $(document).ready(function() {

        $.ceFormValidator('registerValidator', {
            class_name: 'cm-gc-validate-amount',
            message: '',
            func: function(id) {
                var max = parseInt((parseFloat(max_amount) / parseFloat(_.currencies.secondary.coefficient))*100)/100;
                var min = parseInt((parseFloat(min_amount) / parseFloat(_.currencies.secondary.coefficient))*100)/100;

                var amount = parseFloat($('#' + id).val());
                if ((amount <= max) && (amount >= min)) {
                    return true;
                }

                return false;
            }
        }); 
        
        $('#' + (send_via == 'E' ? 'post' : 'email') + '_block').switchAvailability(true, true);

        $(_.doc).on('click', 'input[name="gift_cert_data[send_via]"]', function() {
            $('#email_block').switchAvailability($(this).val() == 'P', true);
            $('#post_block').switchAvailability($(this).val() == 'E', true);
        });
    });
}(Tygh, Tygh.$));
</script>

<?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profiles_scripts.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
            ?>



<div class="ty-gift-certificate">

<?php 
            if (!$_smarty_tpl->tpl_vars['config']->value['tweaks']['disable_dhtml'] && !$_smarty_tpl->tpl_vars['no_ajax']->value && $_smarty_tpl->tpl_vars['runtime']->value['mode'] != "update") {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["is_ajax"] = new Smarty_variable(true, null, 0);
            }
            ?>

<form <?php 
            if ($_smarty_tpl->tpl_vars['is_ajax']->value) {
                ?>
class="cm-ajax cm-ajax-full-render" <?php 
            }
            ?>
action="<?php 
            echo htmlspecialchars(fn_url(''), ENT_QUOTES, 'UTF-8');
            ?>
" method="post" target="_self" name="gift_certificates_form">
<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "update") {
                ?>
<input type="hidden" name="gift_cert_id" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_id']->value, ENT_QUOTES, 'UTF-8');
                ?>
" />
<input type="hidden" name="type" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['type']->value, ENT_QUOTES, 'UTF-8');
                ?>
" />
<?php 
            }
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['is_ajax']->value) {
                ?>
<input type="hidden" name="redirect_url" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['current_url'], ENT_QUOTES, 'UTF-8');
                ?>
" />
<?php 
            }
            ?>

<div class="ty-control-group">
    <label for="gift_cert_recipient" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("recipients_name");
            ?>
</label>
    <input type="text" id="gift_cert_recipient" name="gift_cert_data[recipient]" class="ty-input-text-full" size="50" maxlength="255" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['recipient'], ENT_QUOTES, 'UTF-8');
            ?>
" />
</div>

<div class="ty-control-group">
    <label for="gift_cert_sender" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("purchasers_name");
            ?>
</label>
    <input type="text" id="gift_cert_sender" name="gift_cert_data[sender]" class="ty-input-text-full" size="50" maxlength="255" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['sender'], ENT_QUOTES, 'UTF-8');
            ?>
" />
</div>

<div class="ty-control-group ty-gift-certificate__amount">
    <label for="gift_cert_amount" class="ty-control-group__title cm-required cm-gc-validate-amount"><?php 
            echo $_smarty_tpl->__("amount");
            ?>
</label>
    <span class="ty-gift-certificate__currency"><?php 
            echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['symbol'];
            ?>
</span>
    <input type="text" id="gift_cert_amount" name="gift_cert_data[amount]" class="ty-gift-certificate__amount-input cm-numeric" data-p-sign="s" data-a-sep="" data-a-dec="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals_separator'], ENT_QUOTES, 'UTF-8');
            ?>
" size="5" value="<?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value) {
                echo htmlspecialchars(fn_format_rate_value($_smarty_tpl->tpl_vars['gift_cert_data']->value['amount'], '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals'], ".", '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['coefficient']), ENT_QUOTES, 'UTF-8');
            } else {
                echo htmlspecialchars(fn_format_rate_value($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount'], '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals'], ".", '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['coefficient']), ENT_QUOTES, 'UTF-8');
            }
            ?>
" />
    
    <div class="ty-gift-certificate__amount-alert form-field-desc"><?php 
            echo $_smarty_tpl->tpl_vars['text_gift_cert_amount_alert']->value;
            ?>
</div>
</div>

<div class="ty-control-group">
    <label for="gift_cert_message" class="ty-control-group__title"><?php 
            echo $_smarty_tpl->__("gift_comment");
            ?>
</label>
    <textarea id="gift_cert_message" name="gift_cert_data[message]" cols="72" rows="4" class="ty-input-text-full" <?php 
            if ($_smarty_tpl->tpl_vars['is_text']->value == "Y") {
                ?>
readonly="readonly"<?php 
            }
            ?>
><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['message'], ENT_QUOTES, 'UTF-8');
            ?>
</textarea>
</div>

<?php 
            if ($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['free_products_allow'] == "Y") {
                ?>
    <div class="ty-gift-certificate__products ty-control-group">
        <?php 
                echo $_smarty_tpl->getSubTemplate("pickers/products/picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('data_id' => "free_products", 'item_ids' => $_smarty_tpl->tpl_vars['gift_cert_data']->value['products'], 'input_name' => "gift_cert_data[products]", 'type' => "table", 'no_item_text' => __("text_no_products_defined"), 'holder_name' => "gift_certificates", 'but_role' => "text", 'but_meta' => "ty-btn__tertiary", 'but_text' => __("gift_add_products"), 'no_container' => true, 'icon_plus' => true), 0);
                ?>

    </div>
<?php 
            }
            ?>

<div class="ty-gift-certificate__switch clearfix">
    <div class="ty-gift-certificate__switch-label gift-send-right"><?php 
            echo $_smarty_tpl->__("how_to_send");
            ?>
</div>
    <div class="ty-gift-certificate__switch-mail">
        <div class="ty-gift-certificate__send">
            <input type="radio" name="gift_cert_data[send_via]" value="E" <?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add" || $_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "E") {
                ?>
checked="checked"<?php 
            }
            ?>
 class="radio" id="sw_gc_switcher_suffix_e" /><label for="sw_gc_switcher_suffix_e" class="ty-valign"><?php 
            echo $_smarty_tpl->__("send_via_email");
            ?>
</label>
        </div>
        <div class="ty-gift-certificate__send">
            <input type="radio" name="gift_cert_data[send_via]" value="P" <?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "P") {
                ?>
checked="checked"<?php 
            }
            ?>
 class="radio" id="sw_gc_switcher_suffix_p" /><label for="sw_gc_switcher_suffix_p" class="ty-valign"><?php 
            echo $_smarty_tpl->__("send_via_postal_mail");
            ?>
</label>
        </div>
    </div>
</div>

<div id="gc_switcher">

    <div class="ty-gift-certificate__block <?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "P") {
                ?>
 hidden<?php 
            }
            ?>
" id="email_block">
        <div class="ty-control-group">
            <label for="gift_cert_email" class="cm-required cm-email ty-control-group__title"><?php 
            echo $_smarty_tpl->__("email");
            ?>
</label>
            <input type="text" id="gift_cert_email" name="gift_cert_data[email]" class="ty-input-text-full" size="40" maxlength="128" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['email'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>
        <div class="ty-control-group">
            <?php 
            if (sizeof($_smarty_tpl->tpl_vars['templates']->value) > 1) {
                ?>
                <label for="gift_cert_template" class="ty-control-group__title"><?php 
                echo $_smarty_tpl->__("template");
                ?>
</label>
                <select id="gift_cert_template" name="gift_cert_data[template]">
                <?php 
                $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["name"]->_loop = false;
                $_smarty_tpl->tpl_vars["file"] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['templates']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["name"]->key => $_smarty_tpl->tpl_vars["name"]->value) {
                    $_smarty_tpl->tpl_vars["name"]->_loop = true;
                    $_smarty_tpl->tpl_vars["file"]->value = $_smarty_tpl->tpl_vars["name"]->key;
                    ?>
                    <option value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['file']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" <?php 
                    if ($_smarty_tpl->tpl_vars['file']->value == $_smarty_tpl->tpl_vars['gift_cert_data']->value['template']) {
                        ?>
selected<?php 
                    }
                    ?>
><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8');
                    ?>
</option>
                <?php 
                }
                ?>
                </select>
            <?php 
            } else {
                ?>
                <?php 
                $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["name"]->_loop = false;
                $_smarty_tpl->tpl_vars["file"] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['templates']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["name"]->key => $_smarty_tpl->tpl_vars["name"]->value) {
                    $_smarty_tpl->tpl_vars["name"]->_loop = true;
                    $_smarty_tpl->tpl_vars["file"]->value = $_smarty_tpl->tpl_vars["name"]->key;
                    ?>
                    <input id="gift_cert_template" type="hidden" name="gift_cert_data[template]" value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['file']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" />
                <?php 
                }
                ?>
            <?php 
            }
            ?>
        </div>
    </div>

    <div class="ty-gift-certificate__block<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add" || $_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "E") {
                ?>
 hidden<?php 
            }
            ?>
" id="post_block">

        <div class="ty-control-group">
            <label for="gift_cert_phone" class="ty-control-group__title"><?php 
            echo $_smarty_tpl->__("phone");
            ?>
</label>
            <input type="text" id="gift_cert_phone" name="gift_cert_data[phone]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['phone'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <label for="gift_cert_address" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("address");
            ?>
</label>
            <input type="text" id="gift_cert_address" name="gift_cert_data[address]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['address'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <input type="text" id="gift_cert_address_2" name="gift_cert_data[address_2]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['address_2'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <label for="gift_cert_city" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("city");
            ?>
</label>
            <input type="text" id="gift_cert_city" name="gift_cert_data[city]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['city'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <?php 
            $_smarty_tpl->tpl_vars['_country'] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['country']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['settings']->value['General']['default_country'] : $tmp, null, 0);
            ?>
        <div class="ty-control-group ty-float-left ty-gift-certificate__country country">
            <label for="gift_cert_country" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("country");
            ?>
</label>
            <select id="gift_cert_country" name="gift_cert_data[country]" class="ty-gift-certificate__select cm-country cm-location-billing" >
                <option value="">- <?php 
            echo $_smarty_tpl->__("select_country");
            ?>
 -</option>
                <?php 
            $_smarty_tpl->tpl_vars["country"] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars["country"]->_loop = false;
            $_smarty_tpl->tpl_vars["code"] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['countries']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars["country"]->key => $_smarty_tpl->tpl_vars["country"]->value) {
                $_smarty_tpl->tpl_vars["country"]->_loop = true;
                $_smarty_tpl->tpl_vars["code"]->value = $_smarty_tpl->tpl_vars["country"]->key;
                ?>
                <option <?php 
                if ($_smarty_tpl->tpl_vars['_country']->value == $_smarty_tpl->tpl_vars['code']->value) {
                    ?>
selected="selected"<?php 
                }
                ?>
 value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['code']->value, ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['country']->value, ENT_QUOTES, 'UTF-8');
                ?>
</option>
                <?php 
            }
            ?>
            </select>
        </div>

        <?php 
            $_smarty_tpl->tpl_vars['_state'] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['state']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['settings']->value['General']['default_state'] : $tmp, null, 0);
            ?>
        <div class="ty-control-group ty-float-right ty-gift-certificate__state state">
            <label for="gift_cert_state" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("state");
            ?>
</label>
            <select class="ty-gift-certificate__select cm-state cm-location-billing" id="gift_cert_state" name="gift_cert_data[state]">
                <option value="">- <?php 
            echo $_smarty_tpl->__("select_state");
            ?>
 -</option>
                <?php 
            if ($_smarty_tpl->tpl_vars['states']->value && $_smarty_tpl->tpl_vars['states']->value[$_smarty_tpl->tpl_vars['_country']->value]) {
                ?>
                    <?php 
                $_smarty_tpl->tpl_vars['state'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['state']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['states']->value[$_smarty_tpl->tpl_vars['_country']->value];
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['state']->key => $_smarty_tpl->tpl_vars['state']->value) {
                    $_smarty_tpl->tpl_vars['state']->_loop = true;
                    ?>
                        <option value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['state']->value['code'], ENT_QUOTES, 'UTF-8');
                    ?>
" <?php 
                    if ($_smarty_tpl->tpl_vars['_state']->value == $_smarty_tpl->tpl_vars['state']->value['code']) {
                        ?>
selected="selected"<?php 
                    }
                    ?>
><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['state']->value['state'], ENT_QUOTES, 'UTF-8');
                    ?>
</option>
                    <?php 
                }
                ?>
                <?php 
            }
            ?>
            </select>
            <input type="text" id="gift_cert_state_d" name="gift_cert_data[state]" class="cm-state cm-location-billing ty-input-text hidden" size="50" maxlength="64" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['_state']->value, ENT_QUOTES, 'UTF-8');
            ?>
" disabled="disabled"  />
        </div>

        <div class="ty-control-group zipcode">
            <label for="gift_cert_zipcode" class="ty-control-group__title cm-required cm-zipcode cm-location-billing"><?php 
            echo $_smarty_tpl->__("zip_postal_code");
            ?>
</label>
            <input type="text" id="gift_cert_zipcode" name="gift_cert_data[zipcode]" class="ty-input-text-short" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['zipcode'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

    </div>

</div>

<div class="ty-gift-certificate__buttons buttons-container">

<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add") {
                ?>
    <input type="hidden" name="result_ids" value="cart_status*,wish_list*,account_info*" />
    <input type="hidden" name="redirect_url" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['current_url'], ENT_QUOTES, 'UTF-8');
                ?>
" />
    <?php 
                $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "gift_certificates:buttons"));
                $_block_repeat = true;
                echo smarty_block_hook(array('name' => "gift_certificates:buttons"), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    ?>

        <?php 
                    echo $_smarty_tpl->getSubTemplate("buttons/add_to_cart.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_name' => "dispatch[gift_certificates.add]", 'but_role' => "action"), 0);
                    ?>

    <?php 
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo smarty_block_hook(array('name' => "gift_certificates:buttons"), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
                ?>

<?php 
            } else {
                ?>
    <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/save.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_name' => "dispatch[gift_certificates.update]"), 0);
                ?>

<?php 
            }
            if ($_smarty_tpl->tpl_vars['templates']->value) {
                ?>
    <div class="ty-float-right ty-gift-certificate__preview-btn">
    <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_text' => __("preview"), 'but_name' => "dispatch[gift_certificates.preview]", 'but_role' => "submit", 'but_meta' => "ty-btn__tertiary cm-new-window"), 0);
                ?>

    </div>
<?php 
            }
            ?>
</div>

</form>
</div>


<?php 
            $_smarty_tpl->_capture_stack[0][] = array("mainbox_title", null, null);
            ob_start();
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add") {
                echo $_smarty_tpl->__("purchase_gift_certificate");
            } else {
                echo $_smarty_tpl->__("gift_certificate");
            }
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
            if (trim(Smarty::$_smarty_vars['capture']['template_content'])) {
                if ($_smarty_tpl->tpl_vars['auth']->value['area'] == "A") {
                    ?>
<span class="cm-template-box template-box" data-ca-te-template="addons/gift_certificates/views/gift_certificates/update.tpl" id="<?php 
                    echo smarty_function_set_id(array('name' => "addons/gift_certificates/views/gift_certificates/update.tpl"), $_smarty_tpl);
                    ?>
"><div class="cm-template-icon icon-edit ty-icon-edit hidden"></div><?php 
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                    ?>
<!--[/tpl_id]--></span><?php 
                } else {
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                }
            }
        } else {
            $_smarty_tpl->tpl_vars["max_amount"] = new Smarty_variable($_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['max_amount']), 0));
            ?>

<?php 
            $_smarty_tpl->tpl_vars["min_amount"] = new Smarty_variable($_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount']), 0));
            ?>

<?php 
            $_smarty_tpl->tpl_vars["text_gift_cert_amount_alert"] = new Smarty_variable($_smarty_tpl->__("text_gift_cert_amount_alert", array("[min]" => $_smarty_tpl->tpl_vars['min_amount']->value, "[max]" => $_smarty_tpl->tpl_vars['max_amount']->value)), null, 0);
            ?>

<script type="text/javascript">
(function(_, $) {

    var max_amount = '<?php 
            echo strtr($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['max_amount'], array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/"));
            ?>
';
    var min_amount = '<?php 
            echo strtr($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount'], array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\\/"));
            ?>
';
    var send_via = '<?php 
            echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via']) === null || $tmp === '' ? "E" : $tmp, ENT_QUOTES, 'UTF-8');
            ?>
';

    $(document).ready(function() {

        $.ceFormValidator('registerValidator', {
            class_name: 'cm-gc-validate-amount',
            message: '',
            func: function(id) {
                var max = parseInt((parseFloat(max_amount) / parseFloat(_.currencies.secondary.coefficient))*100)/100;
                var min = parseInt((parseFloat(min_amount) / parseFloat(_.currencies.secondary.coefficient))*100)/100;

                var amount = parseFloat($('#' + id).val());
                if ((amount <= max) && (amount >= min)) {
                    return true;
                }

                return false;
            }
        }); 
        
        $('#' + (send_via == 'E' ? 'post' : 'email') + '_block').switchAvailability(true, true);

        $(_.doc).on('click', 'input[name="gift_cert_data[send_via]"]', function() {
            $('#email_block').switchAvailability($(this).val() == 'P', true);
            $('#post_block').switchAvailability($(this).val() == 'E', true);
        });
    });
}(Tygh, Tygh.$));
</script>

<?php 
            echo $_smarty_tpl->getSubTemplate("views/profiles/components/profiles_scripts.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
            ?>



<div class="ty-gift-certificate">

<?php 
            if (!$_smarty_tpl->tpl_vars['config']->value['tweaks']['disable_dhtml'] && !$_smarty_tpl->tpl_vars['no_ajax']->value && $_smarty_tpl->tpl_vars['runtime']->value['mode'] != "update") {
                ?>
    <?php 
                $_smarty_tpl->tpl_vars["is_ajax"] = new Smarty_variable(true, null, 0);
            }
            ?>

<form <?php 
            if ($_smarty_tpl->tpl_vars['is_ajax']->value) {
                ?>
class="cm-ajax cm-ajax-full-render" <?php 
            }
            ?>
action="<?php 
            echo htmlspecialchars(fn_url(''), ENT_QUOTES, 'UTF-8');
            ?>
" method="post" target="_self" name="gift_certificates_form">
<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "update") {
                ?>
<input type="hidden" name="gift_cert_id" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_id']->value, ENT_QUOTES, 'UTF-8');
                ?>
" />
<input type="hidden" name="type" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['type']->value, ENT_QUOTES, 'UTF-8');
                ?>
" />
<?php 
            }
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['is_ajax']->value) {
                ?>
<input type="hidden" name="redirect_url" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['current_url'], ENT_QUOTES, 'UTF-8');
                ?>
" />
<?php 
            }
            ?>

<div class="ty-control-group">
    <label for="gift_cert_recipient" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("recipients_name");
            ?>
</label>
    <input type="text" id="gift_cert_recipient" name="gift_cert_data[recipient]" class="ty-input-text-full" size="50" maxlength="255" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['recipient'], ENT_QUOTES, 'UTF-8');
            ?>
" />
</div>

<div class="ty-control-group">
    <label for="gift_cert_sender" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("purchasers_name");
            ?>
</label>
    <input type="text" id="gift_cert_sender" name="gift_cert_data[sender]" class="ty-input-text-full" size="50" maxlength="255" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['sender'], ENT_QUOTES, 'UTF-8');
            ?>
" />
</div>

<div class="ty-control-group ty-gift-certificate__amount">
    <label for="gift_cert_amount" class="ty-control-group__title cm-required cm-gc-validate-amount"><?php 
            echo $_smarty_tpl->__("amount");
            ?>
</label>
    <span class="ty-gift-certificate__currency"><?php 
            echo $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['symbol'];
            ?>
</span>
    <input type="text" id="gift_cert_amount" name="gift_cert_data[amount]" class="ty-gift-certificate__amount-input cm-numeric" data-p-sign="s" data-a-sep="" data-a-dec="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals_separator'], ENT_QUOTES, 'UTF-8');
            ?>
" size="5" value="<?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value) {
                echo htmlspecialchars(fn_format_rate_value($_smarty_tpl->tpl_vars['gift_cert_data']->value['amount'], '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals'], ".", '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['coefficient']), ENT_QUOTES, 'UTF-8');
            } else {
                echo htmlspecialchars(fn_format_rate_value($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['min_amount'], '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['decimals'], ".", '', $_smarty_tpl->tpl_vars['currencies']->value[$_smarty_tpl->tpl_vars['secondary_currency']->value]['coefficient']), ENT_QUOTES, 'UTF-8');
            }
            ?>
" />
    
    <div class="ty-gift-certificate__amount-alert form-field-desc"><?php 
            echo $_smarty_tpl->tpl_vars['text_gift_cert_amount_alert']->value;
            ?>
</div>
</div>

<div class="ty-control-group">
    <label for="gift_cert_message" class="ty-control-group__title"><?php 
            echo $_smarty_tpl->__("gift_comment");
            ?>
</label>
    <textarea id="gift_cert_message" name="gift_cert_data[message]" cols="72" rows="4" class="ty-input-text-full" <?php 
            if ($_smarty_tpl->tpl_vars['is_text']->value == "Y") {
                ?>
readonly="readonly"<?php 
            }
            ?>
><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['message'], ENT_QUOTES, 'UTF-8');
            ?>
</textarea>
</div>

<?php 
            if ($_smarty_tpl->tpl_vars['addons']->value['gift_certificates']['free_products_allow'] == "Y") {
                ?>
    <div class="ty-gift-certificate__products ty-control-group">
        <?php 
                echo $_smarty_tpl->getSubTemplate("pickers/products/picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('data_id' => "free_products", 'item_ids' => $_smarty_tpl->tpl_vars['gift_cert_data']->value['products'], 'input_name' => "gift_cert_data[products]", 'type' => "table", 'no_item_text' => __("text_no_products_defined"), 'holder_name' => "gift_certificates", 'but_role' => "text", 'but_meta' => "ty-btn__tertiary", 'but_text' => __("gift_add_products"), 'no_container' => true, 'icon_plus' => true), 0);
                ?>

    </div>
<?php 
            }
            ?>

<div class="ty-gift-certificate__switch clearfix">
    <div class="ty-gift-certificate__switch-label gift-send-right"><?php 
            echo $_smarty_tpl->__("how_to_send");
            ?>
</div>
    <div class="ty-gift-certificate__switch-mail">
        <div class="ty-gift-certificate__send">
            <input type="radio" name="gift_cert_data[send_via]" value="E" <?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add" || $_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "E") {
                ?>
checked="checked"<?php 
            }
            ?>
 class="radio" id="sw_gc_switcher_suffix_e" /><label for="sw_gc_switcher_suffix_e" class="ty-valign"><?php 
            echo $_smarty_tpl->__("send_via_email");
            ?>
</label>
        </div>
        <div class="ty-gift-certificate__send">
            <input type="radio" name="gift_cert_data[send_via]" value="P" <?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "P") {
                ?>
checked="checked"<?php 
            }
            ?>
 class="radio" id="sw_gc_switcher_suffix_p" /><label for="sw_gc_switcher_suffix_p" class="ty-valign"><?php 
            echo $_smarty_tpl->__("send_via_postal_mail");
            ?>
</label>
        </div>
    </div>
</div>

<div id="gc_switcher">

    <div class="ty-gift-certificate__block <?php 
            if ($_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "P") {
                ?>
 hidden<?php 
            }
            ?>
" id="email_block">
        <div class="ty-control-group">
            <label for="gift_cert_email" class="cm-required cm-email ty-control-group__title"><?php 
            echo $_smarty_tpl->__("email");
            ?>
</label>
            <input type="text" id="gift_cert_email" name="gift_cert_data[email]" class="ty-input-text-full" size="40" maxlength="128" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['email'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>
        <div class="ty-control-group">
            <?php 
            if (sizeof($_smarty_tpl->tpl_vars['templates']->value) > 1) {
                ?>
                <label for="gift_cert_template" class="ty-control-group__title"><?php 
                echo $_smarty_tpl->__("template");
                ?>
</label>
                <select id="gift_cert_template" name="gift_cert_data[template]">
                <?php 
                $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["name"]->_loop = false;
                $_smarty_tpl->tpl_vars["file"] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['templates']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["name"]->key => $_smarty_tpl->tpl_vars["name"]->value) {
                    $_smarty_tpl->tpl_vars["name"]->_loop = true;
                    $_smarty_tpl->tpl_vars["file"]->value = $_smarty_tpl->tpl_vars["name"]->key;
                    ?>
                    <option value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['file']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" <?php 
                    if ($_smarty_tpl->tpl_vars['file']->value == $_smarty_tpl->tpl_vars['gift_cert_data']->value['template']) {
                        ?>
selected<?php 
                    }
                    ?>
><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8');
                    ?>
</option>
                <?php 
                }
                ?>
                </select>
            <?php 
            } else {
                ?>
                <?php 
                $_smarty_tpl->tpl_vars["name"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["name"]->_loop = false;
                $_smarty_tpl->tpl_vars["file"] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['templates']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["name"]->key => $_smarty_tpl->tpl_vars["name"]->value) {
                    $_smarty_tpl->tpl_vars["name"]->_loop = true;
                    $_smarty_tpl->tpl_vars["file"]->value = $_smarty_tpl->tpl_vars["name"]->key;
                    ?>
                    <input id="gift_cert_template" type="hidden" name="gift_cert_data[template]" value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['file']->value, ENT_QUOTES, 'UTF-8');
                    ?>
" />
                <?php 
                }
                ?>
            <?php 
            }
            ?>
        </div>
    </div>

    <div class="ty-gift-certificate__block<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add" || $_smarty_tpl->tpl_vars['gift_cert_data']->value['send_via'] == "E") {
                ?>
 hidden<?php 
            }
            ?>
" id="post_block">

        <div class="ty-control-group">
            <label for="gift_cert_phone" class="ty-control-group__title"><?php 
            echo $_smarty_tpl->__("phone");
            ?>
</label>
            <input type="text" id="gift_cert_phone" name="gift_cert_data[phone]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['phone'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <label for="gift_cert_address" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("address");
            ?>
</label>
            <input type="text" id="gift_cert_address" name="gift_cert_data[address]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['address'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <input type="text" id="gift_cert_address_2" name="gift_cert_data[address_2]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['address_2'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <div class="ty-control-group">
            <label for="gift_cert_city" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("city");
            ?>
</label>
            <input type="text" id="gift_cert_city" name="gift_cert_data[city]" class="ty-input-text-full" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['city'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

        <?php 
            $_smarty_tpl->tpl_vars['_country'] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['country']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['settings']->value['General']['default_country'] : $tmp, null, 0);
            ?>
        <div class="ty-control-group ty-float-left ty-gift-certificate__country country">
            <label for="gift_cert_country" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("country");
            ?>
</label>
            <select id="gift_cert_country" name="gift_cert_data[country]" class="ty-gift-certificate__select cm-country cm-location-billing" >
                <option value="">- <?php 
            echo $_smarty_tpl->__("select_country");
            ?>
 -</option>
                <?php 
            $_smarty_tpl->tpl_vars["country"] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars["country"]->_loop = false;
            $_smarty_tpl->tpl_vars["code"] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['countries']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars["country"]->key => $_smarty_tpl->tpl_vars["country"]->value) {
                $_smarty_tpl->tpl_vars["country"]->_loop = true;
                $_smarty_tpl->tpl_vars["code"]->value = $_smarty_tpl->tpl_vars["country"]->key;
                ?>
                <option <?php 
                if ($_smarty_tpl->tpl_vars['_country']->value == $_smarty_tpl->tpl_vars['code']->value) {
                    ?>
selected="selected"<?php 
                }
                ?>
 value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['code']->value, ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['country']->value, ENT_QUOTES, 'UTF-8');
                ?>
</option>
                <?php 
            }
            ?>
            </select>
        </div>

        <?php 
            $_smarty_tpl->tpl_vars['_state'] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['gift_cert_data']->value['state']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['settings']->value['General']['default_state'] : $tmp, null, 0);
            ?>
        <div class="ty-control-group ty-float-right ty-gift-certificate__state state">
            <label for="gift_cert_state" class="ty-control-group__title cm-required"><?php 
            echo $_smarty_tpl->__("state");
            ?>
</label>
            <select class="ty-gift-certificate__select cm-state cm-location-billing" id="gift_cert_state" name="gift_cert_data[state]">
                <option value="">- <?php 
            echo $_smarty_tpl->__("select_state");
            ?>
 -</option>
                <?php 
            if ($_smarty_tpl->tpl_vars['states']->value && $_smarty_tpl->tpl_vars['states']->value[$_smarty_tpl->tpl_vars['_country']->value]) {
                ?>
                    <?php 
                $_smarty_tpl->tpl_vars['state'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['state']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['states']->value[$_smarty_tpl->tpl_vars['_country']->value];
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['state']->key => $_smarty_tpl->tpl_vars['state']->value) {
                    $_smarty_tpl->tpl_vars['state']->_loop = true;
                    ?>
                        <option value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['state']->value['code'], ENT_QUOTES, 'UTF-8');
                    ?>
" <?php 
                    if ($_smarty_tpl->tpl_vars['_state']->value == $_smarty_tpl->tpl_vars['state']->value['code']) {
                        ?>
selected="selected"<?php 
                    }
                    ?>
><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['state']->value['state'], ENT_QUOTES, 'UTF-8');
                    ?>
</option>
                    <?php 
                }
                ?>
                <?php 
            }
            ?>
            </select>
            <input type="text" id="gift_cert_state_d" name="gift_cert_data[state]" class="cm-state cm-location-billing ty-input-text hidden" size="50" maxlength="64" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['_state']->value, ENT_QUOTES, 'UTF-8');
            ?>
" disabled="disabled"  />
        </div>

        <div class="ty-control-group zipcode">
            <label for="gift_cert_zipcode" class="ty-control-group__title cm-required cm-zipcode cm-location-billing"><?php 
            echo $_smarty_tpl->__("zip_postal_code");
            ?>
</label>
            <input type="text" id="gift_cert_zipcode" name="gift_cert_data[zipcode]" class="ty-input-text-short" size="50" value="<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['gift_cert_data']->value['zipcode'], ENT_QUOTES, 'UTF-8');
            ?>
" />
        </div>

    </div>

</div>

<div class="ty-gift-certificate__buttons buttons-container">

<?php 
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add") {
                ?>
    <input type="hidden" name="result_ids" value="cart_status*,wish_list*,account_info*" />
    <input type="hidden" name="redirect_url" value="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['current_url'], ENT_QUOTES, 'UTF-8');
                ?>
" />
    <?php 
                $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "gift_certificates:buttons"));
                $_block_repeat = true;
                echo smarty_block_hook(array('name' => "gift_certificates:buttons"), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    ?>

        <?php 
                    echo $_smarty_tpl->getSubTemplate("buttons/add_to_cart.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_name' => "dispatch[gift_certificates.add]", 'but_role' => "action"), 0);
                    ?>

    <?php 
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo smarty_block_hook(array('name' => "gift_certificates:buttons"), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
                ?>

<?php 
            } else {
                ?>
    <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/save.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_name' => "dispatch[gift_certificates.update]"), 0);
                ?>

<?php 
            }
            if ($_smarty_tpl->tpl_vars['templates']->value) {
                ?>
    <div class="ty-float-right ty-gift-certificate__preview-btn">
    <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_text' => __("preview"), 'but_name' => "dispatch[gift_certificates.preview]", 'but_role' => "submit", 'but_meta' => "ty-btn__tertiary cm-new-window"), 0);
                ?>

    </div>
<?php 
            }
            ?>
</div>

</form>
</div>


<?php 
            $_smarty_tpl->_capture_stack[0][] = array("mainbox_title", null, null);
            ob_start();
            if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "add") {
                echo $_smarty_tpl->__("purchase_gift_certificate");
            } else {
                echo $_smarty_tpl->__("gift_certificate");
            }
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
        }
    }