Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jeffrey149

    (@jeffrey149)

    If it is not currently available, can you tell me how you compile the typescript into javascript so I can edit the typescript myself and update the existing javascript?

    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)

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