Jump to content

Adding HTML to the Shippng Methods


Recommended Posts

Hey guys!

 

I've looked around, and didnt seem to be able to find anything that could help me out - and im still very new to prestaShop, so i are not to experience yet!

 

So the thing is im working on a little project, and i wanted to mess around with the shipping methods. I manage to create my own shipping method - but i seem unable to find out how i add stuff BELOW the currently choosen shipping method? like seen here http://imgur.com/fcJxIQ6

 

When explaining stuff, i would appreciate if you explained ít like im 5 - since, i have not used alot of time on prestashop, so still very unexperienced!

Edited by ZaxxaDK (see edit history)
Link to comment
Share on other sites

There doesn't appear to be.  There is a hook in there, assigned to HOOK_EXTRACARRIER_ADDR, but it seems to be reserved for a specific purpose, in that I can't see how you would call it to assign your own template.

 

Are you trying to display something when the user selects the shipping method?  You could load the additional html in your carrier template along with some javascript to detect the selection and display your additional html.

 

(that's my best 5 year language old I'm afraid..)

Link to comment
Share on other sites

There doesn't appear to be.  There is a hook in there, assigned to HOOK_EXTRACARRIER_ADDR, but it seems to be reserved for a specific purpose, in that I can't see how you would call it to assign your own template.

 

Are you trying to display something when the user selects the shipping method?  You could load the additional html in your carrier template along with some javascript to detect the selection and display your additional html.

 

(that's my best 5 year language old I'm afraid..)

 

So

 

Like i said im very new, so bare with me :)

 

Yes i would like to show something when the shipping methods i have added is selected, if its below the exact one i pressed - or at the bottom of the page doesnt matter.

But how would i go about adding it the way you said?

Link to comment
Share on other sites

There are a few options;

 

you could load a js file in the header:

 

public function hookDisplayHeader($params)
{

  $this->context->controller->addJS($this->_path.'views/js/roja45contactus.js');

}

 

but without restriction that would load it on everypage, but it would support the CCC functionality of Prestashop, or probably the easiest way is just to include a <script> block in your carrier template file.  When it loads your carrier template, it will load the javascript and the browser will execute it.  In that js you can attach a listener to the checkbox, when selected, display your hidden additional html.

Link to comment
Share on other sites

I thought about the first idea, but i wasnt sure how good that would be - because like you said, it will load on every page!.

 

About the block and the carrier template:

 

  1. How exactly am i going to do that?  like i said i'm kinda new to prestashop, so im not really aware how you are doing it
  2. I figured that when you overwrite a template, what if somebody else have made a shipping module - and they also overwrite the carrier.tpl? want it conflict and one of them want be able to work?
Link to comment
Share on other sites

oh, right, you want to display additional html on an existing carrier?  I had assumed you were adding your own carrier, via the displayCarrierList hook, my bad.

 

Yeah, I wouldn't touch overrides, that way lies pain and sorrow.

 

I guess your only option is the first one then.  You can restrict the pages the js gets loaded on by checking the page name, it should be 'order' in this case I think.

public function hookDisplayHeader($params)
{
    $page = $this->context->controller->php_self;
    if (!$page) {
        $page = $this->context->controller->page_name;
    }
    
    if ($page=='order') {
        $this->context->controller->addJS($this->_path . 'views/js/your-js.js');

etc and so on.

Link to comment
Share on other sites

Well, i ultimately i just want to add some custom html on the shipping page - if it canr be below the shippinh methods it can be on the bottom.

 

Is their some way i can diffrentiate the different shipping methods? Say if i create my own carrier, can i give it a class or a variable - so i can always see if its checked on the shipping page?

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...