Advertisement:

Author Topic: PayPal Plug In Free vs Paid  (Read 20012 times)

360safetygear

  • Jr. Member
  • **
  • Posts: 59
PayPal Plug In Free vs Paid
« on: June 19, 2012, 07:35:41 pm »
Wondering if there is a way to make free ads for the general public, but make dealers and vendors pay for "featured" or Premium ads.
I absolutely love the idea, just don't want everyone to have to pay to post an ad, just vendors.

Thanks in advance!

Cris

  • Full Member
  • ***
  • Posts: 125
Re: PayPal Plug In Free vs Paid
« Reply #1 on: June 20, 2012, 03:47:36 am »
you can do this making some changes..

1st you shold know if user is a company or a private, you can do this:

oc-includes\osclass\helpers\hUsers.php line 300
   add
   
Code: [Select]
function osc_user_is_company() {
                      return (string) osc_user_field("b_company");

2nd on user registration they have to choose from user type:

  on your theme folder \  user-register.php add:
Code: [Select]
<label for="b_company"><?php _e('User type''trovo') ; ?></label>
         <select name="b_company" id="b_company">
         <option value="0" <?php if( !osc_user_field("b_company") ) echo 'selected="selected"'?> ><?php _e('User''trovo') ; ?></option>
         <option value="1" <?php if( osc_user_field("b_company") ) echo 'selected="selected"'?>><?php _e('Company''trovo') ; ?></option>
    </select>       

3rd user can't change this value from control panel!
  on your theme folder \ user-profile.php find the input for the value b_company and change it with:
Code: [Select]
<label for="b_company"><?php _e('User type''trovo') ; ?></label>  : <? if (osc_user_field("b_company")==1) echo _e('Company', 'trovo'); else echo _e('User', 'trovo') ; ?>
<input class="xlarge" type="hidden" value="<?php echo osc_user_field("b_company") ; ?>" name="b_company" id="b_company">
                IMPORTANT!!: the 1st row show the user type, the second row keep the value on submit form!       

Ok, now the changes for paypalplus plugin:
open index.php, find "function paypalplus_publish($item)"
and change
Code: [Select]
if(osc_get_preference('pay_per_post', 'paypalplus')) {with
Code: [Select]
$conn = getConnection();
$usertype = $conn->osc_dbFetchResult("SELECT b_company FROM %st_user WHERE pk_i_id = %d", DB_TABLE_PREFIX, osc_logged_user_id());

          if ($usertype['b_company']=='1') {

that's all!!!
 

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #2 on: June 20, 2012, 04:10:50 am »
Holy cow, thanks so much. I owe ya some beer at least!
I'll start working on it now.

How would it integrate with the paypal plug in?

Thanks again!!!!!  ;D

PS any suggestion on what to use to find the line numbers, ole note pad is not doing it for me LOL!!!
« Last Edit: June 20, 2012, 04:13:26 am by 360safetygear »

Cris

  • Full Member
  • ***
  • Posts: 125
Re: PayPal Plug In Free vs Paid
« Reply #3 on: June 20, 2012, 04:23:26 am »
with this changes you no need to change any options on paypalplus plugin!

the function is around line 300!

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #4 on: June 20, 2012, 04:51:20 am »
with this changes you no need to change any options on paypalplus plugin!

the function is around line 300!

Got it thanks, I am using the regular PayPal plug in I found in the plug in page here on the site.
I am not using Plus on PayPal, just regular account with them.

Just made all the edits, keep your fingers crossed! LOL
Thank you again Cris!

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: PayPal Plug In Free vs Paid
« Reply #5 on: June 20, 2012, 04:54:19 am »
360safetygear,

I would suggest using an editor like bluefish, netbeans, and notepad ++. All of them are free.

jay

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: PayPal Plug In Free vs Paid
« Reply #6 on: June 20, 2012, 04:56:12 am »
Got it thanks, I am using the regular PayPal plug in I found in the plug in page here on the site.
I am not using Plus on PayPal, just regular account with them.

Just made all the edits, keep your fingers crossed! LOL
Thank you again Cris!

The paypal plus plugin just has a few more features then the regular paypal plugin.

Jay

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #7 on: June 20, 2012, 05:13:36 am »
Got it thanks, I am using the regular PayPal plug in I found in the plug in page here on the site.
I am not using Plus on PayPal, just regular account with them.

Just made all the edits, keep your fingers crossed! LOL
Thank you again Cris!

The paypal plus plugin just has a few more features then the regular paypal plugin.

Jay

I didn't see it on the plug in page or in Source Forge. Jay may I bother you please for the download location? Thanks!!
Never mind LOL Found it!!  8)
« Last Edit: June 20, 2012, 05:17:18 am by 360safetygear »

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #8 on: June 20, 2012, 05:15:28 am »
360safetygear,

I would suggest using an editor like bluefish, netbeans, and notepad ++. All of them are free.

jay

Just found notepad++ works like a champ.
It's been a few years since I got out of the web design game, I am VERY rusty and this was before php. So I am basically a noob all over again LOL  ;D
Thank you for your help!

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #9 on: June 20, 2012, 06:51:23 am »
Installed the PayPal Plus plug in, love the options. Not sure I have things set up properly, I tried a test ad and get:
Quote
There was an error
There's no need to pay the publish fee

Cris

  • Full Member
  • ***
  • Posts: 125
Re: PayPal Plug In Free vs Paid
« Reply #10 on: June 20, 2012, 11:47:37 am »
I made this changes whith paypalplus plugin and "pay per post" option enabled, try this!

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #11 on: June 20, 2012, 02:19:59 pm »
I changed a test user to company and was able to post for free   :-\
Thanks for the suggestion, wonder where my problem is?

Now I am getting this when clicking an ad:
Quote
Fatal error: Call to undefined function paypal_is_paid() in /htdocs/usedpolicecar/oc-content/plugins/paypalplus/index.php on line 532

Line 532
Quote
        if(osc_get_preference("pay_per_post", "paypalplus")=="1" && !paypal_is_paid($item['pk_i_id']) ) {

I unchecked Pay per post ads and no error. Still having the posting for free problem tho  :-[

Goodness gracious, that's what I get for sleeping! LOL  ;D
« Last Edit: June 20, 2012, 04:51:37 pm by 360safetygear »

Cris

  • Full Member
  • ***
  • Posts: 125
Re: PayPal Plug In Free vs Paid
« Reply #12 on: June 20, 2012, 05:35:09 pm »
ok, try with the old function

ops!! the correct function is "paypalplus_is_payd" !!

try to change it...

if you have other problems try to change the old function

Code: [Select]
function paypalplus_publish($item) {
        if(osc_get_preference('pay_per_post', 'paypal')) {

and make a new one

Code: [Select]
function paypalplus_compnay_publish($item) {
  $conn = getConnection();
$usertype = $conn->osc_dbFetchResult("SELECT b_company FROM %st_user WHERE pk_i_id = %d", DB_TABLE_PREFIX, osc_logged_user_id());

          if ($usertype['b_company']=='1') {
    // Check if it's already payed or not
            $conn = getConnection();
            // Item is not paid, continue
            $ppl_category = $conn->osc_dbFetchResult("SELECT f_publish_cost FROM %st_paypal_prices WHERE fk_i_category_id = %d", DB_TABLE_PREFIX, $item['fk_i_category_id']);
            if($ppl_category && isset($ppl_category['f_publish_cost'])) {
                $category_fee = $ppl_category["f_publish_cost"];
            } else {
                $category_fee = osc_get_preference('default_publish_cost', 'paypalplus');
            }
            paypalplus_send_email($item, $category_fee);
            if($category_fee>0) {
                // Catch and re-set FlashMessages
                osc_resend_flash_messages();
                Item::newInstance()->update(array('b_enabled' => 0), array('pk_i_id' => $item['pk_i_id']));
                $conn->osc_dbExec("INSERT INTO %st_paypal_publish (fk_i_item_id, dt_date, b_paid) VALUES ('%d',  '%s',  '0')", DB_TABLE_PREFIX, $item['pk_i_id'], date('Y-m-d H:i:s'));
                paypalplus_redirect_to(osc_render_file_url(osc_plugin_folder(__FILE__) . 'payperpublish.php&itemId=' . $item['pk_i_id']));
            } else {
                // PRICE IS ZERO
                $conn->osc_dbExec("INSERT INTO  %st_paypal_publish (fk_i_item_id, dt_date, b_paid) VALUES ('%d',  '%s',  '1')", DB_TABLE_PREFIX, $item['pk_i_id'], date('Y-m-d H:i:s'));
            }
        } else {
            // NO NEED TO PAY PUBLISH FEE
            paypalplus_send_email($item, 0);
        }
        $category = Category::newInstance()->findByPrimaryKey($item['fk_i_category_id']);
        View::newInstance()->_exportVariableToView('category', $category);
        paypalplus_redirect_to(osc_search_category_url());
    }

then at the end of the page add
Code: [Select]
osc_add_hook('posted_item', 'paypalplus_company_publish');

remember to disable "pay per post" option!!

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #13 on: June 20, 2012, 06:30:17 pm »
Still no joy, registered as company. Created an ad and it did not ask for payment. And I can change my user type from company to user as well.
I have also lost the ability for the user to pay to upgrade their ad in the user account settings (manage my items).
 :-[
« Last Edit: June 20, 2012, 07:27:36 pm by 360safetygear »

360safetygear

  • Jr. Member
  • **
  • Posts: 59
Re: PayPal Plug In Free vs Paid
« Reply #14 on: June 20, 2012, 10:15:10 pm »
Well I uninstalled PPplus and installed the standard PP plugin. Redid all the mods you suggested, user can still change their user type, and when they post an ad
Quote
There was an error
There's no need to pay the publish fee
and the ad is accepted but not posted, it shows as being blocked. 
Quote
The item has been suspended

And I get this on the bottom of the main page
Quote
Fatal error: Class 'CWebMain' not found in /homepages/41/d416324443/htdocs/usedpolicecar/index.php on line 117

I am about to pull my hair out on this one LOL!!!

I'll send a case of beer to anyone that can help me resolve this please!!!  ;D
« Last Edit: June 20, 2012, 11:58:27 pm by 360safetygear »