Post by odyssus » Tue May 17, 2022 4:08 am

I created a php file in helper which i call with ajax when a certain button is pressed. The ajax call works correctly. What i want to know is how to call a model method in a php file in helper, so that it executes when the button is pressed. The code of the php file is the following.

Code: Select all

function ac() {
            $this->load->model('total/coupon');

            $this->model_total_coupon->coupon_test();
                }
        
        if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case 'ΕΓΓΡΑΦΗ':
                ac();
                
                break;
        }
    }
calling the model the way i do in the function ac() is wrong apparently. How should i do this.

Newbie

Posts

Joined
Mon May 09, 2022 4:37 pm

Post by straightlight » Tue May 17, 2022 6:34 am

OC version. You would need to pass the $this->registry object into your helper function's parameter where your function is being called originally. Then, to use: $registry->get('load')->model instead of: $this->load->model .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by odyssus » Tue May 17, 2022 3:56 pm

straightlight wrote:
Tue May 17, 2022 6:34 am
OC version. You would need to pass the $this->registry object into your helper function's parameter where your function is being called originally. Then, to use: $registry->get('load')->model instead of: $this->load->model .
Can you help on how to do the $this->registry thing please? Should i do something in my controller file or in my model file first? My open cart version is 2.1.0.2

Newbie

Posts

Joined
Mon May 09, 2022 4:37 pm

Post by straightlight » Tue May 17, 2022 5:46 pm

odyssus wrote:
Tue May 17, 2022 3:56 pm
straightlight wrote:
Tue May 17, 2022 6:34 am
OC version. You would need to pass the $this->registry object into your helper function's parameter where your function is being called originally. Then, to use: $registry->get('load')->model instead of: $this->load->model .
Can you help on how to do the $this->registry thing please? Should i do something in my controller file or in my model file first? My open cart version is 2.1.0.2
You could always create a new service request in the Commercial Support section of the forum or contact me directly via the forum PM to get this done as a custom job.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 174 guests