New mp cart widget

Hi all,

I don’t like (sorry Aaron) The widget core for the cart, and i wanna replace it with a new more simple widget.

This is the script…Really simple… it counts all products in cart and does the total…

So, it require ajax to dinamically update the totals! I’ve just copied the ajax-cart.js code of mp_cart_listeners, andchanghed the name of div focused, but on update, put the old widget on screen!! Why?!

here the code (for best understand):

function instead of widget class:

function widget($args, $instance) {

global $mp, $blog_id, $plugin_url;

$blog_id = (is_multisite()) ? $blog_id : 1;

$settings = get_option(‘mp_settings’:wink:;

$current_blog_id = $blog_id;

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

if ( get_query_var(‘pagename’:wink: == ‘cart’ )


if ($instance && !mp_is_shop_page())


extract( $args );

echo $before_widget;

echo “<h3 class=”widget-title”>”. __(‘Cart’, ‘bh’:wink:.”</h3>”;

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 * $variations;

$object[] = $variations;


$objects = array_sum($object);

$total = array_sum($subtotal);




$objects = 0;

echo “<div class=”byoutique_cart_container”>”;

echo “<div class=”byoutique_cart_objects”>”.__(‘Products:’, ‘bh’:wink:.” “.$objects.”</div>”;

echo “<div class=”byoutique_cart_total”>”.__(‘total:’, ‘bh’:wink:.” “.$mp->format_currency(”, $total).”</div>”;

echo “</div>”;

echo “<div class=”clear”></div>”;

echo mp_cart_link(true, false, __(‘checkout’, ‘bh’:wink:);

echo ‘</div>’;

echo $after_widget;


function instead the js file:

function byoutique_cart_listeners() {

$(“input.mp_button_addcart” {

var input = $(this);

var formElm = $(input).parents(‘form.mp_buy_form’:wink:;

var tempHtml = formElm.html();

var serializedForm = formElm.serialize();

formElm.html(‘<img src=”‘+MP_Ajax.imgUrl+'” alt=”‘+MP_Ajax.addingMsg+'” />’:wink:;

$.post(MP_Ajax.ajaxUrl, serializedForm, function(data) {

var result = data.split(‘||’, 1);

if (result[0] == ‘error’:wink: {




} else {

formElm.html(‘<span class=”mp_adding_to_cart”>’+MP_Ajax.successMsg+'</span>’:wink:;


if (result[0] > 0) {

formElm.fadeOut(2000, function(){




} else {

formElm.fadeOut(2000, function(){

formElm.html(‘<span class=”mp_no_stock”>’+MP_Ajax.outMsg+'</span>’:wink:.fadeIn(‘fast’:wink:;




byoutique_empty_cart(); //re-init empty script as the widget was reloaded



return false;




I just want update products and total…Don’t wanna dispaly the table of mp_show_cart(‘widget’:wink:

Can you help me?

Where i wrong?

  • Patrick
    • Support Monkey

    If you want a much simpler widget display, you can also do it via a bit CSS added to your theme's style-sheet. Try the following for example to get a cart widget much like the screenshot below:

    .mp_cart_contents_widget th, .mp_cart_contents_widget .mp_cart_col_thumb {
    .mp_cart_contents_widget tr, .mp_cart_contents_widget td, .mp_cart_contents_widget tbody {

    Hope this helps! :slight_smile:

  • micdech
    • Flash Drive

    Hi Patrick,

    this help, but isn’t what i want :slight_smile:

    In this mode, i obtain always the photo, the name, the quantity etc…

    I want only the numbers of objects in cart and the total.

    By the way, thank you very much for your answer

  • Aaron
    • CTO

    You are still posting to the default marketpress ajax handler, which is designed to return refreshed cart html. You’ll have to setup an aditional ajax handler, or simply use a static widget that doesn’t refresh when items are added via ajax.

    Note that there is a template function already for getting the item count in cart:


  • PC
    • WPMU DEV Initiate


    Greetings of the day.

    I was doing a regular followup today and found that we missed your last post on this one.

    Are you still seeking support on this one ? Please let us know so that we can take it further and assist you on the same :slight_smile:

    Thanks for being a great community member !



  • Brian Purkiss
    • Smushie Pies

    Well now. This is rather embarrassing as we’re at the point of coming back and asking you if you were able to solve this. Not sure why @pc dropped the ball on this one. I apologize on his behalf.

    However, helping you create a whole new widget goes a little above and beyond the scope of support we offer here.

    We have to draw a line between what is “support” and what is “custom”. Think of support as helping you implement our product in any of the ways it’s meant to “out of the box”. Custom work would be anything additional that the plugin doesn’t do by default.

    It’s tricky, and believe me, we’d love to be able to code every single feature/product/customization requested, but it’s not possible. We DO listen to members and plan our development according to what is most popularly requested.

    If you want to take a stab at creating a new widget we’ll be more than happy to help you with any specific questions you have. For example, if you had a question about which function is needed for x, or what function x does. But beyond that, helping you build a widget, as I said, is beyond the scope of support we can offer here.

    So, if we can support you in using this plugin on your site as it currently exists, we’re more than happy to do so, but if you need a custom plugin or modifications we don’t have the manpower to assist on that. If you are willing to pay someone to develop this, you should take a look at the WPMU Job Board or Tweaky.

    Sorry that I could not be of further assistance. If you have any other questions please don’t hesitate to ask. We’re happy to help!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.