[Marketpress] site wide discount in marketpress

Hi,

is there some way to create a temporary site wide discount of say, 20% in MarketPress?

thanks

Jason

  • Panos
    • SLS

    Hi jasonblewis !

    You can add the following snippet in a mu-plugin :

    add_filter( 'mp_product/get_price', function( $price, $product ){

    $sale_percentage = 15;

    if ( $price['regular'] != $price['lowest'] ) {
    // It means that the sale is set statically for this product, so we might not want to change it:
    return $price;
    }

    $sale_percentage = number_format( $sale_percentage, 2 );
    $regular_price = $price['regular'];
    $discounted_price = $regular_price - ( $regular_price * $sale_percentage / 100 );
    $price['lowest'] = $discounted_price;
    $price['sale']['amount'] = $discounted_price;
    $price['sale']['percentage'] = $sale_percentage;

    return $price;

    }, 20, 2 );

    Set the discount percentage at this line

    $sale_percentage = 15;

    in the snippet. This will add 15% discount to all products in your multisite.

    In case you are not familiar with mu-plugins you can read about them here:

    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    You can add it in your child theme’s functions.php file instead if you prefer, but make you are using child theme so you don’t loose all your changes on theme update.

    Hope this helps!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.