Hi all..
I want to add a generic 'VIEW PRODUCT' button to all products in category view instead of the usual ADD TO CART button. The main reason being is that my template does not accommodate child variants very well, so I get 'Choose a variant' displaying when viewing products with variants on the category page. I'm also keen to learn a little more about this stuff in the process....fingers crossed!
Having had a read through various threads, I came to the conclusion that this feature would be controlled by the 'addtocartbar.php' file in the /templates/mytemplate/html/com_virtuemart/sublayouts directory. Hopefully this is correct...and if so, can anyone point me to the relevant areas of code below that will enable me to achieve this? Will I need to also edit other files too?
defined('_JEXEC') or die('Restricted access');
$product = $viewData['product'];
if(isset($viewData['rowHeights'])){
$rowHeights = $viewData['rowHeights'];
} else {
$rowHeights['customfields'] = TRUE;
}
$init = 1;
if(isset($viewData['init'])){
$init = $viewData['init'];
}
if(!empty($product->min_order_level) and $init<$product->min_order_level){
$init = $product->min_order_level;
}
$step=1;
if (!empty($product->step_order_level)){
$step=$product->step_order_level;
if(!empty($init)){
if($init<$step){
$init = $step;
} else {
$init = ceil($init/$step) * $step;
}
}
if(empty($product->min_order_level) and !isset($viewData['init'])){
$init = $step;
}
}
$maxOrder= '';
if (!empty($product->max_order_level)){
$maxOrder = ' max="'.$product->max_order_level.'" ';
}
$addtoCartButton = '';
if(!VmConfig::get('use_as_catalog', 0)){
if(!$product->addToCartButton and $product->addToCartButton!==''){
$addtoCartButton = shopFunctionsF::getAddToCartButton ($product->orderable);
} else {
$addtoCartButton = $product->addToCartButton;
}
}
$position = 'addtocart';
//if (!empty($product->customfieldsSorted[$position]) or !empty($addtoCartButton)) {
if (!VmConfig::get('use_as_catalog', 0) ) { ?>
<div class="addtocart-bar">
<?php
// Display the quantity box
$stockhandle = VmConfig::get ('stockhandle', 'none');
if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) { ?>
<a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify"><?php echo vmText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a><?php
} else {
$tmpPrice = (float) $product->prices['costPrice'];
if (!( VmConfig::get('askprice', true) and empty($tmpPrice) ) ) { ?>
<?php if ($product->orderable) { ?>
<!-- <label for="quantity<?php echo $product->virtuemart_product_id; ?>" class="quantity_box"><?php echo vmText::_ ('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
<span class="quantity-box">
<input type="number" class="quantity-input js-recalculate" name="quantity[]" data-errStr="<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>" value="<?php echo $init; ?>" min="<?php echo $init; ?>" step="<?php echo $step; ?>" <?php echo $maxOrder; ?> /></span><?php }
if(!empty($addtoCartButton)){
?><span class="addtocart-button"><?php echo $addtoCartButton ?></span><?php
} ?><input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
<noscript><input type="hidden" name="task" value="add"/></noscript> <?php
}
} ?>
</div><?php
} ?>
Hope you can help.
http://forum.virtuemart.net/index.php?topic=128401.0
Sorry...! :-[
Joomla version - 3.6.5
VM Version - 3.0.18
PHP Version - 5.6.29
Template - uses VM styling and overrides
Using SEF - No
Basically, I just want to know what string(s) make the add to cart button display on the front end when on a category page. This will give me something to work off.
Thanks!
cat pages use the sublayout product.php to display each product block
it uses the add to cart sublayouts to display the add to cart etc
you would normally build your own version of the add to cart sublayout .. call it something else -- and load that one in your product.php