Jump to content

ajax call to AdminOrdersController from view.tpl


Diddino12

Recommended Posts

hello, i'm new in developing world, and i hope i can find some help here;

I need to call AdminOrdersController from adminXXXXXXXX\themes\default\template\controllers\orders\helpers\view\view.tpl

inside view.tpl i created a button;

	<button id="ricalcolo_tot" class="btn btn-success" type="button" disabled>
              <i class="fa fa-dollar"></i>
              {l s='calculate total price' d='Admin.Orderscustomers.Feature'}
            </button>

inside AdminOrdersController.php I have a function that should make a db Call to a stores Procedure:

public function callDBPArrotondamenti($id_order) {
        echo "called";
		$orders_qy = Db::getInstance()->ExecuteS('CALL arrotondamenti($id_order)');	
    }

how can i call the function form view.tpl with an ajax request directly from template?

Thanks for any answer.

Link to comment
Share on other sites

hello CedCommerceTeam and thanks for your reply, i already tried to contact AdminOrdersController throught a ajax POST call but this call doesn't reach the controller:

function Button2listener(event) {

       /*   $.ajax({
          type : 'POST',
          dataType : 'json',
          url : 'ajax-tab.php',
          data : {
            //required parameters
            ajax : true,
            controller : 'AdminOrdersController',
            action : 'callDBPArrotondamenti',
            token : '{$token}', 
            //additional parameters to your controller
            id_order : '{$order->id}'
                  }
                })
.done(function(){
  console.log('success');
})
.fail(function(){
  console.log('fail');
});*/
                    }

any advice?

Link to comment
Share on other sites

can you please give me an example of a function that i can use inside my controller to pass the value id_order (received by ajax call from tpl) to a stored procedure inside my db?

dont know how to read the value sent throught the ajax call.

thanks for replies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...