Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter strap

    (@strap)

    Hi,

    everything works! How easy it was..

    Thanks a lot,
    have a nice day!

    Thread Starter strap

    (@strap)

    Hello Greg,

    thanks again for the really quick support, your code works perfectly, i’ve written you an email for the custom fix.

    Bye,
    Stefano

    Thread Starter strap

    (@strap)

    Hello Greg,

    thanks for the really helpful answer.

    I’ve created a custom plugin where i can put all the customizations to wpadverts for that particular website.

    Starting from your input, i’ve been able to add more fields as billing address and company name. Everything works!

    So i reverted to the stock paypal plugin and i’m ready for future updates.

    For payments history, i’ve tryied to understand if it was possible to avoid tampering into the payments addon code. Unfortunately, i was unable to understand how to proceed. I have a working solution for now, but in case of updates it will need maintenance. If you can advice for a clean solution, i would really appreciate.

    Now i’ve modfified to get the followings:

    payments history list https://postimg.cc/LJ3WMxYJ

    payment history edit https://postimg.cc/CdvD9kxw

    Thanks a lot!
    Have a nice day

    P.S. i’m also adding the custom plugin code for others reference:

    
    <?php
    /*
     * Plugin Name:
     * Plugin URI:
     * Description:
     * Author:
     */
     
    add_filter( "adverts_form_load", function( $form ) {	
        if( $form["name"] != "adverts-paypal-standard" ) {
    		return $form;
        }
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_name",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "Company Name / Full Name", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
        $form["field"][] = array(
            "name" => "adverts_billingadd_vat",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "VAT Number", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_street",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "Street Name", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_streetn",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "Street Number", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_postcode",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "Postal Code", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_city",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "City", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
    	$form["field"][] = array(
            "name" => "adverts_billingadd_state",
            "type" => "adverts_field_text",
            "order" => 10,
            "label" => __( "State", "wpadverts-paypal-standard" ),
            "is_required" => true,
            "validator" => array( 
                array( "name" => "is_required" ),
            )
        );
    	
        return $form;
    }, 10 );
    
    add_filter( "adverts_form_bind", function( $form ) {
        if( $form->get_scheme( "name" ) != "adverts-paypal-standard" ) {
            return $form;
        }
    	
    	$args = array(
    		'author'         =>  wp_get_current_user()->ID,
    		'post_type'      => 'advert-author',
    		'posts_per_page' => 1,
    		'post_status'    => array( 'publish', 'advert-hidden' ),
    	);
    
    	$authors = get_posts( $args );
    			
    	if( isset( $authors[0] ) ) {
    		$author = $authors[0];
    		$user_billingadd_name = get_post_meta( $author->ID, "user_billingadd_name", true );
    		$user_billingadd_vat = get_post_meta( $author->ID, "user_billingadd_vat", true );
    		$user_billingadd_street = get_post_meta( $author->ID, "user_billingadd_street", true );
    		$user_billingadd_streetn = get_post_meta( $author->ID, "user_billingadd_streetn", true );
    		$user_billingadd_postcode = get_post_meta( $author->ID, "user_billingadd_postcode", true );
    		$user_billingadd_city = get_post_meta( $author->ID, "user_billingadd_city", true );
    		$user_billingadd_state = get_post_meta( $author->ID, "user_billingadd_state", true );
    	} else {
    		$author = null;
    		$user_billingadd_name = null;
    		$user_billingadd_vat = null;
    		$user_billingadd_street = null;
    		$user_billingadd_streetn = null;
    		$user_billingadd_postcode = null;
    		$user_billingadd_city = null;
    		$user_billingadd_state = null;
    	}
    	
        if( $form->get_value( "adverts_billingadd_name" ) == "" ) {
            $form->set_value( "adverts_billingadd_name", $user_billingadd_name );
        }
    	if( $form->get_value( "adverts_billingadd_vat" ) == "" ) {
            $form->set_value( "adverts_billingadd_vat", $user_billingadd_vat );
        }
    	if( $form->get_value( "adverts_billingadd_street" ) == "" ) {
            $form->set_value( "adverts_billingadd_street", $user_billingadd_street );
        }
    	if( $form->get_value( "adverts_billingadd_streetn" ) == "" ) {
            $form->set_value( "adverts_billingadd_streetn", $user_billingadd_streetn );
        }
    	if( $form->get_value( "adverts_billingadd_postcode" ) == "" ) {
            $form->set_value( "adverts_billingadd_postcode", $user_billingadd_postcode );
        }
    	if( $form->get_value( "adverts_billingadd_city" ) == "" ) {
            $form->set_value( "adverts_billingadd_city", $user_billingadd_city );
        }
    	if( $form->get_value( "adverts_billingadd_state" ) == "" ) {
            $form->set_value( "adverts_billingadd_state", $user_billingadd_state );
        }
    	
        return $form;
    } );
     
     ?>
    
    Thread Starter strap

    (@strap)

    Hi,

    i’ve added the same field to wp-content/plugins/wpadverts/addons/payments/payments.php and ajax.php

    Now i’ve discovered that the fields get saved in wp_postmeta, relatively to the payment post_id. So nice!

    What i’m trying now is to get the fields pre-compiled if the user has filled them in his profile information. I’ve created the field with the custom fields addon for the “Author Profile” form.

    All good, what happens is that the field gets added to wp_postmeta and not wp_usermeta, so from payments.php the data are not found (since it uses get_userdata() row 2179).

    Hope it is clear enough 😛

    Thanks again

    
        if( $data["buyer_id"] > 0 ) {
    
            $user_info = get_userdata( $data["buyer_id"] );
    
        }
    
        if( empty( $data["buyer_name"] ) && $user_info ) {
    
            $data["buyer_name"] = trim( sprintf( "%s %s", $user_info->first_name, $user_info->last_name ) );
    
        }    
    
        if( empty( $data["buyer_email"] ) && $user_info ) {
    
            $data["buyer_email"] = $user_info->user_email;
    
        }
    	
        if( empty( $data["buyer_vat"] ) && $user_info ) {
    
            $data["buyer_vat"] = $user_info->user_vat;
    
        }
    
    • This reply was modified 6 years, 8 months ago by strap. Reason: code added
Viewing 4 replies - 1 through 4 (of 4 total)