MarketPress::load_store_templates() should make $is_shop_page available

Basically, MarketPress::load_store_templates() uses $is_shop_page to denote if the page is a shop page, but keeps it in the local scope. It would be nice to make this a class variable that can be grabbed via a helper method like MarketPress::is_shop_page(). The same thing is in MarketPress_MS::load_marketplace_templates(), so maybe there should actually be a helper function like:

function marketplace_is_shop_place() {
	global $mp, $mp_wpmu;
	if ( is_multisite() )
		return $mp_wpmu->is_shop_page();
	return $mp->is_shop_page();
}

It seems like something that could drop right into template-functions.php.

    rsisales
    • Elite
    • 94
    • #1,188

    Almost forgot. Possible use case: A sidebar containing the cart, product tags, etc, that is only displayed on store pages.

    Mason

    Hiya!

    Thanks for the feedback and suggestion. I've asked Aaron to come by and take a look. He's the lead plugin dev on this one.

    Thanks again!

    Aaron

    Will do. I'll make it a class var and template function.

    rsisales
    • Elite
    • 94
    • #1,188

    Aaron: Thanks. Any idea when it'll be available...or better yet, could you send me a patch (to aaron@xavisys.com) that I can apply so I'm using it the way it'll be implemented?

    Aaron

    There will be a new mp_is_shop_page() template function in 1.1 out soon.

    rsisales
    • Elite
    • 94
    • #1,188

    Thank you very much. For those that need this sooner, there are two steps to add this yourself:
    1) Find "$is_shop_page" and replace it with "$this->is_shop_page" in marketpress-includes/marketpress-ms.php and marketpress.php.
    2) Add this code to marketpress-includes/template-functions.php:

    function mp_is_shop_page() {
    global $mp_wpmu, $mp;
    if ( is_a( $mp_wpmu, 'MarketPress_MS' ) ) {
    return $mp_wpmu->is_shop_page;
    } elseif ( is_a( $mp, 'MarketPress' ) ) {
    return $mp->is_shop_page;
    }
    return false;
    }

    nickd32

    How do we use this? Can you spell it out for us amateur PHP developers?

    Aaron

    Basically in 1.1 in theme templates (or plugins) you can just check:
    if (mp_is_shop_page()) {
    //your code here
    }

    Aaron

    Well it's really a feature update. Though the other issue at the bottom of the thread is fixed as well (passing the checkout step query var)

    rsisales
    • Elite
    • 94
    • #1,188

    Aaron: This fix is actually broken. It says uses $mp->is_shop_page() which doesn't exist. It should use the variable rather than the non-existent method like this: $mp->is_shop_page

    Aaron

    Whoops, thanks. For now you can just access $mp->is_shop_page directly.

    rsisales
    • Elite
    • 94
    • #1,188

    I just fixed the function on this site, assuming you'll fix it for the next release

Join 372274 happy members

Get access to our entire collection of epic plugins, astonishing themes & genius support

Become a member