to: When a business purchases in Woocommerce, no commission should be given

Dear support team!
Referring to the response from (George June 11, 2020 at 1:06 pm #).
We have now developed a code and entered the formula in the rates.

Unfortunately, only the base level will be calculated. Levels 1, 2 and 3 are not calculated.

When guessing in the Value field, we entered the formula as follows:
Basis: t * c * 0.2
Stufe 1: t * c * 0.1
Stufe 2: t * c * 0.05
Stufe 3: t * c * 0.02

The following code is in the theme function (functions.php):
*********************************************

// Hilfsfunktion für Berechnung der Provision
// Funktion zum überprüfen ob ein string mit einer gewissen Zeichenfolge beginnt
function startsWith_2($haystack, $needle)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}

//Berechnung der Provison für Fair-Partner unterbrechen bei Bestellung von Fair-Partnern
// –Provisionen nur bei Bestellungen von Kunden berechnen. Bei Bestellungen von Fair-Partner wird es auf 0,00 gesetzt.
function my_variables( $variables, $rate, $context ) {
$current_user_id = get_current_user_id();
$u_data = get_userdata( $current_user_id );
$is_fairpartner = false;

if ( ! empty( $u_data->roles ) ) {
// ein wp-user kann mehrere Rollen haben – daher müssen alle Rollen überprüft werden
// ob eine der Rollen das Wort “fairpartner” enthält:
foreach ($u_data->roles as $role) {
if (startsWith_2($role, ‘fairpartner’)) {
$is_fairpartner = true;

// Abbruch der Schleife, da eine “fairpartner” Rolle gefunden wurde
break;
}
}
}
if ($is_fairpartner == true){
$variables[’c’] = 0;
}
else{
$variables[’c’] = 1;
}

return $variables;
}
add_filter( ‘affiliates_formula_computer_variables’, ‘my_variables’, 10, 3 );

// –ENDE Provisionen nur bei Bestellungen von Kunden berechnen.
*********************************************************************

This error message appears 4 times in a row in the debug log:
…PHP Notice: Undefined variable: IX74179 in /homepages/8…/…/…/wp-content/plugins/affiliates-enterprise/lib/eext/wordpress/class-affiliates-multi-tier.php on line 48

What have we overlooked?

With the request for support so that all levels are calculated.

 


Comments

7 responses to “to: When a business purchases in Woocommerce, no commission should be given”

  1. Yes exactly that. Now it should be ok and calculate the commissions the way you want them.

    Cheers,
    George

  2. Hi Christa,

    Sorry for the delay on this but please have a look at your rates and make the following adjustments.
    Instead of using formula based rates for each tier level, use the following:
    1. For level 1, enable relative and set the commission to Rate with value 0.5
    2. For level 2, enable relative and set the commission to Rate with value 0.25
    3. For level 3, enable relative and set the commission to Rate with value 0.01

    This way each tier level commission will be related to the OR commission -relative- and the commission amount will be a proportion of that commission.

    Please use these values and let me know if it works as it should. FYI, the error logged requires an update to take place so this way you can avoid pending for the update and use the system right away with the expected results.

    Kind regards,
    George

    1. ProEnergetic Avatar
      ProEnergetic

      Hello George!
      It looks like it will work.
      thank you

      So now the settings are in the rate
      For Basis: formula t * c * 0.2 and Integration – WooCommerce
      1. For level 1, enable relative and set the commission to Rate with value 0.5
      2. For level 2, enable relative and set the commission to Rate with value 0.25
      3. For level 3, enable relative and set the commission to Rate with value 0.01

  3. Hi Christa,

    Thanks for providing your code for this case, much appreciated. It seems to be correct, but I also get the same error you get but shouldn’t. FYI, at the moment I’m in the process of debugging it and if necessary will deploy an update for the plugin.
    What happens if you change your formulas to: s*c*0.1 etc?

    Kind regards,
    George

    1. ProEnergetic Avatar
      ProEnergetic

      Hi George!
      With the formula s * c * 0.1, the commission is not calculated as desired.
      Same error message:
      Undefined variable: IX74179 in /homepages/…./…/wp-content/plugins/affiliates-enterprise/lib/eext/wordpress/class-affiliates-multi-tier.php on line 48

      And the levels’ commissions are not calculated.

      Screenshots:


      thank you for your efforts

  4. ProEnergetic Avatar
    ProEnergetic

    Hello Eugene!
    Thank you we are healthy.
    We look forward to your help.
    best regards

  5. Eugen Bleck Avatar
    Eugen Bleck

    Hi Christa,

    I trust you are feeling great today!

    Many thanks for using Affiliates and for being a valued customer. I must apologize for the delay in response.

    I’ve gone ahead to notify George and he would be reaching out ASAP.

    Once again, I am super sorry I could only issue a response just now.

    In the meantime, I wish you an awesome and productive day.

    STAY SAFE!
    Warm regards,
    Eugen.

Share