Add invoice link on Manual Payment info message

I'm using Membership 2 Pro with Manual Payments enabled and I would like the members to see the invoice details or to have a link to the invoice at the last step of the registration process.

Would it be possible to add the invoice details or a link to the invoice in the "Payment Info" filed under Settings > Payment > Global Payment Settings > Manual Payment > Payment info?

I see that there is a [ms-invoice] shortcode but it requires to use the Single ID of the invoice and I need to grab the ID of the new invoice. Could this be possible?

Many thanks in advance.

  • Adam Czajczyk

    Hi Simon

    I hope you're doing fine today!

    There is a shortcode already for this but it does require a specific invoice's ID so it wouldn't be particularly useful in this case in the current form. However, at the "payment stage" the invoice already exists as a draft so it should be possible to fetch its ID dynamically and display a link there, I believe.

    We've already forwarded this question to our developers so they could take a look into it to see how this could be done and if I'm right and it's doable, we'll let you know here how to achieve it as soon as we got feedback from them.

    Please keep an eye on this ticket for further information.

    Best regards,
    Adam

  • Panos

    Hi Simon !

    Instead of adding the shortcode in the gateway settings, we can filter it's content with the following snippet :

    add_filter( 'ms_gateway_manual_purchase_info_content', function( $info ){
    
    	if ( ! empty( $_POST['ms_relationship_id'] ) ) {
    		$subscription 		= MS_Factory::load(
    			'MS_Model_Relationship',
    			$_POST['ms_relationship_id']
    		);
    		$invoice = $subscription->get_current_invoice();
    
    		$info .= do_shortcode( "[ms-invoice id=\"{$invoice->id}\"]" );
    	}
    
    	return $info;
    });

    The above should print the invoice info at the end of the message. If you need to include a link to the invoice you can use:

    $info .= sprintf(
    				'<a href="%s">%s</a>',
    				get_permalink( $invoice->id ),
    				__( 'View Invoice', 'membership2' )
    			);

    in the snippet.

    The above snippet can be used in child theme's functions.php file, or in a mu-plugin. If you are not familiar with mu-plugins you can read more about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Hope this helps!

    Kind regards!

  • Simon

    Hi Panos,

    This seems to have worked, thank you alot!
    However, I have two more questions regarding this invoice.

    1. I would like to remove the signup button (screenshot provided: http://prntscr.com/m6ek84) without removing the button from the rest of my site. (I had a conversation with violeta about this, it didnt work out)

    2. I would like to add a description thats only visible on the invoice, not when buying the membership. So that people can find the payment details easily again.

    Thanks for all your work!

  • Adam Czajczyk

    Hi Simon

    1. I would like to remove the signup button (screenshot provided: http://prntscr.com/m6ek84) without removing the button from the rest of my site. (I had a conversation with violeta about this, it didnt work out)

    Could you try these CSS rules? One of them should work for you, I believe. Try adding the first one and if it doesn't work, try the second line instead. Let me know, please, if that did the trick.

    .single-ms_invoice .wpmui-submit {display:none;}
    .ms_invoice-template-default .wpmui-submit {display:none;}

    2. I would like to add a description thats only visible on the invoice, not when buying the membership. So that people can find the payment details easily again.

    The Membership 2 Pro plugin supports templates. On the "Membership 2 -> Help -> Customize Membership 2" pag ein your site's back-end, you'll find more information about that and how to apply these templates: where to put them, what they should be named and what is the default template if no custom one is present.

    In this case, you'd want to create "single-ms_invoice.php" template, where you could put your additional content into. As a base of the template, use the internal template from the plugin that you will find in

    /wp-content/plugins/membership-pro/app/template

    folder. Use that "single-ms_invoice.php" file from there as a base (copy it to your theme - preferably child theme - folder) and modify it to your needs to include the message.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.