V
V
Vladislav Kalnaus2018-07-17 09:22:35
WordPress
Vladislav Kalnaus, 2018-07-17 09:22:35

How to split price in woocommerce?

Please tell me there is a code

add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
    // Основная цена
    $prices = array( $product->get_variation_price( 'max', true ), $product->get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( '%s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 

    return $price ;
}

It gives out a price of 33,000 rubles in a variable product.
How can I make this price divided by 30 at the output?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sklyarov, 2018-07-17
@yl1tko1

Replace with , it may need to be converted to int, because I don’t know what value you have in the array. wc_price( $prices[0] )wc_price( $prices[0] / 30)$prices[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question