<?php
/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@buy-addons.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    Buy-Addons <contact@buy-addons.com>
*  @copyright 2007-2020 PrestaShop SA
*  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
* @since 1.6
*/

class AskforaquotemodulbeforegetshippingModuleFrontController extends ModuleFrontController
{
    public function run()
    {
        parent::init();
        parent::initHeader();
        parent::initContent();
        $quote_module_token = Tools::getValue('quote_token');
        if ($quote_module_token != md5(sha1(_COOKIE_KEY_.'askforaquotemodul'))) {
            die;
        }
        $array_tmp = array();
        echo Tools::jsonEncode($array_tmp);
    }
    public function convertToArrayRowProduct($row_product)
    {
        $result = array();
        $row_product = ltrim($row_product, '|');
        $row_product = explode('|', $row_product);
        $total_price = 0;
        foreach ($row_product as $key_row_product => $value_row_product) {
            $value_row_product = explode('-', $value_row_product);
            foreach ($value_row_product as $key_vrp => $value_vrp) {
                if ($key_vrp == 0) {
                    $result[$key_row_product]['id_product'] = $value_vrp;
                }
                if ($key_vrp == 1) {
                    $result[$key_row_product]['id_combination'] = $value_vrp;
                }
                if ($key_vrp == 2) {
                    $result[$key_row_product]['price_product'] = Tools::ps_round($value_vrp, 4);
                }
                if ($key_vrp == 3) {
                    $result[$key_row_product]['quantity'] = $value_vrp;
                }
                if ($key_vrp == 4) {
                    $result[$key_row_product]['total_price_product'] = Tools::ps_round($value_vrp, 4);
                    $total_price += (float) Tools::ps_round($value_vrp, 4);
                }
            }
        }
        $result['total_price'] = $total_price;
        $result['total_tax'] = 0;
        return $result;
    }
}
