• Resolved wpallthetime

    (@wpallthetime)


    I’d like to change the privacy text depending on whether tax is charged.

    I know I could edit functions.php and find something along the lines of:

    add_filter( ‘woocommerce_get_privacy_policy_text’, function ( $text, $type )
    {
    switch ( $type )
    {
    case ‘checkout’:

    But I’m unsure what I’d enter for switch so it shows privacy statement that’s default, but a different privacy when tax is being charged.

    Can anyone help? Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • con

    (@conschneider)

    Engineer

    Hi there,

    add_filter( ‘woocommerce_get_privacy_policy_text’, function ( $text, $type )
    {
    switch ( $type )
    {
    case ‘checkout’:

    You can basically copy and modify this: https://github.com/woocommerce/woocommerce/blob/e1aaa6c63c02bd6197d4b40fce317cf8d424d36b/includes/wc-template-functions.php#L807 and add a control statement that gets the tax type via for example:

     // Get the unformated taxes array
        $taxes = $cart->get_taxes(); 

    Kind regards,

    Thread Starter wpallthetime

    (@wpallthetime)

    Adding this line:

    $taxes = $cart->get_taxes();

    Gives me a there has been a critical error on your web site error. I remove it, it goes away, I add it, the error is back. Is there some additional line I need to preface this one?

    This is really frustrating, I’ve been at this for hours trying all kinds of variations but every time I try to read tax variable it gives me the error.

    Is there something wrong with this:

    add_action(‘woocommerce_checkout_after_terms_and_conditions’, ‘add_terms_and_policy’, 20);

    function add_terms_and_policy( $cart ) {
    $taxes = $cart->get_taxes();
    }

    • This reply was modified 6 years, 2 months ago by wpallthetime.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Show privacy text based on condition’ is closed to new replies.