Add features to shopping cart prestashop
Simple way to add each product feature in shopping cart page.
1. Change in controllers\ParentOrderController.php
in line 244
after:
protected function _assignSummaryInformations() { global $currency; if (file_exists(_PS_SHIP_IMG_DIR_.(int)(self::$cart->id_carrier).'.jpg')) self::$smarty->assign('carrierPicture', 1); $summary = self::$cart->getSummaryDetails(); $customizedDatas = Product::getAllCustomizedDatas((int)(self::$cart->id)); // override customization tax rate with real tax (tax rules) foreach($summary['products'] AS &$productUpdate) {
code:
$features[] = Product::getFeaturesStatic($productId);
and after:
self::$smarty->assign(array( 'token_cart' => Tools::getToken(false), 'isVirtualCart' => self::$cart->isVirtualCart(), 'productNumber' => self::$cart->nbProducts(), 'voucherAllowed' => Configuration::get('PS_VOUCHERS'), 'shippingCost' => self::$cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => self::$cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas,
code:
'features' => $features,
2. Change in themes\prestashop\shopping-cart.tpl
in line 216
after:
\{assign var='productId' value=$product.id_product\}
code:
\{assign var='i' value=$i+1\} [\php] 3. Change in themes\prestashop\shopping-cart-product-line.tpl some in code :\{foreach from=$features[$i] item=feature\} \{if {$feature.id_feature|escape:'htmlall':'UTF-8'} == '12'\} \{if \{$feature.id_feature_value|escape:'htmlall':'UTF-8'\} == '42'\} \{l s='kg'\} \{else\} \{if \{$feature.id_feature_value|escape:'htmlall':'UTF-8'\} == '43'\} \{l s='szt.'\} \{/if\} \{/if\} \{/if\} \{/foreach\}