• Resolved fkoomek

    (@fkoomek)


    Hello.
    Is it possible to recheck currency and recalculate prices in cart when a page is loaded/ajax is complete? I am having a problem when using currency switcher + caching plugin. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Shouldn’t have a problem, everything is dynamic & taken via woocommerce filters.
    Please mention the currency switcher plugin name & your website link.

    Thread Starter fkoomek

    (@fkoomek)

    Thanks for your answer.
    I am using currency switcher by Algoritmika.
    I tried also switcher by WOOCS, but it’s the same. Actually, both plugins work very badly with caching plugins. Algoritmika solution is to enable Woocommerce “detect geolocation with caching support” which actually means losing caching advantages – useless. Plugin by Woocs adds some additional Ajax call, but it doesn’t work either.
    So, I decided to find other solution. I disabled caching support and as I am using also Polylang plugin, I tied up currencies with languages. This way, prices are cached correctly according to currencies tied up with languages.
    However, after switching language, currency doesn’t change in Ajax Cart. Maybe, it’s a problem with the currency switcher plugin.
    You can check it here https://test.liberlapidum.com/
    Try to add an item on a single product page (I disabled Ajax on archives) and switch languages back and forth.

    Hi,

    I have no expertise in caching.
    However, I checked your site , unlike other html, side cart plugin loads it cart contents via ajax “?wc-ajax=get_refreshed_fragments” request
    Its strange that even after you refresh a page , it still shows the earlier selected currency.
    Try placing this in your functions.php , I am not sure if this will work , but this is all i know.

    add_action( 'wp_footer', function(){
    	?>
    	<script type="text/javascript">
    		jQuery(document).ready(function($){
    			$(document.body).on('added_to_cart',function(){
    				$( document.body ).trigger( 'wc_fragment_refresh' );
    			})
    		})
    	</script>
    	<?php
    });
    

    Please respond to this thread, if you ever find a solution.

    Thread Starter fkoomek

    (@fkoomek)

    Thank you.
    I tried your code with no luck.
    I believe it’s a problem with the currency switcher plugin and caching plugin.
    The thing is, that when I switch to a different language which is tied up with certain currency, the currency changes correctly if the page is not cached. But when I switch back to language which is already cached, the function to set currency by language won’t execute, because the PHP code is cached.
    It would have to be some ajax function which checks current language and changes currency according to that, I guess, but I am not a developer, just a beginner.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘ajax call to get current currency’ is closed to new replies.