News:

Support the VirtueMart project and become a member

Main Menu

Notify me! button opens cart!?

Started by Venkko, January 04, 2012, 20:08:42 PM

Previous topic - Next topic

Venkko

I Just noticed that if I have product with stock quantity 0 and I press "notify me!" button on the product details, it opens shopping cart.

Is this how it should work???

VM 2.0.0
J1.5.23
www.pikkukoala.fi (J 1.5 & VM 1.1.5)
www.lastentavarat.fi (J 1.5.23 & V2.0.0)

jfoc

Same happens to me... I think it's a bug...the only way stock control works is using the disable product option... but that just unpublishes the product from the catalog, I haven't been able to fix this yet... stock control is very important... if anyone knows how to fix it or has a workaround... please share!

jfoc

Still no answers??? No option but to remove the product from the shop?

jenkinhill

That still happens in SVN version 5282 so I guess has not yet been fixed in the core.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

smartserver

So what with notify button? Still when i click on button "Notify" its open empty cart. What can we do with it? Plz help!

TBoele

What's the meaning of the Notify button on the product details page ?
In VM 2.0.1N it just add the product to the cart and open de order cart page.

MaHe29

It would be nice to see a fix for this one, since the issue is known for a while.

TBoele

Still not fixed in the stable version VM 2.0.2   :(

delacruise

I cant actually call this a solution, but it is a workaround for the current problem until we get a solution

replace the Add To Cart Button code in components/com_virtuemart/views/productdetails/tmpl/default.php with this.


<?php
// Add To Cart Button
if ($this->product->product_in_stock 1) {
                 if (!empty(
$this->product->prices) and !empty($this->product->images[0]) and $this->product->images[0]->file_is_downloadable==) {
           
      echo $this->loadTemplate('addtocart'); 
 }
}else
{
  echo "<a href='mailto:your@email.address&subject=your subject&body=your content' class='notifyme'>Notify Me</a>";
}
?>



I created my own css class 'notifyme' to replicate the same look as the original button.

Good luck I hope this helps someone

seyi

#9
I went ahead and wrote a hack until core fixes this issue.  Im using virtuemart 2.0.2, here it is:

create file
www/administrator/components/com_virtuemart/tables/waitingusers.php
and add this to it


<?php
# seyi_code

/**
*
* Currency table
*
* @package VirtueMart
* @subpackage Currency
* @author RickG
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: currencies.php 3256 2011-05-15 20:04:08Z Milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

if(!
class_exists('VmTable')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmtable.php');

/**
 * Worldzones table class
 * The class is is used to manage the currencies in the shop.
 *
 * @package VirtueMart
 * @author RickG, Max Milbers
 */
class TableWaitingUsers extends VmTable {

var $virtuemart_waitinguser_id 0;
var $virtuemart_product_id 0;
var $virtuemart_user_id         0;
var $notify_email '';
var $notified          0;
var $notify_date  '';
    var 
$ordering 0;

/**
 * @author Max Milbers
 * @param $db A database connector object
 */
function __construct(&$db) {
parent::__construct('#__virtuemart_waitingusers''virtuemart_waitinguser_id'$db);
$this->setLoggable();

}

function check() {
if(empty($this->notify_email) || !filter_var($this->notify_emailFILTER_VALIDATE_EMAIL)) {
vmError(JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'),JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'));
return false;
}
return parent::check();
}

}
// pure php no closing tag



Then add the code to add customers for notifying:
in  www/administrator/components/com_virtuemart/models/waitinglist.php in the class VirtueMartModelWaitingList add this function

<?php
# seyi_code
public function adduser($data) {
JRequest::checkToken() or jexit'Invalid Token, in notify customer');


$field $this->getTable('waitingusers');

if (!$field->bind($data)) { // Bind data
vmError($field->getError());
return false;
}

if (!$field->check()) { // Perform data checks
vmError($field->getError());
return false;
}

$_id $field->store();
if ($_id === false) { // Write data to the DB
vmError($field->getError());
return false;
}


//jexit();
return $_id ;
}



Then allow a different layout in product details:
in www/components/com_virtuemart/views/productdetails/view.html.php, in function display right before "parent::display($tpl);" add this

<?php
if(JRequest::getVar('layout''')=='notify'$this->setLayout('notify'); # seyi_code


Then create the notify page
create www/components/com_virtuemart/views/productdetails/notify.php and add this to it


<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default_reviews.php 5428 2012-02-12 04:41:22Z electrocity $
 */

// Check to ensure this file is included in Joomla!
defined '_JEXEC' ) or die ( 'Restricted access' );
//echo '<pre>'; print_r($this->user); exit;
?>






<div class="customer-reviews">
<form method="post" action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$this->product->virtuemart_product_id.'&virtuemart_category_id='.$this->product->virtuemart_category_id) ; ?>" name="notifyform" id="notifyform">
<h4><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY'?></h4>

<div class="list-reviews">
We regret to inform you that this product is either out of stock or insufficient in stock for your order. Please submit your email address if you would like to be notified when new stock arrives for this product.
<br /><br />
Thank you!
<br /><br />
<div class="clear"></div>
</div>

<div><input type="text" name="notify_email" value="<?php echo $this->user->email?>" />
<input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY'?>" /></div>


<input type="hidden" name="virtuemart_product_id" value="<?php echo $this->product->virtuemart_product_id?>" />
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="virtuemart_category_id" value="<?php echo JRequest::getInt('virtuemart_category_id'); ?>" />
<input type="hidden" name="virtuemart_user_id" value="<?php echo $this->user->id?>" />
<input type="hidden" name="task" value="notifycustomer" />
<?php echo JHTML::_'form.token' ); ?>
</form>
</div>


Set the controller task
in www/components/com_virtuemart/controllers/productdetails.php, in class VirtueMartControllerProductdetails add the function

<?php
# seyi_code
public function notifycustomer(){
$data JRequest::get('post');

$model VmModel::getModel('waitinglist');
if(!$model->adduser($data)) {
$errors $model->getErrors();
foreach($errors as $error){
$msg = ($error).'<br />';
}
$this->setRedirect(JRoute::'index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$data['virtuemart_product_id']), $msg);
} else {
$msg JText::sprintf('COM_VIRTUEMART_STRING_SAVED',JText::_('COM_VIRTUEMART_CART_NOTIFY') );
$this->setRedirect(JRoute::'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$data['virtuemart_product_id']), $msg);
}


}


Last but not least, adjust the product detail page to call the notify layout created
in www/components/com_virtuemart/views/productdetails/tmpl/default_addtocart.php update this

    <span class="addtocart-button">
<input type="submit" name="<?php echo $button_name ?>"  class="<?php echo $button_cls ?>" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
    </span>


to something like this

<?php
if(($stockhandle=='disableit' or $stockhandle=='disableadd') and ($this->current_product->product_in_stock $this->current_product->product_ordered)<1){
?>

<a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->current_product->virtuemart_product_id); ?>"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY'?></a>
<?php } else { ?>
    <span class="addtocart-button">
<input type="submit" name="<?php echo $button_name ?>"  class="<?php echo $button_cls ?>" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
    </span>
<?php ?>


The notify link would need to be styled.
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

DaggaTora

Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

seyi

you should not need it.  the notifications in the admin side should work fine for 2.0.7j
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

DaggaTora

Where are notifications in the admin side? I can't find them.

I still have the problem that Notify button redirects to cart.  :'(
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

seyi

If you have customers that need notification, it will show up under the product status tab in product details.

For the notify redirect problem, you can temporarily disable sef or copy 2.0.6 router.php into 2.0.7 until the redirection issue is fixed.
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