Поддержка WooCommerce Настройки для вариативного товара

  • Помогите решить пару проблем с WC вариативного товара.
    1)Подскажите как вывести максимальную цену для вариантивного товара, сейчас выводит так 151 руб — 400 руб
    2) Подскажите как можно такое сделать для вариантивного товара, то есть пользователь вводит количесто и заказывает сразу как на скрине
    СКРИН

Просмотр 1 ответа (всего 1)
  • Сделал так

    add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format', 10, 2 );
     
    function bbloomer_variation_price_format( $price, $product ) {
     
    // 1. Get min/max regular and sale variation prices
     
    $min_var_reg_price = $product->get_variation_regular_price( 'min', true );
    $min_var_sale_price = $product->get_variation_sale_price( 'min', true );
    $max_var_reg_price = $product->get_variation_regular_price( 'max', true );
    $max_var_sale_price = $product->get_variation_sale_price( 'max', true );
     
    // 2. New $price, unless all variations have exact same prices
     
    /*if ( ! ( $min_var_reg_price == $max_var_reg_price && $min_var_sale_price == $max_var_sale_price ) ) {   
        if ( $min_var_sale_price < $min_var_reg_price ) {
            $price = sprintf( __( 'From: <del>%1$s</del><ins>%2$s</ins>', 'woocommerce' ), wc_price( $min_var_reg_price ), wc_price( $min_var_sale_price ) );
        } else {
            $price = sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $min_var_reg_price ) );
        }
    }*/
    
     $price = sprintf( __( '%2$s', 'woocommerce' ), wc_price( $max_var_reg_price ), wc_price( $max_var_reg_price ) );
     
    // 3. Return $price
     
    return $price;
    }
Просмотр 1 ответа (всего 1)
  • Тема «Настройки для вариативного товара» закрыта для новых ответов.