Jump to content

Edit History

manioart

manioart

I have this code in priceCalculation method i Product.php:

 

$attributes['width'] = $_GET['width'];
        $attributes['height'] = $_GET['height'];

        $price = ppbs::get_price($id_product, $attributes, $use_tax);

        $price = Tools::ps_round($price, $decimals);

        if ($price < 0) {
            $price = 0;
        }


        self::$_prices[$cache_id] = $price;

        return self::$_prices[$cache_id];

And i prices.tpl:

function delay(callback, ms) {
        var timer = 0;
        return function() {
            var context = this, args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function () {
                callback.apply(context, args);
            }, ms || 0);
        };
    }
    var width = 1;
    var height = 1;
    $(document).ready(function() {
        $("#height").on("input", delay(function (e) {
            height = $('#height').val();
          },500)),
            $("#width").on("input", delay(function (e) {
                width = $('#width').val();
                console.log(height);
                $.ajax({
                    url: 'index.php?controller=product&token=' + prestashop.token + '&id_product=' + {$product.id_product} + '&width=' + width + '&height=' + height,
                    data: { height: height, width: width, ajax: 1,
                        action: 'refresh' },
                    type: 'POST',
                    success: function(result) {
                            if (typeof result ==='object') {
                                if (typeof result.product_details !== 'undefined') {
                                    // if you keep the same classes and ids as in theme product.tpl then you can simply

                                    $(".product-prices").replaceWith(result.product_prices);
                                }

                            }}
            },500)}))

The price was reloaded in product page when i change width and height, but in cart price is not changed.

 

Please help me

Thanks for all support replies

manioart

manioart

I have this code in priceCalculation method i Product.php:

 

$attributes['width'] = $_GET['width'];
        $attributes['height'] = $_GET['height'];

        $price = ppbs::get_price($id_product, $attributes, $use_tax);

        $price = Tools::ps_round($price, $decimals);

        if ($price < 0) {
            $price = 0;
        }


        self::$_prices[$cache_id] = $price;

        return self::$_prices[$cache_id];

And i prices.tpl:

function delay(callback, ms) {
        var timer = 0;
        return function() {
            var context = this, args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function () {
                callback.apply(context, args);
            }, ms || 0);
        };
    }
    var width = 1;
    var height = 1;
    $(document).ready(function() {
        $("#height").on("input", delay(function (e) {
            height = $('#height').val();
          },500)),
            $("#width").on("input", delay(function (e) {
                width = $('#width').val();
                console.log(height);
                $.ajax({
                    url: 'index.php?controller=product&token=' + prestashop.token + '&id_product=' + {$product.id_product} + '&width=' + width + '&height=' + height,
                    data: { height: height, width: width, ajax: 1,
                        action: 'refresh' },
                    type: 'POST',
                    success: function(result) {
                            if (typeof result ==='object') {
                                if (typeof result.product_details !== 'undefined') {
                                    // if you keep the same classes and ids as in theme product.tpl then you can simply

                                    $(".product-prices").replaceWith(result.product_prices);
                                }

                            }}
            },500)}))

The price was reloaded in product page when i change width and height, but in cart price is not changed.

 

Please help me

Thanks for all support replies

×
×
  • Create New...