Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi,
    WCPBC return the price you have set as manual price for the product by the filter ‘woocommerce_product_price’.
    You can “stop” the WCPBC return price by the filter: wc_price_based_country_get_product_price

    Thread Starter mattmuirhead

    (@mattmuirhead)

    Would you be able to give me an example of how that would work/ be implemented?

    For instance my code in my functions.php file looks like this:

    add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
    
    function add_custom_price( ) {
        $product->set_price('1');
    }
    Plugin Author Oscar Gare

    (@oscargare)

    add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
    
    function add_custom_price() {
        $product->set_price('1');
        $flag = TRUE;
        //stop WCPBC calculate price
        add_filters( 'wc_price_based_country_get_product_price', 'stop_wcpbc_calculate_price', 10, 2);
    }
    
    function stop_wcpbc_calculate_price( $stop, $product ){
    	return ! $flag;
    }
    Thread Starter mattmuirhead

    (@mattmuirhead)

    Hi,
    Thank you so much for the reply, but this doesn’t actually work. Firstly ‘add_filters’ isn’t a function so I’ve tried both ‘add_filter’ and ‘apply_filters’ but neither work. Could you please supply some documentation or description of how this filter works and then maybe I can understand it all better.

    Thanks in advance!

    Plugin Author Oscar Gare

    (@oscargare)

    Hi,
    I’m sorry, I made a mistake.

    the wc_price_based_country_get_product_price is in line 119 of class-wcpbc-product-price.php, if apply_filter return false the code that return the WCPBC price not will run.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘set_price() doesn't work with non default currencies’ is closed to new replies.