• Resolved petyots

    (@petyots)


    Hello, I have an issue here. When i try to manually confirm the order and record transaction from MY plugin the llms return this :

    Fatal error: Class 'LLMS_Admin_Metabox' not found in /home/user/project/wp-content/plugins/lifterlms/includes/admin/post-types/meta-boxes/class.llms.meta.box.engagement.php on line 10

    If i try to confirm the order and record transaction from the backend(Admin User) everything is normal. I tried to hook at ‘lifterlms_init’,’lifterlms_loaded’, the error is the same. Basically i am trying to confirm multiple orders. Here is my code :

    foreach ($ara as $value)
                {
    
                    $orderID = $value->order_id;
    
                    $orderC = new \LLMS_Order($orderID);
    
                    //Set causes the error !
                    $orderC->set('status','llms-completed');
    
                    unset($orderC);
    
                    $orderC = new \LLMS_Order($orderID);
    
                    $orderC->record_transaction([
                        'amount' => $data['PAYMENTINFO_0_AMT'],
                        'completed_date' => current_time( 'mysql' ),
                        'customer_id' => $value->student,
                        'fee_amount' => 0,
                        'source_id' => 'PayPal',
                        'source_description' => 'via PayPal',
                        'transaction_id' => $data['PAYMENTINFO_0_TRANSACTIONID'],
                        'status' => 'llms-txn-succeeded',
                        'payment_gateway' => 'PayPal',
                        'payment_type' => 'single',
                    ]);
    
                    $count++;
                }
    
                if ($count == count($ara))
                {
                    return true;
    
                } else {
    
                    return false;
                }

    P.S Sometimes it confirm only the first order from the array but dies on the second without event handle the transaction on the first. Thanks in advance !

Viewing 5 replies - 1 through 5 (of 5 total)
  • @petyots,

    I’m not sure I can identify the issue based on the code you’ve provided here. If you can post the whole code snippet as opposed to this isolated part I may be able to help better.

    I’m guessing you’re calling a class that isn’t meant to be callable (sorry if I built something that shouldn’t be callable and allowed it to be) and aren’t loading the necessary class. I’m really not sure. This bit of code doesn’t appear to do anything incorrectly.

    More code and I can probably help!

    Thread Starter petyots

    (@petyots)

    Hello @thomasplevy, this is the snippet i can provide, because this is the part which causes the problem. The other parts of the code are not related to the lifterlms. I will try to explain better. I have one controller in the admin panel which confirms the order manually. The record is single and it’s not in array, i mean it make only single query not many as i showed with my code. And everything runs perfectly. But when i try to confirm multiple orders from the frontend it is able to confirm only the first order but without recording the transaction because it dies; So if the order is single not many in array is working even from the frontend, but if the orders are multiple it dies. So is there any hook at which i can attach so i can wait for the LifterLMS to load ?. Or can you help me with the native query so i can confirm the order and record a transaction without using LLMS_Order object? Thanks !

    @petyots,

    I’m sorry but the code you’ve posted gives me no indication as to why you’re seeing the error you’re seeing. It’s throwing an error because it’s not loading a class and the class it’s trying to load is a class that is only loaded on the admin panel.

    You could try including the missing file before executing your code but I don’t see anything in your code which points to that class being required.

    If you run a debug_backtrace() on the function that’s responding with that error and post the results maybe that’ll help us find the source of the issue. Otherwise I’m really just guessing at what’s going on here.

    Hope that helps?

    Thread Starter petyots

    (@petyots)

    @thomasplevy

    debug_backtrace() Does not show anything more. Can you give me the native query with wich i can confirm the order enroll the student and record a transaction ? I am looking in LLMS_Post_Model but i can’t find it. This is the only way i can finish the task. Thank you in advance !

    P.S I really appreciate your help and time !
    P.S.2 : Why does it need to load Metabox if the class needs only the basic Post_Model ?
    P.S 3 : The exact method which causes the error is :

    $order = new \LLMS_Order(1);
    $order->set('status','llms-confirmed');

    OR

    $transaction = new \LLMS_Transaction('new',1)
    $transation->set('status','llms-txn-succeeded');
    • This reply was modified 9 years ago by petyots.
    • This reply was modified 9 years ago by petyots.

    @petyots,

    Something is weird here but I’m really sorry to say that I really have no idea what.

    Can you give me the native query with wich i can confirm the order enroll the student and record a transaction ?

    `
    $order_id = 123;
    $order = llms_get_post( $order_id );
    // create a new pending transaction
    $txn = $order->record_transaction( array(
    ‘amount’ => 0,
    ‘completed_date’ => current_time( ‘mysql’ ),
    ‘customer_id’ => ”,
    ‘fee_amount’ => 0,
    ‘source_id’ => ”,
    ‘source_description’ => ”,
    ‘transaction_id’ => ”,
    ‘status’ => ‘llms-txn-pending’,
    ‘payment_gateway’ => $this->get( ‘payment_gateway’ ),
    ‘payment_type’ => ‘single’,
    ) );
    $txn->set( ‘status’, ‘llms-txn-succeeded’ ); // trigger events

    <blockquote>I am looking in LLMS_Post_Model but i can’t find it.</blockquote>

    This is an abstract class, you want to look at models/class.llms.order.php not the post model abstract.

    P.S.2 : Why does it need to load Metabox if the class needs only the basic Post_Model ?

    It shouldn’t this is why I’m confused and a bit lost.

    Hope this helps,

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

The topic ‘Class ‘LLMS_Admin_Metabox’ not found’ is closed to new replies.