marketpress issues

1) i have a custom shopping cart in the header.php where i use mp_items_count_in_cart() to display number of items in cart. when clicking add to cart this does not update. it updates only after page refresh. i really need some help getting this to work with ajax or something.
2) is there anyway to display the subtotal outside the cart?
3) im very dissapointed by the lack of documentation of marketpress. is there even any kind of documentation? all i could find where basic videos.

please, save my day and try answearing me on all the above questions.

  • Mason
    • DEV MAN’s Sidekick

    Hiya andreas,

    You're only wanting to show the number of items in the header section? Is this your own custom theme?

    An easy way to have the shopping cart appear anywhere would be to use the shopping cart widget and create widgetized ares in your theme to correspond to this.

    I assume you've already reviewed the template-functions.php file and the Themeing_Marketpress.txt files found within the plugin? We have inline documentation there to assist with the basics of customizing the product.

    Additionally, you may want to check out our FrameMarket and GridMarket themes which are meant to show how MarketPress functions can be used within a theme:

    Let us know if you need anything further. If you have a link to the site and more information on the theme we may be able to provide more specific directions.


  • ante_bj__rk
    • New Recruit


    I'm trying to insert a snippet into the header.php file that displays the cart's subtotal at the top of the page next to a shopping cart icon. Usually I can track down the code that is calling it but I'm new to Marketpress and haven't been able to find it.

    Does anyone know how to do this?

  • Mason
    • DEV MAN’s Sidekick

    Hiya ante_bj_rk,

    Let me ask a developer to assist with this. In most of our themes we use the function:

    But that displays the entirety of the cart, not the subtotal or number of items. You could probably "hack" around it by adding display:none to the elements you don't want to show. The function itself outputs a table.

    As I said, I've flagged a developer to get you a more complete answer.


  • Paul
    • The Green Incsub

    Hi ante_bj__rk,

    I don't think there is a single function call in Market Press I can point you to that will return the cart total. But let me see if I can provide you a custom function you can add to your theme to determine the subtotal value. Will reply back shortly.

  • Paul
    • The Green Incsub

    Ok. Here is the quick function. I've tested this locally. Just some notes this functions does not include coupons, taxes, shipping total. Just the subtotal of cart product items.

    The function accepts an argument true or false to control the output format. If true the subtotal will be formatted for currency like $1,095.23. If false you will get the raw unformatted number like 1095.23. You will need to format this yourself. The default it true

    You should be able to just add this function to your theme's functions.php file. Then call the function from your header.php

    Let me know if this doesn't work.

    function marketpress_get_cart_subtotal($format_currency=true) {
    	global $mp;
    	$selected_cart = $mp->get_cart_contents(true);
    	if (!$selected_cart) return;
    	foreach ($selected_cart as $bid => $cart) {
    		if (is_multisite())
    		foreach ($cart as $product_id => $variations) {
    			foreach ($variations as $variation => $data) {
    				$totals[] = $mp->before_tax_price($data['price'], $product_id) * $data['quantity'];
    		//go back to original blog
    		if (is_multisite())
    	$total = array_sum($totals);
    	if ($format_currency)
    		return $mp->format_currency('', $total);
    		return $total;

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.