Created
December 8, 2020 23:56
-
-
Save dsebao/af987b1fa250a18e72b319f2a7ce1fad to your computer and use it in GitHub Desktop.
WordPress WooCommerce - Show price with partials fees
This file contains hidden or 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
<?php | |
add_filter('woocommerce_get_price_html', 'custom_price_message', 100, 2); | |
function custom_price_message($price, $product) | |
{ | |
//aca se podria realizar diferentes acciones dependiendo del tipo de producto, es solo de muestra | |
if ($product->get_type() === 'simple') { | |
} | |
//ACA EMPIEZA EL SNIPPET | |
$nuevoprecio = ''; | |
//Obtengo el precio del producto | |
$price = $product->get_price(); | |
//Obtengo las cuotas | |
$precio_en_cuotas = wc_price($price / 12); // Acá fijate si querés con decimales o redondo. | |
//Comparo si hay algun descuento aplicado y si lo hay lo muestro tachado | |
if($price != $product->get_regular_price()){ | |
$nuevoprecio .= "<del>" . wc_price($product->get_regular_price()) . "</del> "; | |
} | |
//Agrego las cuotas correspondientes | |
$nuevoprecio .= wc_price($price) . ' <br><span class="custom-price-prefix">' . __('<b>Hasta 12 Cuotas sin interés de</b> ') . $precio_en_cuotas . '</span>'; | |
//retorno el snippet html resultanto | |
return $nuevoprecio; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment