Дробное число товаров.

Тема в разделе "PrestaShop", создана пользователем ALEX1971, 16 ноя 2016.

  1. ALEX1971

    ALEX1971

    Регистрация:
    19 окт 2016
    Сообщения:
    26
    Симпатии:
    4
    Как реолизовать в престашоп 1,6 продажу дробного числа товара, погонные метры, кг, кв. м.?
     
  2. ALEX1971

    ALEX1971

    Регистрация:
    19 окт 2016
    Сообщения:
    26
    Симпатии:
    4
    Вот решение на форуме престы, кто нибудь сможет перевести, что и где изменить нужно, через переводчик не совсем понятно.
    Hi,



    here's a solution that works for me (version 1.6.0.9):



    1) Change the database quantity related fields type to DECIMAL (17,2).



    ps_product: quantity, minimal_quantity

    ps_order_return_detail: product_quantity

    ps_pack: quantity

    ps_product_attribute: quantity, minimal_quantity

    ps_product_sale: quantity

    ps_stock: physical_quantity, usable_quantity

    ps_cart_rule: quantity, quantity_per_user

    ps_customization: quantity, quantity_refunded, quantity_returned

    ps_order_detail: product_quantity, product_quantity_in_stock, product_quantity_refunded, product_quantity_return

    ps_specific_price_rule: from_quantity

    ps_order_slip_detail: product_quantity

    ps_supply_order_detail: quantity_recieved, quantity_expected

    ps_stock_avaible: quantity

    ps_cart_product: quantity

    ps_stock_mvt: physical_quantity

    ps_cart_rule_product_rule_group: quantity



    2) Change declarations and checks related to variables like quantity, qty and similar from int to float.



    2.1)

    For examle:

    Override the OrderDetail.php class with following changes:

    line 170-173

    'product_quantity' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), 'product_quantity_in_stock' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'product_quantity_return' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'product_quantity_refunded' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'product_quantity_reinjected' =>array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
    line 180

    'product_quantity_discount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
    line 191

    'discount_quantity_applied' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
    line 562

    $this->product_quantity = (float)($product['cart_quantity'])
    line 570-571

    $productQuantity = (float)(Product::getQuantity($this->product_id, $this->product_attribute_id)); $this->product_quantity_in_stock = ($productQuantity - (float)($product['cart_quantity']) < 0) ? $productQuantity : (float)($product['cart_quantity']);
    Remaining classes to check and override are:

    Order.php

    Customization.php

    Cart.php

    Product.php



    2.2) Override front controllers:



    CartController.php

    ProductController.php

    OrderOpcController.php



    2.3) Override admin controllers:



    AdminOrdersController.php

    AdminCartsController.php

    AdminProductsController.php



    2.4) Change admin template file /admin/themes/default/template/controllers/orders/controllers/orders/_product_line.tpl



    line 69

    <span class="product_quantity_show{if (float)$product['product_quantity'] > 1} badge{/if}">{$product['product_quantity']}</span>
    Basically this allows you to see decimal quantity in orders (ORDERS->Orders) from back office.



    2.5) Change your theme templates:



    order-detail.tpl

    shopping-cart.tpl

    product.tpl



    2.6) Change your theme blockcart module:



    blockcart-json.tpl

    blockcart.tpl

    blockcart.php



    2.7) Change your theme js files:



    order-opc.js



    line 932

    newTotalQty += parseFloat($(this).val());
    line 944

    totalQty += parseFloat($(this).val());
    product.js



    line 250

    var currentVal = parseFloat($('input[name='+fieldName+']').val());
    line 264

    var currentVal = parseFloat($('input[name='+fieldName+']').val());
    cart-summary.js



    line 346 - new RegExp checks floats instead of integers, this allows to manually change and automatically update product quantity during checkout on cart page.

    var exp = new RegExp("^[0-9]+\.[0-9]+$");
    line 352

    var QtyToUp = parseFloat(input) - parseFloat(hidden);
    line 354

    if (parseFloat(QtyToUp) > 0)
    line 356

    else if(parseFloat(QtyToUp) < 0)
    line 442

    (parseFloat(jsonData.summary.products.customization_quantity) > 0))
    line 801

    nbrProducts += parseFloat(product_list.quantity);
    So, that’s it. Actually there is more work to do to change customer account views in order to represent decimal values. Maybe some other templates still to change. Anyway, this basically does the trick.
     
  3. shtorybrest

    shtorybrest

    Регистрация:
    7 май 2017
    Сообщения:
    6
    Симпатии:
    0
    Помогите? Этот способ работает.