News:

Support the VirtueMart project and become a member

Main Menu

what happens after user presses notify me

Started by slutsker, April 27, 2012, 13:04:52 PM

Previous topic - Next topic

slutsker

hello
i have some questions about notifications

i select show notify me when product is out of stock

1 - what happens after user press this button on page with ?layout=notify
(there is an input for notification email) - user recieve something from VM immediately or when product is in stock

2 - how can i see notification requests in VM admin page?

3 - when user enters his email and press "notify" he just returns to product details view without any message about successful notification request or somethong like this - what can be done with it?

slutsker

#1
is it true that nobody know what happens after user press "notify me" button? :-[

here is what i found:


  • there is table called virtuemart_waitingusers in this table there is a list of product ids and emails
  • notification request for each product can be viewed only in this products page in tab 'waiting list'

problem: if there are some users in waiting list and i update product count - i see View Not Found [name, type, prefix]: waitinglist, html, virtuemartView

seyi

#2
The backend for notifications has some old code and needs updating.  I will write a patch and submit it when I have time, but for now here is how you can get it working.

Add the attached file to:
www/components/com_virtuemart/views/productdetails/tmpl/mail_notify.php
This is your mail template, so modify as you see fit

In www/components/com_virtuemart/views/productdetails/view.html.php, inside class VirtueMartViewProductdetails, add the function
<?php
function 
renderMailLayout ($doVendor$recipient) {
$tpl 'mail_notify';
$this->doVendor=$doVendor;
$this->fromPdf=false;
$this->uselayout $tpl;
$this->subject 'Product Notification';
$this->layoutName $tpl;
$this->setLayout($tpl);
parent::display();
}
?>


In www/administrator/components/com_virtuemart/models/waitinglist.php inside function notifyList is this
<?php
/* Load the product details */
$q "SELECT product_name FROM #__virtuemart_products WHERE virtuemart_product_id = ".$virtuemart_product_id;
$db->setQuery($q);
$vars['productName'] = $db->loadResult();

/*TODO old URL here Now get the url information */
$vars['url'] = JURI::root().JRoute::_('index.php?page=shop.product_details&flypage=shop.flypage&virtuemart_product_id='.$virtuemart_product_id.'&option=com_virtuemart');

foreach ($waiting_users as $key => $waiting_user) {
$vars['user'] = $waiting_user;
if (shopFunctionsF::renderMail('waitinglist'$waiting_user->notify_email$vars)) {
$this->update($waiting_user->notify_email$virtuemart_product_id);
}
}
?>


change it to this
<?php
/* Load the product details */
//$q = "SELECT product_name FROM #__virtuemart_products WHERE virtuemart_product_id = ".$virtuemart_product_id;
$q "SELECT product_name FROM `#__virtuemart_products_".VMLANG."` WHERE virtuemart_product_id = ".$virtuemart_product_id# seyi_code
$db->setQuery($q);
$vars['productName'] = $db->loadResult();

/*TODO old URL here Now get the url information */
//$vars['url'] = JURI::root().JRoute::_('index.php?page=shop.product_details&flypage=shop.flypage&virtuemart_product_id='.$virtuemart_product_id.'&option=com_virtuemart');
$vars['url'] = JURI::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$virtuemart_product_id;

foreach ($waiting_users as $key => $waiting_user) {
$vars['user'] = $waiting_user;
/*if (shopFunctionsF::renderMail('waitinglist', $waiting_user->notify_email, $vars)) {
$this->update($waiting_user->notify_email, $virtuemart_product_id);
}*/
if (shopFunctionsF::renderMail('productdetails'$waiting_user->notify_email$vars)) {
$db->setQuery('UPDATE #__virtuemart_waitingusers SET notified=1 WHERE virtuemart_waitinguser_id='.$waiting_user->virtuemart_waitinguser_id);
$db->query();
}
}
?>


Notifications should now work and you will not receive the 500 error page anymore.



[attachment cleanup by admin]
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

antonitus

At the moment it seems that the 'Notify Me' feature does not work properly as I have been having issues with it in V2.0.6.

The VM developers are aware of this and have been working on it.  If you set up a test site and download the beta release V2.0.7, you'll see that they have changed this feature somewhat to make it more sense, however there are still some bugs in it, but I'm sure they'll resolve it soon in the next stable release which I believe is 2.0.8. Fingers crossed as this is an important feature to have working.  In the meantime, I'll try the code that seyi put out.
Joomla V3.5.1
Virtuemart V3.0.16

antonitus

#4
Hi seyi,

I tried your script for the 'Notify Me' issue, but I still get the 500 Error.  Also, you need to remove the <php> tags from your code as they are not needed and they result in errors.
Also, what is the attached file used for (mail_notify.php)?  Is to receive an email notification?  If it is then I did not receive one.

Thanks for your script, I look forward in getting it to work.  Hopefully the VM devs will add it to their build.


#### UPDATE ####

I managed to get it working to a point under V2.0.7 (beta release).  When someone processes the 'Notify Me' feature, it gets added to the product's notification part which should happen as normal, however the danger of this is that when you do a 'save' in the admin panel for whatever reason it sends a notification to the user who wanted to be notified. Not sure if this is ideal.  We have to have the option of manually notifying, which is available in V2.0.7.  I suppose you built this script under V2.0.6 and not V2.0.7.  It still needs a bit of tweaking I suppose once we get the new build.   Overall, at last a decent script to get this 'Notify Me' working.  Well done seyi.  I'll test it under the stable release, V2.0.6.

#### UPDATE 2 ####

I tested your script on V2.0.6 and there were no 500 Errors.  However (sorry about that), when the user who receives the notification email, the URL link in the email directs it to the administrator's back-end link, like this and it's not properly parsed:


Quotehttp://www.domainname.com/shop//shop/administrator/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1

My domain name is in this format: http://www.domainname.com/shop/, but the above adds 'shop' twice and with an extra '/' (slash).  Thought I'd let you know.
Joomla V3.5.1
Virtuemart V3.0.16

seyi

great, glad you got it working.  mail_notify.php is the mail template, this should be adjusted to whatever you want the customer to receive.  I use the <?php and ?> tags to beautify the code, nothing more, sorry its confusing.  To adjust the url, find this code in www/administrator/components/com_virtuemart/models/waitinglist.php
<?php
$vars['url'] = JURI::root().JRoute::_('index.php?page=shop.product_details&flypage=shop.flypage&virtuemart_product_id='.$virtuemart_product_id.'&option=com_virtuemart');
?>


change it to this
<?php
$vars['url'] = JURI::root().'index.php?page=shop.product_details&flypage=shop.flypage&virtuemart_product_id='.$virtuemart_product_id.'&option=com_virtuemart';
?>


This will send a non-sef url
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

antonitus

Hi seyi,

Thank you for your speedy response and thank you for the fix, however the URL does not seem to link to the actual product in question.  Is this possible to achieve?

I have to say, I really like this script, it's perfect.
Joomla V3.5.1
Virtuemart V3.0.16

seyi

I copied the wrong code.  That url points to your product in virtuemart 1.  Here is the virtuemart 2 version

change
<?php
$vars
['url'] = JURI::root().JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$virtuemart_product_id); # seyi_code
?>


to
<?php
$vars
['url'] = JURI::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$virtuemart_product_id# seyi_code
?>


You can comment out the other version.
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

antonitus

Excellent. Nice work, this worked a treat and now it directs the user to the product that was notified.  VM devs, please take note of the next piece of script to add to the new build.

All that is needed now is a way to manage/edit/delete notified emails within the back-end of VM. I'm not sure why this was overlooked.

Can I ask you, are an official VM developer, if so someone needs to look into the shopper group permissions as certain permissions were overlooked and do not work at all in terms of security to certain shopper groups.
Joomla V3.5.1
Virtuemart V3.0.16

antonitus

Hi seyi,

Sorry to trouble you again.  I installed the latest build V2.0.7b and I applied your code but it doesn't seem to work.  Whatever the VM developers did, did not make it work.  When you click on the notify me button, an info message does not appear letting the user know that he/she was notified.  Do you have any suggestions on how to fix this?

Thanks
Tony
Joomla V3.5.1
Virtuemart V3.0.16

seyi

Hi Tony,

Using the latest, com_virtuemart.2.0.7.b, the notify function works for me.  After entering an email, I am taken back to the product and receive the message 'Notify Me successfully saved'.  The message is sent through Joomla's messaging system, so verify that your template has the relevant code to display it.
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

antonitus

Hi Seyi,

Before I updated to v2.0.7b all was ok with the messaging and your script. Now for some strange reason I am not getting any messaging and my Joomla messaging system works ok.

What I noticed on my working v2.0.6 version, the URL link is something like this: nameofproduct?layout=notify.  When I add this to the end of the product URL it works.  However when I click on the 'Notify Me' link the URL is like this: nameofproduct/notify, which doesn't seem to work and somehow is not passing the code.  So I'm not sure what might have gone wrong.  I reverted back to the original 2.0.7b files and as a test to 2.0.6 and still no success.
Joomla V3.5.1
Virtuemart V3.0.16

seyi

I see now.  It works fine with non sef urls, but once you turn it on, the problem happens.  The urls for notify:

vm 2.0.6: power-sander-detail?layout=notify
vm 2.0.8: power-sander-detail/notify

The router does not compensate for /notify causing the problems.  Here is the fix

in www/components/com_virtuemart/router.php, around line 148 is this
<?php
if (
substr(end($segments ), -(int)$helper->seo_sufix_size ) == $helper->seo_sufix ) {
?>


change to
<?php
 
//if (substr(end($segments ), -(int)$helper->seo_sufix_size ) == $helper->seo_sufix ) {
 $last_elem end($segments);
 $slast_elem prev($segments);
 if ( (substr($last_elem, -(int)$helper->seo_sufix_size ) == $helper->seo_sufix
|| ($last_elem=='notify' && substr($slast_elem, -(int)$helper->seo_sufix_size ) == $helper->seo_sufix) ) {
if($last_elem=='notify') {
$vars['layout'] = 'notify';
array_pop($segments);
}
?>

in
Seyi A
--------------------
Promotion enhancement for Virtuemart:
   - AwoCoupon FREE - http://www.awocoupon.com/starter
   - AwoCoupon Pro - http://awodev.com/products/joomla/awocoupon
   - AwoRewards - http://awodev.com/products/joomla/aworewards
   - AwoAffiliate - http://awodev.com/products/joomla/awoaffiliate

antonitus

Thanks for the code Seyi.  I replaced the code, but still no success.  I turned off SEO and still it doesn't work.  Apart from amending your notify scripts, I haven't modified any other scripts.  The only way I could get the notify to work was to replace the router.php from V2.0.6 and I got the 'notify me' message to pop up as normal.  I don't know what repercussions this will be, but hopefully it is confined to the 'notify me' portion of the software.  I have been looking at the old V2.0.6 router.php code to try to compare it to new one and your code and I can't figure it out.  Although your new code is omitted and SEO is turned on at the moment and the V2.0.6 router.php still works.  Complicated stuff. I wish I was an expert in PHP.
Joomla V3.5.1
Virtuemart V3.0.16

Lexiboy

Can you tell if progress has been made in Virtuemart on functionality with product notifications?

Quote from: seyi on May 07, 2012, 22:39:18 PM
The backend for notifications has some old code and needs updating.  I will write a patch and submit it when I have time, but for now here is how you can get it working.


Notifications should now work and you will not receive the 500 error page anymore.



[attachment cleanup by admin]
With kind regards,
Alex Stienstra