New cart Widget

Hi all,

i've made a little new widget, that can is subsitute of default Marketpress cart widget.

This, beacuase the default widget use tables, and this, is not vary powerful to use in all part of the template.

For example, many ecommerce site, uses the cart on top right of header. This is not possible with default widget... otherwise is not so beautiful :slight_smile:

This little widget, shows only number of products, the link for empty cart, the link for checkout, and the total.

Simple and beautiful (for me)! :slight_smile:

But thers is a problem. It don't use an akx to update the total and the number of products...How can i make this?

Because i want to share this code, in GPL license, i post the code here...

class byoutique_cart extends WP_Widget {

function byoutique_cart() {
$widget_ops = array('classname' => 'byoutique_cart_widget', 'description' => __('Shows amazing shopping cart contents along with a checkout button for your store.', 'bh') );
$this->WP_Widget('byoutique_cart_widget', __('Cart', 'bh'), $widget_ops);

function widget($args, $instance) {
global $mp, $blog_id, $plugin_url;
$blog_id = (is_multisite()) ? $blog_id : 1;
$settings = get_option('mp_settings');
$current_blog_id = $blog_id;

$global_cart = $mp->get_cart_contents(true);

if ( get_query_var('pagename') == 'cart' )

if ($instance['only_store_pages'] && !mp_is_shop_page())

extract( $args );

echo $before_widget;
echo "<h3 class=\"widget-title\">". __('Cart', 'bh')."</h3>";
//$title = $instance['title'];
//if ( !empty( $title ) ) { echo $before_title . apply_filters('widget_title', $title) . $after_title; };

//if ( !empty($instance['custom_text']) )
//echo '<div class="custom_text">' . $instance['custom_text'] . '</div>';

echo '<div class="byoutique_cart_widget_content">';
$selected_cart = $global_cart[$blog_id];

foreach ($selected_cart as $bid => $cart){
foreach ($cart as $product_id => $variations){
$subtotal[$i++] = $variations['price'] * $variations['quantity'];
$object[] = $variations['quantity'];
$objects = array_sum($object);
$total = array_sum($subtotal);
echo "<div class=\"byoutique_cart_container\">";
echo "<div class=\"byoutique_cart_objects\">$objects</div>";
echo '<div class="byoutique_cart_empty">'.__('Empty Cart', 'mp').'</div>';
echo "</div>";
echo "<div class=\"clear\"></div>";
echo mp_cart_link(true, false, __('checkout', 'bh'));
echo "<div class=\"byoutique_cart_total\">".__('total:', 'bh')." ".$mp->format_currency('', $total)."</div>";
echo '</div>';

echo $after_widget;

Any suggestions?
Best regards!