Skip to Content
Menu
This question has been flagged
2 Replies
1489 Views

I want to be able to change the uom in the shopping cart at meter with 0.1 steps. So this means I want to add for example 0.2 meter of a product in the shopping cart. Originally I had 1 meter in the shopping cart and now I want to adjust to 1.2 meter. If I do that it will go back to 1 meter.


Here is a image for the better explanation: https://imgur.com/a/HnHiijI

I have found something in the java script code:


website_sale.js

var default_price = parseFloat($dom.find('.text-danger > span.oe_currency_value').text());

When I chance to "int" it doesn't work either because the refresh. This is a java-script problem and I'm not a developer anyway.


    /**
     * @private
     * @param {Event} ev
     */
    _onChangeCartQuantity: function (ev) {
        var $input = $(ev.currentTarget);
        if ($input.data('update_change')) {
            return;
        }
        var value = parseInt($input.val() || 0, 10);
        if (isNaN(value)) {
            value = 1;
        }
        var $dom = $input.closest('tr');
        var default_price = parseFloat($dom.find('.text-danger > span.oe_currency_value').text());
        var $dom_optional = $dom.nextUntil(':not(.optional_product.info)');
        var line_id = parseInt($input.data('line-id'), 10);
        var productIDs = [parseInt($input.data('product-id'), 10)];
        this._changeCartQuantity($input, value, $dom_optional, line_id, productIDs);
    },
    /**
     * @private
     * @param {Event} ev
     */
    _onClickSuggestedProduct: function (ev) {
        $(ev.currentTarget).prev('input').val(1).trigger('change');
    },
    /**
     * @private
     * @param {Event} ev
     */


Does anyone has an idea how to fix this?


Thank you for your answers,

Avatar
Discard
Author Best Answer

Hi Ravi,

Do you know in which places I have to replace it?


I also found this: https://www.odoo.com/de_DE/forum/hilfe-1/question/i-have-question-related-ecommerce-website-i-have-multiple-vegetables-as-my-product-in-ecommerce-website-and-user-want-to-buy-a-few-product-of-unit-means-if-i-am-user-and-i-want-to-potato-1-5kg-so-how-can-i-do-it-if-any-configauration-in-odoo-or-i-make-code-if-am-i-do-code-then-give-the-hint-170678

This should be the same.

Avatar
Discard
Best Answer

replace parseInt to ParseFloat 
 
var value = parseInt($input.val() || 0, 10);  to var value = parseFloat($input.val())

also, parseInt($input.val()) used some other couple of place you have to replace them as well

Avatar
Discard
Related Posts Replies Views Activity
1
Dec 24
126
2
Nov 24
84
1
Oct 24
264
0
Sep 24
213
2
Sep 24
648