Reputation: 11
How i can add options price to cart.tpl ???
i find option price in product.tpl
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
<?php } ?>
Is there a way to add price to this code?
In the product.tpl and the product.php (controller) we have $option_value['price'] but I don't see this in the cart.php or the cart.tpl. How can we pull this variable into the cart and the checkout page to add it?
Upvotes: 1
Views: 2914
Reputation: 5092
In the cart.php search for this line
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
Around the line 226 and you can add the price like this
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
'price' => $this->currency->format($option['price'])
);
// var_dump($option); // look more options
Now in the cart.tpl you can show the price
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?>
price: <?php echo $option['price']; ?></small><br />
<?php } ?>
Upvotes: 2