Jump to content

[solved] Display multiple items in same hook


Recommended Posts

Hello,

 

I built a module to display extra fields on product page which is working quite fine. But my issue is that I can not display multiple extra fields in one position.

In public function hookDisplayProductAdditionalInfo($params) I have a foreach loop returning content.
 

public function hookDisplayProductAdditionalInfo($params)

{
    ...

    foreach($available_extra_fields as $available_extra_field) {

        if($available_extra_field['location'] == 'additional_info') {

            return $this->displayProductExtraFieldContent($id_lang, $available_extra_field, $product_extra_fields);

        }

    }

}

Only one extra field shows up. Surely because of the "return" statement..?

I tried to return an array, but can't get this right.

Any idea on how I could get this solved please?

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

OK sorry, this was quite simple finally.

In case this can help someone spare some time, all I did was :

public function hookDisplayProductAdditionalInfo($params)

{
    ...

    $html = '';

    foreach($available_extra_fields as $available_extra_field) {

        if($available_extra_field['location'] == 'additional_info') {

            $html .= $this->displayProductExtraFieldContent($id_lang, $available_extra_field, $product_extra_fields);

        }

    }

    return $html;

}

 

Edited by Shapes (see edit history)
  • Like 1
Link to comment
Share on other sites

  • Shapes changed the title to [solved] Display multiple items in same hook

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