Support » Plugin: LifterLMS » Custom URL after checkout page

  • Resolved serhiishevchenko

    (@serhiishevchenko)


    Hello,
    I want to make a custom page after checkout page. I’ve tried to add lifterlms_registration_redirect filter with code snippets plugin but it doesn’t work for me.
    Can you help me please to make a custom page so when I click Buy now button I’m redirected to a custom page URL?

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Thomas Patrick Levy

    (@thomasplevy)

    It doesn’t work either. I’m getting redirect to my courses page with pending payment displaying on the page. I’m using manual payment method so I think payment isn’t completed. So what filter should I use for that?

    Plugin Author Thomas Patrick Levy

    (@thomasplevy)

    @serhiishevchenko,

    You can hook a redirct to this action for a pending payment on a manual order: https://github.com/gocodebox/lifterlms/blob/a4982002871e844b39ff50046585cbed700dbfb3/includes/class.llms.gateway.manual.php#L182

    eg:

    
    add_action( 'lifterlms_handle_pending_order_complete', function( $order ) {
      wp_redirect( 'http://myredirect.com' );
      exit;
    } );
    

    That should get the job done for you!

    • This reply was modified 2 years, 9 months ago by Thomas Patrick Levy. Reason: messed up formatting

    Holy smokes… It doesn’t wanna work for me…
    I tried use this 2 examples:

    1. Adding this snippet using code snippets plugin:

    add_action( 'lifterlms_handle_pending_order_complete', function( $order ) {
      wp_redirect( 'http://myredirect.com' );
      exit;
    } );
    

    2. Adding this code:

    /**
    	 * Handle a Pending Order
    	 * Called by LLMS_Controller_Orders->create_pending_order() on checkout form submission
    	 * All data will be validated before it's passed to this function
    	 *
    	 * @param   obj       $order   Instance LLMS_Order for the order being processed
    	 * @param   obj       $plan    Instance LLMS_Access_Plan for the order being processed
    	 * @param   obj       $person  Instance of LLMS_Student for the purchasing customer
    	 * @param   obj|false $coupon  Instance of LLMS_Coupon applied to the order being processed, or false when none is being used
    	 * @return  void
    	 * @since   3.0.0
    	 * @version 3.10.0
    	 */
    	public function handle_pending_order( $order, $plan, $person, $coupon = false ) {
    		// no payment (free orders)
    		if ( floatval( 0 ) === $order->get_initial_price( array(), 'float' ) ) {
    			// free access plans do not generate receipts
    			if ( $plan->is_free() ) {
    				$order->set( 'status', 'llms-completed' );
    				// free trial, reduced to free via coupon, etc...
    				// we do want to record a transaction and then generate a reciept
    			} else {
    				// record a $0.00 transaction to ensure a receipt is sent
    				$order->record_transaction( array(
    					'amount' => floatval( 0 ),
    					'source_description' => __( 'Free', 'lifterlms' ),
    					'transaction_id' => uniqid(),
    					'status' => 'llms-txn-succeeded',
    					'payment_gateway' => 'manual',
    					'payment_type' => 'single',
    				) );
    			}
    			$this->complete_transaction( $order );
    			// payment due
    		} else {
    			/**
    			 * @hooked LLMS_Notification: manual_payment_due - 10
    			 */
    			do_action( 'llms_manual_payment_due', $order, $this );
    			// show the user payment instructions for the order
    			add_action( 'lifterlms_handle_pending_order_complete', function( $order ) {
      wp_redirect( 'https://serhiishevchenko.com/' );
      exit;
    }// End if().
    	}
    

    And nothing happens. I still get redirected to the default pending payment page.

    What do I do wrong?

    Plugin Author Thomas Patrick Levy

    (@thomasplevy)

    @serhiishevchenko,

    You may need to try “late initialization” on the action. This means that your action is attached before the action exists so it never actually runs and fails silently.

    Here’s an example of that: https://lifterlms.com/docs/can-remove-display-course-syllabus-author/#late-init

    Your code could be adjusted to:

    
    add_action( 'init', 'my_late_init', 15 );
    function my_late_init() {
      add_action( 'lifterlms_handle_pending_order_complete', function( $order ) {
        wp_redirect( 'http://myredirect.com' );
        exit;
      } );
    }
    

    Hope that helps,

    Oh.. Nope… Still doesn’t work… I actually left this thing like it is by default… But I need to know what do I do wrong…

    Can you give me please full code examples so I could check one more time?

    Plugin Author Thomas Patrick Levy

    (@thomasplevy)

    @serhiishevchenko,

    Short of getting access to your site and debugging this I cannot help you any further (I WILL NOT DEBUG YOUR SITE DO NOT POST CREDENTIALS!)

    I do my very best to assist with custom code examples and they don’t always work because of a potential hundred thousand reasons, conflicts, plugins, themes, and so on.

    This is working for me locally and I don’t know why it’s not working for you.

    This is an extension of the core functionality and I’m sorry if the core is failing you. As you have opened many tickets needing custom code solutions perhaps this out of the box (free) solution is the wrong solution given your needs and requirements. There’s other LMSs out there that may server you better and as much as I’d like LifterLMS to be the solution for you, it may not be. In which case I’d encourage you to look elsewhere or make due with what I am pretty sure is a pretty great FREE feature set. Yea, it doesn’t do everything, but it does a ton…

    Well, I didn’t say LifterLMS is bad LMS. I’m sorry if my questions mislead you or smth… I know LifterLMS is great! I just wanted to make some customizations and had some questions how to do that and hoped I could get help and answers to my questions on this forum.
    Once again I’m sorry if I bothered you. I really appreciate your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom URL after checkout page’ is closed to new replies.