Jump to content
thirty bees forum

Recommended Posts

Posted

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

Posted

@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

Posted

@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

Posted

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

Posted

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.

Posted

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

Posted

Hello datakick,

  1. Module is enabled
  2. Product Availability is enabled
  3. Stock Management is enabled
  4. Product can be orderd when out of stock
  5. 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.

Posted

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 ?

Posted

@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):

0_1543163343840_ce816ca0-73d6-4c27-8061-577a3924fd06-image.png

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

Posted

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 ?

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