• Resolved idinteractive

    (@idinteractive)


    Hello,

    I’m using WC Vendors (2.0.10) for a recently released project. I installed version 2.0.10 on August 2, 2018. Everything worked perfectly for commissions. In the day of August 8, 2018, without any update of the plugin (WC Vendors or other), WC Vendors no longer took into consideration the numbers with a comma.
    For example, I set the commissions on 100%, with a product to 29 € TTC, I had 24,17 € of commission and 4,83 € of tax.
    Now, for a product at € 29, I have € 24 commission and € 4 tax.
    The problem is that I miss 1 € in my transactions now.

    I use WooCommerce, Mangopay and WC Vendors.

    It is possible that I modified a parameter without realizing it, but after searching everywhere in the back office, I can not find a solution.

    Would you have a solution to my problem?

    Thank you in advance

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello,

    What is your currency set to in WooCommerce? Does this also happen on the latest install of WC Vendors Marketplace?

    cheers,

    Jamie.

    Thread Starter idinteractive

    (@idinteractive)

    Hello,

    The currency is the euro (€). We did the update (so we have latest version 2.1.1).

    The problem is still here. Order at 29 €, 24 € commission and 4 € tax.

    Sincerely,

    Hello,

    I switched my currency to EUR on one of my test installs and have been unable to replicate this issue. Does this work on 2.1.0?

    cheers,

    Jamie.

    Thread Starter idinteractive

    (@idinteractive)

    Hello,

    We tested with version 2.1.0 and it does not work better.

    I checked again on the side of WooCommerce and Mangopay, these two plugins display the good value (29 €).

    There must be a problem in WC Vendors or an incompatibility with another plugin.

    Yours,

    Hello,

    The commission calculation code has not been changed since version 2.0.0 was released so I’m not entirely sure how or what might be causing the issue.

    Are you able to setup a staging server and run the bare minimum plugins to see if there is an issue with the plugins, payment gateway or theme.

    WooCommerce
    WC Vendors Marketplace
    Storefront theme

    Then run some transactions and see if they work.

    cheers,

    Jamie.

    Thread Starter idinteractive

    (@idinteractive)

    Hello,

    We did tests on a development version. We managed to fix the problem by modifying the “insert_new_commission()” function in the “class-commission.php” class.

    Indeed, in this function when calling the “insert()” and “update()” functions of WordPress (wpdb), no format is specified. Therefore, WordPress considers all fields as “string”, so it uses “%s” in the SQL statement before the “prepare()” function.

    So I add a variable “$format” which simply modifies the formats of “total_due” and “tax” to consider them like float (“%f”):
    $format = array(“%s”, “%s”, “%s”, “%f”, “%s”, “%f”, “%s”, “%s”, “%s”);

    So I changed the call to both functions to use this variable:
    $update = $wpdb->update( $table, $order, $where, $format );
    if ( !$update ) $insert = $wpdb->insert( $table, $order, $format );

    The final result here is as follows:
    $format = array(“%s”, “%s”, “%s”, “%f”, “%s”, “%f”, “%s”, “%s”, “%s”);
    $update = $wpdb->update( $table, $order, $where, $format );
    if ( !$update ) $insert = $wpdb->insert( $table, $order, $format );

    I checked your old versions and it’s exactly the same. So I can not tell you what has changed, but with this correction everything works again correctly.

    Can be a server update at our host …

    Good day to you,

    Hello,

    Did your host recently update to PHP7? All of our dev is done with the latest PHP7.2 so I’m not sure why this isn’t an issue in our environments. If you want to prepare a pull request we can test it and integrate it so your changes are upgrade safe.

    https://github.com/wcvendors/wcvendors/issues

    cheers,

    Jamie.

    Thread Starter idinteractive

    (@idinteractive)

    We use 7.0.32 on our prod environment and 5.6.38 on our dev environment. The problem is present on both servers.

    Our problem is perhaps isolated, but since in this function we know the types of the variables, it might be interesting to implement this modification in the next version of the plugin. This will only affect people in the same situation as me.

    Do you prefer that I create a new issue on GitHub?

    Hello,

    Yes please create an issue with your code, or submit a Pull Request with your suggested changes.

    cheers,

    Jamie.

    Thread Starter idinteractive

    (@idinteractive)

    All right, I opened a new issue:

    https://github.com/wcvendors/wcvendors/issues/499

    If it can be added in the next update, it’s great!

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

The topic ‘Commissions are calculated on integers’ is closed to new replies.