Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support mediawebster

    (@mediawebster)

    Hello

    our plugin redraws prices in ajax mode. But the problem is different: We use woocommece to determine the location and with some cache settings these requests are cached. And we can’t change it

    Thread Starter jeffrey149

    (@jeffrey149)

    Hi, for people having similar issue, I have resolved this issue by implementing a custom php function in functions.php and a custom js script to make a call to the php function via ajax.

    The javascript create cookie to keep track of user selected currency, and call functions.php via ajax.

    The process is simply

    1. In javascript, get product ids in the current page using jquery [data-product-id]
    2. Ajax call to php function ({action, currency, product_ids})
    3. In php function, $WOOCS->set_currency(currency), the currency is default geolocation/cookie value if present.
    4. for each product ids, $_product->get_price_html()
    5. Return the data as {[product_price_html], current_currency}
    6. Back to javascript, refresh all product price by matching and replacing all span[data-product-id] with returned product_price_html
    7. Refresh mini cart(ajax call wc_cart_fragments_params), refresh shopping cart

    I have tested and seems to work for my website, but test thoroughly in your website!
    This is just to give some direction incase anyone face similar issue and don’t know where to start.

    I can now changed the woocommerce geolocate (with page caching support) to geolocate, remove the extra page redirect at the cost of couple ajax calls, saving ~2-3 seconds on initial page load, also reducing load by not having to cache multiple version of website (the added v=?parameter with woocommerce)

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    Great! Thank you for your cooperation!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Page caching with multicurrency’ is closed to new replies.