• Resolved mkirkeby

    (@mkirkeby)


    Hi.

    Im trying to get my table on 3dpriser.dk to work with live currency rates. im at the moment using the worldcurrency plugin together with tablepress. my problem is now that i cant sort the column with prices because of the shortcodes from the worldcurrency plugin.

    does anybody know how to get live currency rates in a tablepress table?

    -Mikkel

    https://www.ads-software.com/extend/plugins/tablepress/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi Mikkel,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I’m not really sure which sorting you are talking about here. Can you please clarify where exactly the sorting is not working?

    Thanks,
    Tobias

    Thread Starter mkirkeby

    (@mkirkeby)

    Hello.
    Sorry for the unclarity of my post.

    if you go to https://3dpriser.dk/3d-printer and try to sort the table py price by clicking “pris” its not sorting them. The prices are connverted from USD to DKK by the worldcurrencyplugin. in every price field i have the following shortcode. [worldcurrency curr=”USD” value=”xxx”]

    how can i get the table to sort the column by the result of shortcodes?
    or is there another script og code that makes me able to convert prices live to native currencies?

    thankyou

    -Mikkel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Mikkel,

    thanks for the clarification! Now I understand what you mean.

    The problem here is the output of the World Currency plugin (and not the Shortcodes themselves). The Shortcodes result in HTML code like

    <span class="worldcurrency" postId="13" curr="USD" value="1499" ></span>

    for which the World Currency plugin then triggers an AJAX request to obtain the converted value from the server. Therefore, the value is not in the page HTML when the sorting (using the DataTables JavaScript library) is initialized. And that results in the weird/wrong sorting results.
    Unfortunately, with this approach of the World Currency plugin, I don’t see an easy possibility to make this sortable ?? One would have extend the JS of the World Currency plugin to trigger another initialization of the sorting after finishing the AJAX requests, which is probably hard to do ??
    Another idea would be to have the Shortcode return the converted value directly, instead of using an AJAX request. In that case, you could develop a custom sorting algorithm for the special HTML format, or use the existing one for currencies.

    Regards,
    Tobias

    Thread Starter mkirkeby

    (@mkirkeby)

    Thankyou for your help. I have now gotten the currency extension to work by sorting the table as you can see. however, the user is not able to toggle the price column, to show low to high instead of high to low. Is there a way to get the table to toggle the sorting of the extension?

    -Mikkel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Mikkel,

    no, as I said, that pricing colum is not sortable, due to the special way how the World Currency plugin works.
    Or do you want to deactivate sorting for that column, when you say “toggle the sorting”.

    Regards,
    Tobias

    Thread Starter mkirkeby

    (@mkirkeby)

    No, your right. the table doesnt sort the products by price. Im justing looking for a way or an table that makes me able to sort the products by live prices. dont know if it is even possible.?

    -Mikkel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that’s what I was trying to explain above. Sorting by live prices is not possible due to the way the World Currency plugin works. To make this sortable, you will need to either extend the JavaScript code of that plugin (which is probably not easy) or find another solution for the live prices.

    Regards,
    Tobias

    Thread Starter mkirkeby

    (@mkirkeby)

    last question. would it be possible to make the table de calculus with predefined values. for example.
    in a cell in the would there would be. (100*USD)
    and USD predefined en the extra javascripe line for the plugin. “USD=10”

    Would it be possible to make the cell display “1000” and be able to sort the values?

    regards.
    -Mikkel

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Mikkel,

    yes, you can have formulas in table cells, but unfortunately, these must be just numbers, so they can not have units on them ?? You would therefore have to put the name of the currency (like USD or EUR) into the table head column).

    For example, you could have a column with the USD prices, which you will with values like “50”, “100” (whatever the price is).
    Then in another column, you can use a formula like in Excel: =A2/B6
    A2 would be the cell with the one currency value (just as a number), and B6 would be the cell with the conversion factor.

    Regards,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Currency conversion for tablepress’ is closed to new replies.