Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Chrome problem for a print plugin. WordPress


Hello friends,
i was trying to find but without luky.

I have this code

<strong><?php _e( 'Val: 20 lei', 'woocommerce' ); ?></strong><br>

<strong><?php _e('Rmb:', 'woocommerce'); ?></strong>
<strong><?php echo $woocommerce->cart->get_total(); ?></strong><br><br>

its from woocommerce delivery note plugin template.
I cant find the reason why in firefox i get the corect total from the order and its printed well.
On the Chrome browser i get Rmb: 0$
This code need to echo that value from the order total but in chrome its not working:
<?php echo $woocommerce->cart->get_total(); ?>

Some sugestions?

Answers (2)


Just Me answers:

Maybe for some reason, the value is not present yet, just for testing try this

<?php $my_total =$woocommerce->cart->get_total(); ?>
<?php _e( 'Val: 20 lei', 'woocommerce' ); ?><br>

<?php _e('Rmb:', 'woocommerce'); ?>

<?php echo $my_total; ?><br><br>

Balanean Corneliu comments:

Is not working , i think i will be back to the original code but i will need to cut out some prices to remain just with the total one.

if i use:
<?php foreach( wcdn_get_order_totals() as $total ) : ?>

<?php echo $total['value']; ?>

<?php endforeach; ?>

i get Rmb: 170 lei 18 lei via FAN Courier 188 lei
I need just the last one 188 lei is the total of the cart.

all i have find for this wcdn_get_order_totals is :

* Return the order totals listing
if ( !function_exists( 'wcdn_get_order_totals' ) ) {
function wcdn_get_order_totals() {
global $wcdn;

// get totals and remove the semicolon
$totals = apply_filters( 'wcdn_raw_order_totals', $wcdn->print->get_order()->get_order_item_totals() );

// remove the colon for every label
foreach ( $totals as $key => $total ) {
$label = $total['label'];
$colon = strrpos( $label, ':' );
if( $colon !== false ) {
$label = substr_replace( $label, '', $colon, 1 );
$totals[$key]['label'] = $label;

return apply_filters( 'wcdn_order_totals', $totals );

I think i need to change this code to show me just the total not all that prices.

Just Me comments:

I am not familiar with Woocommerce code, just looking at it from code-view

This should work (although probably not the most efficient way to handle it)

<?php foreach( wcdn_get_order_totals() as $total ) : ?>
<?php echo $GrandTotal[]=$total['value']; ?>
<?php endforeach; ?>
<?php echo end($GrandTotal); ?>

Balanean Corneliu comments:

With this code now i have Rmb: 85 lei 99 lei 99 lei But i need Rmb:99 lei
Is more close because i dont have enymore via FAN Courier

Balanean Corneliu comments:

seems like i have 2 times total price and once the product sale price.

Just Me comments:

my bad remove the echo from the foreach code

Balanean Corneliu comments:

I have fixed first in other way but to asign you the price i have tested now your code to, and its working .
My solution was:

I changed the code and it works

change this function to following:

if ( !function_exists( 'wcdn_get_order_totals' ) ) {
function wcdn_get_order_totals() {
global $wcdn;

return $totals;

and go to the template file under print folder:
print-delivery-notes.php order-summary div change to following

<?php $total=wcdn_get_order_totals(); /*foreach( wcdn_get_order_totals() as $total ) : */?>

<?php /*echo $total['label'];*/ ?>
<td class="price"><?php echo $total; ?>

<?php /*endforeach; */?>

Thank you Just Me and thanks for Agus efort to.


Agus Setiawan answers:

try to add this line <?php ini_set('default_charset', 'utf-8') ?> to the template.php

Balanean Corneliu comments:

I dont have template.php but i was try to add your code in the template file weare is my code located
template/print/print-delivery-note.php but is still give me 0$ on chrome.

Agus Setiawan comments:

please PM me your url.

Balanean Corneliu comments:

I have try to use <?php echo $woocommerce->cart->get_cart_total(); ?> but this give me a fix value from the product to all orders.