Example #1
0
 $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) {
         $order_info['sum_tax'] = $order_info['sum_tax'] + $data_tax['tax_subtotal'];
     }
 }
 $order_info['info_customer'] = "";
 if (!empty($order_info['payment_info'])) {
     if (!empty($order_info['payment_info']['organization_customer'])) {
         $order_info['info_customer'] .= $order_info['payment_info']['organization_customer'] . ' ';
     }
     if (!empty($order_info['payment_info']['inn_customer'])) {
         $order_info['info_customer'] .= __("inn_customer") . ': ' . $order_info['payment_info']['inn_customer'] . ' ';
     }
Example #2
0
function fn_correct_gift_certificate(&$gift_cert_data)
{
    $currencies = Registry::get('currencies');
    if (!empty($gift_cert_data['products'])) {
        foreach ($gift_cert_data['products'] as $product_id => $v) {
            if (!is_numeric($v['product_id'])) {
                unset($gift_cert_data['products'][$product_id]);
            }
        }
    }
    $min_amount = Registry::get('addons.gift_certificates.min_amount');
    $max_amount = Registry::get('addons.gift_certificates.max_amount');
    $gift_cert_data['amount'] = fn_format_price($gift_cert_data['amount']);
    // If this amount in BASE currencythan we should convert it to customer currency to compare
    if (!isset($gift_cert_data['correct_amount']) && $currencies[CART_SECONDARY_CURRENCY]['is_primary'] != 'Y') {
        $gift_cert_data['amount'] = fn_format_price_by_currency($gift_cert_data['amount'], CART_SECONDARY_CURRENCY, CART_PRIMARY_CURRENCY);
    }
    if ($gift_cert_data['amount'] > $max_amount || $gift_cert_data['amount'] < $min_amount) {
        $gift_cert_data['amount'] = $gift_cert_data['amount'] > $max_amount ? $max_amount : $min_amount;
        // Correct the values for customer currency view
        if ($currencies[CART_SECONDARY_CURRENCY]['is_primary'] != 'Y') {
            // By default this function converts from PRIMARY_CURRENCY to CART_SECONDARY_CURRENCY
            $min_amount = fn_format_price_by_currency($min_amount);
            $max_amount = fn_format_price_by_currency($max_amount);
        }
        fn_set_notification('N', __('notice'), __('gift_cert_amount_changed') . "<br />" . __('text_gift_cert_amount_alert', array('[min]' => $min_amount, '[max]' => $max_amount)));
    }
    $gift_cert_data['http_location'] = Registry::get('config.http_location');
    if (fn_allowed_for('ULTIMATE') && !empty($gift_cert_data['gift_cert_code'])) {
        $company_location = db_get_field('SELECT ?:companies.storefront FROM ?:companies JOIN ?:gift_certificates ON ?:gift_certificates.gift_cert_code = ?s AND ?:companies.company_id = ?:gift_certificates.company_id', $gift_cert_data['gift_cert_code']);
        $gift_cert_data['http_location'] = !empty($company_location) ? 'http://' . $company_location : $gift_cert_data['http_location'];
    }
}
Example #3
0
function fn_qwintry_get_price($price)
{
    $currencies = array_keys(fn_get_currencies());
    if (in_array('USD', $currencies)) {
        $price = fn_format_price_by_currency($price, CART_PRIMARY_CURRENCY, 'USD');
    } elseif (CART_PRIMARY_CURRENCY == 'EUR') {
        $price = $price * 1.097;
    } elseif (CART_PRIMARY_CURRENCY == 'RMB') {
        $price = $price * 1.157;
    }
    return $price;
}
Example #4
0
/**
 * Generate title string for order details page
 *
 * @param int $order_id order identifier
 * @return string
 */
function fn_get_order_name($order_id)
{
    $total = db_get_field("SELECT total FROM ?:orders WHERE order_id = ?i", $order_id);
    if ($total == '') {
        return false;
    }
    if (Registry::get('settings.General.alternative_currency') == 'use_selected_and_alternative') {
        $result = fn_format_price_by_currency($total, CART_PRIMARY_CURRENCY);
        if (CART_SECONDARY_CURRENCY != CART_PRIMARY_CURRENCY) {
            $result .= ' (' . fn_format_price_by_currency($total) . ')';
        }
    } else {
        $result = fn_format_price_by_currency($total);
    }
    return $order_id . ' - ' . $result;
}
Example #5
0
function ls_minicart_generate_markup($ls_cart_product, $hash)
{
    $base_url = fn_ls_get_base_url();
    //get thumbnail path
    //   $image_relative_path = fn_get_image_pairs($ls_cart_product['product_id'], 'product', 'M', true, true, CART_LANGUAGE);
    //    $image_relative_path=$image_relative_path['detailed']['relative_path'];
    $image_relative_path = fn_get_cart_product_icon($ls_cart_product['product_id'], $ls_cart_product, true);
    $image_relative_path = $image_relative_path['detailed']['relative_path'];
    $thumbnail_path = fn_generate_thumbnail($image_relative_path, 120, null, false);
    if (!empty($thumbnail_path)) {
        $ls_product_image = "<img class='ty-pict' src='{$thumbnail_path}'>";
    } else {
        $ls_product_image = "<span class='ty-no-image' style='min-width: 120px; min-height: 168px;'><i class='ty-no-image__icon ty-icon-image'></i></span>";
    }
    //format price
    $ls_product_price = $ls_cart_product['price'];
    $ls_product_price = fn_format_price_by_currency($ls_product_price);
    //generate product options
    $ls_cart_options = "";
    foreach ($ls_cart_product['ls_minicart_options'] as $k => $option) {
        if ($_SESSION['settings']['cart_languageC']['value'] === 'en') {
            if (isset($option[0]['variant_name'])) {
                $ls_cart_options = $ls_cart_options . "<span class='ty-product-options clearfix'>\n                <span class='ty-product-options-name ls_minicart_option_name'>{$option[0]['option_name']}:&nbsp;</span>\n                <span class='ty-product-options-content ls_minicart_variant_name'>{$option[0]['variant_name']}&nbsp;</span>\n                </span>";
            }
        } else {
            if (isset($option[1]['variant_name'])) {
                $ls_cart_options = $ls_cart_options . "<span class='ty-product-options clearfix'>\n                <span class='ty-product-options-name ls_minicart_option_name'>{$option[1]['option_name']}:&nbsp;</span>\n                <span class='ty-product-options-content ls_minicart_variant_name'>{$option[1]['variant_name']}&nbsp;</span>\n                </span>";
            }
        }
    }
    //generate product options
    //$ls_move_form_options="<span class='ls_move_to_wishlist'>add_to_wishlist</span>";
    $ls_move_form_options = "<input type='hidden' name='product_data[{$ls_cart_product['product_id']}][product_id]' value='{$ls_cart_product['product_id']}'>";
    $ls_move_form_options .= "<input type='hidden' name='ls_move_to' value='wishlist'>";
    $ls_move_form_options .= "<input type='hidden' name='ls_cart_combination_hash' value='{$hash}'>";
    foreach ($ls_cart_product['product_options'] as $option_id => $option) {
        $ls_move_form_options .= "<input type='hidden' name='product_data[{$ls_cart_product['product_id']}][product_options][{$option_id}]' value='{$option}'>";
    }
    $ls_move_form_options .= "<span class='ls_move_to_wishlist'>add_to_wishlist</span>";
    //return the html
    if (!empty($ls_cart_product['product_options'])) {
        $markup = "<li class='ty-cart-items__list-item'>\n            <span style='display: none' class='ls_cart_combination_hash'>{$hash}</span>\n            <span style='display: none' class='ls_cart_combination_id'>{$ls_cart_product['product_id']}</span>\n            <div class='ty-cart-items__list-item-desc'>\n                <a href='{$base_url}/?dispatch=products.view?product_id={$ls_cart_product['product_id']}&wishlist_id={$hash}'>{$ls_cart_product['product']}</a>\n                <p>\n                    <span class='ls_cart_product_amount'>{$ls_cart_product['amount']}</span><span>&nbsp;x&nbsp;</span><span>{$ls_product_price}</span>\n                </p>\n                <div class='row-fluid'>\n                    <span class='span4'>\n                        <div class='ty-cart-items__list-item-image ls_cart_product_image'>\n                            {$ls_product_image}\n                        </div>\n                    </span>\n                            <form class='ls_move_to_wishlist_form'>\n                                {$ls_move_form_options}\n                            </form>\n                    <!--div class='ls_cart_options'-->\n                    <span class='span8'>\n                        <div class='ty-control-group ty-product-options__info clearfix'>\n                        <!--div class='ls_cart_options_title'--><label class='ty-product-options__title'>Optiuni:</label><!--/div-->                                    \n                       {$ls_cart_options}\n                        </div>\n                    </span>\n                    <!--/div-->\n                <div/>\n            </div>\n                <div class='ty-cart-items__list-item-tools cm-cart-item-delete'>\n                        <a data-ca-dispatch='delete_cart_item' href='{$base_url}/index.php?dispatch=checkout.delete.from_status&amp;cart_id={$hash}' class='cm-ajax ls_delete_icon' data-ca-target-id='cart_status*'><i title='Ştergeţi' class='ty-icon-cancel-circle'></i></a>\n                </div>\n        </li>";
    } else {
        $markup = "<li class='ty-cart-items__list-item'>\n            <span style='display: none' class='ls_cart_combination_hash'>{$hash}</span>\n            <span style='display: none' class='ls_cart_combination_id'>{$ls_cart_product['product_id']}</span>\n            <div class='ty-cart-items__list-item-desc'>\n                <a href='{$base_url}/?dispatch=products.view?product_id={$ls_cart_product['product_id']}&wishlist_id={$hash}'>{$ls_cart_product['product']}</a>\n                <p>\n                    <span class='ls_cart_product_amount'>{$ls_cart_product['amount']}</span><span>&nbsp;x&nbsp;</span><span>{$ls_product_price}</span>\n                </p>\n                <div class='row-fluid'>\n                <span class='span4'>\n                    <div class='ty-cart-items__list-item-image'>\n                        {$ls_product_image}\n                    </div>\n                </span>\n                <form class='ls_move_to_wishlist_form'>\n                                {$ls_move_form_options}\n                </form>\n                <span class='span8'>\n                    <!--div class='ls_cart_options'-->\n                        <div class='ty-control-group ty-product-options__info clearfix'>\n                        </div>\n                    <!--/div-->\n                </span>    \n                </div>\n            </div>\n                <div class='ty-cart-items__list-item-tools cm-cart-item-delete'>\n                        <a data-ca-dispatch='delete_cart_item' href='{$base_url}/index.php?dispatch=checkout.delete.from_status&amp;cart_id={$hash}' class='cm-ajax ls_delete_icon' data-ca-target-id='cart_status*'><i title='Ştergeţi' class='ty-icon-cancel-circle'></i></a>\n                </div>\n        </li>";
    }
    return $markup;
}
Example #6
0
            Tygh::$app['view']->assign('order_action', __('text_paypal_processing_payment'));
            Tygh::$app['view']->display('views/orders/components/placing_order.tpl');
            fn_flush();
        }
    } elseif ($mode == 'cancel') {
        $pp_response['order_status'] = 'N';
        $pp_response['reason_text'] = __('text_transaction_cancelled');
        fn_finish_payment($order_id, $pp_response, false);
        fn_order_placement_routines('route', $order_id);
    } elseif ($mode == 'finish') {
        fn_order_placement_routines('route', $order_id);
    }
    exit;
} else {
    $currency = fn_paypal_get_valid_currency($processor_data['processor_params']['currency']);
    $paypal_total = fn_format_price_by_currency($order_info['total'], CART_PRIMARY_CURRENCY, $currency['code']);
    $cancel_url = fn_url("payment_notification.cancel?payment=paypal_advanced&order_id={$order_id}");
    $post_data = array('VENDOR' => $processor_data['processor_params']['merchant_login'], 'PARTNER' => $processor_data['processor_params']['api_partner'], 'USER' => $processor_data['processor_params']['api_user'], 'PWD' => $processor_data['processor_params']['api_password'], 'TRXTYPE' => 'S', 'BUTTONSOURCE' => 'ST_ShoppingCart_DP_US', 'AMT' => $paypal_total, 'TENDER' => 'C', 'CREATESECURETOKEN' => 'Y', 'SECURETOKENID' => uniqid(rand()), 'DISABLERECEIPT' => 'TRUE', 'RETURNURL' => fn_url("payment_notification.return?payment=paypal_advanced&order_id={$order_id}&security_hash=" . fn_generate_security_hash()), 'CANCELURL' => $cancel_url, 'ERRORURL' => fn_url("payment_notification.return?payment=paypal_advanced&order_id={$order_id}&security_hash=" . fn_generate_security_hash()), 'URLMETHOD' => 'POST', 'TEMPLATE' => $processor_data['processor_params']['layout'], 'PAGECOLLAPSEBGCOLOR' => $processor_data['processor_params']['collapse_bg_color'], 'PAGECOLLAPSETEXTCOLOR' => $processor_data['processor_params']['collapse_text_color'], 'PAGEBUTTONBGCOLOR' => $processor_data['processor_params']['button_bgcolor'], 'PAGEBUTTONTEXTCOLOR' => $processor_data['processor_params']['button_text_color'], 'BUTTONTEXT' => $processor_data['processor_params']['label_text_color'], 'PAYFLOWCOLOR' => $processor_data['processor_params']['payflowcolor'], 'HDRIMG' => $processor_data['processor_params']['header_image'], 'BILLTOFIRSTNAME' => $order_info['b_firstname'], 'BILLTOLASTNAME' => $order_info['b_lastname'], 'BILLTOSTREET' => $order_info['b_address'], 'BILLTOCITY' => $order_info['b_city'], 'BILLTOSTATE' => fn_pp_get_state($order_info, 'b_'), 'BILLTOZIP' => $order_info['b_zipcode'], 'BILLTOCOUNTRY' => $order_info['b_country'], 'SHIPTOFIRSTNAME' => $order_info['s_firstname'], 'SHIPTOLASTNAME' => $order_info['s_firstname'], 'SHIPTOSTREET' => $order_info['s_address'], 'SHIPTOCITY' => $order_info['s_city'], 'SHIPTOSTATE' => fn_pp_get_state($order_info, 's_'), 'SHIPTOZIP' => $order_info['s_zipcode'], 'SHIPTOCOUNTRY' => $order_info['s_country'], 'EMAIL' => $order_info['email'], 'PHONENUM' => $order_info['phone'], 'CURRENCY' => $currency['code']);
    $result = fn_pp_request($post_data, $processor_data['processor_params']['testmode']);
    if ($result['RESULT'] == '0') {
        $query_data = array('SECURETOKEN' => $result['SECURETOKEN'], 'SECURETOKENID' => $result['SECURETOKENID'], 'MODE' => $processor_data['processor_params']['testmode'] == 'Y' ? 'TEST' : '');
        $iframe_url = 'https://payflowlink.paypal.com/?' . http_build_query($query_data);
        Tygh::$app['view']->assign('iframe_url', $iframe_url);
        Tygh::$app['view']->assign('cancel_url', $cancel_url);
        Tygh::$app['view']->display('views/checkout/processors/paypal_advanced.tpl');
        exit;
    } else {
        $pp_response['order_status'] = 'F';
        $pp_response["reason_text"] = 'RESULT:' . $result['RESULT'] . '; RESPMSG:' . $result['RESPMSG'];
    }
}
Example #7
0
 /**
  * Prepare request information
  *
  * @return array Prepared data
  */
 public function getRequestData()
 {
     $weight_data = fn_expand_weight($this->_shipping_info['package_info']['W']);
     $package_cost = $this->_shipping_info['package_info']['C'];
     $shipping_settings = $this->_shipping_info['service_params'];
     $pounds = $weight_data['pounds'];
     $location = $this->_shipping_info['package_info']['location'];
     $type = $this->_get_type();
     $currencies = array_keys(fn_get_currencies());
     if (in_array('USD', $currencies)) {
         $package_cost = fn_format_price_by_currency($package_cost, CART_PRIMARY_CURRENCY, 'USD');
     } elseif (CART_PRIMARY_CURRENCY == 'EUR') {
         $package_cost = $package_cost * 1.097;
     } elseif (CART_PRIMARY_CURRENCY == 'RMB') {
         $package_cost = $package_cost * 1.157;
     }
     if ($type == 'courier') {
         $data = array('params' => array('method' => 'qwair', 'hub_code' => empty($shipping_settings['hub']) ? 'DE1' : $shipping_settings['hub'], 'insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'addr_country' => $location['country'], 'addr_zip' => $location['zipcode'], 'addr_line1' => $location['address'], 'addr_line2' => empty($location['address_2']) ? '' : $location['address_2'], 'addr_city' => $location['city'], 'addr_state' => fn_get_state_name($location['state'], $location['country'])));
     } elseif ($type == 'pickup') {
         $data = array('params' => array('insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'delivery_pickup' => $this->_get_pickup_point()));
     }
     $request_data = array('method' => 'get', 'url' => 'cost', 'data' => $data);
     return $request_data;
 }
function fn_paypal_build_details($data, $processor_data, $express = true)
{
    $currency = fn_paypal_get_valid_currency($processor_data['processor_params']['currency']);
    if ($currency['code'] == CART_PRIMARY_CURRENCY) {
        $details = array();
        $shipping_data = array();
        if (!empty($processor_data['processor_params']['send_adress']) && $processor_data['processor_params']['send_adress'] == 'Y') {
            if ($express) {
                $shipping_data = fn_paypal_get_shipping_data($data['user_data']);
            } else {
                $shipping_data = fn_paypal_get_shipping_data($data);
            }
        }
        $order_data = fn_paypal_get_order_data($data);
        return array_merge($details, $shipping_data, $order_data);
    } else {
        $total = fn_format_price_by_currency($data['total'], CART_PRIMARY_CURRENCY, $currency['code']);
        return array('L_PAYMENTREQUEST_0_NAME0' => __('total_product_cost'), 'L_PAYMENTREQUEST_0_NUMBER0' => 'ORDER_ID_' . (isset($data['order_id']) ? $data['order_id'] : 'NEW'), 'L_PAYMENTREQUEST_0_DESC0' => '', 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_AMT0' => $total, 'PAYMENTREQUEST_0_ITEMAMT' => $total, 'PAYMENTREQUEST_0_TAXAMT' => 0, 'PAYMENTREQUEST_0_SHIPPINGAMT' => 0, 'PAYMENTREQUEST_0_AMT' => $total);
    }
}
Example #9
0
function fn_pp_standart_prepare_products($order_info, $paypal_currency = '', $max_pp_products = MAX_PAYPAL_PRODUCTS)
{
    if (empty($paypal_currency)) {
        $paypal_currency = !empty($order_info['payment_method']['processor_params']['currency']) ? $order_info['payment_method']['processor_params']['currency'] : CART_PRIMARY_CURRENCY;
    }
    $currency = fn_paypal_get_valid_currency($paypal_currency);
    $post_data = array();
    $product_count = 1;
    $paypal_currency = $currency['code'];
    if ($paypal_currency != CART_PRIMARY_CURRENCY) {
        $post_data['item_name_1'] = __('total_product_cost');
        $post_data['amount_1'] = fn_format_price_by_currency($order_info['total'], CART_PRIMARY_CURRENCY, $paypal_currency);
        $post_data['quantity_1'] = '1';
        return array($post_data, 1);
    }
    $paypal_shipping = fn_order_shipping_cost($order_info);
    $paypal_total = fn_format_price($order_info['total'] - $paypal_shipping, $paypal_currency);
    if (empty($order_info['use_gift_certificates']) && !floatval($order_info['subtotal_discount']) && empty($order_info['points_info']['in_use']) && count($order_info['products']) < MAX_PAYPAL_PRODUCTS) {
        $i = 1;
        if (!empty($order_info['products'])) {
            foreach ($order_info['products'] as $k => $v) {
                $suffix = '_' . $i++;
                $v['product'] = htmlspecialchars(strip_tags($v['product']));
                $v['price'] = fn_format_price(($v['subtotal'] - fn_external_discounts($v)) / $v['amount'], $paypal_currency);
                $post_data["item_name{$suffix}"] = $v['product'];
                $post_data["amount{$suffix}"] = $v['price'];
                $post_data["quantity{$suffix}"] = $v['amount'];
                if (!empty($v['product_options'])) {
                    foreach ($v['product_options'] as $_k => $_v) {
                        $_v['option_name'] = htmlspecialchars(strip_tags($_v['option_name']));
                        $_v['variant_name'] = htmlspecialchars(strip_tags($_v['variant_name']));
                        $post_data["on{$_k}{$suffix}"] = $_v['option_name'];
                        $post_data["os{$_k}{$suffix}"] = $_v['variant_name'];
                    }
                }
            }
        }
        if (!empty($order_info['taxes']) && Registry::get('settings.General.tax_calculation') == 'subtotal') {
            foreach ($order_info['taxes'] as $tax_id => $tax) {
                if ($tax['price_includes_tax'] == 'Y') {
                    continue;
                }
                $suffix = '_' . $i++;
                $item_name = htmlspecialchars(strip_tags($tax['description']));
                $item_price = fn_format_price($tax['tax_subtotal'], $paypal_currency);
                $post_data["item_name{$suffix}"] = $item_name;
                $post_data["amount{$suffix}"] = $item_price;
                $post_data["quantity{$suffix}"] = '1';
            }
        }
        // Gift Certificates
        if (!empty($order_info['gift_certificates'])) {
            foreach ($order_info['gift_certificates'] as $k => $v) {
                $suffix = '_' . $i++;
                $v['gift_cert_code'] = htmlspecialchars($v['gift_cert_code']);
                $v['amount'] = !empty($v['extra']['exclude_from_calculate']) ? 0 : fn_format_price($v['amount'], $paypal_currency);
                $post_data["item_name{$suffix}"] = $v['gift_cert_code'];
                $post_data["amount{$suffix}"] = $v['amount'];
                $post_data["quantity{$suffix}"] = '1';
            }
        }
        if (fn_allowed_for('MULTIVENDOR') && fn_take_payment_surcharge_from_vendor('')) {
            $take_surcharge = false;
        } else {
            $take_surcharge = true;
        }
        // Payment surcharge
        if ($take_surcharge && floatval($order_info['payment_surcharge'])) {
            $suffix = '_' . $i++;
            $name = __('surcharge');
            $payment_surcharge_amount = fn_format_price($order_info['payment_surcharge'], $paypal_currency);
            $post_data["item_name{$suffix}"] = $name;
            $post_data["amount{$suffix}"] = $payment_surcharge_amount;
            $post_data["quantity{$suffix}"] = '1';
        }
        $product_count = $i - 1;
    } elseif ($paypal_total <= 0) {
        $post_data['item_name_1'] = __('total_product_cost');
        $post_data['amount_1'] = fn_format_price($order_info['total'], $paypal_currency);
        $post_data['quantity_1'] = '1';
        $post_data['amount'] = fn_format_price($order_info['total'], $paypal_currency);
        $post_data['shipping_1'] = 0;
    } else {
        $post_data['item_name_1'] = __('total_product_cost');
        $post_data['amount_1'] = $paypal_total;
        $post_data['quantity_1'] = '1';
    }
    return array($post_data, $product_count);
}
Example #10
0
    }
    exit;
} elseif ($mode == 'updateCartNo') {
    // echo var_dump($_SESSION[cart][products]);
    $ammount = 0;
    foreach ($_SESSION[cart][products] as $k0 => $v0) {
        if (isset($v0["amount_total"])) {
            $ammount = $ammount + $v0['amount'];
        }
    }
    $response['ammount'] = $ammount;
    //$response['subtotal']=$_SESSION[cart]["subtotal"];
    $ls_subtotal = $_SESSION[cart]["subtotal"];
    //get the subtotal of the primary currency
    //format the subtotal acording to the selected currency
    $ls_subtotal = fn_format_price_by_currency($ls_subtotal);
    $response['subtotal'] = $ls_subtotal;
    echo json_encode($response);
    exit;
} elseif ($mode == 'lsAvailableProducts') {
    $product_id = $_REQUEST['product_id'];
    $combination_hash = $_REQUEST['combination_hash'];
    $ls_deleted_product = db_get_array("SELECT cscart_products.amount, cscart_products.tracking, \n        cscart_product_options_inventory.amount AS inventory_amount FROM cscart_products\n        JOIN cscart_product_options_inventory ON cscart_products.product_id=cscart_product_options_inventory.product_id WHERE\n        cscart_products.product_id = ?i AND cscart_product_options_inventory.combination_hash = ?i\n     ", $product_id, $combination_hash);
    if ($ls_deleted_product[0]['tracking'] === 'O') {
        $available_products = $ls_deleted_product[0]['inventory_amount'];
    } elseif ($ls_deleted_product[0]['tracking'] === 'B') {
        $available_products = $ls_deleted_product[0]['amount'];
    } else {
        //no tracking, don't display any availability message
        $available_products = 'no tracking';
    }
Example #11
0
 /**
  * Gets shipping cost and information about possible errors
  *
  * @param string $response
  * @internal param string $resonse Reponse from Shipping service server
  * @return array Shipping cost and errors
  */
 public function processResponse($response)
 {
     $return = array('cost' => false, 'error' => false, 'delivery_time' => false);
     $response = json_decode($response, true);
     $service_params = $this->_shipping_info['service_params'];
     if ($service_params['display_type'] = 'CMS') {
         $this->processCms($response, $service_params, $return);
     } else {
         $this->processWidget($response, $service_params, $return);
     }
     if (CART_PRIMARY_CURRENCY != 'RUB') {
         $return['cost'] = fn_format_price_by_currency($return['cost'], 'RUB', CART_PRIMARY_CURRENCY);
     }
     return $return;
 }