Zen Cart Logo
Forums / General Questions / Jrox Zen Integration - how do I skip commissions if group discounts apply?

Jrox Zen Integration - how do I skip commissions if group discounts apply?

Locked

Views: 5,435

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
23 Feb 2008, 7:34 AM
#1
kehrli avatar

kehrli

Zen Follower

Join Date:
Aug 2007
Location:
Cannon Beach, OR
Posts:
180
Plugin Contributions:
0

Jrox Zen Integration - how do I skip commissions if group discounts apply?

I think my question is an easy one for php guys. I'm definitely not one of those yet, I'm afraid.

I have setup a group discount that my affiliates use to purchase products at my store. The problem is, that I don't want to give them the group discount plus the affiliate commission. Just the group discount. The code that we are given from jrox to put in tpl_footer.php (in the checkout_success override directory), is as follows:

##########################################
## START JAM INTEGRATION WITH ZEN CART  ##
## ZC Integration code by DrByte 8/2006 ##
##########################################
if ((int)$orders_id > 0) {
  $JAM = $db->Execute("select class, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '".(int)$orders_id."' AND class in ('ot_coupon', 'ot_subtotal', 'ot_group_pricing')");
  while (!$JAM->EOF) {
    switch ($JAM->fields['class']) {
      case 'ot_subtotal':
       $order_subtotal = $JAM->fields['value'];
        break;
      case 'ot_coupon':
       $coupon_amount = $JAM->fields['value'];
        break;
      case 'ot_group_pricing':
       $group_pricing_amount = $JAM->fields['value'];
        break;
    }
    $JAM->MoveNext();
  }
  $commissionable_order = ($order_subtotal - $coupon_amount - $group_pricing_amount);
  $commissionable_order = number_format($commissionable_order,2,'.','');
echo "<script language=\"JavaScript\" type=\"text/javascript\" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id\"></script></td></tr>

</table>";
}
#######################################
## END JAM INTEGRATION WITH ZEN CART ##
#######################################

Can someone help me with the code modification needed to block the generation of a commission if there is a group discount amount? This has got to be an easy one, something like:

if ($group_pricing_amount == 0)
{
echo "<script language="JavaScript" type="text/javascript" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id"></script>
}

But as you can see, I don't know php syntax. Can someone help me with this?

24 Feb 2008, 12:55 AM
#2
kehrli avatar

kehrli

Zen Follower

Join Date:
Aug 2007
Location:
Cannon Beach, OR
Posts:
180
Plugin Contributions:
0

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

I've since gotten some help at the jrox forum and have modified the code to include the following:

  if (empty($group_discount_amount))
  { 
  $commissionable_order = ($order_subtotal - $coupon_amount - $group_pricing_amount);
  $commissionable_order = number_format($commissionable_order,2,'.',',');
echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://www.yourdomain.com/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id\"></script></td></tr>
</table>";
  }

However, the variable used in the if clause above ($group_discount_amount) doesn't work, as it's apparently never empty and therefore commissions are never generated. What file is calling this footer? Where can I find the variable that is holding the group_discount amount, that will enable me to test for the presence of a group discount?

Thanks.

24 Feb 2008, 12:57 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

What version of Zen Cart?

24 Feb 2008, 1:28 AM
#4
kehrli avatar

kehrli

Zen Follower

Join Date:
Aug 2007
Location:
Cannon Beach, OR
Posts:
180
Plugin Contributions:
0

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

Doh!

1.3.7.1

24 Feb 2008, 1:47 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

kehrli:

if ($group_pricing_amount == 0)
{
echo "<script language="JavaScript" type="text/javascript" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id"></script>
}

I would expect that the concept you originally suggested should work fine.
I've copied it below, with a small correction.

Basically, using the original JAM-supplied code, just replace this:```
echo "<script language="JavaScript" type="text/javascript" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id"></script></td></tr>

</table>"; ```with this:``` if ($group_pricing_amount == 0) { echo "<script language=\"JavaScript\" type=\"text/javascript\" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id\"></script></td></tr> </table>"; } ``` NOTE: This will end up with two lines at the end containing just a brace: }
24 Feb 2008, 2:11 AM
#6
kehrli avatar

kehrli

Zen Follower

Join Date:
Aug 2007
Location:
Cannon Beach, OR
Posts:
180
Plugin Contributions:
0

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

Thanks, but I tried that before posting. I just tried it again to be sure. I got the following:

[B]Parse error[/B]:  syntax error, unexpected '=' in [B]/home/linksslc/public_html/fuelsaver-mpg/store/includes/templates/soft_blue/checkout_success/tpl_footer.php[/B] on line [B]90[/B]
```Line 90 is the line with the echo statement.  I haven't a clue why that line doesn't work after making the change.  But it didn't throw an error before the change.

The modified code (that is throwing the error) is as follows:

$commissionable_order = ($order_subtotal - $coupon_amount - $group_pricing_amount);
$commissionable_order = number_format($commissionable_order,2,'.','');
if ($group_pricing_amount == 0)
{
echo "<script language="JavaScript" type="text/javascript" src="/affiliates/sale.php?amount=$commissionable_order&trans_id=$orders_id"></script></td></tr>

</table>"; } } ```
24 Feb 2008, 2:15 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

src="/affiliates/sale.php
```change that by adding another backslash:```
src=\"/affiliates/sale.php
24 Feb 2008, 2:48 AM
#8
kehrli avatar

kehrli

Zen Follower

Join Date:
Aug 2007
Location:
Cannon Beach, OR
Posts:
180
Plugin Contributions:
0

Re: Jrox Zen Integration - how do I skip commissions if group discounts apply?

Ok, that's got it now. Thank you very much. Group members don't generate commissions and non-members do. Thanks a lot.

Now if I can just figure out why the commissions are exactly 1/2 what they should be... (not meant to be answered, haven't looked into it much yet).