Changing a 1.4 theme to support gift products
Last updated
Last updated
Themes built during the PrestaShop 1.4 most often cannot properly display gift products in their shopping cart summary. This can result in this kind of display:
The total does not match the sum of totals in the summary: 188.10 + 376.20 does not equal 752.40.
In order to properly display gift products, you have to edit two templates:
shopping-cart-product-line.tpl: displays the product rows.
shopping-cart.tpl: calls the first template for each product.
You have to find the product loop. That line should start as such:
The loop code ends with{/foreach
}, after which you should add the following lines.
Right now, it is possible to delete a gift product, and it is not even marked as free. We must change the template which display the product rows, in order to improve its display.
To hide the "Delete" button, you must first find the template code which displays it. In our case, it is this one:
This block of code must be embedded in a conditional test depending on the presence of $product.gift
. In PS 1.4's default theme, you can edit the existing conditional test to add a condition on $product.gift
.
In order to prevent conflicts with JavaScript code which edit id}}s on the fly by suffixing them (for instance, with {{_gift
Il faut pour éviter les problème avec les script JS modifier les ids en les suffixant (par exemple par "_gift"), you have to replace this code:
...with this one:
You can add a logo in the gift product's row, in order to help customers understand why there is such a line in their cart summary.
To that end, find the product's title (<td class="cart_description">
) and add the following lines:
You also must add the following line in the global.css
file:
Of course, you should adapt all these code blocks to your theme's needs: colors, placement, etc.
The page should now display this: