Hello,
I adjusted the browse view, I added the add to cart, but it does not work me Notify me when the item is not in stock.
Here is code:
<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @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.php 6556 2012-10-17 18:15:30Z kkmediaproduction $
*/
//vmdebug('$this->category',$this->category);
//vmdebug ('$this->category ' . $this->category->category_name);
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
JHTML::_ ('behavior.modal');
/* javascript for list Slide
Only here for the order list
can be changed by the template maker
*/
$js = "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
";
$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);
if (empty($this->keyword) and !empty($this->category)) {
?>
<?php
}
/* Show child categories */
if (VmConfig::get ('showCategory', 1) and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {
// Category and Columns Counter
$iCol = 1;
$iCategory = 1;
// Calculating Categories Per Row
$categories_per_row = VmConfig::get ('categories_per_row', 3);
$category_cellwidth = ' width' . floor (100 / $categories_per_row);
// Separator
$verticalseparator = " vertical-separator";
?>
<div class="category_description">
<?php echo $this->category->category_description; ?>
</div>
<?php
}
}
?>
<div class="clr"></div>
<h1 class="title"><?php echo $this->category->category_name; ?></h2>
<div class="category-view">
<?php // Start the Output
if (!empty($this->category->children)) {
foreach ($this->category->children as $category) {
// Show the horizontal seperator
if ($iCol == 1 && $iCategory > $categories_per_row) {
?>
<div class="horizontal-separator"></div>
<?php
}
// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) {
?>
<?php
}
// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
$show_vertical_separator = ' ';
} else {
$show_vertical_separator = $verticalseparator;
}
// Category Link
$caturl = JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id, FALSE);
// Show Category
?>
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<div class="spacer">
<div class="cat-image">
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb ("", FALSE);
//} ?>
</div>
<div class="clr"></div>
<div class="cat-title">
<h2>
<?php echo $category->category_name ?>
</h2>
</div>
</div>
</a>
</div>
<?php
$iCategory++;
// Do we need to close the current row now?
if ($iCol == $categories_per_row) {
?>
<?php
$iCol = 1;
} else {
$iCol++;
}
}
}
// Do we need a final closing row tag?
if ($iCol != 1) {
?>
<?php } ?>
</div>
<div class="clr"></div>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
?>
<h3 class="vm"><?php echo $this->keyword; ?></h3>
<?php
} ?>
<?php if (!empty($this->keyword)) {
$category_id = JRequest::getInt ('virtuemart_category_id', 0); ?>
<form action="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0', FALSE); ?>" method="get">
<!--BEGIN Search Box -->
<div class="virtuemart_search">
<?php echo $this->searchcustom ?>
<?php echo $this->searchcustomvalues ?>
<input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>"/>
<input type="submit" value="<?php echo JText::_ ('COM_VIRTUEMART_SEARCH') ?>" class="button" onclick="this.form.keyword.focus();"/>
</div>
<input type="hidden" name="search" value="true"/>
<input type="hidden" name="view" value="category"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="virtuemart_category_id" value="<?php echo $category_id; ?>"/>
</form>
<!-- End Search Box -->
<?php } ?>
<?php // Show child categories
if (!empty($this->products)) {
?>
<div class="orderby-displaynumber">
<div style="float:left">
<?php echo $this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div style="float:right" class="display-number">
<div class="result"><?php echo $this->vmPagination->getResultsCounter ();?></div>
<div style="float:right"><?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?></div>
</div>
<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->
<?php
// Category and Columns Counter
$iBrowseCol = 1;
$iBrowseProduct = 1;
// Calculating Products Per Row
$BrowseProducts_per_row = $this->perRow;
$Browsecellwidth = ' width' . floor (100 / $BrowseProducts_per_row);
// Separator
$verticalseparator = " vertical-separator";
$BrowseTotalProducts = count($this->products);
// Start the Output
foreach ($this->products as $product) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) {
?>
<div class="horizontal-separator"></div>
<?php
}
// this is an indicator wether a row needs to be opened or not
if ($iBrowseCol == 1) {
?>
<?php
}
// Show the vertical seperator
if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
$show_vertical_separator = ' middle';
} else {
$show_vertical_separator = $verticalseparator;
}
// Show Products
?>
<div class="product floatleft<?php echo $Browsecellwidth . $show_vertical_separator ?>">
<div class="spacer">
<div class="image">
<a title="<?php echo $product->product_name ?>" rel="vm-additional-images" href="<?php echo $product->link; ?>">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</a>
</div>
<div class="description">
<h2><?php echo JHTML::link ($product->link, $product->product_name); ?></h2>
<?php // Product Short Description
if (!empty($product->product_s_desc)) {
?>
<div class="clr"></div>
<?php } ?>
</div>
<div class="vote">
<!-- The "Average Customer Rating" Part -->
<?php if ($this->showRating) { ?>
<span class="title"><?php echo JText::_ ('COM_VIRTUEMART_CUSTOMER_RATING') ?>:</span>
<?php
// $img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
// echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
// echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes;
?>
<?php } ?>
<?php
if ( VmConfig::get ('display_stock', 1)) { ?>
<!-- if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')){?> -->
<div class="browse-stock">
<span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
</div>
<?php } ?>
</div>
<div class="clr"></div>
<?php
if (isset($this->product->step_order_level))
$step=$this->product->step_order_level;
else
$step=1;
if($step==0)
$step=1;
$alert=JText::sprintf ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED', $step);
?>
<form method="post" class="product js-recalculate" action="<?php echo JRoute::_ ('index.php'); ?>">
<input name="quantity" type="hidden" value="<?php echo $step ?>" />
<?php // Product custom_fields
if (!empty($this->product->customfieldsCart)) { ?>
<div class="product-fields">
<?php foreach ($this->product->customfieldsCart as $field)
{ ?><div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-fields-title" ><b><?php echo JText::_($field->custom_title) ?></b></span>
<?php echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png'); ?>
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
</div><br/ >
<?php
}
?>
</div>
<?php }
/* Product custom Childs
* to display a simple link use $field->virtuemart_product_id as link to child product_id
* custom_value is relation value to child
*/
if (!empty($this->product->customsChilds)) { ?>
<div class="product-fields">
<?php foreach ($this->product->customsChilds as $field) { ?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field->field_type ?>">
<span class="product-fields-title" ><b><?php echo JText::_($field->field->custom_title) ?></b></span>
<span class="product-field-desc"><?php echo JText::_($field->field->custom_value) ?></span>
<span class="product-field-display"><?php echo $field->display ?></span>
</div><br/ >
<?php
} ?>
</div>
<?php } ?>
<div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
<?php
if ($this->show_prices == '1') {
if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and !$product->images[0]->file_is_downloadable) {
echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE');
}
//todo add config settings
if ($this->showBasePrice) {
echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $product->prices);
}
echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";
}
if (round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
}
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $this->currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
} else {
echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
}
echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
$unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', $product->product_unit);
echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
} ?>
</div>
</form>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
<div class="cart-detail">
<input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
echo $product->min_order_level;
} else {
echo '1';
} ?>" />
<div class="addtocart-bar">
<script type="text/javascript">
function check(obj) {
// use the modulus operator '%' to see if there is a remainder
remainder=obj.value % <?php echo $step?>;
quantity=obj.value;
if (remainder != 0) {
alert('<?php echo $alert?>!');
obj.value = quantity-remainder;
return false;
}
return true;
}
</script>
<!-- <label for="quantity<?php echo $product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
<?php // Display the quantity box END ?>
<?php // Add the button
$button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO_CAT');
$button_cls = ''; //$button_cls = 'addtocart_button';
if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
$button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls = 'notify-button';
} ?>
<?php // Display the add to cart button ?>
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
</span>
</div>
</div>
<?php // Display the add to cart button END ?>
<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<noscript><input type="hidden" name="task" value="add" /></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
<?php /** @todo Handle the manufacturer view */ ?>
<input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
<input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</div>
<!-- end of spacer -->
</div> <!-- end of product -->
<?php
// Do we need to close the current row now?
if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {
?>
<!-- end of row -->
<?php
$iBrowseCol = 1;
} else {
$iBrowseCol++;
}
$iBrowseProduct++;
} // end of foreach ( $this->products as $product )
// Do we need a final closing row tag?
if ($iBrowseCol != 1) {
?>
<?php
}
?>
<div class="clear"></div>
<div class="vm-pagination"><?php echo $this->vmPagination->getPagesLinks (); ?><span><?php echo $this->vmPagination->getPagesCounter (); ?></span></div>
<?php
} elseif (!empty($this->keyword)) {
echo JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}
?>
</div><!-- end browse-view -->
VirtueMart 2.6.10
http://test.rcmshop.cz/prepravni-obaly
Product is not stock (red cross)
Thaks you for your help
Vana
code isn't there to do that ... try this one: http://www.gjcwebdesign.com/joomla-virtuemart-tips/767-virtuemart-2-add-to-cart-button-on-category-page.html
I joined file with the changes in the browse view. Notyfi me is not displayed when a product is not in stock. All shows Add to cart.
VirtueMart 2.6.10
[attachment cleanup by admin]
mine just showa a out of stock message
<span class="addtocart-button">
<?php if ($button_cls == "notify-button") { ?>
<span class="outofstock"><?php echo JText::_('COM_VIRTUEMART_CART_PRODUCT_OUT_OF_STOCK'); ?></span>
<?php } else {?>
<input name="<?php echo $button_name ?>" class="<?php echo $button_cls ?>" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" type="submit" />
<?php } ?>
</span>
you'll have to use the detailspage code
It does not work. :-\
sorry - but with feedback like that you will be lucky to get anyone to help -- what doesn't work?
We aren't all totally focussed on your particular code and problems...
if the details page code doesn't work then VM is in real trouble...
Quote from: vanaveno on November 15, 2014, 18:46:00 PM
I added the add to cart, but it does not work me Notify me when the item is not in stock
Add to cart /notify works out of the box in VM2.9.9.5 so maybe try that version?
Thank you for your response jenkilhill. Yes in version VM2.9.9.5 Notify me working, but do not work other modules as a onepage cart etc. I am a little bit desperate. In module_virtuemart_product Notify me working.
I found this solution, which works in VM 2.6.10
QuoteThis is working if you have done what madking's solution suggested, not if you have used files from somewher in the thread!
These are the steps:
1 Create a folder rootOfYourSite/templates/yourTemplate/html/com_virtuemart/category
Copy into this:-
2 default.php from com_virtuemart/views/category/tmpl
3 default_addtocart.php from components/com/virtuemart/views/productdetails/tmpl
4 Rename default_addtocart.php to something sensible e.g. addtocartCategory.php works for me
5 In the new file addtocartCategory.php replace $this->product with $product
6 Now go to the copied default.php (the browse view for a category) and add the new add to cart template (button etc.) in the position you want
Do this somewhere between
// Show Products and <!-- end of product -->
Using the code
Code: [Select]
<?php include 'addtocartCategory.php'; ?>
The category add to cart should then perform the same as the product add to cart.