This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Goal of this custom snippet: | |
* | |
* Override all commission calculations with a fixed value. | |
* The value should be the value of \SolidAffiliate\Lib\Settings::KEY_REFERRAL_RATE | |
* Ensure that only affiliate referred orders receive a commission. | |
* Make sure to catch any errors | |
* | |
* Add a note to the Settings > General page to inform the user of this change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Applies a maximum cap to the commission amount. | |
* | |
* @param float $total The calculated total commission for the order. | |
* @param \SolidAffiliate\Models\Affiliate $affiliate The affiliate object for whom the commission is calculated. | |
* @param \SolidAffiliate\Lib\VO\OrderDescription $order_description The order description object containing details about the order. | |
* @return float The possibly adjusted commission total, ensuring it does not exceed the maximum cap. | |
*/ | |
function set_max_commission_cap(float $total, \SolidAffiliate\Models\Affiliate $affiliate, \SolidAffiliate\Lib\VO\OrderDescription $order_description): float { | |
// Set the maximum commission amount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// James wants to limit recurring referrals to 1 or 6 periods depending on the product. | |
// 'solid_affiliate/should_skip_referral_creation_for_order' is the filter to use. | |
// The filter is passed a tuple [bool, string[]] where the bool is whether or not to skip the referral creation and the string[] is the reasons why. | |
// The filter is also passed the OrderDescription object. Using the OrderDescriptions, we need to determine whether or not the order is a recurring order, and if so, how many months it is recurring for. | |
add_filter( | |
'solid_affiliate/should_skip_referral_creation_for_order', | |
/** | |
* @param array{0: bool, 1: string[]} $tuple | |
* @param OrderDescription $order_description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- See https://psalm.dev/docs/running_psalm/configuration/#projectfiles --> | |
<psalm | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="https://getpsalm.org/schema/config" | |
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | |
phpVersion="5.6.20" | |
errorLevel="1" | |
resolveFromConfigFile="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function will attempt to find the Affiliate who referred the current visitor, | |
* and then return the user id of that affiliate. | |
* | |
* Example: | |
* $id = get_user_id_sld (); defaults user id to "1" | |
* $id = get_user_id_sld ( 2 ); defaults user id to "2" | |
* | |
* @param integer $user_id_to_return_if_no_affiliate_found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ids = \SolidAffiliate\Models\Visit::select_ids([ | |
'referral_id' => 0, | |
'created_at' => [ | |
'operator' => '<', | |
'value' => \SolidAffiliate\Lib\Utils::date_picker_time('-30 days') | |
] | |
]); | |
foreach ($ids as $id) { | |
\SolidAffiliate\Models\Visit::delete($id, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="bodyTable" style="border-collapse: collapse; height: 100%; margin: 0; padding: 0; width: 100%; background-color: #fafbff;" border="0" width="100%" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td id="bodyCell" style="height: 100%; margin: 0; padding: 60px 0; width: 100%;" align="center" valign="top"> | |
<table style="width: 600px;" border="0" width="600" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td style="width: 600px;" align="center" valign="top" width="600"> | |
<table class="templateContainer" style="border-collapse: collapse; border: 1px solid #d9e1ec; max-width: 600px !important;" border="0" width="100%" cellspacing="0" cellpadding="0"> | |
<tbody> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="bodyTable" style="border-collapse: collapse; height: 100%; margin: 0; padding: 0; width: 100%; background-color: #fafbff;" border="0" width="100%" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td id="bodyCell" style="height: 100%; margin: 0; padding: 60px 0; width: 100%;" align="center" valign="top"> | |
<table style="width: 600px;" border="0" width="600" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td style="width: 600px;" align="center" valign="top" width="600"> | |
<table class="templateContainer" style="border-collapse: collapse; border: 1px solid #d9e1ec; max-width: 600px !important;" border="0" width="100%" cellspacing="0" cellpadding="0"> | |
<tbody> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="bodyTable" style="border-collapse: collapse; height: 100%; margin: 0; padding: 0; width: 100%; background-color: #fafbff;" border="0" width="100%" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td id="bodyCell" style="height: 100%; margin: 0; padding: 60px 0; width: 100%;" align="center" valign="top"> | |
<table style="width: 600px;" border="0" width="600" cellspacing="0" cellpadding="0" align="center"> | |
<tbody> | |
<tr> | |
<td style="width: 600px;" align="center" valign="top" width="600"> | |
<table class="templateContainer" style="border-collapse: collapse; border: 1px solid #d9e1ec; max-width: 600px !important;" border="0" width="100%" cellspacing="0" cellpadding="0"> | |
<tbody> |
NewerOlder