Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #229948

    For those who are struggling with the new price range format of woocommerce concerning grouped products (and variable products aswell (there is specific code available too)):

    <?php
    // Place in your theme’s functions.php file
    // Revert grouped product prices to WooCommerce 2.0 format
    add_filter( ‘woocommerce_grouped_price_html’, ‘wc_wc20_grouped_price_format’, 10, 2 );
    function wc_wc20_grouped_price_format( $price, $product ) {
    $tax_display_mode = get_option( ‘woocommerce_tax_display_shop’ );
    $child_prices = array();

    foreach ( $product->get_children() as $child_id ) {
    $child_prices[] = get_post_meta( $child_id, ‘_price’, true );
    }

    $child_prices = array_unique( $child_prices );
    $get_price_method = ‘get_price_’ . $tax_display_mode . ‘uding_tax’;

    if ( ! empty( $child_prices ) ) {
    $min_price = min( $child_prices );
    $max_price = max( $child_prices );
    } else {
    $min_price = ”;
    $max_price = ”;
    }

    if ( $min_price == $max_price ) {
    $display_price = wc_price( $product->$get_price_method( 1, $min_price ) );
    } else {
    $from = wc_price( $product->$get_price_method( 1, $min_price ) );
    $display_price = sprintf( __( ‘From: %1$s’, ‘woocommerce’ ), $from );
    }
    return $display_price;
    }

    regards
    Pedro

    #229949

    recource:
    http://gerhardpotgieter.com/2014/02/24/woocommerce-2-1-grouped-prices-revert-to-woocommerce-2-0-format/

    #230003

    Hey!

    Thank you for the hint :)

    Regards,
    Peter

    #230452

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘code for bringing 'grouped products' back to woocommerce 2.0 format’ is closed to new replies.