Show lowest price of variable prices

Support Area Forums Elite Show lowest price of variable prices

Viewing 2 posts - 1 through 2 (of 2 total)
URL to the page in question: http://cheekybanana.com/cheekywordpress
  • Author
    Posts
  • #23909
    Lesley Fleming
    Participant

    Hi,
    I’m not sure if you’ll be able to help with this. I have dynamic pricing so I can show my Wholesale Customers (one user group) prices that are different from my Retail Customers (my second user group).
    In order to allow bulk purchasing without paying for additional plugins, I created an attribute called “Wholesale Bulk Ordering” which allows my Wholesale customers to purchase the whole line of clothing, rather than add several items one by one. That said, when I did this the prices for retail customers shows a very high range on the shop page (e.g. $80-420). When my Wholesale customers login, Dynamic Pricing changes it to say “From $” and displays the lowest wholesale prices (which is appropriate). I would like to hide the high price from my retail customers so it says the price of a single item of clothing, without messing up the Dynamic Pricing plugin, which is working properly.
    I added the following code to revert WooCommerce back to its other setting, but it no longer lets Dynamic Pricing show “From $(lowest wholesale price)” on the Shop page. Instead, it shows the retail price. The individual products still show the Wholesale prices though.

    Code added to functions.php

    // Use WC 2.0 variable price format, now include sale price strikeout
    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 ) {
    // Main Price
    $prices = array( $product->get_variation_price( ‘min’, true ), $product->get_variation_price( ‘max’, true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( ‘From: %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    // Sale Price
    $prices = array( $product->get_variation_regular_price( ‘min’, true ), $product->get_variation_regular_price( ‘max’, true ) );
    sort( $prices );
    $saleprice = $prices[0] !== $prices[1] ? sprintf( __( ‘From: %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

    if ( $price !== $saleprice ) {
    $price = ‘‘ . $saleprice . ‘ <ins>’ . $price . ‘</ins>’;
    }
    return $price;
    }

    Do you have any advice?

    Thanks for your help.

    #23910
    Bill Robbins
    Moderator

    More than likely the plugin uses the same filter as the code snippet your adding. WordPress loads plugins first then child themes and lastly themes. Since you’re adding this code to the theme, it’ll override what the plugin is already doing since it’s loaded last.

    I would ask the folks who make the dynamic pricing extension if they have any advice for you. They know their own code and can let you know what your options are.

    Take care,
    Bill

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Show lowest price of variable prices’ is closed to new replies.