B
Baldomero Gar
Gamma
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Hola. He instalado el plugin "Advanced Dynamic Pricing for WooCommerce" para poder aplicar una regla-descuento general a unas categorías de productos, pero el problema es que esos precios ya rebajados me los vuelve a mostrar con el intervalo típico de Wordpress. El resto de productos que no tienen esa regla-descuento sí salen bien (con el precio "desde xxxx". Además me gustaría que me mostrase los precios "antiguos" tachados, pero no ocurre
Actualmente tengo este código en el functions.php
function precio_desde( $price, $product ) {
// Precio normal
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'Desde: %1$s', 'quitar-intervalo' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Precio rebajado
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'Desde: %1$s', 'quitar-intervalo' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
}
return $price;
}
add_filter( 'woocommerce_variable_sale_price_html', 'precio_desde', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'precio_desde', 10, 2 );
y también el código:
function custom_price_message( $price ) {
global $post;
$product_id = $post->ID;
$textafter = '<span style="font-size:0.7em;"> (IVA inc)</span>'; //texto que vamos agregar
return $price . '' . $textafter . ''; //class textafter para el CSS
}
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
¿Qué se os ocurre? ¡Mil gracias!
Actualmente tengo este código en el functions.php
function precio_desde( $price, $product ) {
// Precio normal
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'Desde: %1$s', 'quitar-intervalo' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Precio rebajado
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'Desde: %1$s', 'quitar-intervalo' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
}
return $price;
}
add_filter( 'woocommerce_variable_sale_price_html', 'precio_desde', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'precio_desde', 10, 2 );
y también el código:
function custom_price_message( $price ) {
global $post;
$product_id = $post->ID;
$textafter = '<span style="font-size:0.7em;"> (IVA inc)</span>'; //texto que vamos agregar
return $price . '' . $textafter . ''; //class textafter para el CSS
}
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
¿Qué se os ocurre? ¡Mil gracias!