Pay for Listings

13 posts by 4 authors in: Forums > CMS Builder
Last Post: May 16, 2012   (RSS)

By gversion - May 11, 2012

Hello,

I got you guys to create a plug-in so I can charge customers to create listings using PayPal. Attached is the code.

Could you please tell me how to change this so that the amount charged is a flat-fee of £14.99?

Currently the price is calculated as 5% of the Sale price with a maximum amount of £50, but this is a bit too complicated.

The calculation is around lines 40-53 I think.

Thank you,
Greg

Re: [gversion] Pay for Listings

By gkornbluth - May 11, 2012

Hi Greg,

you never posted the plugin

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Pay for Listings

By gversion - May 11, 2012

Thanks for the message, here it is. That's not the first time I've forgotten to hit the "upload attachment" button!

Regards,
Greg
Attachments:

calcaddcost.php 11K

Re: [gversion] Pay for Listings

By gkornbluth - May 11, 2012

Hi Greg,

Not sure SO TEST IT FIRST!, but you may just be able to change the code in lines 35 - 61 (effectively making the $adcost variable always 14.99) to:
function calcAdCost_process($tableName, $isNewRecord, $oldRecord, $id) {
if($tableName == 'listings') {
$listingsTable = $GLOBALS["TABLE_PREFIX"] . "listings";
$accountsTable = $GLOBALS["TABLE_PREFIX"] . "accounts";
$adCost = 0;
if(@$_REQUEST['sale_price']) {

$adCost = "14.99";

}
mysql_query("UPDATE $listingsTable SET ad_cost = '$adCost' WHERE num = '$id'");
}
}




function updatemailchimp($tableName, $isNewRecord, $oldRecord, $id) {


Hope it works for you,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Pay for Listings

By gversion - May 11, 2012

Hi Jerry,

Thanks for your help. I will test that out and let you know how it works out.

Regards,
Greg

Re: [gversion] Pay for Listings

By gversion - May 11, 2012

Hi Jerry,

The script doesn't seem to display any price... I think there might be a bug somewhere else with it.

Hopefully the Interactive Tools team will come to the rescue!

Thanks anyway!

Regards,
Greg

Re: [gversion] Pay for Listings

By Jason - May 11, 2012

Hi Greg,

Jerry was very close. What we need to do is remove all calculations, and just hard code in a value.

try this:

function calcAdCost_process($tableName, $isNewRecord, $oldRecord, $id) {
if($tableName == 'listings') {
$listingsTable = $GLOBALS["TABLE_PREFIX"] . "listings";
$accountsTable = $GLOBALS["TABLE_PREFIX"] . "accounts";
$adCost = 14.99;

mysql_query("UPDATE $listingsTable SET ad_cost = '$adCost' WHERE num = '$id'");
}
}


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Pay for Listings

By gversion - May 13, 2012

Hi Jason,

Thanks for trying to help out with this. I have tried to use the code you have provided but it's still not working. I think I might need to edit another file because the calculation is still coming up as 5% of the sale price...

Do you know if there is anywhere else I might need to edit the code?

Thank you,
Greg

Re: [gversion] Pay for Listings

By Jason - May 14, 2012

Hi Greg,

That seems to be the only place in your code where ad_cost is calculated. Could you post your latest version of your plugin?

Is this value calculated in any other plugins?

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/