• Hello on the site https://klitgaard-digital.dk/ i have issues with a popup that switches prices between Ex vat and Inc vat.

    As of now, you have to click a couple of time for it to actually work.
    If you go to the shop: https://klitgaard-digital.dk/shop/
    You can see prices say: “Inkl. moms” as suffix.

    If you press the Privat/Erhverv in the menu, you can switch to “Erhverv” this should change the prices to Ex vat, and set the suffix to: “ekskl. moms”

    Right now you have to press this button multiple times before it works.

    Code to help with functionality:
    `/**
    * @snippet Adds translatable suffix WooCommerce Prices with price ex tax
    * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
    * @source https://businessbloomer.com/?p=472
    * @author Rodolfo Melogli
    * @compatible WooCommerce 3.5.1
    * @donate $9 https://businessbloomer.com/bloomer-armada/
    */

    add_filter( ‘woocommerce_get_price_suffix’, ‘bbloomer_price_translatable_suffix’, 99, 4 );

    function bbloomer_price_translatable_suffix( $html, $product, $price, $qty ){

    $current_tax_value = ( ” == ( $session_value = wcj_session_get( ‘wcj_toggle_tax_display’ ) ) ? get_option( ‘woocommerce_tax_display_shop’, ‘excl’ ) : $session_value );
    $tax_rates = WC_Tax::get_rates( $product->get_tax_class() );

    $tax_rate_value = ’25’;

    if (!empty($tax_rates)) {
    $tax_rate = reset($tax_rates);
    $tax_rate_value = $tax_rate[‘rate’];
    }

    if( ($value) && $tax_rate_value == ‘0’ ) {
    $html .= ” . __( ‘ ‘.$value.”, ‘bbloomer’ ) . ”;
    }

    else if ( $tax_rate_value == ‘0’ ) {
    $html .= ” . __( ”, ‘bbloomer’ ) . ”;
    }

    else if( $current_tax_value == ‘excl’ ) {
    $html .= ‘ ekskl. moms’ . __( ‘ ‘.$value.”, ‘bbloomer’ ) . ”;
    }

    else if( $current_tax_value == ‘incl’ ) {
    $html .= ‘ inkl. moms’ . __( ‘ ‘.$value.”, ‘bbloomer’ ) . ”;
    }

    return $html;
    }

    add_filter( ‘body_class’,’my_body_classes’ );
    function my_body_classes( $classes ) {
    $current_tax_value = ( ” == ( $session_value = wcj_session_get( ‘wcj_toggle_tax_display’ ) ) ? get_option( ‘woocommerce_tax_display_shop’, ‘excl’ ) : $session_value );
    $classes[] = ‘current-tax-‘.$current_tax_value.”;
    return $classes;
    }

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

  • The topic ‘Switch between inc VAT and ex VAT’ is closed to new replies.