From acac9ff5d7c626292167e4a0a03cd845c67f19b6 Mon Sep 17 00:00:00 2001 From: cchalamon Date: Mon, 10 Apr 2023 10:39:54 +0200 Subject: [PATCH] PS 8 compliancy --- controllers/front/validation.php | 4 +- everpsquotation.php | 49 +++++-------------------- models/HTMLTemplateEverQuotationPdf.php | 4 +- override/classes/Configuration.php | 30 +++++++++++++++ override/classes/index.php | 18 +++++++++ override/index.php | 18 +++++++++ 6 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 override/classes/Configuration.php create mode 100644 override/classes/index.php create mode 100644 override/index.php diff --git a/controllers/front/validation.php b/controllers/front/validation.php index 1b8803c..eb1a9f3 100644 --- a/controllers/front/validation.php +++ b/controllers/front/validation.php @@ -144,10 +144,10 @@ public function initContent() } // Subject - $ever_subject = Configuration::getInt('EVERPSQUOTATION_MAIL_SUBJECT'); + $ever_subject = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_MAIL_SUBJECT'); $subject = $ever_subject[(int)Context::getContext()->language->id]; // Filename - $filename = Configuration::getInt('EVERPSQUOTATION_FILENAME'); + $filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME'); $ever_filename = $filename[(int)Context::getContext()->language->id]; $id_shop = (int)Context::getContext()->shop->id; diff --git a/everpsquotation.php b/everpsquotation.php index 73f358c..d3ad14f 100644 --- a/everpsquotation.php +++ b/everpsquotation.php @@ -41,7 +41,7 @@ public function __construct() { $this->name = 'everpsquotation'; $this->tab = 'payments_gateways'; - $this->version = '3.3.1'; + $this->version = '4.0.1'; $this->author = 'Team Ever'; $this->need_instance = 0; $this->bootstrap = true; @@ -51,7 +51,7 @@ public function __construct() $this->displayName = $this->l('Ever PS Quotation'); $this->description = $this->l('Simply accept quotations on your Prestashop !'); $this->confirmUninstall = $this->l('Do you REALLY want to uninstall this awesome module ?'); - $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); + $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); } /** @@ -82,8 +82,6 @@ public function checkHooks() { return ($this->createQuoteHooks() && $this->registerHook('header') - && $this->registerHook('actionBeforeCreateEverQuote') - && $this->registerHook('actionAfterCreateEverQuote') && $this->registerHook('displayCustomerAccount') && $this->registerHook('displayShoppingCart') && $this->registerHook('displayReassurance') @@ -590,13 +588,13 @@ protected function postProcess() Configuration::updateValue( 'EVERPSQUOTATION_CATEGORIES', - Tools::jsonEncode(Tools::getValue('EVERPSQUOTATION_CATEGORIES')), + json_encode(Tools::getValue('EVERPSQUOTATION_CATEGORIES')), true ); Configuration::updateValue( 'EVERPSQUOTATION_GROUPS', - Tools::jsonEncode(Tools::getValue('EVERPSQUOTATION_GROUPS')), + json_encode(Tools::getValue('EVERPSQUOTATION_GROUPS')), true ); @@ -650,27 +648,6 @@ protected function postProcess() */ protected function getConfigFormValues() { - $everpsquotation_subject = array(); - $everpsquotation_filename = array(); - $everpsquotation_text = array(); - foreach (Language::getLanguages(false) as $lang) { - $everpsquotation_subject[$lang['id_lang']] = (Tools::getValue( - 'EVERPSQUOTATION_MAIL_SUBJECT_'.$lang['id_lang'] - )) ? Tools::getValue( - 'EVERPSQUOTATION_MAIL_SUBJECT_'.$lang['id_lang'] - ) : ''; - $everpsquotation_filename[$lang['id_lang']] = (Tools::getValue( - 'EVERPSQUOTATION_FILENAME_'.$lang['id_lang'] - )) ? Tools::getValue( - 'EVERPSQUOTATION_FILENAME_'.$lang['id_lang'] - ) : ''; - $everpsquotation_text[$lang['id_lang']] = (Tools::getValue( - 'EVERPSQUOTATION_TEXT_'.$lang['id_lang'] - )) ? Tools::getValue( - 'EVERPSQUOTATION_TEXT_'.$lang['id_lang'] - ) : ''; - } - return array( 'EVERPSQUOTATION_CATEGORIES' => Tools::getValue( 'EVERPSQUOTATION_CATEGORIES', @@ -733,19 +710,13 @@ protected function getConfigFormValues() 'EVERPSQUOTATION_RENDER_ON_VALIDATION' ) ), - 'EVERPSQUOTATION_MAIL_SUBJECT' => (!empty( - $everpsquotation_subject[(int)Configuration::get('PS_LANG_DEFAULT')] - )) ? $everpsquotation_subject : Configuration::getInt( + 'EVERPSQUOTATION_MAIL_SUBJECT' => Configuration::getConfigInMultipleLangs( 'EVERPSQUOTATION_MAIL_SUBJECT' ), - 'EVERPSQUOTATION_FILENAME' => (!empty( - $everpsquotation_filename[(int)Configuration::get('PS_LANG_DEFAULT')] - )) ? $everpsquotation_filename : Configuration::getInt( + 'EVERPSQUOTATION_FILENAME' => Configuration::getConfigInMultipleLangs( 'EVERPSQUOTATION_FILENAME' ), - 'EVERPSQUOTATION_TEXT' => (!empty( - $everpsquotation_text[(int)Configuration::get('PS_LANG_DEFAULT')] - )) ? $everpsquotation_text : Configuration::getInt( + 'EVERPSQUOTATION_TEXT' => Configuration::getConfigInMultipleLangs( 'EVERPSQUOTATION_TEXT' ), ); @@ -1134,7 +1105,7 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i // die(var_dump($price_without_tax)); $quotedetail = new EverpsquotationDetail(); $quotedetail->id_everpsquotation_quotes = (int)$quote->id; - $quotedetail->id_warehouse = (int)$cart_details['total_discounts']['id_warehouse']; + // $quotedetail->id_warehouse = (int)$cart_details['total_discounts']['id_warehouse']; $quotedetail->id_shop = (int)$cart_product['id_shop']; $quotedetail->product_id = (int)$cart_product['id_product']; $quotedetail->product_attribute_id = (int)$cart_product['id_product_attribute']; @@ -1166,10 +1137,10 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i } // Subject - $ever_subject = Configuration::getInt('EVERPSQUOTATION_MAIL_SUBJECT'); + $ever_subject = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_MAIL_SUBJECT'); $subject = $ever_subject[(int)Context::getContext()->language->id]; // Filename - $filename = Configuration::getInt('EVERPSQUOTATION_FILENAME'); + $filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME'); $ever_filename = $filename[(int)Context::getContext()->language->id]; $id_shop = (int)Context::getContext()->shop->id; diff --git a/models/HTMLTemplateEverQuotationPdf.php b/models/HTMLTemplateEverQuotationPdf.php index ec69f95..2513ddd 100644 --- a/models/HTMLTemplateEverQuotationPdf.php +++ b/models/HTMLTemplateEverQuotationPdf.php @@ -32,8 +32,8 @@ public function __construct($id_everpsquotation_quotes, $smarty) $this->context = Context::getContext(); $this->shop = new Shop(Context::getContext()->shop->id); $this->lang = new Language((int)Context::getContext()->language->id); - $text = Configuration::getInt('EVERPSQUOTATION_TEXT'); - $filename = Configuration::getInt('EVERPSQUOTATION_FILENAME'); + $text = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_TEXT'); + $filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME'); $this->text = $text[(int)Context::getContext()->language->id]; $this->filename = $filename[(int)Context::getContext()->language->id] .$this->id_everpsquotation_quotes; diff --git a/override/classes/Configuration.php b/override/classes/Configuration.php new file mode 100644 index 0000000..743705a --- /dev/null +++ b/override/classes/Configuration.php @@ -0,0 +1,30 @@ +