Will there be a D7 port for this module?

Comments

suncombo’s picture

Assigned: Unassigned » suncombo
StatusFileSize
new10.52 KB

I try to update modules for the first time. Want to help you.

Quarantine’s picture

Thank you so much for this suncombo! I'll give this a shot and will report back if I've any issues. :)

Quarantine’s picture

Hey suncombo,

I installed this module on my site, then went to Edit a product, clicked on "Stock", and under "Active", I made a mark on its checkbox.

After I saved the changes, these error messages immediately appeared:

Notice: Undefined variable: result_array in uc_stock_notify_edit_submit() (line 122 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).
Notice: Trying to get property of non-object in uc_stock_notify_edit_submit() (line 122 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).

Would you know what would be the problem?

suncombo’s picture

StatusFileSize
new10.57 KB

I update the module,Please try it.

Quarantine’s picture

Thank you so much again for your effort suncombo!

I just tried it again, and this time, using the same exact steps that I described above, this error code is appearing again:

Notice: Undefined variable: result_array in uc_stock_notify_edit_submit() (line 145 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).
Notice: Trying to get property of non-object in uc_stock_notify_edit_submit() (line 145 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).

But this time it's on a different line.

At the product itself, these error messages are appearing:

Notice: Trying to get property of non-object in uc_stock_notify_form_alter() (line 77 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).
Notice: Trying to get property of non-object in uc_stock_notify_form_alter() (line 83 of /var/www/URL.com/sites/all/modules/uc_stock_notify/uc_stock_notify.module).
suncombo’s picture

StatusFileSize
new10.5 KB

I have the same problem, I uploaded an updated version, please forgive me I was a rookie.

Quarantine’s picture

Hey suncombo,

Don't worry, I'm an even worse rookie. :P But thanks again for all your effort in this.

I think it worked fine now! Just one more error message that I spotted. Here's what I did:

1. Change stock level of a product to 0, and make it "active".
2. Go to "View" for the product, and click on the button for "Notify me when this product is in stock".
3. Change the stock level of that product to 3 (any value other than 0).
4. Then immediately this error message appears:

Notice: Undefined index: message in uc_order_mail() (line 564 of /var/www/URL.com/sites/all/modules/ubercart/uc_order/uc_order.module).

Actually, where do I go to edit the message for the e-mail to be sent?

The e-mail I received in the inbox has this exact title: "[store-name]: [title] back in stock" and the body of the e-mail is blank/empty.

suncombo’s picture

StatusFileSize
new10.55 KB

I have had this problem, I uploaded the new updates.
Please test again.

Allthegearnoidea’s picture

This is actually a really useful module... How do you make it an official release?

Allthegearnoidea’s picture

Just been playing with this a bit... I notice that the email that comes through.

Mostly it's great and it's definitely a great marketing tool for any store.

The issue I am having is that the email it sends out has the website's URL included in it. So it will display example.com However if you click on the URL generated the email client tries to follow [store:url] rather than the actual url shown (if you hover over the URL generated you will see (in Outlook) that it says " [store:url] click to follow link " whereas you'd expect it to say " example.com click to follow link ". This leads (certainly in Outlook) for a warning to be given "This location may be unsafe: [store:url]"

I've tried to fix this to just remove this part of the email so the store's main URL is not included (as it has the product link working just fine) but (as I am useless with code) I am succeeding only in breaking the module.

Any thoughts on how to overcome the issue above?

Thanks

Allthegearnoidea’s picture

I solved this in the end... I finally worked out how to remove the [store:url] part and not break the module :-)

Thanks

waltercat’s picture

I am having the same issue where the email is blank. Does anyone know how to fix this? It is such a useful module.

waltercat’s picture

Willing to contribute some money to get a D7 Port working up to speed. Thanks!

gukudrupal’s picture

Issue summary: View changes

Hi,

I was just playing around with this and finally got it working where I got the emails with the text showing up in the body.

This is the code I used in the uc_stock_notify.module file.:

$settings = array(
        'from' => uc_store_email_from(),
        'subject' => t('[store:name] : [node:title] back in stock'),
        'message' => t('This message has been sent to let you know that <a href="[node:url]">[node:title]</a> is now back in stock. Thank you for your interest.<a href="put your url here">[store:name]</a>'),
        'format' => 1); 

instead of all this:

    $settings = array(
        'from' => uc_store_email_from(),
        'subject' => t('[store:name] : [node:title] back in stock'),
        'message' => t('This message has been sent to let you know that <a href="!node_url">!node_title</a> is now back in stock.\n\nThanks,\n\n <a href="!store_url">!store_name</a>',
                                  array('!node_url'=>'[node:url]','!store_url'=>'[store:url]','!node_title'=>'[node:title]','!store_name'=>'[store:name]')),
        'format' => 'full_html');

No more blank emails.

Hope that helps, as this took me a while to get fixed for our store.

David

mr_byte’s picture

There are some issues with module for me, mainly it doesn't work at all with attributes. I also had issues with email tokens not being properly replaced, so I re-wrote a portion of that as well.

What I have so far, is with the help of uc_attribute_stock_filter, made this module a bit more aware of attributes and their options that may contain stock.

It's a work in progress. I will post here once it's to the "works for me" stage and a bit simplified.

mr_byte’s picture

StatusFileSize
new11.09 KB

As promised, the "it works for me" stage.

It will properly flag items that are out of stock, with no attributes. It will flag items with 1 attribute and all options are out of stock. I assume (but have not tested...) multiple attributes will perform the same way.

The use can select the option they want and hit "notify" and they'll get added to the list.

There is code in there for adding a logged in user to the list if they select an out-of-stock option for an item that still has stock on other options. Maybe someone can find a graceful way to put a message up to let users know this beforehand. It does notify users when they try to add an out-of-stock option to the cart.

This last (and most difficult) case requires a patch to your out of stock module. I use uc_out_of_stock, so the relevant code goes into function uc_out_of_stock_validate_addtocart:

    if ($stockinfo['stock'] <= 0) {
      if (user_is_logged_in() && module_exists('uc_stock_notify')) {
        $error = uc_stock_notify_add_to_list($nid, $attrs);
      } else {
        $error = _uc_out_of_stock_get_error('out_of_stock', $nid, $attrs, $stockinfo['stock']);    
      }
    }

If there's a better way to do this so the out of stock module needs no modification, feel free to share.

As is, it should work without the uc_out_of_stock module, but I have not tested it this way. YMMV.

mr_byte’s picture

StatusFileSize
new15.06 KB

Embarrasing. I uploaded the wrong file. This one is correct.

BigMike’s picture

Hello fellow Ubercart lovers!

Feel free to skip to (2) below. Sorry for the unnecessarily long post. I'm just excited over here :-D

(1) Background:
We've used D6/UC2 for over 8 yrs (and before that was D5/UC1) and earlier this year we/I finally made the switch to D7/UC3! I knew that, very sad to see, Ubercart support has dwindled due to a former UC team member who left and, as far as I can tell from a complete outsider, has some deep grudge empowering his mission to derail UC with a competing Store module and it just makes me sick. So many new D7 modules appearing for that other system with fewer D7 module support for the entire reason why we made the switch to Drupal nearly a decade ago: Because of the awesome Ubercart module!! So I am an UC fan through-and-through and I hope support from the community (3rd party contrib modules) can continue as we'll be moving to D8/UC4 someday.

Little by little I've been learning more and more about module development and have an ability to get in trouble and also to troubleshoot. As I get better I hope someday to actually be a contributor to Ubercart to help support the cause!!

(2) Couple small updates to mr_byte's #17 post/module
When I was upgrading our UC2 site naturally I looked to install our #1 most important user-contrib module and that is UC Stock Notify. I've messed with both suncombo and mr_byte's ports to D7 and I HAVE to first say THANK YOU to you both for doing this.

I don't know if this is needed for others but I finally got mr_byte's #17 post/module to work on our site. It took me two days and I figured out the following four changes are needed for me. Our site is D7.54, UC3.10, operating over PHP v5.3.x (already in the works on upgrading this). I'm also using AJAX Cart Alternative 1.7+8-dev (2016-Jun-16) and it works with Javascript enabled or disabled in Firefox and IE11 for both authenticated and anonymous users so all seems good!

Using uc_stock_notify_4.zip from post #17 (https://www.drupal.org/files/issues/uc_stock_notify_4.zip)
File: uc_stock_notify.module

[Change 1]
Line 53: Old
if (count($models) == 1) $model = $models[0];
New:
if (count($models) == 1) $model = reset($models);

[Change 2]
Lines 75-78: Old

          $form['model'] = array(
              '#type' => 'value',
              '#value' => $model,
          );

New:

          if (count($models) == 1)
            $form['model'] = array(
                '#type' => 'value',
                '#value' => $model,
            );

[Change 3]
Line 185: Old
$attrs = isset($form_state['values']['attributes']);

New:
$attrs = $form_state['values']['attributes'];

[Change 4]
Finally, there are a few calls to a function called uc_out_of_stock_getstockinfo() which doesn't exist and is found in the project "Ubercart Out of stock Notification" (https://www.drupal.org/project/uc_out_of_stock). I was previously using this module so fortunately it was easy to figure it out:
1. Download that module (I used v1.1, https://ftp.drupal.org/files/projects/uc_out_of_stock-7.x-1.1.tar.gz)
2. Open 'uc_out_of_stock.module' and copy the function (lines #105-154)
3. Paste the function anywhere to uc_stock_notify.module (I pasted it after the function uc_stock_notify_get_sku() at line 220).

Ok! At this point mr_byte's module began working without errors! Maybe it's just our old PHP version or maybe it's that D7 has been updated since my_byte's code. Nevertheless, if this helps someone then I'm glad I posted up. THANK YOU mr_byte for compatibility with attributes, and have a nice day!

Regards,
BigMike

fox mulder’s picture

The sended mail is not translatable because a new translatable string will be created to any product.
Recommended changes from line 306 in uc_stock_notify/uc_stock_notify.module

function uc_stock_notify_action_email($model) {
    ...    
    $settings = array(
        'from' => uc_store_email_from(),
        // ORIG.: 'subject' => t('[store:name] : ' . $node->title . ' is back in stock'),
        'subject' => t('@store_name : @node_title is back in stock', array('@store_name' => variable_get('uc_store_name', variable_get('site_name', '')), '@node_title' => $node->title)),
        // ORIG.: 'message' => t('Per your request, we are letting you know that ' . l($node->title, url($nodeurl,$urlopts)) . ' is now back in stock.<br><br>Thanks,<br><br> ' . l('[store:name]', url('/',$urlopts))),
        'message' => t(
          'Per your request, we are letting you know that <a href="@node_url">@node_title</a> is now back in stock.<br><br>Thanks,<br><br><a href="@store_url">@store_name</a>',
          array(
            '@node_url' => url($nodeurl,$urlopts),
            '@node_title' => $node->title,
            '@store_url' => url('/',$urlopts),
            '@store_name' => variable_get('uc_store_name', variable_get('site_name', ''))
          )
        ),
        'format' => 'full_html');

    $settings['replacements'] = array(
      ...
Mar1ak10’s picture

Thank you all for taking the time to update this issue, it greatly helped me.
Thanks to BigMike in comment #18 I was able to get rid of an error appearing about undefined something at line 53 of the module, but I have a couple of issues when trying to follow his steps.

1- [Change 3]
Line 185: Old
$attrs = isset($form_state['values']['attributes']);

New:
$attrs = $form_state['values']['attributes'];

When I got to this step I noticed that the new code he is requesting us to place is actually the code I found in the module, maybe he mixed up the 'Old' and 'New' around?

2- When copying the function from the module uc_out_of_stock.module into this module file I get this error on the site
"Fatal error: Cannot redeclare uc_out_of_stock_getstockinfo() (previously declared in /home/user/public_html/sites/all/modules/uc_out_of_stock/uc_out_of_stock.module:105"

I remember doing a a drupal core update not long ago, definitely after his comment, so maybe it has to do something with that?

Anyway, I did not do anything about what I mentioned in number 1 AKA I left the code as it is and removed the function uc_out_of_stock_getstockinfo() from this module and everything is running fine after testing. Wish if someone could shed some light on these two points.
P.S: The e-mails I've been receiving are never blank so I did not need to modify anything about emails.
Thanks everybody.

mr_byte’s picture

I know it's been a while. Glad my spaghetti is usable to someone :-) I'm no longer using this module myself, as I switched my system to internal use (POS) only.