Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Adds a note after a product price, showing how many points can be earned.
- * Requested by C.Hollebeke (https://www.facebook.com/groups/woohelp/permalink/2034366710123107/)
- *
- * Need help customising the code for your need? Hire us on Codeable: http://bit.ly/codeable_discount_aelia
- *
- * @param string price_html The HTML showing the product price.
- * @param WC_Product The product for which the price is being displayed.
- * @return string The product price, with the note appended to it.
- * @author Aelia
- * @link https://aelia.co
- */
- add_filter('woocommerce_get_price_html', function($price_html, $product) {
- /* Possible improvements
- * - Don't show the note if the price is zero
- * - Replace text domain placeholder with real text domain
- */
- $note = '<div class="custom_note">';
- $note .= sprintf(__('Earn %s points', 'some_text_domain'), (string)floor($product->get_price()));
- $note .= '</div>';
- return $price_html . $note;
- }, 10, 2);
Add Comment
Please, Sign In to add comment