I'm trying to make a block with an image that would change when there is something in his or hger basket (empty basket image when basket is empty, full basket when it's full) My understanding of PHP is weak, but I found this topic :
http://www.drupalcommerce.org/discussions/787/simple-shopping-cart-summary
and I wrote that:
<?php
global $user;
$order = commerce_cart_order_load($user->uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_total = $wrapper->commerce_order_total->value();
if ($order_total['amount']>0) echo ('<a href="/twotrees/cart"> <img src="/sites/default/files/basketfull.png" > </img> </a>');
else echo ('<a href="/twotrees/cart"> <img src="/sites/default/files/basketempty.png" > </img> </a>');
?>
Now on my home server everything worked as expected. On the reomte one i got several show-stopping errors.
If i put the whole thing, I get
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. w EntityDrupalWrapper->set() (line 744 of /profiles/commerce_kickstart/modules/entity/includes/entity.wrapper.inc).
By trial and error, I detected that leaving the first two lines
global $user;
$order = commerce_cart_order_load($user->uid);
are 'innocent'. It's the third one
$wrapper = entity_metadata_wrapper('commerce_order', $order);
that generates the error. So actually it's the code from that commerce thread that seems to generate the error. To me it seems pretty innocent, though.
As I said, I know very little about PHP, not to mention the internals of Drupal Commerce. I'd be grateful for any suggestions.