• With the latest plugin version, commissions are not inserted during the order placement. Bulk recalculation (from the Pro version) works well.

    Looks like in the latest update, the strict comparison was added in WCV_Commission::insert_new_commission():

    $count = self::check_commission_status( $order, 'paid' );
    
    if ( 0 === $count ) {
    ...

    The function WCV_Commission::check_commission_status() is declared to return integer value, while it always return the string. Which fail the equation 0 === "0" and the commissions are not inserted.

    At other hand, the bulk processing in the Pro version wasn’t changed to strict comparison yet and thanks God it allows us to recalculate commissions.

    The resolution is to fix the return type of WCV_Commission::check_commission_status(), thank you in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Josh Kohlbach

    (@jkohlbach)

    Hey Max @cadic,

    Thanks for the heads up on this, appreciate it!

    We’ve pushed out a patch today 2.4.7.2 which should correct the issue. Let me know if you experience any further problems 🙂

    Thread Starter Max Lyuchin

    (@cadic)

    Thanks for the quick fix @jkohlbach

    It looks like the better solution will be fixing the return value:

    diff --git a/classes/class-commission.php b/classes/class-commission.php
    index a1dccc3..eeaf404 100644
    --- a/classes/class-commission.php
    +++ b/classes/class-commission.php
    @@ -338,7 +338,7 @@ class WCV_Commission {
                                                            AND status = %s
                    ";
     
    -               return $wpdb->get_var( $wpdb->prepare( $query, $status ) ); //phpcs:ignore
    +               return intval( $wpdb->get_var( $wpdb->prepare( $query, $status ) ) ); //phpcs:ignore
            }

    Because the return value of WC_Vendors::check_commission_status() is declared “int”:

    /**
     * Check the commission status for the order.
     *
     * @param array  $order The order.
     * @param string $status The status.
     *
     * @return int
     */
    public static function check_commission_status( $order, $status ) {

    While in fact, the function returns $wpdb->get_var() which is always the string!

    In the other way, the same issue may happen with WC Vendors Pro in the future, which currently use non-strict compare (same as WC Vendors prior to 2.4.7.1 did)

    Plugin Author Josh Kohlbach

    (@jkohlbach)

    Hey Max,

    Apologies I thought I’d already replied to this thread, but I must have closed the tab by mistake!

    Appreciate the follow up and the code suggestion!

    We actually had this fixed already in our upcoming 2.4.8 release and turns out we did implement this fix the same way as what you suggested.

    2.4.8 is basically ready but we’re going to hold onto it until after Black Friday as its a fairly big release (HPOS compat, better PHP 8.x+ compat, class restructuring, and various other changes).

    But there was another issue we wanted to patch today ahead of that, just released as 2.4.7.3, so we fixed up that other code change while there.

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Commissions are not inserted’ is closed to new replies.