Grazulex Posted July 20, 2019 Share Posted July 20, 2019 bonjour, depuis des jours je me bas pour afficher des champs supplémentaires dans la fiche client dans la backend depuis un nouveau module de paiement que je dois faire. j'ai tout essayer, le hook, l'override,...rien n'y fait. je suis en mode multi-boutiques. voici mon code actuel. <?php if (!defined('_PS_VERSION_')) { exit; } class Facture extends PaymentModule { public $hooks = [ 'actionAdminCustomersFormModifier', 'actionAdminCustomersControllerSaveAfter', 'paymentOptions', 'paymentReturn', ]; public function __construct() { $this->author = 'JNKConsult'; $this->name = 'facture'; $this->tab = 'payments_gateways'; $this->version = '0.4'; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->bootstrap = true; $this->need_instance = 0; $this->ps_versions_compliancy = [ 'min' => '1.7.0', 'max' => _PS_VERSION_ ]; $this->controllers = [ 'payment', 'validation' ]; parent::__construct(); $this->displayName = $this->l('Facture Mensuelle'); $this->description = $this->l('Paiement via facture mensuelle'); } /** * Installation du module * @return boolean */ public function install() { return parent::install() && $this->registerHook($this->hooks) && $this->installDatabase(); } /** * Modifications sql du module * @return boolean */ protected function installDatabase() { return Db::getInstance()->execute( 'ALTER TABLE ' . _DB_PREFIX_ . 'customer' . ' ADD ' . $this->name . '_invoice_customer_id VARCHAR(255) NULL' ); } /** * Désinstallation du module * @return boolean */ public function uninstall() { return parent::uninstall() && $this->uninstallDatabase(); } /** * Suppression des modification sql du module * @return boolean */ protected function uninstallDatabase() { return Db::getInstance()->execute( 'ALTER TABLE ' . _DB_PREFIX_ . 'customer' . ' DROP ' . $this->name . '_invoice_customer_id' ); } /** * Returns a string containing the HTML necessary to * generate a configuration screen on the admin * * @return string */ public function getContent() { return ''; } /** * Display this module as a payment option during the checkout * * @return array|void */ public function hookPaymentOptions() { /** * Verify if this module is active */ if (!$this->active) { return; } /** * Form action URL. The form data will be sent to the * validation controller when the user finishes * the order process. */ $formAction = $this->context->link->getModuleLink( $this->name, 'validation', [], true ); /** * Assign the url form action to the template var $action */ $this->smarty->assign(['action' => $formAction]); /** * Load form template to be displayed in the checkout step */ $paymentForm = $this->fetch('module:facture/views/templates/hook/payment_options.tpl'); /** * Create a PaymentOption object containing the necessary data * to display this module in the checkout */ $newOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption; $newOption->setModuleName($this->displayName) ->setCallToActionText($this->displayName) ->setAction($formAction) ->setForm($paymentForm); $payment_options = [ $newOption ]; return $payment_options; } /** * Display a message in the paymentReturn hook * * @return string */ public function hookPaymentReturn() { /** * Verify if this module is enabled */ if (!$this->active) { return; } return $this->fetch('module:facture/views/templates/hook/payment_return.tpl'); } public function hookActionAdminCustomersFormModifier($params) { $params['fields'][$this->name] = [ 'form' => [ 'legend' => [ 'title' => $this->l('OTM'), 'icon' => 'icon-tags', ], 'description' => $this->l('Facturation mensuelle'), 'input' => [ [ 'type' => 'text', 'label' => $this->l('Customer invoice id'), 'name' => $this->name . '_invoice_customer_id', ], ] ] ]; $params['fields_value'][$this->name . '_invoice_customer_id'] = 'Custom value 1'; } public function hookActionAdminCustomersControllerSaveAfter() { $custom1 = Tools::getValue($this->name . '_invoice_customer_id'); } } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now