• Resolved Lyk

    (@lyk-1)


    Hello and thank you for this useful plugin.

    I have the following scenario:

    For some countries, a second price for B2B cases was needed.
    A B2B customer user role is created for B2B changes throughout the eshop

    However in the pricing zone of Price Based on Country you cannot create a zone with countries already used which makes sense.

    Thus, I added the B2B cases as extra countries, i.e.

    add_filter( 'woocommerce_countries',  'add_b2b_countries' );
    function add_b2b_countries( $countries ) {
        $new_countries = array(
            'IT_B2B'  => __( 'Italy - B2B', 'woocommerce' ),
            // .....
        );
    
        return array_merge( $countries, $new_countries );
    }

    Obviously these countries do not have any geolocation.

    Is there any filter/hook where one could change the country before the price is selected? Or just change the price?
    So that I could simply check something like:

    if ( wc_current_user_has_role( 'b2b_customer' ) ) {
        // select a different pricing zone
        //  or or something similar
    }
    

    Thank you in advance!

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

    (@oscargare)

    Use the action wc_price_based_country_before_frontend_init and the function wcpbc_set_woocommerce_country to set the country.

    Thread Starter Lyk

    (@lyk-1)

    Thank you! Will check them both and will report back if I face any problems.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter/hook for changing prices’ is closed to new replies.