Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have copied the commerce-cart-block.tpl.php and created a custom content view. I only have a bit knowledge in PHP.
I used the devel module to get the data I need.
Here is the code I put on the tpl.php but I have this error.
Notice: Undefined variable: currency_code in commerce_currency_format()
I don't know if it's a module issue or just my code.
$orderprice = commerce_currency_format($order->commerce_order_total[LANGUAGE_NONE][0]['amount']);
$qty = $order->commerce_line_items[LANGUAGE_NONE];
$i = 0;
foreach($qty as $key => $value) {
$line_item = $order->commerce_line_items[LANGUAGE_NONE][$key]['line_item_id'];
$itemqty = commerce_line_item_load($line_item);
$i += $itemqty->quantity;
}
print t('<a href="/cart">Cart</a>: ' . $i . ' item(s) - ' . $orderprice);
Please help me to fix this issue. Thanks!!
___________________
Fixed issue:
$amount = $order->commerce_order_total[LANGUAGE_NONE][0]['amount'];
$currency_code = $order->commerce_order_total[LANGUAGE_NONE][0]['currency_code'];
$orderprice = commerce_currency_format($amount, $currency_code);
$qty = $order->commerce_line_items[LANGUAGE_NONE];
$i = 0;
foreach($qty as $key => $value) {
$line_item = $order->commerce_line_items[LANGUAGE_NONE][$key]['line_item_id'];
$itemqty = commerce_line_item_load($line_item);
$i += $itemqty->quantity;
}
print t('<a href="/cart">Cart</a>: @qty item(s) - @price', array('@qty' => $i, '@price' => $orderprice));
Comments
Comment #1
madelyncruz CreditAttribution: madelyncruz commentedI have been so careless and I missed to put the currency code at the commerce_currency_format.
Please mark this one as fixed. Thank you.
Comment #2
madelyncruz CreditAttribution: madelyncruz commentedComment #3
madelyncruz CreditAttribution: madelyncruz commentedComment #4
madelyncruz CreditAttribution: madelyncruz commented