Jump to content

Commision Script


PierreL

Recommended Posts

Hi Guys

 

I'm pretty new to PHP and need desperate help to modify a function. This function calculates commision for an auction.

 

function vbccalc_commission($vbc_finalprice, $vbcomm_increments){
	settype($vbc_finalprice, "float");

	// Build the Commissions Structure
	$vbcomm_inc = explode("\n", $vbcomm_increments);
	$vbccomm_index = '0';
	foreach($vbcomm_inc AS $vbcomm_inc_bit){
		$vbccomm_bit = explode("|", $vbcomm_inc_bit);
		$vbccomm_index++;
		$vbccomm_level[$vbccomm_index] = $vbccomm_index;
		settype($vbccomm_bit[0], "float");
		$vbccomm_price[$vbccomm_index] = $vbccomm_bit[0];
		settype($vbccomm_bit[1], "float");
		$vbccomm_fee[$vbccomm_index] = $vbccomm_bit[1];
		$max = $vbccomm_index;
	}

	$count = $max;
	$vbcomm_sum = '0';
	while ($count > 0) {
		if($vbc_finalprice >= $vbccomm_price[$count]){
			$vbcomm_step = $vbc_finalprice - $vbccomm_price[$count];
			$vbcomm_bit = $vbcomm_step * $vbccomm_fee[$count];
			$vbcomm_sum = $vbcomm_sum + $vbcomm_bit;
			$vbc_finalprice = $vbc_finalprice - $vbcomm_step;
		}
		$count--;
	}
	$vbc_commission = $vbcomm_sum;
	return $vbc_commission;
}


 

The $vbcomm_increments is not needed anymore. The new commision structure can be hard coded. $vbcomm_increments allowed you to modify the script but the modifier can not do what i want the script to do. Below is an example of what i want this script to do

 

- Listing fee for all items is R 15.00

- Goods listed from R 0.01 - R 500.00, only the listing fee has to be paid.

- From R 500.01 - R 10 000.00, listing fee + 5%

- From R 10 000.01 and above, listing fee + 3%

 

Examples

 

- You sell a fly box with flies for R 200.00, the fee is the listing fee of R 15.00

 

- You sell a rod for R 600.00, the fee is the listing fee (R 15.00) + 5% of R 600.00 (R 30.00) = R 45.00

 

- You sell a Sage for R 1200.00, the fee is the listing fee (R 15.00) + 5% of R 1200.00 (R60.00) = R 75.00

 

- You sell your vehicle for R 50 000.00, the fee is the listing fee (R15.00) + 3% of R 50 000.00 (R 1500.00) = R 1515.00

 

The guy that wrote this mod for an auction scripts is not supporting this anymore and is un available which leaves me in a bad spot not being able to launch.  >:(

 

I would be really gratefull if someone can help me out.

 

Thanks in advance

 

All the best

 

Pierre

Link to comment
Share on other sites

Hi Blade

 

No i dont expect you guys to do it, just needed advise, this is what i tried.

 


$vbc_finalprice = 200.00;

		if($vbc_finalprice <= 500.00)
		     {
                   $vbcomm_sum = 15.00;

			    }else if ($vbc_finalprice >= 500.01 && $vbc_finalprice <= 10000.00){

			       $vbcomm_sum = $vbc_finalprice * (1 - 0.05) + 15.00;

			     }else($vbc_finalprice >= 10000.01){

                       $vbcomm_sum = $vbc_finalprice * (1 - 0.03) + 15.00;

			     }

			   $vbc_commission = $vbcomm_sum;
			   return $vbc_commission;
			   				   
			   print "$vbc_commission";

 

PHP does not seem to like this, but you get what i am trying to do here

 


else if ($vbc_finalprice >= 500.01 && $vbc_finalprice <= 10000.00)

 

Cheers

Link to comment
Share on other sites

Ok i think i;ve cracked it

 


if(($vbc_finalprice >= 0.01) and ($vbc_finalprice <= 500.00))
		     {
                   $vbcomm_sum = 15.00;

			    }else if (($vbc_finalprice >= 500.01) and ($vbc_finalprice <= 10000.00)){

			       $vbcomm_sum = $vbc_finalprice * 0.05 + 15.00;

			     }else if($vbc_finalprice >= 10000.01){

                       $vbcomm_sum = $vbc_finalprice * 0.03 + 15.00;

			     }else{

				 $vbcomm_sum = 0;

				 }

			   $vbc_commission = $vbcomm_sum;
			   return $vbc_commission;


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.