Pilou Posted November 22, 2018 Posted November 22, 2018 Hello, I used this module in my Ps 1.6 I modified this module to allow customers to register when the item is out of stock to receive an email when the item is back in stock. The modification: Original Code in ps module: public function hookActionProductOutOfStock($params) { if (!$this->customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->out_of_stock)) return; Code modified: public function hookActionProductOutOfStock($params) { if (!$this->customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT')) return; I tried to make the same mod in the ThirtyBees mailalert module, but I have a blank screen on my frontoffice. And an error message appeared in BO: "mailalerts (syntax error in /modules/mailalerts/mailalerts.php)" Can you help me please ? Kind regards, Pilou
wakabayashi Posted November 23, 2018 Posted November 23, 2018 Well you have a syntax error... You should recheck your code. Probably ";" or "{" or something like that is wrong.
Traumflug Posted November 23, 2018 Posted November 23, 2018 Syntax errors usually appear in the server's (Apache's) error log.
Pilou Posted November 23, 2018 Author Posted November 23, 2018 @wakabayashi said in Mailalert module: Well you have a syntax error... You should recheck your code. Probably ";" or "{" or something like that is wrong. But the code works perfectly on my Ps 1.6
datakick Posted November 23, 2018 Posted November 23, 2018 @Pilou it is syntax error, and that has nothing to do with thirtybees or prestashop. It means that the code could not be parsed by php server There are two possible explanations: - you have made a typo when you copied the code - you run the code on different server with different version of PHP
colorful-ant Posted November 23, 2018 Posted November 23, 2018 @Pilou I'm not sure I understand it correctly. Does the customer have to register separately in the shop so that he can use this function? I also use the module, a registration is not necessary for me. no matter if already registered customers or even simple visitors can be informed with me, as soon as the product is available again. EDIT: i think some users from tb use the mailalert-module and it works with and without registration only the option with additional module "customer out of stock" i need me own changes to see the date in the list
Pilou Posted November 24, 2018 Author Posted November 24, 2018 @colorful-ant no need to register @datakick same php version and same server (just another directory). So I have a Ps shop under 1.6.20 I made a backup (files and database) and put it on a different sql server and another directory. I did the migration to Tb 1.07 All seems to work but except this feature which work well on my Ps shop. Thank you for your answers.
Pilou Posted November 24, 2018 Author Posted November 24, 2018 Here is a printscreen of my Prestashop, you can see the product is out of stock and you can write your email. https://i.imgur.com/VETYM5Z.jpg Here's the printscreen of my Thirtybees shop, product is out of stock and nowhere to write your email https://i.imgur.com/IcBMPjF.jpg And i activated the option "customer out of stock" in mailalert module.
datakick Posted November 24, 2018 Posted November 24, 2018 This is the hook code that renders the subscription form: ``` if (!$this->customerqty || !Configuration::get('PSSTOCKMANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->outof_stock) ) { return ''; } $context = Context::getContext(); $idProduct = (int) $params['product']->id; $idProductAttribute = 0; $idCustomer = (int) $context->customer->id; if ((int) $context->customer->id <= 0) { $this->context->smarty->assign('email', 1); } elseif (MailAlert::customerHasNotification($idCustomer, $idProduct, $idProductAttribute, (int) $context->shop->id)) { return ''; } ``` If nothing is rendered, then the only explanations are: 1) hooks is actually not triggered -- please ensure that the module is enabled 2) Product Availability option is disabled in mailalerts module configuration 3) Enable stock management is disabled in Preferences > Products 4) product can be ordered even when out of stock (although this should be bypassed by your modification) 5) user is logged in, and has already submitted mail alert
Pilou Posted November 25, 2018 Author Posted November 25, 2018 Hello datakick, Module is enabled Product Availability is enabled Stock Management is enabled Product can be orderd when out of stock User is not logged in I tried to modified the code of mailalerts.php as you described but it has no effet. But thanks for trying to help, i appreciate a lot.
Pilou Posted November 25, 2018 Author Posted November 25, 2018 As I tried to resolve this, I enabled the debug mode and I have this message : Warning à la ligne 265 du fichier /home/www/***********/classes/PageCache.php [2] Invalid argument supplied for foreach() Do you think it's important ?
datakick Posted November 25, 2018 Posted November 25, 2018 @Pilou that warning is not really important, you can safely disregard it. It's really strange that it does not work for you. I've just tested it on my installation and it works just fine out of the box. You can troubleshoot this further by editing the hook code, and inserting return statement such as php return '-------------------HERE--------------'; on different places. Start with the very beginning of the hook, so you know that the hook is is actually called by your theme. You should see this in your product page (don't forget to clear cache in Administration > Performace after every edit): If you see this, then edit the hook again, and move it further down the code, just before the first return '';. Clear cache, and check product page again. If you see the same result, it means that hook is prematurely terminated because one of the condition in preceding if statement. If you don't see anything, move it before the next return ''; statement. That should give you the idea what and where goes wrong
Pilou Posted November 26, 2018 Author Posted November 26, 2018 Hello datakick, Thank you for the answer. Sorry, but I do not understand where do I need to edit the hook code.. In which file please ? mailalerts.php ?
datakick Posted November 26, 2018 Posted November 26, 2018 @Pilou that's the same hook you already modified, see your first post
Pilou Posted November 26, 2018 Author Posted November 26, 2018 Ok, thank you datakick. Yes it works: https://i.imgur.com/ehiDgxc.jpg
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