Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
Created March 2, 2020 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helgatheviking/8f3c9746a4d573e3075aa4e27435681d to your computer and use it in GitHub Desktop.
Save helgatheviking/8f3c9746a4d573e3075aa4e27435681d to your computer and use it in GitHub Desktop.
Change Mix and Match price string from From: $99 to range style $99 - $100
<?php
/**
* Change price string from From: $99 to range style $99 - $100
*
* @return string
*/
function kia_mnm_price_range( $price, $product ) {
if ( $product->get_max_container_size() && $product->get_mnm_price( 'max' ) && $product->get_mnm_price( 'min' ) !== $product->get_mnm_price( 'max' ) ) {
$price = sprintf( _x( '%1$s - %2$s', 'Price range', 'woocommerce-mix-and-match-products' ), $price . $product->get_price_suffix(), $product->get_mnm_price( 'max' ) . $product->get_price_suffix() );
}
return $price;
}
add_filter( 'woocommerce_mnm_price_html', 'kia_mnm_price_range', 10, 2 );
@helgatheviking
Copy link
Author

Updating for 2.0, removing suffix for now.

/**
 * Change price string from From: $99 to range style $99 - $100
 * 
 * @return string
 */
function kia_mnm_price_range( $price, $product ) {
    if ( $product->get_max_container_size() && $product->get_container_price( 'max' ) && $product->get_container_price( 'min' ) !== $product->get_container_price( 'max' ) ) {
    	$price = sprintf( _x( '%1$s - %2$s', 'Price range', 'woocommerce-mix-and-match-products' ), wc_price( $product->get_container_price( 'min' ) ), wc_price( $product->get_container_price( 'max' ) ) );
    }
    return $price;
}
add_filter( 'wc_mnm_container_get_price_html', 'kia_mnm_price_range', 10, 2 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment