Search code examples
prestashopprestashop-1.6

How to display product condition in ajax-cart.js


I have done:

  1. added in classes > cart.php at line 510 p.condition

  2. added in blockcart-json.tpl "condition": {$product.condition|intval},

it works in blockcart.tpl but it is not working in the ajax-cart.tpl. In other words I must refresh the page. But it should work without refresh when adding products to cart.

in ajax-cart.js I call it by this variable "this.condition" but the result is "undefined"

Any idea what I am missing?


Solution

  • |intval
    

    It´s a number value. You may use something like that

    {$product.condition|capitalize|json_encode}
    

    Then to add it in the ajax without refresh do the following

    -In the blockcart-json.tpl (* div layer_cart *) add this. example #default-theme:

    <div class="product-condition" style="margin-top:10px"> <span style="font-weight: bold; color:#333;margin-top:10px"> {l s='Condition: ' mod='blockcart'}</span> <span id="layer_cart_product_condition" class="product-condition"></span></div>
    <div>
    

    -And, finally in ajax-cart.js (* updateLayer : function(product) *) add this

    $('#layer_cart_product_condition').text(product.condition);