• Resolved Dan

    (@danielnr87)


    Hi, I am interested in using the Tax options module, specfically the toggle for display the price with or without tax [wcj_button_toggle_tax_display].

    I’d like it to look like a toggle button, something like the VAT display toggle at the top left of https://www.posturite.co.uk/. Is there a way that it can be a checkbox rather than an input type=”submit”?

    Potentionally a function I could use?

    Many thanks
    Dan

    • This topic was modified 2 years, 10 months ago by Dan.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support David G

    (@gravid7)

    Hi @danielnr87,

    Thanks for reaching out to us.

    Sorry, currently there is no features in the plugin for display toggle including tax or excluding tax price. You can use below shortcodes for display price including tax and excluding tax.

    [wcj_product_price_including_tax]
    [wcj_product_price_excluding_tax]

    Let me know if you need any further help.

    Thread Starter Dan

    (@danielnr87)

    Hi David, thank you for your reply.

    Regarding the toggle idea – This could be easier implemented if you used a <button> rather than <input> within the form, as I can manipulate it better with CSS.

    Is there a way I can change the text on the button as it is?

    Thanks
    Dan

    Thread Starter Dan

    (@danielnr87)

    Also, is there a way to output the text Inc VAT and Ex VAT (based on the toggle selection) on the WooCommerce price as a suffix?

    Hello, I’m trying to accomplish the same has @danielnr87.
    I intend to show “Inc VAT” and “Ex Vat” has price suffix depending on the toggle.

    Is there a filter or action that I can use?

    Regards

    Thread Starter Dan

    (@danielnr87)

    A filter would be great. I am using jquery to change the input value currently, but it is a little clunky as it jars with a delay in changing.

    Are there any filters or actions for this text?

    Did you find a solution @pedrodigitalgreen ?

    Thanks Dan

    Hi @danielnr87, what I did after analyzing the booster code was to change the suffix depending on the current session toggle value.

    In the ‘woocommerce_get_price_suffix’ filter, I use the ‘wcj_toggle_tax_display’ to change the suffix as needed.

    My snippet is bellow, maybe this will help you.

    
    /* Change the suffix of tax based on booster bt */
    add_filter( 'woocommerce_get_price_suffix', 'dg_add_price_suffix', 99, 4 );
    function dg_add_price_suffix( $html, $product, $price, $qty ){
    	
    	//current booster toogle session value	
    	$session_toogle = wcj_session_get('wcj_toggle_tax_display');
    	
    		if($session_toogle == 'excl'){
    			//sem iva
    			$html .= ' excl/iva';
    		}
    	
    		if($session_toogle == 'incl'){
    			//com iva
    			$html .= ' incl/iva';
    		}
    
        return $html;
    }
    

    Regards.

    Thread Starter Dan

    (@danielnr87)

    @pedrodigitalgreen That works a treat, thank you very much. Did you manage to also get the filter to change the text on the actual toggle button as well?
    Thanks again,
    Dan

    Hi @danielnr87, my booster shortcode to show the tax switcher is this:

    [wcj_button_toggle_tax_display class=”tax-switcher” label_incl=”Com Iva” label_excl=”Sem Iva” ]

    I stayed with the “button like switcher” only added a custom css class (tax-switcher) changing the button aspect to follow my theme colors. To modify it as a checkbox I believe we must change the code of the booster itself. This was a workaround.

    As for the text inside the button, the params “label_incl” and “label_excl” will do the trick.

    The documentation I have follow is in this Link

    Regards

    Thread Starter Dan

    (@danielnr87)

    @pedrodigitalgreen this is perfect thanks, I didn’t realise that you could use attributes on the shortcode as I didn’t find it in any documentation!

    Yea I used the toggle input button in the end and styled it too. Hopefully, a checkbox style will come in due course.

    Thanks for the info.

    @gravid7 You should add this information in to the documentation/instructions.

    That’s a great solution @pedrodigitalgreen to get the suffix to change depending on the tax display status.

    For me, when I initially access the shop page or a product page however, it does not display the suffix straight away. Only when I click the toggle to change the tax display it then adds the suffix. It seems like every time i start a new browser session I have to click the toggle to activate the suffix.
    I have tried this on multiple browsers.

    Hello @cjhill44, you’re right, I had to fix that issue after my vacations.
    I updated the code to use a default suffix when the booster session toggle is not defined.

    The updated code:

    
    /* Change the suffix of tax based on booster bt */
    add_filter('woocommerce_get_price_suffix', 'dg_add_price_suffix', 99, 4);
    function dg_add_price_suffix($html, $product, $price, $qty)
    {
    
        //current booster toggle session value	
        $session_toggle = wcj_session_get('wcj_toggle_tax_display');
    
        if ($session_toggle == 'excl') {
            //sem iva
            $html .= ' excl/iva';
        } else if ($session_toggle == 'incl') {
            //com iva
            $html .= ' incl/iva';
        } else {
            //default suffix - toggle value not defined
            $html .= ' excl/iva';
        }
    
        return $html;
    }

    @danielnr87 maybe you want to update the code as well.

    Regards

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Turn Tax Toggle into a checkbox’ is closed to new replies.