Created
May 22, 2017 08:06
-
-
Save gabrielmerovingi/7e71236a5bd332ee46b307bd2fe58c6a to your computer and use it in GitHub Desktop.
Append the product price in points to WooCommerce products.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show Cost in Points | |
* Show the cost of a product in points next to the regular price. | |
* @version 1.0 | |
*/ | |
function mycred_pro_append_point_price( $rendered_price, $product ) { | |
if ( $product->get_price() > 0 ) { | |
$price = $product->get_price(); | |
// How many points does it take to get 1 store currency? | |
$exchange_rate = 100; | |
$mycred = mycred(); | |
$rendered_price .= '<small class="point-price">( ' . $mycred->format_creds( $price * $exchange_rate ) . ' )</small>'; | |
} | |
return $rendered_price; | |
} | |
add_filter( 'woocommerce_get_price_html', 'mycred_pro_append_point_price', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I used this code to show the points next to the price but I want to hide it in the price range of variable products. How can I do it?
I have managed to hide the price range of the product with this code:
//Remove Price Range
add_filter( 'woocommerce_variable_sale_price_html', 'detect_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'detect_variation_price_format', 10, 2 );
function detect_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
if ($prices[0] !== $prices[1] && is_product()) {
$price = $prices[0] !== $prices[1] ? sprintf( __( '', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
}
return $price;
}
But I don't know so much about programing. I'm a designer. Can anybody help me?