Jump to content

Useful to develop a module to add fields?


__fabrice

Recommended Posts

Hi all,

I posted two messages that were left unanswered, here and here. We would say that it's too complicated ...

Is it possible in this case, to do a module that manages a date (field) in the management of extra shopping cart and orders.

This is just to manage a date in the order. Not the date of the order, but a date related to the product (eg a trip).

Thank you for your help.
Fabrice

Link to comment
Share on other sites

A hook is an overrider for the default system behaviour. In other words, it's changing the core functionallity of Prestashop.

A module is something that works kind of standalone, given the Prestashop API or basic funcionality.

Be aware that a hook, if not well done, would make it hard to upgrade Prestashop in the future.

Link to comment
Share on other sites

ok, thank you to explain.

I my case; i don't think it's appropriate to create a module. I just want to add a field in the product table, a date field, that i could retreive in the shopping cart and in the order.

Regards,
Fabrice

Link to comment
Share on other sites

  • 8 months later...

In 1.4 you would override the Product class to add fields to it, for example. Then you get all the joy of the standard object facilities without the pain of hacking around with adding hooks or modules etc.

For example to add a mandatory "Title" field to use instead of radio buttons for gender you could do:

class Customer extends CustomerCore
{
 /** @var string Title */
 public         $title;

 public function __construct($id = NULL, $id_lang = NULL)
 {
   $this->fieldsRequired[] = 'title';

   parent::__construct();
 }

 public function getFields()
{
  parent::validateFields();

  $fields = parent::getFields();
  $fields['title'] = pSQL(Tools::strtoupper($this->title));

  return $fields;
}

}



You would then probably write some member functions to manipulate/query the value. Simple :D

Paul

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