• Resolved selycha

    (@selycha)


    Hi,

    I was wondering, where could I insert conditions, so that the basic payment is assigned based on the category name / ID in the code. The reason is, we have different type of articles (short, interview, long) and we need pay a different amount for the basic payment for each type.

    Is it possible to edit the code (tried, but with no luck yet :/… seems like in the basic payment section of the plugin code you calculate just how many times the basic amount should be added to the author, so I cant add any conditions for category check -> set basic payment valie) and add this functionality?

    Do you plan to add this functionality?

    Thanks in advance & for the hard work.

    ** If anyone has a solution, or knows how to edit the code, the help is appreciated 🙂

    Bests

    https://ww.wp.xz.cn/plugins/post-pay-counter/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Stefano

    (@ste_95)

    Hi there,
    please see this post for details on the matter 🙂

    Though there are workarounds (again, see the post above), the point is that

    It will probably be possible to set different payment rates for different categories/post types in the future with an addon, but this is not an option right now.

    Thread Starter selycha

    (@selycha)

    Thanks,

    unfortunately, thats not a solution for me right now :). Can you at least point me to a function, where I can check for the post category and based on that add som ammount to the payment of the post?

    Or would it be possible to add a filter, which would go through the authors posts after the PPC has counted the payment and add specific ammounts for posts which are in the categories I am looking for, so that the final payment would be basically the same as if there would be more basic payment ammounts?
    – I am new to wordpress core functionality and filters / actions, thats why I’m asking.

    If we could write a quick filter for this, it could be a temporary solution for many people until later addons would arive.

    Thanks again 😉

    Plugin Author Stefano

    (@ste_95)

    I’m working on a new addon to allow different settings depending on the category, give me roughly a week 🙂

    Thread Starter selycha

    (@selycha)

    Hey :),

    that’s great news! I’ll be looking forward to it. If you don’t mind, I would share the temporary workaround to multiple basic payments I made since I needed a solution right away. It can come in handy for someone.

    **PLEASE KEEP IN MIND THAT THIS IS A WORKAROUND NOT a permanent solution and don’t forget to delete it and update to the latest version when ready**

    I decided to use a custom taxonomy, since the payment categories are usually not the same as the post categories and it could be a headache if you would need to add for example three new categories (pay1, pay2, pay3) which would then be visible to the readers on the frontend.

    SOLUTION(dont forget to change the taxonomy ‘type’ and the terms ‘pay1’, ‘pay2’, ‘no_pay’ and keep in mind that these are the “slugs” not the “names” of the terms):

    I adjust the basic payment(for correct display in stats), but also the total payment. The different basic payments are calculated based on the one set in the options. So that in my example my basic payment is 4 in the options, but I want 6 for the ‘pay1’ posts so I increase the basic payment by +2. Change this amount as you please.

    The ‘no_pay’ posts are posts, which I don’t want to pay for – so I set the amount to 0.

    The ‘default’ is for posts for which I want to pay the basic payment set in the plugin options.

    1. set a default basic payment in the plugin options
    2. (FTP)Go to the plugin directory > post-pay-counter > classes
    3. Open the file “ppc_html_functions_class.php” in a text editor
    4. Look for the function “data2cash” and go to the line with “$single->ppc_count = $post_countings;”
    5. Between this line and the line “$single->ppc_payment = $post_payment[‘ppc_payment’];” add the folowing code:

    /* Adjust basic payment based on custom taxonomy "type" */
    
    				$post_terms = get_the_terms( $single->ID , 'type' );
    
    				if ( $post_terms && ! is_wp_error( $post_terms ) ) {
    					foreach($post_terms as $term) {
    						switch ($term->slug) {
    							case 'pay1':
    										$post_payment['ppc_payment']['normal_payment']['basic'] = $post_payment['ppc_payment']['normal_payment']['basic'] + 2;
    										$post_payment['ppc_payment']['normal_payment']['total'] = $post_payment['ppc_payment']['normal_payment']['total'] + 2;
    									break;
    							case 'pay2':
    										$post_payment['ppc_payment']['normal_payment']['basic'] = $post_payment['ppc_payment']['normal_payment']['basic'] + 4;
    										$post_payment['ppc_payment']['normal_payment']['total'] = $post_payment['ppc_payment']['normal_payment']['total'] + 4;
    									break;
    							case 'no_pay':
    									$post_payment['ppc_payment']['normal_payment']['basic'] = 0;
    									$post_payment['ppc_payment']['normal_payment']['total'] = 0;
    							default:
    									break;
    						}
    					}
    				}

    Hope this helps someone. Enjoy.

    Plugin Author Stefano

    (@ste_95)

    Thanks for sharing your solution!

    Meanwhile I’ve released the native addon Category Custom Settings, that allows to set different settings for different categories. If you decide to go for it, do let me know your thoughts about it 🙂

    Have a nice day,
    Stefano

    Thread Starter selycha

    (@selycha)

    Wow,

    fast work thanks! 🙂 I’ll give it a try 😉

    Bests,

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Add more basic payments / Basic payment for a category’ is closed to new replies.