[Skip to main content](#vessel-content)

#   Advise regarding the Affiliate statistics needed

##

- **[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")**
- [![seoweb's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4686.gif)](/forum/user/4686-seoweb "View seoweb's Profile") Topic Author
- [ Offline](/forum/user/4686-seoweb)

Less More

- Posts: 80
- Thank you received: 1
-
-

14 years 8 months ago -  14 years 8 months ago [\#41522](#41522) by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile")  *[Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#41522 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")* was created by *[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")*

Hello,

At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.

This logic might be used in a file components/com_hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order_full_price looks like this:
Code:

if ($row-&gt;order_full_price == 39.9900){ echo '&amp;#163;20.00'; } elseif ($row-&gt;order_full_price == 79.9800){ echo '&amp;#163;40.00'; }

The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:
Code:

elseif($row-&gt;order_full_price == 24.9900){ echo '&amp;#163;10.00'; } elseif($row-&gt;order_full_price == 49.9800){ echo '&amp;#163;20.00'; } else echo 'No rule for this!';

and so on...

As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order_full_price different from predefined ones, all the calculations will be wrong.

So... I am looking to make calculations based on product_id + order_product_quantity + order_product_price (which are stored in different tables _hikashop_order_product and _hikashop_order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.

Please advise how can I accomplish the task.

Last edit: 14 years 8 months ago by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

14 years 8 months ago [\#41676](#41676) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#41676 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

Hi,

Do like that: Code:

$orderClass = hikashop_get('class.order'); $allOrderInfo = $orderClass-&gt;loadFullOrder($row-&gt;order_id);

Then, you can loop through the products of the order like that: Code:

foreach($allOrderInfo-&gt;products as $product){ //my calculations code }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")**
- [![seoweb's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4686.gif)](/forum/user/4686-seoweb "View seoweb's Profile") Topic Author
- [ Offline](/forum/user/4686-seoweb)

Less More

- Posts: 80
- Thank you received: 1
-
-

14 years 8 months ago -  14 years 8 months ago [\#42819](#42819) by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile")  Replied by *[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#42819 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

Hello,

I am getting an error:
Code:

Warning: Invalid argument supplied for foreach() in /home/didamobi/public_html/templates/didamobile/html/com_hikashop/affiliate/sales.php on line 182 N/A

should be something wrong here:
Code:

foreach($allOrderInfo-&gt;products as $product){

Please advise

Last edit: 14 years 8 months ago by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

14 years 8 months ago [\#42837](#42837) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#42837 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

If you get that error, it means that the system could not load the order information.

I think that it's because you're not the owner of the order. In that case, you need to change the code:
$allOrderInfo = $orderClass-&gt;loadFullOrder($row-&gt;order_id);

to:
$allOrderInfo = $orderClass-&gt;loadFullOrder($row-&gt;order_id,false, false);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")**
- [![seoweb's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4686.gif)](/forum/user/4686-seoweb "View seoweb's Profile") Topic Author
- [ Offline](/forum/user/4686-seoweb)

Less More

- Posts: 80
- Thank you received: 1
-
-

14 years 8 months ago -  14 years 8 months ago [\#42861](#42861) by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile")  Replied by *[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#42861 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

No, still no luck.

At the moment I use this code:
Code:

$orderClass = hikashop_get('class.order'); $allOrderInfo = $orderClass-&gt;loadFullOrder($row-&gt;order_id); $affil_array = array( 25 =&gt; 20, // for product with id 25 there is £20 payout 39 =&gt; 20, 40 =&gt; 20, 45 =&gt; 20 ); $affil_total = 0; foreach($this-&gt;order-&gt;products as $product){ if (array_key_exists($product-&gt;order_product_id, $affil_array)) { $affil_total+= ($affil_array[$product-&gt;order_product_id]*$product-&gt;order_product_quantity); } } echo ($affil_total&gt;0)?'&amp;#163;'.number_format($affil_total, 2, '.', ''):'N/A';

Any more ideas?

Thanx

Last edit: 14 years 8 months ago by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

14 years 8 months ago [\#42908](#42908) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#42908 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

Your code doesn't use the modification of my previous message and the variable of the foreach is different from what I said in my first message. Finally, it should be product_id and not order_product_id that you use in your code. Thus, it should be: Code:

$orderClass = hikashop_get('class.order'); $allOrderInfo = $orderClass-&gt;loadFullOrder($row-&gt;order_id,false, false); $affil_array = array( 25 =&gt; 20, // for product with id 25 there is £20 payout 39 =&gt; 20, 40 =&gt; 20, 45 =&gt; 20 ); $affil_total = 0; foreach($allOrderInfo-&gt;products as $product){ if (array_key_exists($product-&gt;product_id, $affil_array)) { $affil_total+= ($affil_array[$product-&gt;product_id]*$product-&gt;order_product_quantity); } } echo ($affil_total&gt;0)?'&amp;#163;'.number_format($affil_total, 2, '.', ''):'N/A';

The following user(s) said Thank You: [seoweb](/forum/user/4686-seoweb "View seoweb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")**
- [![seoweb's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4686.gif)](/forum/user/4686-seoweb "View seoweb's Profile") Topic Author
- [ Offline](/forum/user/4686-seoweb)

Less More

- Posts: 80
- Thank you received: 1
-
-

14 years 8 months ago [\#45124](#45124) by [seoweb](/forum/user/4686-seoweb "View seoweb's Profile")  Replied by *[seoweb](/forum/user/4686-seoweb "View seoweb's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#45124 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

Thanx Nikolas,

Could you, please, advice on how to implement the same for the back end view of Affiliates -&gt; Partners where the TOTAL_UNPAID_AMOUNT are shown?

Regards,
SeoWeb

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

14 years 7 months ago [\#45314](#45314) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Advise regarding the Affiliate statistics needed](/forum/4-how-to/41522-advise-regarding-the-affiliate-statistics-needed#45314 "Hello,  At the moment I am working on some changes to Affiliate statistics. Say, I have some products in my store The first one cost 39.99 and is eligible to the Affiliate program.  This logic might be used in a file components/com&#95;hikashop/views/affiliate/tmpl/sales.php to show how much money the reseller is going to get based on a order&#95;full&#95;price looks like this:  The second one cost 24.99 and is also eligible to the Affiliate program. For this one this logic will work:  and so on...  As you understand the major problem here is if the product price will change or there will be another product within the order which will make the order&#95;full&#95;price different from predefined ones, all the calculations will be wrong.  So... I am looking to make calculations based on product&#95;id + order&#95;product&#95;quantity + order&#95;product&#95;price (which are stored in different tables &#95;hikashop&#95;order&#95;product and &#95;hikashop&#95;order) and ideally the discount value to be deducted from predefined payout figure (20.00 or 40.00 as shown in the first example) if the reseller gave the discount code to the customer and is happy to get the discount code value deducted form his profit.  Please advise how can I accomplish the task.")*

For the total unpaid amount of that listing, it's the file "listing" of the view "user" that you should edit in a similar manner.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQxNTIyLWFkdmlzZS1yZWdhcmRpbmctdGhlLWFmZmlsaWF0ZS1zdGF0aXN0aWNzLW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.100 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
