• Resolved Leandro

    (@leandroprz)


    Hi,

    I’m using the following piece of code based on the one I found here to round down prices:

    
    add_filter('woocs_raw_woocommerce_price', function($price) {
        return 100 * floor($price / 100); // redondea para abajo en 100
    });
    
    add_filter('woocs_woocommerce_variation_prices', function($price) {
        return 100 * floor($price / 100);
    });
    

    but I need to exclude external products from this. Is there a way to do it?

    I tried using if( $product->is_type( 'external' ) but I’m getting PHP errors.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Leandro

    (@leandroprz)

    I decided to just hide prices in external products in case they change the prices, that way I don’t have to keep tabs on them.

    
    // Hide External Products Only Prices
    add_filter( 'woocommerce_variable_sale_price_html', 'woocommerce_remove_prices', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'woocommerce_remove_prices', 10, 2 );
    add_filter( 'woocommerce_get_price_html', 'woocommerce_remove_prices', 10, 2 );
    function woocommerce_remove_prices( $price, $product ) {
        if( $product->is_type( 'external' ))
            $price = '';
            //$price = ' <a href='. esc_url( $product->get_product_url() ) .' target=_blank>Check Price</a> ';
    
        return $price;
    }
    
    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Unfortunately with these hooks it is not possible to identify the current product

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude external product from price rounding’ is closed to new replies.